<template>
	<view class="container">
		<!-- 优惠券列表区域 -->
		<view class="body">
			<!-- 每一张优惠券区域 -->
			<view class="body_item" v-for="item in list" :key="item.id">
				<img src="../../static/my/couponTitle.png" />
				<view class="item_type" v-if="item.type === 1">折扣卷</view>
				<view class="item_type" v-if="item.type === 2">代金卷</view>
				<view class="item_box">
					<view class="box_left">
						<view class="left_title">{{ item.name }}</view>
						<view class="left_time">{{ item.time }} 可领取</view>
						<view class="left_tags">
							<view class="tag" v-for="(ele, index) in item.tags" :key="index" @click="handleClickTag(ele)">
								{{ ele }}
								<img v-if="ele === '指定民宿'" src="../../static/index/right2.png" />
							</view>
						</view>
					</view>
					<view class="box_right">
						<view class="right_info">
							<view class="info_top">{{ item.info }}</view>
							<view class="info_bottom">满200可用</view>
							<view class="info_btn" v-if="item.isFull">立即领取</view>
							<view class="info_btn2" v-else>已领取</view>
						</view>
					</view>
				</view>
			</view>
		</view>

		<!-- 指定民宿弹窗区域 -->
		<uni-popup ref="popup" type="center" :is-mask-click="false">
			<view class="popup_body">
				<view class="popup_header">
					<img src="../../static/my/popup_title.png" />
					<view class="header_title">指定民宿</view>
					<img src="../../static/my/popup_title.png" />
				</view>
				<view class="popup_center">民宿名称，民宿名称，民宿名称</view>
				<view class="popup_btn" @click="handleClose">我知道了</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
export default {
	data() {
		return {
			// 优惠券列表数据
			list: [
				{
					id: 1,
					name: '7.5折折扣卷',
					type: 1,
					info: '7.5折',
					isFull: false,
					time: '2023.09.01  12:00 - 2023.10.01  12:00',
					tags: ['可通用', '全民宿']
				},
				{
					id: 2,
					name: '20元代金券',
					type: 2,
					info: '¥20',
					isFull: true,
					time: '2023.09.01  12:00 - 2023.10.01  12:00',
					tags: ['可通用', '指定民宿']
				},
				{
					id: 3,
					name: '7.5折折扣卷',
					type: 1,
					info: '7.5折',
					isFull: false,
					time: '2023.09.01  12:00 - 2023.10.01  12:00',
					tags: ['可通用', '全民宿']
				}
			]
		}
	},
	methods: {
		// 点击指定民宿tag回调
		handleClickTag(ele) {
			if (ele === '指定民宿') {
				this.$refs.popup.open()
			}
		},
		// 点击弹窗我知道了按钮回调
		handleClose() {
			this.$refs.popup.close()
		}
	}
}
</script>

<style lang="scss" scoped>
.container {
	box-sizing: border-box;
	padding: 20rpx 30rpx;
	height: 100vh;
	overflow-y: auto;
	background-color: #f2f3f5;

	.body {
		.body_item {
			position: relative;
			margin-bottom: 20rpx;
			padding-bottom: 22rpx;
			width: 690rpx;
			border-radius: 15rpx;
			background-color: #fff;

			img {
				width: 100rpx;
				height: 36rpx;
			}

			.item_type {
				position: absolute;
				top: 0;
				left: 14rpx;
				font-size: 24rpx;
				font-weight: bold;
				color: #fff;
			}

			.item_box {
				padding: 0 25rpx;
				display: flex;

				.box_left {
					flex: 6;
					overflow: hidden;

					.left_title {
						margin: 12rpx 0;
						font-size: 36rpx;
						font-weight: bold;
						overflow: hidden;
						text-overflow: ellipsis;
						white-space: nowrap;
					}

					.left_time {
						display: flex;
						flex-wrap: wrap;
						color: #808080;
						font-size: 20rpx;
					}

					.left_tags {
						display: flex;
						align-items: center;
						margin-top: 20rpx;
						color: #808080;
						font-size: 20rpx;

						.tag {
							display: flex;
							align-items: center;
							margin-right: 44rpx;

							img {
								margin-top: 4rpx;
								margin-left: 4rpx;
								width: 28rpx;
								height: 28rpx;
							}
						}
					}
				}

				.box_right {
					flex: 2;
					display: flex;

					.right_info {
						flex: 1;
						display: flex;
						flex-direction: column;
						align-items: flex-end;
						width: 100rpx;
						color: #ff5733;

						.info_top {
							margin-top: 10rpx;
							font-size: 36rpx;
						}

						.info_bottom {
							margin-top: 10rpx;
							font-size: 20rpx;
						}

						.info_btn {
							display: flex;
							justify-content: center;
							align-items: center;
							margin-top: 25rpx;
							width: 122rpx;
							height: 48rpx;
							color: #fff;
							font-size: 24rpx;
							border-radius: 6rpx;
							background-color: #096562;
						}

						.info_btn2 {
							display: flex;
							justify-content: center;
							align-items: center;
							margin-top: 25rpx;
							width: 122rpx;
							height: 48rpx;
							color: #fff;
							font-size: 24rpx;
							border-radius: 6rpx;
							background-color: #cccccc;
						}
					}
				}
			}
		}
	}

	.popup_body {
		display: flex;
		flex-direction: column;
		align-items: center;
		width: 481rpx;
		height: 404rpx;
		border-radius: 22.5rpx;
		background-color: #fff;

		.popup_header {
			display: flex;
			justify-content: center;
			align-items: center;
			height: 123rpx;
			font-size: 34rpx;
			font-weight: bold;
			color: #0f194d;

			img {
				width: 16rpx;
				height: 16rpx;
			}

			.header_title {
				margin: 0 10rpx;
			}
		}

		.popup_center {
			height: 135rpx;
			color: rgba(15, 25, 77, 0.6);
			font-size: 28rpx;
			font-weight: bold;
		}

		.popup_btn {
			display: flex;
			justify-content: center;
			align-items: center;
			width: 396rpx;
			height: 76rpx;
			color: #fff;
			font-size: 26rpx;
			border-radius: 43rpx;
			background: linear-gradient(90deg, #0bc196 0%, #096562 100%);
		}
	}
}
</style>
