<template>
	<view class="container">
		<text class="iconfont icon-youjiantou zuojiantou" @click="goBack()" style="left: 20rpx;"></text>
		<!-- <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" style="">
					<text>暂无数据!</text>
				</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';
	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
			}
		},
		onLoad() {

		},
		mounted() {
			this.switchTab(3)
			this.getmyseatem()
		},
		methods:{
			goBack(){
				uni.navigateBack({
					delta: 1  
				});
			},
			getmyseatem() {
				api.queryMyTeamInfo({
					userId: this.userId,
					type: '2'
				}).then(res =>{
					if(res['success']){
						let data = res.data
						if(data.orgInfo) {
							//this.levelName =data.orgInfo.areaCenterName;
							this.levelName = data.orgInfo.name;
						}
						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)=>{
								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.dateFormat(val);
			}
		},
	}
</script>

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

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

				text {
					color: #333;
				}
			}

		}



	}
</style>
