mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
* [Improvement] CouponCell text adjust * fix: Coupon test cases * [bugfix] SubmitBar i18n not work
51 lines
981 B
Vue
51 lines
981 B
Vue
<template>
|
|
<van-cell-group class="van-coupon-cell">
|
|
<van-cell :title="title || '优惠券码'" :value="value" :isLink="editable" @click="$emit('click')" />
|
|
</van-cell-group>
|
|
</template>
|
|
|
|
<script>
|
|
import Cell from '../cell';
|
|
import CellGroup from '../cell-group';
|
|
|
|
export default {
|
|
name: 'van-coupon-cell',
|
|
|
|
components: {
|
|
[Cell.name]: Cell,
|
|
[CellGroup.name]: CellGroup
|
|
},
|
|
|
|
model: {
|
|
prop: 'chosenCoupon'
|
|
},
|
|
|
|
props: {
|
|
title: String,
|
|
coupons: {
|
|
type: Array,
|
|
default: () => []
|
|
},
|
|
chosenCoupon: {
|
|
type: Number,
|
|
default: -1
|
|
},
|
|
editable: {
|
|
type: Boolean,
|
|
default: true
|
|
}
|
|
},
|
|
|
|
computed: {
|
|
value() {
|
|
const { coupons } = this;
|
|
const coupon = coupons[this.chosenCoupon];
|
|
if (coupon) {
|
|
return `省¥${(coupon.value / 100).toFixed(2)}`;
|
|
}
|
|
return coupons.length === 0 ? '使用优惠' : `您有 ${coupons.length} 个可用优惠`;
|
|
}
|
|
}
|
|
};
|
|
</script>
|