<template>
	<view class="container club clearfix" :style="{paddingBottom:isIphoneX?'140rpx':'98rpx'}">
		<view class="club-search clearfix">
			<view class="search-from name">
				<text class="iconfont icon-iconfonticonfontsousuo1"></text>
				<input class="input" type="text" v-model="linkman" placeholder="请输入机构名称搜索" maxlength="12"/>
			</view>
			<view class="search-btn">
				<button class="search-btn" type="default" @click.stop="searchOpertor">搜索</button>
			</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">
						<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.name}}</text>
								<text class="txt sm"><text class="txt-le">{{item.linkName}}</text>{{item.mobile}}</text>
							</view>
						</view>
						<view class="list-opea" v-if="tabCurrentIndex===2">
							<view class="opea-type-dell" @click.stop="checkData(item.clubID)">
								<text class="iconfont icon-xieboke"></text>
								<text>修改资料</text>
							</view>
							<view class="opea-type-dell or" @click.stop="orderHistory(item.clubID)">
								<text class="iconfont icon-dingdanxuanzhong"></text>
								<text>历史订单</text>
							</view>
						</view>
						<view class="list-opea" v-else>
							<view class="opea-type-cell" @click.stop="checkData(item.clubID)">
								<text class="iconfont icon-xieboke"></text>
								<text>修改资料</text>
							</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" :class="{ 'current' : tabCurrentIndex === 0}"   @click="tabClick(0)" >
					<text class="iconfont icon-lishidingdan"></text>
					<view class="tabBar_name">待审核</view>
				</view>
				<view  class="tabBar_item" :class="{ 'current1' : tabCurrentIndex === 1}"   @click="tabClick(1)" >
					<text class="iconfont icon-shenhebutongguo"></text>
					<view class="tabBar_name">审核未通过</view>
				</view>
				<view  class="tabBar_item" :class="{ 'current2' : tabCurrentIndex === 2}"   @click="tabClick(2)" >
					<text class="iconfont icon-shenhetongguo"></text>
					<view class="tabBar_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:'',//上一个页面
				tabCurrentIndex:0,
				clubList:[
					{headimgurl:'../../../static/temp/logo@3x.png',name:'上海默默美容会所管理机构',linkName:'郑先生',mobile:'13979770617',clubID:123},
					{headimgurl:'../../../static/temp/logo@3x.png',name:'上海默默美容会所管理机构',linkName:'郑先生',mobile:'13979770617',clubID:321},
					{headimgurl:'../../../static/temp/logo@3x.png',name:'上海默默美容会所管理机构',linkName:'郑先生',mobile:'13979770617',clubID:456},
					{headimgurl:'../../../static/temp/logo@3x.png',name:'上海默默美容会所管理机构',linkName:'郑先生',mobile:'13979770617',clubID:567},
				],
				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
			},  
			tabClick(index) {//商品详情&&供应商信息tab切换
				this.tabCurrentIndex = index;
				console.log(this.tabCurrentIndex)
			},
			checkData(id){
				switch(this.tabCurrentIndex){
					case 0:
						this.$api.navigateTo(`/market/pages/login/information?id=${id}`)
						break;
					case 1:
						this.$api.navigateTo(`/market/pages/login/apply?id=${id}`)
						break;
					case 2:
						this.$api.navigateTo(`/market/pages/login/information?id=${id}`)
						break;
				}
			},
			orderHistory(id){
				this.$api.navigateTo(`/market/pages/order/order-history?id=${id}`)
			}
		},
		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;
	}
	.club-search{
		height: 64rpx;
		width: 702rpx;
		padding: 24rpx;
		background: #FFFFFF;
		display: flex;
		align-items: center;
		margin-bottom: 20rpx;
		.search-from{
			width: 582rpx;
			height: 64rpx;
			background: #F7F7F7;
			border-radius: 14rpx;
			float: left;
			.iconfont{
				width: 64rpx;
				height: 64rpx;
				line-height: 64rpx;
				text-align: center;
				display: block;
				font-size: $font-size-38;
				float: left;
				color: #999999;
			}
			.input{
				width: 500rpx;
				height: 64rpx;
				float: left;
				line-height: 64rpx;
				color: $text-color;
				font-size: $font-size-24;
			}
		}
		.search-btn{
			width: 120rpx;
			line-height: 64rpx;
			text-align: center;
			font-size: $font-size-28;
			color: $color-system;
			float: left;
			background: #FFFFFF;
		}
	}
	.club-main{
		.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: 8;
				.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;
						&.sm{
							font-size: $font-size-24;
							color: #666666;
							.txt-le{
								margin-right: 26rpx;
							}
						}
					}
				}
			}
			.list-opea{
				display: flex;
				flex: 2;
				color: #166CE1;
				flex-direction: column;
				.opea-type-cell{
					font-size: 24rpx;
					.iconfont{
						font-size: 34rpx;
						margin-right: 5rpx;
					}
				}
				.opea-type-dell{
					line-height: 46rpx;
					font-size: 24rpx;
					&.or{
						color: #E19B16;
					}
					.iconfont{
						font-size: 34rpx;
						margin-right: 5rpx;
					}
				}
			}
		}
	}
	.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;
					}
				}
				&.current1{
					color: #FF0000;
					.iconfont{
						color:#FF0000;
					}
				}
				&.current2{
					color: #16E15C;
					.iconfont{
						color:#16E15C;
					}
				}
				.iconfont{
					width:48rpx;
					height: 48rpx;
					display: block;
					margin-bottom:2rpx;
					text-align: center;
					font-size: 46rpx;
					color: #999999;
				}
			}
		 } 
	}
	.nav_active{
		color: $color-system;
	}
</style>

