<template>
	<view class="coupon-popup" v-if="show">
		<view class="coupon-container">
			<image class="coupon-background"
				src="https://bjzmky-1323137866.cos.ap-chongqing.myqcloud.com/userapp/images/coupon_bg.png" />
			<image class="coupon-header"
				src="https://bjzmky-1323137866.cos.ap-chongqing.myqcloud.com/userapp/images/coupon_top.png" />
			<image @click="$emit('close')" class="coupon-close-button"
				src="https://bjzmky-1323137866.cos.ap-chongqing.myqcloud.com/userapp/images/close_white.png" />
			<view class="coupon-content">
				<view class="coupon-name">{{ coupon.couponName }}</view>
				<view class="coupon-price">
					￥
					<text class="coupon-price-integer">{{ coupon.couponPrice }}</text>
				</view>
				<view class="coupon-condition">满{{ coupon.useMinPrice }}元可用</view>
				<view class="coupon-description">指定商品可用</view>
				<view class="coupon-validity">自领取起{{ coupon.couponTime }}天内有效</view>
				<view class="coupon-get-button" @click="$emit('claim')">立即领券</view>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	name: 'LiveCouponPanel',
	props: {
		show: { type: Boolean, default: false },
		coupon: { type: Object, default: () => ({}) }
	}
}
</script>

<style scoped lang="scss">
.coupon-popup {
	position: fixed;
	left: 50%;
	top: 50%;
	transform: translate(-50%, -50%);
	z-index: 10077;
	border-radius: 20rpx;
	width: 320rpx;

	.coupon-container {
		width: 100%;
		position: relative;

		.coupon-background {
			height: 452rpx;
			width: 100%;
		}

		.coupon-header {
			position: absolute;
			height: 120rpx;
			top: -120rpx;
			left: 0;
			width: 100%;
			z-index: 6;
		}

		.coupon-close-button {
			position: absolute;
			right: 10rpx;
			top: 10rpx;
			width: 40rpx;
			height: 40rpx;
			z-index: 99;
		}

		.coupon-content {
			width: 100%;
			position: absolute;
			top: 20rpx;
			display: flex;
			flex-direction: column;
			align-items: center;
			color: #fff;

			.coupon-name {
				font-weight: 500;
				font-size: 30rpx;
				margin: 16rpx 0 12rpx;
			}

			.coupon-price {
				font-size: 40rpx;

				.coupon-price-integer {
					font-size: 56rpx;
					font-weight: 600;
				}
			}

			.coupon-condition,
			.coupon-description,
			.coupon-validity {
				font-weight: 500;
				font-size: 30rpx;
				margin: 5rpx 0;
			}

			.coupon-description {
				margin-top: 26rpx;
			}

			.coupon-get-button {
				width: 240rpx;
				height: 72rpx;
				line-height: 72rpx;
				background: linear-gradient(180deg, #fff4d5 0%, #ffe5b1 100%);
				border-radius: 36rpx;
				font-weight: 600;
				font-size: 32rpx;
				color: #c32008;
				text-align: center;
				margin-top: 20rpx;
			}
		}
	}
}
</style>
