<template>
	<view class="container">
		<view class="list-item" v-for="(item,index) in listData" :key="index">
			<view class="top">
				<view class="top-left">
					<image class="icon" src="/static/kehu/person_gray.png" mode="" />{{item.personName}}
				</view>
				<view class="time">{{item.customerViewTime}}</view>
			</view>
			<view class="bot">{{item.address}}</view>
		</view>
		<view class="loading" v-if="loading">
				<u-loading size="40" :show="loading"/>
				正在加载中
			</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>
</template>
<script>
	export default {
		data() {
			return {
				listData: [],
				pageNo: 1,
				pageSize: 10,
				loadDone: false,
				loading: false,
				roomId:''
			};
		},
		
		onReachBottom() {
			this.getList();
		},
		methods: {
			getList(){
				if (this.loadDone) return;
				this.loading = true;
				let body = {
					pageNo:this.pageNo,
					pageSize:this.pageSize,
					roomId: this.roomId
				}
				this.$u.api.housecustomerViewHistory({body:body}).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 = []
						}
					}
				})
			},
		},

		onLoad: function(options) {
			this.roomId=options.id
			this.getList();
		},
		onHide: function() {},
	};
</script>

<style lang="scss" scoped>
.container{
	width: 750rpx;
	min-height: 100vh;
	background: #F8F8F8;
	padding-top: 20rpx;
	.list-item{
		background: #fff;
		margin-bottom: 20rpx;
		padding: 30rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		.top{
			display: flex;
			justify-content: space-between;
			align-items: center;
			.top-left{
				display: flex;
				align-items: center;
				font-size: 30rpx;
				font-weight: 400;
				color: #333333;
				.icon{
					width: 28rpx;
					height: 30rpx;
					margin-right: 12rpx;
				}
			}
			.time{
				height: 42rpx;
				font-size: 30rpx;
				font-weight: 400;
				color: #666666;
				line-height: 42rpx;
			}
		}
		.bot{
			font-size: 30rpx;
			font-weight: 400;
			color: #333333;
			line-height: 42rpx;
			margin-top: 20rpx;
		}
	}
}
</style>
