151 lines
3.3 KiB
Vue
151 lines
3.3 KiB
Vue
<template>
|
|
<view class="coupon-card">
|
|
<!-- 背景图 -->
|
|
<image class="coupon-card-bg" src="/static/item_bg2.png" mode="scaleToFill" />
|
|
<!-- 左侧券类型 -->
|
|
<view class="coupon-left">
|
|
<template v-if="coupon.couponType === 'discount'">
|
|
<text class="coupon-price">¥{{ coupon.discountAmount }}</text>
|
|
<text class="coupon-type-label">折扣券</text>
|
|
</template>
|
|
<template v-else>
|
|
<text class="coupon-price">免费</text>
|
|
<text class="coupon-type-label">洗车券</text>
|
|
</template>
|
|
</view>
|
|
<!-- 右侧信息 -->
|
|
<view class="coupon-right">
|
|
<text class="coupon-name">{{ coupon.storeName }}</text>
|
|
<text class="coupon-info">券码:{{ coupon.code }}</text>
|
|
<text class="coupon-info">有效期:{{ formatValidity(coupon) }}</text>
|
|
<!-- 操作按钮 -->
|
|
<view class="coupon-bottom">
|
|
<view v-if="coupon.source === 'ygl'" class="ygl-tip-text">
|
|
<text class="coupon-info">需在驿公里洗车小程序中使用</text>
|
|
</view>
|
|
<view
|
|
v-if="coupon.source === 'platform'"
|
|
class="action-btn"
|
|
@click.stop="$emit('showQrcode', coupon)"
|
|
>
|
|
<text class="action-btn-text">二维码</text>
|
|
</view>
|
|
<view
|
|
v-else-if="coupon.source === 'ygl'"
|
|
class="action-btn"
|
|
@click.stop="$emit('gotoYgl', coupon)"
|
|
>
|
|
<text class="action-btn-text">去使用</text>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
name: 'CouponCard',
|
|
props: {
|
|
coupon: { type: Object, required: true }
|
|
},
|
|
emits: ['showQrcode', 'gotoYgl'],
|
|
methods: {
|
|
formatValidity(coupon) {
|
|
if (!coupon.validStart && !coupon.validEnd) return '-'
|
|
const endYear = new Date(coupon.validEnd).getFullYear()
|
|
if (endYear >= 2099) return '永久有效'
|
|
const fmt = (d) => d ? d.substring(0, 10) : ''
|
|
return `${fmt(coupon.validStart)}至${fmt(coupon.validEnd)}`
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped>
|
|
.coupon-card {
|
|
display: flex;
|
|
margin-bottom: 20rpx;
|
|
overflow: hidden;
|
|
position: relative;
|
|
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.05);
|
|
}
|
|
.coupon-card-bg {
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
width: 100%;
|
|
height: 100%;
|
|
z-index: 0;
|
|
}
|
|
/* 左侧标签 */
|
|
.coupon-left {
|
|
width: 160rpx;
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
justify-content: center;
|
|
padding: 24rpx 0 24rpx 20rpx;
|
|
flex-shrink: 0;
|
|
position: relative;
|
|
z-index: 1;
|
|
}
|
|
.coupon-price {
|
|
font-size: 65rpx;
|
|
font-weight: bold;
|
|
color: #E8C7AA;
|
|
line-height: 1.2;
|
|
}
|
|
.coupon-type-label {
|
|
font-size: 32rpx;
|
|
color: #E8C7AA;
|
|
margin-top: 6rpx;
|
|
}
|
|
/* 右侧信息 */
|
|
.coupon-right {
|
|
flex: 1;
|
|
padding: 24rpx 24rpx 20rpx;
|
|
display: flex;
|
|
margin-left: 20rpx;
|
|
flex-direction: column;
|
|
min-width: 0;
|
|
position: relative;
|
|
z-index: 1;
|
|
}
|
|
.coupon-name {
|
|
font-size: 36rpx;
|
|
font-weight: bold;
|
|
color: #FFFFFF;
|
|
margin-bottom: 8rpx;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
white-space: nowrap;
|
|
}
|
|
.coupon-info {
|
|
font-size: 26rpx;
|
|
color: #FFFFFF;
|
|
line-height: 1.6;
|
|
}
|
|
.coupon-bottom {
|
|
display: flex;
|
|
justify-content: flex-end;
|
|
align-items: center;
|
|
margin-top: 12rpx;
|
|
}
|
|
.ygl-tip-text {
|
|
flex: 1;
|
|
}
|
|
.action-btn {
|
|
background: #FFF8E8;
|
|
border-radius: 10rpx;
|
|
padding: 10rpx 28rpx;
|
|
}
|
|
.action-btn:active {
|
|
opacity: 0.8;
|
|
}
|
|
.action-btn-text {
|
|
font-size: 24rpx;
|
|
color: #E8C7AA;
|
|
font-weight: 500;
|
|
}
|
|
</style>
|