<template>
	<view class="container">
		<view class="calendar">
			<view class="date" @click="openCalendar(0)">
				 <view v-if="starDate">{{starDate}}</view>
				 <view v-else class="desc">起始日期</view>
			</view>
			<view class="date" @click="openCalendar(1)">
				<view v-if="endDate">{{endDate}}</view>
				<view v-else class="desc">结束日期</view>
			</view>
			<u-calendar :min-date="mindate" :max-date="maxdate" v-model="calendarShow" mode="date" @change="changeDate"></u-calendar>
		</view>
		<view class="list-item" v-for="(item,index) in listData" :key="index">
			<view class="top">
				<view class="name">{{item.roomNum}}</view>
				<view>应收日期：{{item.payableDate.replace(/-/g,'.')}}</view>
				<!-- 收费状态 0未收 1已收 2未缴清 -->
				<view class="mark" v-if="item.payableStatus==0">未收</view>
				<view class="mark" v-if="item.payableStatus==1">已收</view>
				<view class="mark" v-if="item.payableStatus==2">未缴清</view>
			</view>
			<view class="bot">
				<view>租客：{{item.customerName}}</view>
				<view>租金{{item.payableMoney}}</view>
				<view class="tel"><image class="tel-icon" src="/static/my/tel.png" mode="" />{{item.customerMobile}}</view>
				</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>
</template>
<script>
	export default {
		data() {
			return {
				starDate: '',
				endDate: '',
				type: 0,// 默认是开始时间
				calendarShow: false,
				mindate: '',
				maxdate: '2099-12-31',
				pageNo: 1,
				pageSize: 10,
				loadDone: false,
				loading: false,
				listData: []
			};
		},
		onLoad(options) {
		},
		onShow() {
		
		},
		created() {
			this.getList()
		},
		onReachBottom() {
			this.getList();
		},
		methods: {
			getList(){
				if (this.loadDone) return;
				this.loading = true;
				let body = {
					pageNo:this.pageNo,
					pageSize:this.pageSize,
					message: this.keyword,
					startTime: this.starDate,
					endTime: this.endDate
				}
				this.$u.api.customerReceivable({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 = []
						}
					}
				})
			},
			openCalendar(type){
				if(type==0){
					this.type = 0
					this.mindate = ''
					this.maxdate = this.endDate
				}else{
					this.type = 1
					this.mindate = this.starDate
					this.maxdate = '2099-12-31'
				}
				this.calendarShow = true;
			},
			changeDate(e){
				// console.log(e)
				if(this.type==0){
					this.starDate = e.result
				}else{
					this.endDate = e.result
				}
				this.pageNo =1
				this.loadDone = false,
				this.listData = []
				this.getList()
			}

		},

	};
</script>

<style lang="scss" scoped>
.container{
	width: 750rpx;
	min-height: 100vh;
	background: #F8F8F8;
	.search{
		width: 100%;
		height: 110rpx;
		padding: 16rpx 30rpx;
		background: #fff;
	}
	.calendar{
		width: 750rpx;
		height: 92rpx;
		background: #FFFFFF;
		margin-bottom: 20rpx;
		display: flex;
		align-items: center;
		justify-content: space-around;
		font-size: 26rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		padding: 0 40rpx;
		.date{
			flex:1;
			color: #333333;
			position: relative;
			text-align: center;
			&::after{
				position: absolute;
				content: "";
				top: 16rpx;
				right: 60rpx;
				border-color: #FF6D25;
				border: 8rpx solid transparent;
				border-top: 8rpx solid #FF6D25;
			}
			.desc{
				color: #999999;
			}
		}
	}
	.list-item{
		margin-bottom: 20rpx;
		padding: 0 30rpx;
		background: #fff;
		.top{
			height: 96rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			font-size: 30rpx;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: #333333;
			.name{
				width: 230rpx;
				color: #333333;
			}
			.mark{
				color: #fff;
				margin-left: 26rpx;
				min-width: 116rpx;
				height: 52rpx;
				text-align: center;
				line-height: 52rpx;
				background: #FF6D25;
				border-radius: 0px 20rpx 0px 20rpx;
			}
		}
		.bot{
			height: 96rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;
			font-size: 30rpx;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: #505050;
			border-top: 1px solid #e0e0e0;
			.tel{
				display: flex;
				align-items: center;
				.tel-icon{
					width: 30rpx;
					height: 30rpx;
					margin-right: 12rpx;
				}
			}
		}
	}
}
</style>
