mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
45 lines
862 B
Vue
45 lines
862 B
Vue
<template>
|
|
<cell-group :class="b()">
|
|
<cell :title="title || $t('title')" :value="value" :is-link="editable" @click="$emit('click')" />
|
|
</cell-group>
|
|
</template>
|
|
|
|
<script>
|
|
import create from '../utils/create';
|
|
|
|
export default create({
|
|
name: 'coupon-cell',
|
|
|
|
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 `${this.$t('reduce')}¥${(coupon.value / 100).toFixed(2)}`;
|
|
}
|
|
return coupons.length === 0 ? this.$t('tips') : this.$t('count', coupons.length);
|
|
}
|
|
}
|
|
});
|
|
</script>
|