<template>
	<view class="container club clearfix">
		
	</view>
</template>

<script>
	import authorize from '@/common/config/authorize.js'	
	import tuiLoadmore from "@/components/tui-components/loadmore/loadmore"
	import tuiNomore from "@/components/tui-components/nomore/nomore"
	import { queryclubList, deleteclub , updateCode } from "@/api/operator.js"
	export default {
		components:{
			tuiLoadmore,
			tuiNomore,
		},
		data() {
			return {
				clubID:'',
				clubName:'',
				clubImage:'',
				linkman:'',
				clubMobile:'',
				isEmpty:false,
				nomoreText: '上拉显示更多',
				userID:'',
				pageNum:1,
				pageSize:10,
				hasNextPage:false,
				loadding: false,
				pullUpOn: true,
				pullFlag: true,
				allowDataStatus:true,
				wrapperHeight:'100%',
				scrollHeight:'',
				deleteAddressId:'',
				currPage:'',//当前页面
				prevPage:'',//上一个页面
				clubList:[],
				isIphoneX:this.$store.state.isIphoneX,
			}
		},
		onLoad(){				
			this.setScrollHeight();
		},
		methods: {
			setScrollHeight() {
				// 窗口高度 - 底部距离
				setTimeout(()=> {
					const query = wx.createSelectorQuery().in(this);
					query.selectAll('.add-btn').boundingClientRect();
					query.exec(res => {
						if(res[0][0]){
							let winHeight = this.$api.getWindowHeight(),
								eleTop = res[0][0].top - 1;
								this.scrollHeight =  eleTop;
						}
					})
				}, 500)
			},
			searchOpertor(){
				this.pageNum=1
				this.initclubList()
			},
			initclubList(){	
				let params = {clubID:this.clubID,pageNum:1,pageSize:this.pageSize,linkName:this.linkman,mobile:this.clubMobile}
				queryclubList(params).then(response =>{
					let responseData = response.data
					if(responseData.results&&responseData.results.length > 0){
						this.isEmpty = false
						this.hasNextPage = response.data.hasNextPage
						this.clubList =responseData.results
						this.pullFlag = false;
						setTimeout(()=>{this.pullFlag = true;},500)
						if(this.hasNextPage){
							this.pullUpOn = false
							this.nomoreText = '上拉显示更多'
						}else{
							this.pullUpOn = true
							this.loadding = false
							this.nomoreText = '已至底部'
						}
					}else{
						this.isEmpty = true
					}
				}).catch(response =>{
					this.$util.msg(response.msg,2000)
				})
			},	
			getOnReachBottomData(){
				this.pageNum+=1
				let params = {pageNum:this.pageNum,pageSize:this.pageSize,linkName:this.linkman,mobile:this.clubMobile}
				queryclubList(params).then(response =>{
					let responseData = response.data
					if(responseData.results&&responseData.results.length > 0){
						this.hasNextPage = response.data.hasNextPage
						this.clubList = this.clubList.concat(responseData.results) 
						this.pullFlag = false;// 防上拉暴滑
						setTimeout(()=>{this.pullFlag = true;},500)
						if(this.hasNextPage){
							this.pullUpOn = false
							this.nomoreText = '上拉显示更多'
						}else{
							this.pullUpOn = false
							this.loadding = false
							this.nomoreText = '已至底部'
						}
					}
				}).catch(response =>{
					this.$util.msg(response.msg,2000)
				})
			},
			rexpStautsColor(status) {
			  let textColor = ''
			  switch (status) {
				case '1':
				  textColor = '#55BB00'
				  break
				case '2':
				  textColor = '#0056BB'
				  break
				case '3':
				  textColor = '#BB0000'
				  break
			  }
			  return textColor
			},  
			iconStautsColor(status) {
			  let textColor = ''
			  if(status == '2'){
				   textColor = '#09BB07'
			  }else{
				   textColor = '#DDDDDD'
			  }
			  return textColor
			},
		},
		onReachBottom() {
			if(this.hasNextPage){
				this.loadding = true
				this.pullUpOn = true
				this.getOnReachBottomData()
			}	
		},
		onShow() {
			this.$api.getCommonStorage('clubInfo').then(response =>{

			})
		}
	}
</script>

<style lang='scss'>
	page {
		height: auto;
	}
	page,.container{
		/* padding-bottom: 120upx; */
		background: #F7F7F7;
		border-top: 1px solid #EBEBEB;
	}
</style>

