<!-- 分享记录 -->
<template>
	<view class="">
		<!-- #ifdef H5 -->
		<view style="color: #000000;">
			<tn-nav-bar backgroundColor="#ffffff" :bottomShadow="false">我的团队</tn-nav-bar>
			<view :style="{height: tobheight+'px'}"></view>
		</view>
		<!-- #endif -->

		<!-- #ifdef H5 -->
		<view class="z_tabs"></view>
		<!-- #endif -->
		<view class="page_box">
			<!-- 标题栏 -->
			<view class="head_box">
				<view class="nav-box">
					<!-- 标题栏 -->
					<!-- <shopro-navbar back-icon-color="#fff" :background="{}" :backTextStyle="{ color: '#fff', fontSize: '40rpx', fontWeight: '500' }" backText="分享记录"></shopro-navbar> -->
				</view>
				<!-- 分类tab -->
				<view class="tab-box u-flex">
					<view class="tab-item u-flex-1" v-for="" :key="" @tap="onTab(1)">
						<view class="u-flex">
							<!-- 	<text class="tab-title"
									:class="{ 'title-active': tabCurrent === index }">{{ index+1 }}级团队</text> -->
							<text class="tab-title title-active">1级团队</text>
							<text v-if="firstLevelTeamList.length!=0">({{firstLevelTeamList.length}}人)</text>
						</view>
						<text v-if="currTabIndex==1" class="underline underline-active"></text>
					</view>
					<view class="tab-item u-flex-1" v-for="" :key="" @tap="onTab(2)">
						<view class="u-flex">
							<text class="tab-title title-active">2级团队</text>
							<text v-if="secondLevelTeamList.length!=0">({{secondLevelTeamList.length}}人)</text>
						</view>
						<text v-if="currTabIndex==2" class="underline underline-active"></text>
					</view>
				</view>
			</view>

			<view class="content_box" v-if="currTabIndex==1">
				<view class="log-list u-flex" v-for="(item,index) in firstLevelTeamList" :key="item.id">
					<view class="log-avatar-wrap">
						<u-avatar :src="item.avatar?item.avatar:'static/images/head.jpg'" size="30"></u-avatar>
					</view>
					<view class="item-right">
						<view class="name">{{item.nickname}}</view>
						<view class="item-bottom u-flex u-row-between">
							<view class="time">{{item.created_at}}</view>
							<view class="from-text">来自邀请码分享</view>
						</view>
					</view>
				</view>
				<empty bcolor="#fff" pt="60%" v-if="firstLevelTeamList.length==0"></empty>
			</view>
			<view class="content_box" v-if="currTabIndex==2">
				<view class="log-list u-flex" v-for="(item,index) in secondLevelTeamList" :key="item.id">
					<view class="log-avatar-wrap">
						<u-avatar :src="item.avatar?item.avatar:'static/images/head.jpg'" size="30"></u-avatar>
					</view>
					<view class="item-right">
						<view class="name">{{item.nickname}}</view>
						<view class="item-bottom u-flex u-row-between">
							<view class="time">{{item.created_at}}</view>
							<view class="from-text">来自邀请码分享</view>
						</view>
					</view>
				</view>
				<empty bcolor="#fff" pt="60%" v-if="secondLevelTeamList.length==0"></empty>
			</view>
		</view>
		<u-loadmore v-if="firstLevelTeamList.length!=0&&currTabIndex==1" :status="status" />
		<u-loadmore v-if="secondLevelTeamList.length!=0&&currTabIndex==2" :status="status" />
		<!-- <wike-loading-page :isLoading="isLoading"></wike-loading-page> -->
	</view>
</template>

<script>
	import
	moment
	from 'moment'
	import {
		mapMutations,
		mapActions,
		mapState,
		mapGetters
	} from 'vuex';

	import {
		myTeam
	} from '@/api/my/index.js'
	import empty from '@/components/empty/empty.vue'
	export default {
		data() {
			return {
				status: 'nomore',

				jobList: [],
				isLoading: true,
				shareLogList: [], //分享记录
				tabCurrent: 0, //默认
				tabsList: [{
						name: '一级团队',
						value: 'first'
					},
					{
						name: '二级团队',
						value: 'second'
					},
					{
						name: '三级团队',
						value: 'third'
					}
				],
				typeObj: {
					index: '名片',
					goods: '商品',
					groupon: '拼团',
					link: '链接'
				},
				loadStatus: 'loadmore', //loadmore-加载前的状态，loading-加载中的状态，nomore-没有更多的状态
				currentPage: 1,
				lastPage: 1,
				level: 1,
				isEmpty: false,
				tobheight: 45,
				platform: this.$platform.get(),
				setting: {},
				total: 0,



				teamDataList: [],
				currTabIndex: 1,

				firstLevelTeamList: [],
				secondLevelTeamList: []

			};
		},
		computed: {
			...mapGetters(['appInfo', 'userInfo'])
		},
		async onLoad() {
			console.log(moment(Date.now()).format('YYYY-MM-DD HH:MM:SS'));

			let res = await myTeam()
			if (res.code == 0) {

				this.firstLevelTeamList = res.data.one
				this.secondLevelTeamList = res.data.two

				this.firstLevelTeamList.forEach((item, index) => {
					item.created_at = moment(item.created_at).format('YYYY-MM-DD HH:MM:SS')
				})
				this.secondLevelTeamList.forEach((item, index) => {
					item.created_at = moment(item.created_at).format('YYYY-MM-DD HH:MM:SS')
				})
			}
			console.log('我的团队返回值', res, res.data);
			console.log('我的团队返回值-1级', this.firstLevelTeamList);
			console.log('我的团队返回值-2级', this.secondLevelTeamList);
		},
		methods: {
			queryList(pageNo, pageSize) {
				this.$refs.paging.complete();
				this.isLoading = false;
				// 	}
				// });
			},
			// 切换分类
			onTab(index) {
				this.currTabIndex = index


				this.tabCurrent = index;
				this.level = index + 1;
				this.jobList = [];
				this.$refs.paging.reload(true);
			},
		}
	};
</script>

<style lang="scss">
	// nav
	.head_box {
		height: 280rpx;
		background: url('http://file.shopro.top/imgs/commission/share_head_bg.png') no-repeat;
		background-size: 100% auto;
		position: relative;
	}

	// 分类
	.tab-box {
		background-color: #fff;
		border-radius: 20rpx 20rpx 0px 0px;
		position: absolute;
		width: 100%;
		bottom: 0;

		.tab-item {
			height: 100%;
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;

			.tab-title {
				color: #666;
				font-weight: 500;
				font-size: 28rpx;
				line-height: 90rpx;
			}

			.title-active {
				color: #333;
			}

			.underline {
				display: block;
				width: 68rpx;
				height: 4rpx;
				background: #fff;
				border-radius: 2rpx;
			}

			.underline-active {
				background: #5e49c3;
				display: block;
				width: 68rpx;
				height: 4rpx;
				border-radius: 2rpx;
			}
		}
	}

	// 分享记录列表
	.log-list {
		background-color: #fff;
		padding: 30rpx;
		margin: 10rpx 0;
		align-items: flex-start;

		.log-avatar-wrap {
			margin-right: 14rpx;

			.log-avatar {
				width: 60rpx;
				height: 60rpx;
				border-radius: 50%;
			}
		}

		.item-right {
			flex: 1;

			.name {
				font-size: 28rpx;
				font-weight: 500;
				color: #7f7aa5;
				margin-bottom: 28rpx;
			}

			.content {
				background: rgba(241, 241, 241, 0.46);
				border-radius: 2rpx;
				padding: 10rpx;
				margin-bottom: 20rpx;

				.content-img-wrap {
					margin-right: 16rpx;
					width: 80rpx;
					height: 80rpx;

					.content-img {
						width: 80rpx;
						height: 80rpx;
						border-radius: 6rpx;
					}
				}

				.content-text {
					font-size: 24rpx;
					font-weight: 500;
					color: #333333;
				}
			}

			.item-bottom {
				width: 100%;

				.time {
					font-size: 22rpx;
					font-weight: 500;
					color: #c8c8c8;
				}

				.from-text {
					font-size: 22rpx;
					font-weight: 500;
					color: #c8c8c8;
				}
			}
		}
	}
</style>