<template>
	<view class="container">
		<view class="search">
			<u-search placeholder="请输入小区名/台账号" height="78" :show-action="false" v-model="keyword"></u-search>
		</view>
		<view class="list-box">
			<view class="list-item" @click="selectItem(item)" v-for="(item,index) in listData" :key="index">
				<view class="person-info">
					<image class="icon" src="/static/kehu/person_gray.png" mode="" />
					<view class="name u-line-1">{{item.personName}}</view>
				</view>
				<view class="house u-line-1">{{item.address}}</view>
				<view class="right">
					<view class="house">{{item.accountNum}}</view>
					<image class="path" src="/static/path.png" mode="" />
				</view>
			</view>
			<view class="empty-box" v-if="listData.length==0&&!loading">
				<image class="img" src="http://images.2weisou.com/20221031114904TSF6jF4S.png" mode=""/>
				<view class="no-data">暂无数据</view>
			</view>
			<view class="loading" v-if="loading">
				<u-loading size="40" :show="loading"/>
				正在加载中
			</view>
		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				keyword: '',
				listData: [],
				pageNo: 1,
				pageSize: 10,
				loadDone: false,
				loading: false,
			};
		},
		onLoad(options) {
		},
		onShow() {
		
		},
		created(){
			this.getList()
		},
		onReachBottom() {
			this.getList();
		},
		methods: {
			selectItem(item){
				wx.setStorageSync('houseSource',item)
				wx.navigateBack()
			},
			getList(){
				if (this.loadDone) return;
				this.loading = true;
				let params = {
					pageNo:this.pageNo,
					pageSize:this.pageSize,
					message:this.keyword
				}
				this.$u.api.findProxyHouse({body:params}).then((res)=>{
					// console.log(res)
					this.loading = false;
					if(res.result&&res.result.length){
						if(this.pageNo==1){
							this.listData = res.result
						}else{
							this.listData = [...this.listData, ...res.result];
						}
						if(res.result.length<this.pageSize){
							this.loadDone = true;
							return ;
						}
						this.pageNo += 1;
						this.loadDone = false
					}else{
						this.loadDone = true;
						if(this.pageNo==1){
							this.listData = []
							
						}
					}
				})
			}
		},
	};
</script>

<style lang="scss" scoped>
.container{
	width: 750rpx;
	min-height: 100vh;
	.search{
		width: 100%;
		height: 100rpx;
		padding: 30rpx;
	}
	.list-box{
		padding: 0 30rpx;
		.list-item{
			padding: 30rpx 0;
			font-size: 28rpx;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: #333333;
			display: flex;
			align-items: center;
			border-bottom: 1px solid #E0E0E0;
			.person-info{
				display: flex;
				align-items: center;
				.icon{
					width: 28rpx;
					height: 30rpx;
					margin-right: 12rpx;
				}
				.name{
					width: 120rpx;
				}
			}
			.house{
				flex:1;
				margin: 0 10rpx;
			}
			.right{
				display: flex;
				align-items: center;
				
				.path{
					width: 14rpx;
					height: 30rpx;
					margin-left: 12rpx;
				}
			}
			
		}
	}
}
</style>
