<template>
	<RefreshView id="mescrollRef" ref="mescrollRef" text="等待成员加入的队员" :useDownScroll="false" :useUpScroll="false">
		<view class="list" v-for="(teamItem,index) in page.list " :key="index">
			<view class="team">
				<view class="info">
					<view >
						<text class="team-name">{{teamItem.name}}</text>	
						<text class="link" @click="applyJoinTeam(teamItem.sid)">申请加入</text>	
					</view>
					<view class="label-list">
						<text class="label">{{teamItem.adName}}</text>
						<text class="label">{{teamItem.sportCategoryName}}</text>
						<text class="label">{{teamItem.memberNumber}}/{{teamItem.memberNumberLimit}}</text>
					</view>
				</view>
				<scroll-view class="scorll" scroll-x="true">
					<view v-for="(memberItem,pos) in teamItem.listTeamMemberArea" :key="pos" class="user-info-list"  scroll-x="true">
						<view class="user-info  margin-left20">
							<image  class="head-image" :src="memberItem.headImage" mode="scaleToFill"></image>
							<text class="real-name">{{memberItem.realName}}</text>
						</view>
					</view>
				</scroll-view>
			</view>
		</view>
	</RefreshView>
</template>
<script>
	export default {
		data() {
			return {
				isAdmin:0,
				page: {
					state: "",
					current:1,
					menuList: [{
						'title': '默认活动类型',
						'key': 'state',
						'reflexTitle': true,
						'defaultSelectedIndex': 0,
						detailList: [{
							'title': '全部运动项目',
							'value': ""
							}]
						}
					],
					list:[]
				},
			}
		},
		onShow() {
			let _this = this
			this.HTTP({
				url: 'aos/v1/aosUser/getMyTeamAreaPagerList',
				paramsType: "JSON",
				method: "POST",
				data: {
					current: _this.page.current,
					size: 10,
					params: {
						sysUserSid: getApp().globalData.sysUserSid,
						type: 0,
					}
				},
				loading: true
			})
			.then((res) => {
				_this.page.list = res.data.records
				// 追加数据.concat
				console.log("我的队伍:",_this.page.list )
			});
		},

		methods: {
			applyJoinTeam(teamSid){
				let _this = this
				_this.HTTP({
					url: 'aos/v1/aosUser/applyJoinTeam',
					method: 'POST',
					paramsType: "JSON",
					data: {
						memberSid: getApp().globalData.sysUserSid,
						teamSid: teamSid,
					},
					toast: true,
					loading: true
				}).then((res) => {
					console.log('=======', res)
					// 保存
					uni.navigateBack({
						delta: 1
					})
				
				});
			},
			refresh(page) {
				let _this = this
				this.HTTP({
					url: 'aos/v1/aosUser/getMyTeamAreaPagerList',
					paramsType: "JSON",
					method: "POST",
					data: {
						current: _this.page.current,
						size: 10,
						params: {
							sysUserSid:  getApp().globalData.sysUserSid,
							type: 0,
						}
					},
					loading: true
				}).then((res) => {
					// 成功关闭刷新状态
					_this.$refs.mescrollRef.refreshFinished(res.data.records.length)
					if (_this.page.current == 1) {
						// 第一页 先清空集合数据
						_this.list = []
					}
					
					// 追加数据
					//_this.list = _this.list.concat(res.data.records)
			
				}).catch(function(err) {
					console.log("11111");
					_this.$refs.mescrollRef.refreshError()
				});
			},
			clickItem(index) {
				let raceSid = this.list[index].sid
				console.log(raceSid)
				uni.navigateTo({
					url: '../find/DetailActivity?raceSid=' + raceSid
				});
			
			},
			
			result(val) {
				console.log("aaa", val);
				if (!this.IsEmpty(val.state)) {
					this.page.state = val.state;
					this.list = []
					console.log("this.page.state", this.page.state);
				} else {
					this.page.state = val.state;
					this.list = []
				}


			},
			isShow(sid) {
				if (!this.IsEmpty(sid)) {
					return true
				} else {
					return false
				}
			},
			toExamineMember(sid) {
				// 查看申请
				uni.navigateTo({
					url: 'MemberManage?sid=' + sid+"&type="+0
				})
			},
			toDeleteMember(sid) {
				// 查看申请
				uni.navigateTo({
					url: 'MemberManage?sid=' + sid+"&type="+1
				})
			},
			invitation(sid) {
				// 邀请
			},
			toMyTeamCreate(){
				uni.navigateTo({
					url: 'MyTeamCreate'
				})
			},
			toWaitJoin(){
				uni.navigateTo({
					url: '../team/WaitJoin'
				})
			}

		}
	}
</script>

<style lang="scss">
	@import url("../../static/columns.css");
	.show_view {
	  display: inline;
	}
	.hide_view {
	  display: none;
	}
</style>
