<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="btnscreh">
					搜索
				</view>
			</view>
		</view>

		<scroll-view scroll-y="true" @scrolltolower="onScrollToLower" style="height: 1360rpx;" class="order_list">
			<view class="order_item" v-for="(item,index) in wateringList" :key="index" @click="btndetail(item.userId)">
				<view class="tops">
					<view>{{item.realOrUserName == undefined ? '--' : item.realOrUserName}}  {{item.phonenumber == undefined ? '--' : item.phonenumber}}</view>
					<view style="color: #8883F0;"> 查看详情 </view>
				</view>
                 <view class="devixexq">
                 	<view class="xiaoav">
                 		<view class="">经营场所</view>
                 		<view class="aa">{{item.storeCount == undefined ? '--' : item.storeCount}}</view>
                 	</view>
                 	<view class="xiaoav">
                 		<view class="">设备数</view>
                 		<view class="aa">{{item.deviceCount == undefined ? '--' : item.deviceCount}}</view>
                 	</view>
                 	<view class="xiaoav">
                 		<view class="">订单数</view>
                 		<view class="aa">{{item.billCount == undefined ? '--' : item.billCount}}</view>
                 	</view>
                 </view>
                 <view class="zong">
                    推广人：{{item.referenceName == undefined ? '--' : item.referenceName}}
                 </view>
				<view class="bot">
					<view>{{item.createTime == undefined ? '--' : item.createTime}}</view>
					<view>可支配分成比例：{{item.point == undefined ? '--' : item.point}}%</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, // 一页多少数据
				total: 0,
				type:4,
				keyword:'',
				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{
            			this.getlists()
            		}
            	}
            })
		},
		// 分享到好友（会话）
		onShareAppMessage: function() {
			return {
				title: '创亿康',
				path: '/pages/index/index'
			}
		},

		// 分享到朋友圈  
		onShareTimeline: function() {
			return {
				title: '创亿康',
				query: '',
				path: '/pages/index/index'
			}
		},
		methods: {
			// 搜索合作伙伴-代理
			getlist(){
				this.$u.get(`/agent/user/investorList?pageNum=${this.pagenum}&pageSize=${this.pagesize}&type=${this.type}&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++
						}
					}
				})
			},
			// 搜索业务员-渠道商
			getlists(){
				this.$u.get(`/biz/user/investorList?pageNum=${this.pagenum}&pageSize=${this.pagesize}&type=${this.type}&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++
						}
					}
				})
			},
			// 滚动到底部
			onScrollToLower() {
				if (this.total > this.wateringList.length) {
					if(this.type == 2){
						this.getlist() // 上拉加载更多
					}else{
						this.getlists() // 上拉加载更多
					} 
				} else {
			        
				}
			},
			btnscreh(){
				this.wateringList = []
				this.pagenum = 1
				if(this.type == 2){
					this.getlist() // 搜索合作伙伴-代理
				}else{
					this.getlists() // 搜索业务员-渠道商
				}
			},
			
             // 跳转详情
			 btndetail(userId){
				 uni.navigateTo({
				 	url:'/page_user/touzixq?userId=' + userId
				 })
			 }

		}
	}
</script>

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

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

	.pages {
		background-color: #F7FAFE !important;
		height: 100vh;
		width: 100%;
        overflow: hidden;
		.order_list {
			padding-bottom: 100rpx;
			box-sizing: border-box;
            // height: 1260rpx;
            // overflow: scroll;
			.order_item {
				width: 672rpx;
				max-height: 370rpx;
				background: #FFFFFF;
				box-shadow: 0rpx 4rpx 22rpx 0rpx rgba(0, 0, 0, 0.07);
				border-radius: 20rpx 20rpx 20rpx 20rpx;
				margin: auto;
				margin-top: 18rpx;
				padding: 24rpx 28rpx;
				box-sizing: border-box;
                .devixexq {
                	display: flex;
                	justify-content: space-between;
                	margin-top: 14rpx;
                	text-align: center;
                
                	.xiaoav {
                		font-size: 28rpx;
                		color: #3D3D3D;
                		view {
                			margin-top: 12rpx;
                		}
						.aa{
							font-size: 24rpx;
							color: #3D3D3D;
							font-weight: 600;
							margin-top: 24rpx;
						}
                	}
                }
				.zong {
					font-size: 24rpx;
					color: #3D3D3D;
					margin-top: 26rpx;
				}
				.bot {
					display: flex;
					justify-content: space-between;
					border-top: 1px solid #D8D8D8;
					padding-top: 22rpx;
					box-sizing: border-box;
					margin-top: 22rpx;
                    font-size: 24rpx;
					view {
						text {
							color: #8883F0;
						}
					}
				}

				.tops {
					display: flex;
					justify-content: space-between;
					width: 100%;
					border-bottom: 1px solid #D8D8D8;
					padding-bottom: 20rpx;
					box-sizing: border-box;

					view {
						display: flex;
						align-items: center;

						text {
							display: inline-block;
							width: 14rpx;
							height: 14rpx;
							border-radius: 50%;
							background-color: #8883F0;
							margin-right: 6rpx;
						}
					}
				}
			}
		}

		.serch {
			width: 750rpx;
			height: 136rpx;
			background: #FFFFFF;
			display: flex;
			padding: 0 36rpx;
			box-sizing: border-box;

			.inp {
				display: flex;
				align-items: center;
				margin-top: 26rpx;
				height: 68rpx;
				border: 2rpx solid #C7C7C7;
				width: 100%;
				border-radius: 20rpx;
				justify-content: space-between;
				// padding-right: 24rpx;
				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: 220rpx;

					image {
						width: 46rpx;
						height: 46rpx;
						margin-right: 12rpx;
					}
				}

			}
		}
	}
</style>