<template>
	<view class="container">
		<view class="list-box">
			<view class="list-item" v-for="(item,index) in listData" :key="index">
				<view class="item-info">
					<view class="name">合同地址</view>
					<view class="value u-line-1">{{item.contractAddress}}</view>
					<image class="path" src="/static/path.png" mode="" />
				</view>
				<view class="item-info">
					<view class="name">签约时间</view>
					<view class="value">{{item.rentDateStart}}-{{item.rentDateEnd}}</view>
				</view>
				<view class="item-info">
					<view class="name">租约期限</view>
					<view class="value">{{item.leaseTime}}</view>
				</view>
				<view class="item-info">
					<view class="name">付款方式</view>
					<view class="value">{{item.paymentWay}}</view>
				</view>
				<view class="item-info">
					<view class="name">租金/月</view>
					<view class="value">{{item.rentPrice}}</view>
				</view>
				<view class="item-info">
					<view class="name">定金</view>
					<view class="value">{{item.money}}</view>
				</view>
				<view class="item-info">
					<view class="name">卫生费</view>
					<view class="value">{{item.wsFee}}</view>
				</view>
				<view class="item-info">
					<view class="name">有线费</view>
					<view class="value">{{item.tvFee}}</view>
				</view>
				<view class="item-info">
					<view class="name">服务费</view>
					<view class="value">{{item.fee}}</view>
				</view>
				<view class="btn-box">
					<!-- 审核状态 0 未审核 1 已审核 2 拒绝 -->
					<view class="btn pass" @click="checkFun(item,1)">通过</view>
					<view class="btn refuse" @click="checkFun(item,0)">驳回</view>
				</view>
			</view>
		</view>
		<u-modal title="确认操作" @confirm="confirm" show-cancel-button confirm-color="#FF6D25" confirm-text="通过" :mask-close-able="true" v-model="showmodal" :title-style="titleStyle">
			<view class="slot-content">
				<view class="my-tip">您确认通过该审核吗？</view>
			</view>
		</u-modal>
		<view class="loading" v-if="loading">
			<u-loading size="40" :show="loading"/>
			正在加载中
		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				loading: false,
				showmodal: false,
				titleStyle: {
					fontSize: '32rpx',
					fontFamily: 'PingFangSC-Semibold, PingFang SC',
					fontWeight: 600,
					color: '#333333'
				},
				listData: [],
				pageNo: 1,
				pageSize: 10,
				loadDone: false,
			};
		},
		onLoad(options) {

		},
		onShow() {
		
		},
		created() {
			this.getList()
		},
		onReachBottom() {
			this.getList();
		},
		methods: {
			getList(){
				if (this.loadDone) return;
				this.loading = true;
				let params = {
					pageNo:this.pageNo,
					pageSize:this.pageSize,
				}
				this.$u.api.getDepositList({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 = []
						}
					}
				})
			},
			checkFun(item,num){
				this.showmodal = true;
				this.contractId = item.contractId
				this.status = num
			},
			confirm(){
				this.$u.api.depositExamine({body:{contractId:this.contractId,status: this.status}}).then((res)=>{
					if(res.ErrNo=='0000'){
						this.showmodal = false;
						uni.showToast({
							title: '审核成功',
							icon:'none'
						})
					}
					this.listData = []
						this.pageNo = 1
						this.loadDone = false
					this.getList()
				})
			}
		},
	};
</script>

<style lang="scss" scoped>
.container{
	width: 750rpx;
	min-height: 100vh;
	background: #F8F8F8;
	padding-top: 20rpx;
	.list-box{
		.list-item{
			padding: 30rpx;
			background: #fff;
			font-size: 28rpx;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: #333333;
			margin-bottom: 20rpx;
			.item-info{
				display: flex;
				align-items: center;
				margin-bottom: 24rpx;
				font-size: 28rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				line-height: 40rpx;
				.name{
					flex: 0 0 112rpx;
					color: #666666;
					margin-right: 58rpx;
				}
				.value{
					flex: 1;
					color: #333;
				}
				.path{
					flex: 0 0 14rpx;
					width: 14rpx;
					height: 30rpx;
					margin-left: 10rpx;
				}
			
			}
			.btn-box{
				display: flex;
				justify-content: flex-end;
				.btn{
					width: 128rpx;
					height: 54rpx;
					line-height: 54rpx;
					text-align: center;
					font-size: 26rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					border-radius: 8rpx;
				}
				.pass{
					background: #FF6D25;
					color: #fff;
					border: 1px solid #FF6D25;
					margin-right: 30rpx;
				}
				.refuse{
					background: #FFFFFF;
					border: 1px solid #FF6D25;
					color: #FF6D25;
				}
			}
			
		}
	}
	.my-tip{
		text-align: center;
		margin: 40rpx 0;
		color: #666
	}
}
</style>
