<template>
	<view class="pages">
		<u-navbar title="经营场所列表" :border-bottom="false" :background="bgc" back-icon-color="#fff" title-color='#fff'
			title-size='36' height='44'></u-navbar>
        <view class="serch">
        	<view class="inp">
        		<view class="bor">
        			<image src="https://api.ccttiot.com/smartmeter/img/static/uBY0VGovU7BZrSdUi7cn" mode=""></image>
        			<input type="text" v-model="keyword" placeholder="搜索" />
        		</view>
        		<view class="sousuo" @click="serch">
        			搜索
        		</view>
        	</view>
			<view class="chuangj" @click="btncj" v-if="type == 5">
				创建场所
			</view>
        </view>
		
		<!-- 店铺列表 -->
         <scroll-view scroll-y="true" @scrolltolower="onScrollToLower" style="height: 83vh;" class="listbox">
         	<view class="list" v-for="(item,index) in wateringList" :key="index" @click="btnxq(item.storeId)">
         		<view class="top">
         			<view class="lt">
         				<image src="https://api.ccttiot.com/smartmeter/img/static/uZEQ9jhFPBFSyvHQROgi" mode=""></image><view>{{item.name}}</view>
         			</view>
         			<view class="rt">
         				<view class="yuan">
         					<text></text>
         					<text></text>
         					<text></text>
         				</view>
         			</view>
         		</view>
         		<view class="shou">
         			<view class="shou_val">
         				<view class="one">日收</view>
         				<view class="two"><text>￥</text>{{item.todayIncome == undefined ? '--' : item.todayIncome}}  </view>
         			</view>
         			<view class="shou_val">
         				<view class="one">月收</view>
         				<view class="two"><text>￥</text>{{item.monthIncome == undefined ? '--' : item.monthIncome}}  </view>
         			</view>
         			<view class="shou_val">
         				<view class="one">上月收</view>
         				<view class="two"><text>￥</text>{{item.lastMonthIncome == uniCloud ? '--' : item.lastMonthIncome}} </view>
         			</view>
         			<view class="shou_val">
         				<view class="one">设备数</view>
         				<view class="two">{{item.deviceCount == undefined ? '--' : item.deviceCount}} <text>台</text> </view>
         			</view>
         		</view>
				<view class="name" v-if="item.status == 2">
					<text>审核状态：</text> 审核中
				</view>
				<view class="name" v-if="item.status == 1">
					<text>审核状态：</text> 正常
				</view>
				<view class="name" style="margin-top: 16rpx;">
					<text>是否生效：</text> {{item.enabled == false ? '未生效' : '生效'}}
				</view>
         		<view class="name">
         			<view class="name_one">联系人：</view>
         			<view class="name_two">{{item.contactName}}</view>
         		</view>
         		<view class="name">
         			<view class="name_one">联系电话：</view>
         			<view class="name_two">{{item.contactMobile}}</view>
         		</view>
         		<view class="name">
         			<view class="name_one" style="width: 128rpx;">详细地址：</view>
         			<view class="name_two">{{item.address}}</view>
         		</view>
         		<view class="bot">
         			<view class="bot_one">{{item.createTime}}</view>
         		</view>
         	</view>
			<view class="" style="width: 100%;text-align: center;color: #ccc;margin-top: 50rpx;">
				-已经到底了-
			</view>
         </scroll-view>
		 
		 
	</view>
</template>

<script>
	export default {
		data() {
			return {
				bgc: {
					backgroundColor: "#8883f0",
				}, 
				pagenum: 1,
				wateringList: [],
				pagesize: 10, // 一页多少数据
				isLoading: false, // 是否正在加载数据  
				noMoreData: false, // 是否没有更多数据  
				total: 0,
				keyword: '',
				showflag: false,
				type:''
			}
		},
		onLoad() {
            this.$u.get(`/app/user/userInfo`).then(res => {
            	if(res.code == 200){
            		this.type = res.data.type
            		if(res.data.type == 2){
            			this.getlist()
            		}else if(res.data.type == 4){
            			this.getlistcyz()
            		}else if(res.data.type == 3){
						this.getlistywy()
					}else{
						this.getlistcs()
					}
            	}
            })
		},
		onShow() {
			this.pagenum = 1
			this.wateringList = []
			if(this.type == 2){
				this.getlist()
			}else if(this.type == 4){
				this.getlistcyz()
			}else if(this.type == 3){
				this.getlistywy()
			}else if(this.type == 5){
				this.getlistcs()
			}else{
				console.log('11');
			}
			// this.getlist()
		},
		// 分享到好友（会话）
		onShareAppMessage: function() {
			return {
				title: '创亿康',
				path: '/pages/index/index'
			}
		},

		// 分享到朋友圈  
		onShareTimeline: function() {
			return {
				title: '创亿康',
				query: '',
				path: '/pages/index/index'
			}
		},
		methods: {
			// 经营场所
			getlist() {
				this.isLoading = true
				this.$u.get(`/agent/store/list?isDefault=true&pageNum=${this.pagenum}&pageSize=${this.pagesize}&keyword=${this.keyword}`).then(res => {
					if (res.code == 200) {
						this.total = res.total
						if (this.total > 0) {
							this.showflag = false
						} else {
							this.showflag = true
						}
						if (res.rows.length > 0) {
							// 有数据，追加到列表  
							this.wateringList = this.wateringList.concat(res.rows)
							this.pagenum++
						} else {
							// 没有更多数据  
							this.noMoreData = true
						}
						this.isLoading = false
					}
				})
			},
			// 投资人（创业者）
			getlistcyz() {
				this.isLoading = true
				this.$u.get(`/investor/store/list?isDefault=true&pageNum=${this.pagenum}&pageSize=${this.pagesize}&keyword=${this.keyword}`).then(res => {
					if (res.code == 200) {
						this.total = res.total
						if (this.total > 0) {
							this.showflag = false
						} else {
							this.showflag = true
						}
						if (res.rows.length > 0) {
							// 有数据，追加到列表  
							this.wateringList = this.wateringList.concat(res.rows)
							this.pagenum++
						} else {
							// 没有更多数据  
							this.noMoreData = true
						}
						this.isLoading = false
					}
				})
			},
			// 业务员（渠道商）
			getlistywy() {
				this.isLoading = true
				this.$u.get(`/biz/store/list?isDefault=true&pageNum=${this.pagenum}&pageSize=${this.pagesize}&keyword=${this.keyword}`).then(res => {
					if (res.code == 200) {
						this.total = res.total
						if (this.total > 0) {
							this.showflag = false
						} else {
							this.showflag = true
						}
						if (res.rows.length > 0) {
							// 有数据，追加到列表  
							this.wateringList = this.wateringList.concat(res.rows)
							this.pagenum++
						} else {
							// 没有更多数据  
							this.noMoreData = true
						}
						this.isLoading = false
					}
				})
			},
			// 经营场所
			getlistcs() {
				this.isLoading = true
				this.$u.get(`/app/store/list?isDefault=true&pageNum=${this.pagenum}&pageSize=${this.pagesize}&keyword=${this.keyword}`).then(res => {
					if (res.code == 200) {
						this.total = res.total
						if (this.total > 0) {
							this.showflag = false
						} else {
							this.showflag = true
						}
						if (res.rows.length > 0) {
							// 有数据，追加到列表  
							this.wateringList = this.wateringList.concat(res.rows)
							this.pagenum++
						} else {
							// 没有更多数据  
							this.noMoreData = true
						}
						this.isLoading = false
					}
				})
			},
			
			// 滚动到底部
			onScrollToLower() {
				if (this.total > this.wateringList.length) {
					this.getlist() // 上拉加载更多  
				} 
			},
			// 搜索
			serch(){
				this.wateringList = []
				this.getlist()
			},
			
             btnxq(storeId){
				 uni.navigateTo({
				 	url:'/page_user/changsuoxq?storeId=' + storeId
				 })
			 },
			 btncj(){
				 uni.navigateTo({
				 	url:'/page_user/dianpu'
				 })
			 }
			 

		}
	}
</script>

<style lang="scss" scoped>
	/deep/ .u-title {
		padding-bottom: 15rpx;
	}

	/deep/ .u-icon__icon {
		padding-bottom: 15rpx;
	}

	.pages {
		background-color: #F7FAFE !important;
		height: 100%;
		width: 100%;
		overflow: hidden;
		.listbox{
			padding-bottom: 100rpx;
			box-sizing: border-box;
		}
		.list{
			width: 680rpx;
			max-height: 590rpx;
			background: #FFFFFF;
			border-radius: 38rpx 38rpx 38rpx 38rpx;
			margin: auto;
			margin-top: 24rpx;
			padding: 42rpx 40rpx;
			box-sizing: border-box;
			
			.bot{
				display: flex;
				justify-content: space-between;
				border-top: 1px solid #D8D8D8;
				padding-top: 28rpx;
				box-sizing: border-box;
				font-size: 24rpx;
				color: #808080;
				margin-top: 24rpx;
			}
			.name{
				display: flex;
				margin-top: 16rpx;
				.name_one{
					font-size: 24rpx;
					color: #808080;
				}
				.name_two{
					font-size: 24rpx;
					color: #3D3D3D;
				}
			}
			.shou{
				display: flex;
				justify-content: space-between;
				margin-top: 28rpx;
				padding: 0 26rpx;
				box-sizing: border-box;
				margin-bottom: 20rpx;
				.shou_val{
					.one{
						font-size: 24rpx;
						color: #808080;
					}
					.two{
						font-size: 32rpx;
						color: #3D3D3D;
						font-weight: 600;
						margin-top: 10rpx;
						text{
							font-size: 24rpx;
							color: #808080;
						}
					}
				}
			}
			.top{
				display: flex;
				justify-content: space-between;
				width: 100%;
				border-bottom: 1px solid #D8D8D8;
				padding-bottom: 22rpx;
				box-sizing: border-box;
				.lt{
					display: flex;
					align-items: center;
					view{
						font-size: 30rpx;
						color: #3D3D3D;
						font-weight: 600;
					}
					image{
						width: 28rpx;
						height: 28rpx;
						margin-right: 10rpx;
					}
				}
				.rt{
					display: flex;
					align-items: center;
					.bang{
						width: 104rpx;
						height: 34rpx;
						background: #8883F0;
						border-radius: 6rpx 6rpx 6rpx 6rpx;
						text-align: center;
						line-height: 34rpx;
						font-size: 20rpx;
						color: #FFFFFF;
					}
					.yuan{
						margin-left: 10rpx;
						display: flex;
						text{
							width: 8rpx;
							height: 8rpx;
							border-radius: 50%;
							background-color: #575B66;
							margin-right: 6rpx;
						}
					}
				}
			}
		}
		.serch {
			width: 750rpx;
			height: 136rpx;
			background: #FFFFFF;
			display: flex;
			align-items: center;
			padding: 0 36rpx;
			box-sizing: border-box;
		    .chuangj{
				width: 200rpx;
				height: 68rpx;
				background-color: #8883F0;
				color: #fff;
				line-height: 68rpx;
				border-radius: 20rpx;
				text-align: center;
			}
			.inp {
				display: flex;
				align-items: center;
				margin-right: 20rpx;
				height: 68rpx;
				border: 2rpx solid #C7C7C7;
				width: 100%;
				border-radius: 20rpx;
				justify-content: space-between;
				box-sizing: border-box;
		
				.sousuo {
					width: 112rpx;
					height: 68rpx;
					border-left: 2rpx solid #C7C7C7;
					text-align: center;
					line-height: 68rpx;
					font-size: 32rpx;
					color: #3D3D3D;
				}
		
				.bor {
					display: flex;
					align-items: center;
					padding-left: 60rpx;
		
					image {
						width: 46rpx;
						height: 46rpx;
						margin-right: 12rpx;
					}
				}
		
			}
		}
	}

</style>