<template>
	<view class="container">
		<view class="teamHeader">
			<view class="iconfont icon-youjiantou zuojiantou" @click="goBack()" ></view>
			<view  v-if="tabType!==2">
				<text style="font-size: 30rpx;">团队总人数：{{teamCount}}人</text>
				<view class="desTxt">
					不包含育成团队
				</view>
			</view>
		</view>
			
		<!-- <text class="iconfont icon-youjiantou zuojiantou" @click="goBack()" style="left: 20rpx;"></text> -->
		<!-- tab选项 -->
		
		<view class="tabTitle">
			<text :class="{'actived': tabType===3}" @click="switchTab(3)">直辖团队</text>
			<text :class="{'actived': tabType===1}" @click="switchTab(1)">所辖团队</text>
			<text :class="{'actived': tabType===2}" @click="switchTab(2)">育成团队</text>
		</view>
		<!-- tab内容 -->
		<view class="tabContent">
			<view v-if="tabType===1">
				<members v-if="directList" :directList="directList" :levelName = "levelName" :count= "count" dataShowType="1"></members>
				<view v-else class="zdata" >
					<text>暂无数据!</text>
				</view>
			</view>
			<view v-if="tabType===2">
				<!-- <jurisdiction v-if="raiseList" :raiseList="raiseList"></jurisdiction> -->
				<members v-if="raiseList" :directList="raiseList" :levelName = "levelName" :count= "countRaise" dataShowType="2"></members>
				<view v-else class="zdata" style="">
					<text>暂无数据!</text>
				</view>
			</view>
			<view class="other" v-if="tabType===3">
				<other-team v-if="otherList" :otherList="otherList" :count="countOther"></other-team>
				<view v-else class="zdata" >
					暂无数据!
				</view>
			</view>
		</view>
	</view>
</template>

<script>
    import api from "../../../api/api";
	import Members from './members.vue';
	import OtherTeam from './otherteam.vue';
	import Jurisdiction from './jurisdiction.vue';
	import dataHandling from "@/util/dataHandling";
	export default {
		components: {
			OtherTeam,
			Members,
			Jurisdiction
		},
		data() {
			return {
				tabType: 3,
				userStudyLists: [],
				userId: uni.getStorageSync('cffp_userId'),
				countOther:0,
				count:0,
				countRaise:0,
				directList: null, //直属团队数组
				raiseList: null,  //所辖团队数组
				otherList: null, // 其他
				levelName: null,
				teamCount:0//团队总人数，育成团队人数不算
			}
		},
		onLoad() {

		},
		mounted() {
			this.switchTab(3)
			this.getmyseatem()
		},
		methods:{
			goBack(){
				uni.navigateBack({
					delta: 1  
				});
			},
			getmyseatem() {
				api.queryMyTeamInfo({
					userId: this.userId,
					type: '1'
				}).then(res =>{
					if(res['success']){
						let data = res.data
						if(data.orgInfo) {
							//this.levelName =data.orgInfo.areaCenterName;
							this.levelName = data.orgInfo.name;
							this.teamCount = data.orgInfo.count
						}
						// data.directList = [{levelName:'1',name:'1',parentName:'1'}]
						if(data.directList && data.directList.length != 0 && data.directList != null){
							this.directList = data['directList'];
							this.count = this.directList.length;
							this.directList.forEach((x)=>{
								this.$set(x, 'hasChildren' , true)
								this.$set(x, 'children' , [])
							})
						}
						if(data.raiseList && data.raiseList.length != 0 && data.raiseList != null) {
							this.raiseList = data['raiseList'];
							this.countRaise = this.raiseList.length;
							this.raiseList.forEach((x)=>{
								x.raiseTime = dataHandling.dateFormat2(x.raiseTime)
								this.$set(x, 'hasChildren', true)
								this.$set(x, 'children' , [])
							})
						}
						if(data.other && data.other.length != 0 && data.other != null){
							this.otherList = data['other'];
							this.countOther = this.otherList.length;
						}
					}
				})
			},
			// userStudyList() {
			// 	api.userStudyList({
			// 		userId: this.userId
			// 	}).then(res => {
			// 		if (res['success']) {
			// 			this.userStudyLists = res['data']['userStudyTimeInfos'];
			// 		}
			// 	})
			// },
			switchTab(type) {
				this.tabType = type;
			},
			dateFormat(val) {
				return dataHandling.dateFormat2(val);
			}
		},
	}
</script>

<style lang="scss" scoped>
	.container {
		position: relative;
		height: 100%;
		text-align: center;
		margin-bottom: 20px;
		background: #FFFFFF;
		.teamHeader{
			margin-top: 20rpx;
			height: 90rpx;
			.desTxt{
				color: rgba(102, 102, 102, 1);
				font-size: 25rpx;
				margin-top: 3rpx;
			}
		}
		.zuojiantou{
			transform: rotate(180deg);
			font-size: 30rpx;
			z-index: 1;
		}
		.tabTitle {
			color: #666666;
			background-color: #fff;
			display: flex;
			align-items: center;
			justify-content: space-between;
			// justify-content: space-around;
			padding: 50rpx 30rpx 0;
			font-size: 28rpx;

			text {
				&.actived {
					color: #333;
					border-bottom: 4rpx solid #20269B;
				}
			}
		}
.text-ce{
	margin: auto;
}
        .zdata{
				width: 100vw;
				// display: flex;
				// align-items: center;
				// justify-content: center;
				
				text-align: center;
				margin-top: 40rpx;color: #666666;
				font-size: 28rpx;
			}
		.tabContent {
			display: flex;
			align-items: center;
			justify-content: space-between;
			// padding: 0 20rpx;
			box-sizing: border-box;
			
			.direct-team {
				width: 223px;
				height: 40px;
				opacity: 1;
				border: 1px solid #3F52B7;
				margin: 15px auto;
				text {
					color: #333;
				}
			}

		}



	}
</style>
