[new feature] Coupon: add currency prop (#2274)

This commit is contained in:
neverland 2018-12-12 16:59:09 +08:00 committed by GitHub
parent a4a2ce9635
commit 267e5eda1d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 20 additions and 4 deletions

View File

@ -22,6 +22,10 @@ export default create({
props: {
title: String,
coupons: Array,
currency: {
type: String,
default: '¥'
},
border: {
type: Boolean,
default: true
@ -42,7 +46,7 @@ export default create({
const coupon = coupons[this.chosenCoupon];
if (coupon) {
const value = coupon.denominations || coupon.value;
return `-${(value / 100).toFixed(2)}`;
return `-${this.currency}${(value / 100).toFixed(2)}`;
}
return coupons.length === 0 ? this.$t('tips') : this.$t('count', coupons.length);
}

View File

@ -34,7 +34,8 @@ export default create({
props: {
data: Object,
chosen: Boolean,
disabled: Boolean
disabled: Boolean,
currency: String
},
components: {
@ -48,7 +49,7 @@ export default create({
faceAmount() {
return this.data.denominations !== 0
? `<span>¥</span> ${this.formatAmount(this.data.denominations)}`
? `<span>${this.currency}</span> ${this.formatAmount(this.data.denominations)}`
: this.data.discount !== 0
? this.formatDiscount(this.data.discount)
: '';

View File

@ -74,6 +74,7 @@ export default {
| coupons | Coupon list | `Array` | `[]` |
| editable | Cell editable | `Boolean` | `true` |
| border | Whether to show innner border | `Boolean` | `true` |
| currency | Currency symbol | `String` | `¥` |
### CouponList API
@ -90,6 +91,7 @@ export default {
| displayed-coupon-index | Index of displayed coupon | `Number` | - |
| close-button-text | Close button text | `String` | `Close` |
| input-placeholder | Input placeholder | `String` | `Coupon code` |
| currency | Currency symbol | `String` | `¥` |
### CouponList Event

View File

@ -35,6 +35,7 @@
v-for="(item, index) in coupons"
:key="item.id || item.name"
:data="item"
:currency="currency"
:chosen="index === chosenCoupon"
@click.native="$emit('change', index)"
/>
@ -57,6 +58,7 @@
v-for="item in disabledCoupons"
:key="item.id || item.name"
:data="item"
:currency="currency"
/>
<div
v-if="!disabledCoupons.length"
@ -129,6 +131,10 @@ export default create({
showCloseButton: {
type: Boolean,
default: true
},
currency: {
type: String,
default: '¥'
}
},

View File

@ -20,7 +20,7 @@ exports[`coupon cell 2`] = `
<div class="van-cell__title"><span>优惠券</span>
<!---->
</div>
<div class="van-cell__value"><span>-1.00</span></div>
<div class="van-cell__value"><span>-¥1.00</span></div>
<i class="van-icon van-icon-arrow van-cell__right-icon">
<!---->
<!---->

View File

@ -75,6 +75,7 @@ export default {
| coupons | 可用优惠券列表 | `Array` | `[]` | - |
| editable | 能否切换优惠券 | `Boolean` | `true` | - |
| border | 是否显示内边框 | `Boolean` | `true` | 1.3.10 |
| currency | 货币符号 | `String` | `¥` | - | 1.4.10 |
### CouponList API
@ -93,6 +94,7 @@ export default {
| close-button-text | 列表底部按钮文字 | `String` | `不使用优惠` | - |
| input-placeholder | 输入框文字提示 | `String` | `请输入优惠码` | - |
| show-exchange-bar | 是否展示兑换栏 | `Boolean` | `true` | - |
| currency | 货币符号 | `String` | `¥` | - | 1.4.10 |
### CouponList Event
@ -102,6 +104,7 @@ export default {
| exchange | 兑换优惠券回调 | code, 兑换码 |
### 数据格式
#### 优惠券字段说明
| key | 说明 | 类型 |