mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
[Improvement] CouponCell text adjust (#371)
* [Improvement] CouponCell text adjust * fix: Coupon test cases * [bugfix] SubmitBar i18n not work
This commit is contained in:
parent
b50d8cd8f6
commit
bbdf135724
@ -1,15 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="van-coupon-cell">
|
<van-cell-group class="van-coupon-cell">
|
||||||
<van-cell-group>
|
<van-cell :title="title || '优惠券码'" :value="value" :isLink="editable" @click="$emit('click')" />
|
||||||
<van-cell :title="title" :isLink="editable" @click="$emit('click')">
|
</van-cell-group>
|
||||||
<div v-if="coupons[chosenCoupon]">
|
|
||||||
<div>{{ coupons[chosenCoupon].name }}</div>
|
|
||||||
<div>{{ coupons[chosenCoupon].condition }}</div>
|
|
||||||
</div>
|
|
||||||
<template v-else>{{ guide }}</template>
|
|
||||||
</van-cell>
|
|
||||||
</van-cell-group>
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@ -29,10 +21,7 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
title: {
|
title: String,
|
||||||
type: String,
|
|
||||||
default: '优惠'
|
|
||||||
},
|
|
||||||
coupons: {
|
coupons: {
|
||||||
type: Array,
|
type: Array,
|
||||||
default: () => []
|
default: () => []
|
||||||
@ -48,8 +37,13 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
guide() {
|
value() {
|
||||||
return this.coupons.length === 0 ? '使用优惠' : `您有 ${this.coupons.length} 个可用优惠`;
|
const { coupons } = this;
|
||||||
|
const coupon = coupons[this.chosenCoupon];
|
||||||
|
if (coupon) {
|
||||||
|
return `省¥${(coupon.value / 100).toFixed(2)}`;
|
||||||
|
}
|
||||||
|
return coupons.length === 0 ? '使用优惠' : `您有 ${coupons.length} 个可用优惠`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -21,10 +21,13 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import Button from '../button';
|
import Button from '../button';
|
||||||
|
import { i18n } from '../locale';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'van-submit-bar',
|
name: 'van-submit-bar',
|
||||||
|
|
||||||
|
mixins: [i18n],
|
||||||
|
|
||||||
components: {
|
components: {
|
||||||
[Button.name]: Button
|
[Button.name]: Button
|
||||||
},
|
},
|
||||||
|
@ -82,7 +82,7 @@ describe('CouponCell', () => {
|
|||||||
|
|
||||||
DOMChecker(wrapper, {
|
DOMChecker(wrapper, {
|
||||||
text: {
|
text: {
|
||||||
'.van-cell__value--link div div': '新手专用优惠券'
|
'.van-cell__value--link span': '省¥1.50'
|
||||||
},
|
},
|
||||||
count: {
|
count: {
|
||||||
'.van-cell__right-icon': 1
|
'.van-cell__right-icon': 1
|
||||||
@ -101,7 +101,7 @@ describe('CouponCell', () => {
|
|||||||
|
|
||||||
DOMChecker(wrapper, {
|
DOMChecker(wrapper, {
|
||||||
text: {
|
text: {
|
||||||
'.van-cell__value div div': '新手专用优惠券'
|
'.van-cell__value span': '省¥1.50'
|
||||||
},
|
},
|
||||||
count: {
|
count: {
|
||||||
'.van-cell__right-icon': 0
|
'.van-cell__right-icon': 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user