huangye-parking/miniapp/components/CouponCard.vue
2026-02-28 17:35:49 +08:00

97 lines
1.9 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view class="coupon-card">
<view class="coupon-info">
<view class="coupon-name">{{ coupon.name }}</view>
<view class="coupon-store">适用门店{{ coupon.storeName }}</view>
<view class="coupon-code">券码{{ coupon.code }}</view>
<view class="coupon-expire">有效期{{ coupon.validStart }} ~ {{ coupon.validEnd }}</view>
</view>
<view class="coupon-action">
<!-- 平台券显示二维码按钮 -->
<button
v-if="coupon.source === 'platform'"
class="btn btn-primary"
size="mini"
@click="$emit('showQrcode', coupon)"
>二维码</button>
<!-- 驿公里券:显示跳转按钮 -->
<view v-else-if="coupon.source === 'ygl'" class="ygl-action">
<text class="ygl-tip">需在驿公里使用</text>
<button
class="btn btn-ygl"
size="mini"
@click="$emit('gotoYgl', coupon)"
>去使用</button>
</view>
</view>
</view>
</template>
<script>
export default {
name: 'CouponCard',
props: {
coupon: {
type: Object,
required: true
}
},
emits: ['showQrcode', 'gotoYgl']
}
</script>
<style scoped>
.coupon-card {
display: flex;
justify-content: space-between;
align-items: center;
background: #fff;
border-radius: 16rpx;
padding: 24rpx;
margin-bottom: 20rpx;
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.08);
}
.coupon-info {
flex: 1;
}
.coupon-name {
font-size: 32rpx;
font-weight: bold;
color: #333;
margin-bottom: 8rpx;
}
.coupon-store,
.coupon-code,
.coupon-expire {
font-size: 24rpx;
color: #999;
margin-bottom: 4rpx;
}
.coupon-action {
margin-left: 20rpx;
flex-shrink: 0;
}
.btn {
border-radius: 8rpx;
font-size: 24rpx;
}
.btn-primary {
background: #007aff;
color: #fff;
}
.btn-ygl {
background: #ff9500;
color: #fff;
}
.ygl-action {
display: flex;
flex-direction: column;
align-items: center;
}
.ygl-tip {
font-size: 20rpx;
color: #999;
margin-bottom: 8rpx;
}
</style>