<template>
	<view>
		<view class="cu-bar search bg-gray">
			<view class="search-form round text-center">
				<text class="cuIcon-search"></text>
				<input v-model="searchval" :adjust-position="false" type="text" placeholder="搜索店名或手机号" confirm-type="search" @confirm="pageRefresh()"></input>
			</view>
			<view class="action">
				<button class="cu-btn bg-white shadow-blur round" @click="pageRefresh()">搜索</button>
			</view>
		</view>
		<!-- <scroll-view scroll-x class="bg-white nav text-center solid-bottom">
			<block v-for="(item,index) in followstatusarr" :key="index">
			<view class="cu-item" :class="followstatus==index?'text-blue cur':''" @tap="tabSelect" :data-followstatus="index">{{item}}</view>
			</block>
		</scroll-view> -->
		
		<view class="cu-list menu-avatar">
			<view class="cu-item" v-for="item in plist">
				<view class="cu-avatar round lg" :style="'background-image:url('+item.tilpic+');'"></view>
				<view class="content">
					<view class="text-grey">{{item.title}}</view>
					<view class="text-gray text-sm flex">
						<text class="text-cut">{{item.mobile}}</text>
					</view>
				</view>
			</view>
		</view>
		
		<uni-load-more :status="pstatus"></uni-load-more>

		
	</view>
</template>

<script>
	import uniLoadMore from "@/components/uni-load-more/uni-load-more.vue";
	var _this;
	export default {
		components: {
			uniLoadMore
		},
		data() {
			return {
				brokerinfo: {},
				searchval: "",
				
				pstatus: 'more',
				ppage: 1,
				psize: 20,
				plist: [],
			};
		},
		onLoad: function(){
			_this = this;
			_this.brokerinfo = uni.getStorageSync('brokerinfo') || false;
			if (_this.brokerinfo===false){
				uni.reLaunch({
					url: "/pages/my/my"
				});
				return false;
			}
			_this.getMore();
		},
		onPullDownRefresh: function() {
			_this.ppage = 1;
			_this.pstatus = 'more';
			_this.plist = [];
			_this.getMore();
		},
		onReachBottom: function() {
			if (_this.pstatus !== 'more') {
				return;
			}
			_this.getMore();
		},
		methods: {
			getMore: function() {
				_this.$req.ajax({
					path: "broker/listWorker",
					data: {
						ppage: _this.ppage,
						psize: _this.psize,
						brokerid: _this.brokerinfo.id,
						keyword: _this.searchval,
					}
				}).then((data) => {
					_this.pstatus = data.pstatus;
					_this.plist = _this.plist.concat(data.plist);
					_this.ppage += 1;
					uni.stopPullDownRefresh();
				}).catch((err) => {
					uni.showModal({
						title: '信息提示',
						content: err,
						showCancel: false
					});
				});
			},
			
			pageRefresh: function() {
				_this.pstatus = 'more';
				_this.ppage = 1;
				_this.plist = [];
				_this.getMore();
			},
		}
	}
</script>

<style>
	.cu-list.menu-avatar .cu-item{ height: 170rpx !important; }
</style>
