<template>
	<view class="container club clearfix" :style="{paddingBottom:isIphoneX?'140rpx':'98rpx'}">
		<view class="club-top clearfix">
			<view class="club-search">
				<view class="search-wrap">
					<view class="search-from name">
						<input class="input" type="text" v-model="linkman" placeholder="请输入姓名" maxlength="6"/>
					</view>
					<view class="search-from search">
						<button class="search-btn" type="default" @click.stop="searchOpertor">搜索</button>
					</view>
				</view>
			</view>
		</view>
		<view class="club-main">
			<view v-if="isEmpty" class="empty-container">
				<view class="txt">暂无运营人员</view>
			</view>
			<view v-else class="club-list">
				<scroll-view scroll-y="true" >
					<view class="list" v-for="(item, index) in clubList" :key="index" @click.stop="showclubModel(item)">
						<view class="list-left">
							<view class="list-head"><image :src="item.headimgurl ? item.headimgurl : '../../../static/temp/logo@3x.png'" mode=""></image></view>
							<view class="list-tel">
								<text class="txt">{{item.linkName}}</text>
								<text class="txt">{{item.mobile}}</text>
							</view>
						</view>
						<view class="list-opea">
							<view class="opea-type">
								<view class="opea-type-cell" v-if="item.effectiveFlag != null">
									<text class="iconfont icon-iconfontweixin" :style="{color: iconStautsColor(item.status)}"></text>
									<text :style="{color: rexpStautsColor(item.effectiveFlag)}">{{ rexpStautsText(item.effectiveFlag) }}</text>
								</view>
								<view class="opea-type-cell none" v-else>
									<text>- -</text>
								</view>
							</view>
							<view class="opea-del">
								<view class="opea-type-cell" @click.stop="deleteclub(item.id)">
									<text class="iconfont icon-shanchu"></text>
									<text>删除</text>
								</view>
							</view>
						</view>
					</view>
					<!--加载loadding-->
					<tui-loadmore :visible="loadding" :index="3" type="black"></tui-loadmore>
					<tui-nomore :visible="!pullUpOn" bgcolor="#F7F7F7" :text='nomoreText'></tui-nomore>
					<!--加载loadding-->
				</scroll-view>
			</view>
		</view>
		<view class="tabBar" :style="{height:isIphoneX?'140rpx':'98rpx'}">
			<view class="tabBar_list" :style="{paddingBottom:isIphoneX?'40rpx':''}">
				<view  class="tabBar_item" v-for="(item,index) in  tabBarList" 
					   :key="index" 
					   :class="{ 'current' : tabCurrentIndex === index}"  
					   @click="tabClick(index)" >
					<text class="iconfont" :class="item.icon"></text>
					<view class="tabBar_name">{{item.name}}</view>
				</view>
			</view>
		</view>
	</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:'',//上一个页面
				tabBarList:[
					{name:'待审核',icon:'icon-lishidingdan'},
					{name:'审核未通过',icon:'icon-shenhebutongguo'},
					{name:'已上线',icon:'icon-shenhetongguo'}
				],
				tabCurrentIndex:0,
				clubList:[],
				isIphoneX:this.$store.state.isIphoneX,
				show_index:0,//控制显示那个组件
			}
		},
		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
			},
			tabClick(index) {//商品详情&&供应商信息tab切换
				this.tabCurrentIndex = index;
				console.log(this.tabCurrentIndex)
			},
		},
		onReachBottom() {
			if(this.hasNextPage){
				this.loadding = true
				this.pullUpOn = true
				this.getOnReachBottomData()
			}	
		},
		onShow() {
			this.$api.getCommonStorage('clubInfo').then(response =>{
				console.log(response)
				this.clubID = response.clubID
				this.clubName = response.name
				this.clubImage = response.image
				this.pageNum = 1;
				this.initclubList();
			})
		}
	}
</script>

<style lang='scss'>
	page {
		height: auto;
	}
	page,.container{
		/* padding-bottom: 120upx; */
		background: #F7F7F7;
		border-top: 1px solid #EBEBEB;
	}
	.container{
		position: relative;
	}
	.list{
		display: flex;
		align-items: center;
		width: 702rpx;
		height: 92rpx;
		padding: 24rpx;
		background: #FFFFFF;
		position: relative;
		border-bottom: 1px solid #EBEBEB;
		.list-left{
			display: flex;
			flex: 4;
			.list-head{
				width: 92rpx;
				height: 92rpx;
				border-radius: 14rpx;
				image{
					width: 92rpx;
					height: 92rpx;
					border-radius: 14rpx;
				}
			}
			.list-tel{
				margin-left: 18rpx;
				.txt{
					display: flex;
					flex: 1;
					font-size: $font-size-28;
					color: $text-color;
					line-height: 46rpx;
				}
			}
		}
		.list-opea{
			flex:6;
			.opea-type{
				flex-direction: column;
				align-items: center;
				margin-left: 20rpx;
				float: left;
				.opea-type-cell{
					width: 186rpx;
					height: 64rpx;
					padding:0 16rpx;
					border-radius: 10rpx;
					border: 1px solid #DDDDDD;
					line-height: 64rpx;
					font-size: $font-size-24;
					.icon-iconfontweixin{
						margin-right: 8rpx;
						font-size: $font-size-32;
					}
					&.none{
						text-align: center;
					}
				}
			}
			.opea-del{
				float: right;
				flex-direction: column;
				align-items: center;
				.opea-type-cell{
					width: 86rpx;
					height: 64rpx;
					padding:0 24rpx;
					border-radius: 10rpx;
					border: 1px solid #DDDDDD;
					line-height: 64rpx;
					font-size: $font-size-24;
					color: #FF0000;
					.icon-shanchu{
						font-size: $font-size-32;
						margin-right: 6rpx;
					}
				}
			}
		}
	}
	.tabBar{
		width:100%;
		height: 98rpx;
		background: #fff;
		border-top:1px solid #E5E5E5;
		position: fixed;
		bottom:0px;
		left:0px;
		right:0px;
		display: flex;
		align-items: center;
		justify-content: center;
		.tabBar_list{ 
			width:86%;
			display: flex;
			justify-content: space-between;
			.tabBar_item{ 
				width:120rpx;
				display: flex;
				justify-content: center;
				align-items: center;
				flex-direction: column;
				font-size: 20rpx;
				color: #999999;
				&.current{
					color: #166CE1;
					.iconfont{
						color:#166CE1;
					}
				}
				.iconfont{
					width:48rpx;
					height: 48rpx;
					display: block;
					margin-bottom:2rpx;
					text-align: center;
					font-size: 46rpx;
					color: #999999;
				}
			}
		 } 
	}
	.nav_active{
		color: $color-system;
	}
</style>

