<template>
	<view class="page">
		<u-navbar title="代理列表" :border-bottom="false" :background="bgc" title-color='#000' title-size='36'
			height='58'></u-navbar>
        <view class="box">
        	<view class="nav">
        		<view class="top">
        			<u-search placeholder="搜索" input-align="center" v-model="keyword" @custom="searchs"></u-search>
        		</view>
        	</view>
			<view class="list" v-for="(item,index) in wateringList" :key="index">
				<view class="top">
					<view class="lt">
						<view class="" style="font-weight: 500;font-size: 24rpx;color: #3D3D3D;">{{item.name}}</view>
						<view class="" style="font-size: 20rpx;color: #808080;">ID:{{item.agentId}} - {{item.level}}级代理</view>
					</view>
					<view class="rt" @click="btnxq(item)">
						<text style="width: 9rpx;height: 9rpx;border-radius: 50%;margin-right: 5rpx;display: inline-block;background-color: #575B66;"></text>
						<text style="width: 9rpx;height: 9rpx;border-radius: 50%;margin-right: 5rpx;display: inline-block;background-color: #575B66;"></text>
						<text style="width: 9rpx;height: 9rpx;border-radius: 50%;margin-right: 5rpx;display: inline-block;background-color: #575B66;"></text>
					</view>
				</view>
				<view class="" style="width: 680rpx;height: 1px;background: #F0F0F0;margin-left: -30rpx;margin-top: 14rpx;"></view>
				<view class="list_val">
					<view class="list_shop">
						<view class="" style="font-size: 24rpx;color: #808080;">代理</view>
						<view class="" style="font-weight: 500;font-size: 24rpx;color: #3D3D3D;">{{item.childrenCount}}</view>
					</view>
					<view class="list_shebei">
						<view class="" style="font-size: 24rpx;color: #808080;">店铺数</view>
						<view class="" style="font-weight: 500;font-size: 24rpx;color: #3D3D3D;">{{item.storeCount}}</view>
					</view>
					<!-- <view class="list_shebei">
						<view class="" style="font-size: 24rpx;color: #808080;">商户人数</view>
						<view class="" style="font-weight: 500;font-size: 24rpx;color: #3D3D3D;">1</view>
					</view> -->
					<view class="list_shebei">
						<view class="" style="font-size: 24rpx;color: #808080;">设备统计</view>
						<view class="" style="font-weight: 500;font-size: 24rpx;color: #3D3D3D;">{{item.cabinetCount}}</view>
					</view>
				</view>
				<view class="photo" style="color: #808080;font-size: 24rpx;">联系电话：<text style="color: #3D3D3D;">{{item.mobile}}</text> </view>
				<view class="" style="width: 680rpx;height: 1px;background: #F0F0F0;margin-left: -30rpx;margin-top: 14rpx;"></view>
				<view class="" style="font-size: 24rpx;color: #3D3D3D;margin-top: 10rpx;">{{item.createTime}}</view>
			</view>
        </view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
                bgc: {
                	backgroundColor: " #25CE88"
                }, 
				pagenum: 1,
				wateringList: [],
				pagesize: 10, // 一页多少数据
				isLoading: false, // 是否正在加载数据  
				noMoreData: false, // 是否没有更多数据  
				total: 0,
				keyword:''
			}
		},
		onShow() {
			this.pagenum = 1
			this.wateringList = []
			this.getlist()
		},
		methods: {
           btnxq(item){
			   uni.navigateTo({
			   	  url:'/page_user/listshu/xqdetail?agentId=' + item.agentId
			   })
		   },
		   
		   getlist() {
		   	this.$u.get("/agent/agent/list?pageNum=" + this.pagenum + '&pageSize=' + this.pagesize + '&keyword=' + this.keyword).then(res => {
		   		if (res.code == 200) {
		               this.total = res.total
		               if (res.rows.length > 0) {
		               	// 有数据，追加到列表  
		               	this.wateringList = this.wateringList.concat(res.rows)
		               	this.pagenum++
		               } else {
		               	// 没有更多数据  
		               	this.noMoreData = true;
		               }
		               this.isLoading = false;
		   		}
		   	})
		   },
		   searchs(){
			this.pagenum = 1
		   	this.wateringList = []
		   	this.getlist()
		   },
		   onReachBottom() {
		   	let sum = this.total / this.pagesize
		   	if (this.pagenum-1 < sum) {
		   		this.getlist(); // 上拉加载更多  
		   	} else {
		   		uni.showToast({
		   			title: '没有更多代理人员了',
		   			icon: 'none',
		   			duration: 1000
		   		});
		   	}
		   },
		   
		}
	}
</script>

<style lang="scss">
	/deep/ .u-title,
	/deep/ .uicon-nav-back {
		padding-bottom: 40rpx;
	}
	page {
		// background: linear-gradient(180deg, #25CE88 0%, rgba(255, 255, 255, 0) 100%);
	}

	.page {
		width: 750rpx;
		.box{
			width: 750rpx;
			height:100%;
			background: #F4F5F7;
			border-radius: 0rpx 0rpx 0rpx 0rpx;
			padding-bottom: 200rpx;
			.list{
				width: 680rpx;
				height: 336rpx;
				margin-top: 30rpx !important;
				margin: auto;
				background: #FFFFFF;
				border-radius: 24rpx 24rpx 24rpx 24rpx;
				padding: 20rpx 30rpx;
				box-sizing: border-box;
				.top{
					display: flex;
					justify-content: space-between;
				}
				.list_val{
					display: flex;
					justify-content: space-between;
					padding: 36rpx 50rpx;
					box-sizing: border-box;
					text-align: center;
				}
			}
			.nav {
				margin-bottom: 30rpx;
				.top {
					width: 750rpx;
					height: 136rpx;
					background: #FFFFFF;
					padding: 32rpx 36rpx;
					box-sizing: border-box;
			
					/deep/ .u-content {
						border: 1px solid #ccc;
						border-radius: 50rpx 0 0 50rpx !important;
					}
			
					/deep/ .u-action {
						border-radius: 0 50rpx 50rpx 0 !important;
						width: 112rpx;
						height: 65rpx;
						line-height: 65rpx;
						border: 2rpx solid #ccc;
						margin-left: 0;
						color: #3D3D3D;
						background-color: #f2f2f2;
					}
				}
			
				.date {
					padding-left: 80rpx;
					padding-right: 80rpx;
					box-sizing: border-box;
					display: flex;
					justify-content: space-between;
					width: 750rpx;
					height: 70rpx;
					background: #FFFFFF;
					margin-bottom: 36rpx;
			
					text {
						padding: 6rpx 18rpx;
						box-sizing: border-box;
						background: #eee;
						height: 46rpx;
						border-radius: 10rpx 10rpx 10rpx 10rpx;
						font-size: 24rpx;
						color: #808080;
					}
				}
			}
		}
	}
</style>