<template>
	<view>
		<view class="tab ddflex">
			<view :class="'li ' + (type == 1 ? 'active' : '')" @click="swiType(1)">我加入的</view>
			<view :class="'li ' + (type == 2 ? 'active' : '')" @click="swiType(2)">我创建的</view>
		</view>
		<view class="placeholder-view"></view>
		<view class="list" v-if="pageList.length>0">
			<view class="li ddflex" v-for="(item,index) in pageList" :key="index" @click="jumpUrl(item)">
				<image :src="item.url?item.url:picUrlss+'office_images/team_default.png'" mode="aspectFill" class="team-img"></image>
				<view class="fflex">
					<view class="team-tit tover">{{item.title}}</view>
					<view class="team-sta">日新贴{{item.dayMomentsNum}}</view>
				</view>
				<view class="join-btn" v-if="type == 1">去看看</view>
				<block v-else>
					<view class="join-btn" v-if="item.auditStatus == 1">去看看</view>
					<view :class="'sta'+(item.auditStatus == 2 ? ' fail':'')" v-else>{{item.auditStatus == 0 ? '审核中' : '审核失败'}}</view>
				</block>
			</view>
		</view>
		<view class="nodata" v-else>
			<image :src="picUrlss + 'empty_dd.png'"></image>
			<text>暂无团队</text>
		</view>
	</view>
</template>

<script>
const app = getApp();
const api = require('../../utils/api.js');
const req = require('../../utils/request.js');
export default {
	data() {
		return {
			picUrlss: req.public.picUrls,
			type: 1,//团队类型 1、我加入的 2、我创建的
			form: {
				page: 1,
				limit: 12
			},
			isLoad: true,
			pageList: []
		};
	},
	onLoad() {
		this.getPageList();
	},
	methods: {
		swiType(type){
			if(this.type == type) return false;
			this.type = type;
			this.form.page = 1;
			this.isLoad = true;
			this.getPageList();
		},
		getPageList(){
			if (!this.isLoad) return false;
			this.isLoad = false;
			let form = this.form;
			form.teamType = this.type;
			req.getRequest(api.user_team_list,form,data=>{
				if (data.list && data.list.length >= 10) this.isLoad = true;
				if (this.form.page > 1) data.list = this.pageList.concat(data.list);
				this.pageList = data.list;
			})
		},
		jumpUrl(item){
			if(item.auditStatus != 1 && item.auditStatus != 2) return req.msg('团队正在审核中');
			if(item.auditStatus == 1){//审核 0待审核 1通过 2未通过
				uni.navigateTo({
					url: '/office/team/index?id=' + item.id
				})
			}else{
				uni.navigateTo({
					url: '/office/createTeam/index?id=' + item.id
				})
			}
		}
	}
};
</script>

<style>
@import './index.css';
</style>
