<template>
	<view>
		<view class="upper-switch">
			<view
				:class="[{ active: upperStatus == 1 }]"
				@click="switchCount(1)"
			>
				全部
			</view>
			<view
				:class="[{ active: upperStatus == 2 }]"
				@click="switchCount(2)"
			>
				待确认
			</view>
			<view
				:class="[{ active: upperStatus == 3 }]"
				@click="switchCount(3)"
			>
				进行中
			</view>
			<view
				:class="[{ active: upperStatus == 4 }]"
				@click="switchCount(4)"
			>
				已完结
			</view>
			<view
				:class="[{ active: upperStatus == 5 }]"
				@click="switchCount(5)"
			>
				驳回
			</view>
		</view>
		<view 
			class="single-loans"
			v-for="(loan, index) in modeList"
			:key="index"
		>
			<view class="upper-infos">
				<view class="info-lef">
					<image :src="loan.pic" mode=""></image>
				</view>
				<view class="info-rig">
					<view class="rig-top">{{ loan.name }}</view>
					<view class="rig-others">订单编号：{{ loan.code }}</view>
					<view class="rig-others">租赁时长：{{ loan.time }}</view>
				</view>
			</view>
			<view class="lower-cash">
				<view class="btns" v-show="loan.status == '退租申请' || loan.status == '续租申请' || loan.status == '待确认'">
					<view v-show="loan.status == '待确认'" style="background-color: #5199FF;">确认</view>
					<view v-show="loan.status == '退租申请' || loan.status == '续租申请'" style="background-color: #5199FF;">审核</view>
				</view>
				<text>
					<span v-show="loan.status == '退租申请'">实付款</span>
					<span v-show="loan.status == '待确认' || loan.status == '进行中' || loan.status == '续租申请'">月租金</span>
					：￥{{ loan.cash }}
				</text>
			</view>
			<view 
				:class="[ 
					'right-top-stick', 
					{ waitconfirm: loan.status == '待确认' }, 
					{ exitloan: loan.status == '退租申请' },
					{ ongoing: loan.status == '进行中' },
					{ continueloan: loan.status == '续租申请' }
				]"
			>
				{{ loan.status }}
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				upperStatus: 1,
				modeList: [
					{
						name: '522单杠震动压路机',
						pic: '/static/bg1.jpg',
						code: '22335566',
						time: '2023.12.12-2023.12.14',
						cash: '20000',
						status: '1'
					},
					{
						name: '522单杠震动压路机',
						pic: '/static/bg2.jpg',
						code: '44778899',
						time: '2023.12.17-2023.12.19',
						cash: '30000',
						status: '2'
					},
					{
						name: '522单杠震动压路机',
						pic: '/static/bg3.jpg',
						code: '22446622',
						time: '2023.12.19-2023.12.21',
						cash: '40000',
						status: '3'
					},
					{
						name: '522单杠震动压路机',
						pic: '/static/bg4.jpg',
						code: '99113355',
						time: '2023.12.23-2023.12.25',
						cash: '35000',
						status: '4'
					},
					{
						name: '522单杠震动压路机',
						pic: '/static/bg3.jpg',
						code: '22446622',
						time: '2023.12.19-2023.12.21',
						cash: '40000',
						status: '3'
					}
				]
			}
		},
		methods: {
			switchCount (count) {
				this.upperStatus = count
			}
		},
		onShow() {
			let that = this
			for (let i = 0; i < this.modeList.length; i++) {
				switch (this.modeList[i].status) {
					case '1':
						this.modeList[i].status = '待确认'
						break;
					case '2':
						this.modeList[i].status = '退租申请'
						break;
					case '3':
						this.modeList[i].status = '进行中';
						break;
					case '4':
						this.modeList[i].status = '续租申请';
						break;
				}
			}
		}
	}
</script>

<style lang="scss">
	body{
		background-color: #F9F9F9;
	}
	.upper-switch{
		width: 90%;
		margin: 20rpx auto;
		display: flex;
		view{
			width: 15%;
			margin-right: 15rpx;
			font-size: 14px;
			color: #A6A6A6;
			display: flex;
			justify-content: center;
			align-items: center;
		}
		.active{
			color: #000;
			font-size: 16px;
			font-weight: bold;
		}
	}
	.single-loans{
		width: 90%;
		margin: 20rpx auto;
		display: flex;
		flex-direction: column;
		background-color: #fff;
		box-sizing: border-box;
		padding: 30rpx;
		border-radius: 15rpx;
		position: relative;
		.upper-infos{
			width: 100%;
			box-sizing: border-box;
			padding: 0 0 20rpx 0;
			display: flex;
			border-bottom: 1px solid #F1F1F1;
			.info-lef{
				width: 25%;
				height: 10.5vh;
				border-radius: 15rpx;
				overflow: hidden;
				image{
					width: 100%;
					height: 100%;
				}
			}
			.info-rig{
				flex: 1;
				display: flex;
				flex-direction: column;
				justify-content: space-around;
				align-items: center;
				box-sizing: border-box;
				padding: 15rpx;
				view{
					width: 100%
				}
				.rig-top{
					font-size: 18px;
					font-weight: bold;
					margin-bottom: 15rpx;
				}
				.rig-others{
					font-size: 12px;
					color: #7A7A7A;
				}
			}
		}
		.lower-cash{
			width: 100%;
			display: flex;
			justify-content: space-between;
			align-items: center;
			box-sizing: border-box;
			padding: 20rpx 0 0 0;
			.btns{
				width: 40%;
				display: flex;
				justify-content: space-between;
				view{
					width: 45%;
					border-radius: 20rpx;
					color: #fff;
					box-sizing: border-box;
					padding: 8rpx 15rpx;
					font-size: 12px;
					display: flex;
					justify-content: center;
					align-items: center;
				}
			}
			text{
				font-size: 14px;
			}
		}
		.right-top-stick{
			box-sizing: border-box;
			padding: 6rpx 18rpx;
			border-radius: 10rpx;
			display: flex;
			justify-content: center;
			align-items: center;
			position: absolute;
			font-size: 14px;
			top: 10rpx;
			right: 10rpx;
		}
		.waitconfirm{
			border: 1px solid #318DFF;
			color: #318DFF;
		}
		.exitloan{
			border: 1px solid #F920C7;
			color: #F920C7;
		}
		.ongoing{
			border: 1px solid #4BF85A;
			color: #4BF85A;
		}
		.continueloan{
			border: 1px solid #B747FF;
			color: #B747FF;
		}
	}
</style>
