<template>
	<view class="page">
		<u-navbar title="我的记录" :border-bottom="false" :background="bgc" back-icon-color="#fff" title-color='#fff'
			title-size='36' height='36' id="navbar">
		</u-navbar>
		<view class="tab">
			<view :class="[tab_item, tabindex == item.type ? 'active' : '']" v-for="(item,index) in tablist"
				:key="index" @click="btnnum(item.type)">
				{{item.name}}
				<view class=""></view>
			</view>
		</view>

		<scroll-view class="list" @scrolltolower="handqixing" scroll-y v-if="list.length != 0">
			<view class="list_item" v-for="(item,index) in list" :key="index">
				<view class="top">
					<view class=""></view>
					<view class="cg" v-if="item.type == 1">拼桌成功</view>
					<view class="cg" v-if="item.type == 2">预约成功</view>
				</view>
				<view class="cen">
					<image :src="item.avatar" mode=""></image>
					<view class="name">
						<view class="wo">
							<!-- <text>我</text> -->
							{{item.team.name == null ? '--' : item.team.name}}
						</view>
						<view class="xc">
							{{item.joinType == 1 ? '现场拼桌' : '预约拼桌'}}：{{item.team.topic}}
						</view>
					</view>
				</view>
				<view class="bot">
					<view class="" style="width: 70%;">
						<image src="https://api.ccttiot.com/smartmeter/img/static/uLLSJMJnxUq6CY4nyOUj" mode=""></image>
						 {{item.createTime}}
					</view>
					<view class="">
						<image src="https://api.ccttiot.com/smartmeter/img/static/u12rHypOGim3RgRDr6Zf" mode=""></image>
						{{item.team.storeName}}
					</view>
				</view>
			</view>
		</scroll-view>
		<view style="width: 480rpx;height: 373rpx;margin: auto;margin-top: 390rpx;" v-else>
		  <image src="https://api.ccttiot.com/smartmeter/img/static/uEiNJh8Rfurw9ORQzlit" mode="aspectFit"></image>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				bgc: {
					backgroundColor: "#010000",
				},
				tablist: [{
					name: '全部',
					type: 0
				}, {
					name: '邀请我的',
					type: 3
				}, {
					name: '我加入的',
					type: 2
				}, {
					name: '我发起的',
					type: 1
				}],
				tabindex: 0,
				list: [],
				total:0,
				pageNum:1
			}
		},
		onLoad() {
			this.getlist()
		},
		methods: {
			// 下拉刷新
			onRefresh() {
				this.isRefreshing = true
				this.pageNum = 1
				this.getlist()
				setTimeout(() => {
					this.isRefreshing = false
				}, 1000)
			},
			// 切换tab
			btnnum(type) {
				this.pageNum = 1
				this.tabindex = type
				this.getlist()
			},
			// 上拉加载更多
			handqixing(){
				if(this.total > this.list.length){
					this.getlist()
				}else{
					console.log(11);
				}
			},
			// 获取拼桌列表
			getlist() {
				this.$u.get(`/app/team/myJoinRecord?pageNum=${this.pageNum}&pageSize=10&joinType=${this.tabindex == 0 ? '' : this.tabindex}`).then(res => {
					if (res.code == 200) {
						this.total = res.total
						if (this.pageNum == 1) {
							this.list = res.rows
							this.pageNum++
						} else {
							this.list = this.list.concat(res.rows)
							this.pageNum++
						}
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		background: #010000;
	}

	.list {
		width: 688rpx;
		margin: auto;
		height: 82vh;
		padding-bottom: 40rpx;
		box-sizing: border-box;

		.list_item {
			width: 688rpx;
			height: 168rpx;
			background: #1C1C1E;
			border-radius: 14rpx 14rpx 14rpx 14rpx;
			margin-top: 30rpx;
			padding: 16rpx;
			box-sizing: border-box;

			.top {
				display: flex;
				justify-content: space-between;

				.cg {
					width: 126rpx;
					height: 42rpx;
					background: #444444;
					border-radius: 21rpx 21rpx 21rpx 21rpx;
					text-align: center;
					line-height: 42rpx;
					font-size: 24rpx;
					color: #D8D8D8;
				}
			}

			.bot {
				display: flex;

				view {
					display: flex;
					align-items: center;
					font-size: 24rpx;
					color: #6E7191;
					margin-top: 28rpx;
					width: 50%;

					image {
						width: 32rpx;
						height: 32rpx;
						margin-right: 16rpx;
					}
				}
			}

			.cen {
				display: flex;

				.name {
					.xc {
						font-size: 24rpx;
						color: #FFFFFF;
					}

					.wo {
						display: flex;
						align-items: center;
						font-size: 24rpx;
						color: #FFFFFF;
					}

					text {
						width: 24rpx;
						height: 24rpx;
						background: linear-gradient(135deg, #76FF8E 0%, #BAFFE5 100%);
						border-radius: 6rpx 6rpx 6rpx 6rpx;
						font-size: 16rpx;
						color: #1D5013;
						text-align: center;
						line-height: 24rpx;
						margin-right: 8rpx;
					}
				}

				image {
					width: 68rpx;
					height: 68rpx;
					border-radius: 50%;
					margin-right: 26rpx;
				}
			}
		}
	}

	.active {
		font-weight: 600;
		font-size: 34rpx;
		color: #FFFFFF;

		view {
			width: 40rpx;
			height: 6rpx;
			background: #FF8998;
			border-radius: 5rpx 5rpx 5rpx 5rpx;
			margin: auto;
			margin-top: 8rpx;
		}
	}

	.tab {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding-top: 50rpx;
		padding-left: 68rpx;
		padding-right: 68rpx;
		box-sizing: border-box;

		.tab_item {
			font-size: 30rpx;
			color: #808080;
		}
	}
</style>