From 1f3c2fa9db33bb970457bcc64a80cf385305cb10 Mon Sep 17 00:00:00 2001 From: neverland Date: Thu, 20 Jun 2019 20:33:44 +0800 Subject: [PATCH] =?UTF-8?q?[new=20feature]=20CouponList:=20add=20enabled-t?= =?UTF-8?q?itle=E3=80=81disabled-title=20props=20(#3578)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/coupon-list/en-US.md | 4 +++- packages/coupon-list/index.js | 28 ++++++++++++++-------------- packages/coupon-list/zh-CN.md | 2 ++ 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/packages/coupon-list/en-US.md b/packages/coupon-list/en-US.md index 30743abf6bc..3657f5e4f16 100644 --- a/packages/coupon-list/en-US.md +++ b/packages/coupon-list/en-US.md @@ -86,7 +86,9 @@ export default { | v-model | Current exchange code | `String` | - | | chosen-coupon | Index of chosen coupon | `Number` | `-1` | | coupons | Coupon list | `Array` | `[]` | -| disabled-coupons | Disabled voupon list | `Array` | `[]` | +| disabled-coupons | Disabled coupon list | `Array` | `[]` | +| enabled-title | Title of coupon list | `String` | `Available` | - | +| disabled-title | Title of disabled coupon list | `String` | `Unavailable` | - | | exchange-button-text | Exchange button text | `String` | `Exchange` | | exchange-button-loading | Whether to show loading in exchange button | `Boolean` | `false` | | exchange-button-disabled | Whether to disable exchange button | `Boolean` | `false` | diff --git a/packages/coupon-list/index.js b/packages/coupon-list/index.js index 1771e38ee12..28ec121f49b 100644 --- a/packages/coupon-list/index.js +++ b/packages/coupon-list/index.js @@ -19,6 +19,8 @@ export default sfc({ disabledCoupons: Array, closeButtonText: String, inputPlaceholder: String, + enabledTitle: String, + disabledTitle: String, exchangeButtonText: String, exchangeButtonLoading: Boolean, exchangeButtonDisabled: Boolean, @@ -66,14 +68,6 @@ export default sfc({ ); }, - title() { - return `${t('enable')} (${this.coupons.length})`; - }, - - disabledTitle() { - return `${t('disabled')} (${this.disabledCoupons.length})`; - }, - listStyle() { return { height: this.winHeight - (this.showExchangeBar ? 140 : 94) + 'px' @@ -150,6 +144,12 @@ export default sfc({ }, render(h) { + const { coupons, disabledCoupons } = this; + const title = `${this.enabledTitle || t('enable')} (${coupons.length})`; + const disabledTitle = `${this.disabledTitle || t('disabled')} (${ + disabledCoupons.length + })`; + const ExchangeBar = this.showExchangeBar && ( () => this.$emit('change', index); const CouponTab = ( - +
- {this.coupons.map((coupon, index) => ( + {coupons.map((coupon, index) => ( ))} - {!this.coupons.length && this.renderEmpty()} + {!coupons.length && this.renderEmpty()}
); const DisabledCouponTab = ( - +
- {this.disabledCoupons.map(coupon => ( + {disabledCoupons.map(coupon => ( ))} - {!this.disabledCoupons.length && this.renderEmpty()} + {!disabledCoupons.length && this.renderEmpty()}
); diff --git a/packages/coupon-list/zh-CN.md b/packages/coupon-list/zh-CN.md index 7d8176227e8..39581ca287e 100644 --- a/packages/coupon-list/zh-CN.md +++ b/packages/coupon-list/zh-CN.md @@ -87,6 +87,8 @@ export default { | chosen-coupon | 当前选中优惠券的索引 | `Number` | `-1` | - | | coupons | 可用优惠券列表 | `Array` | `[]` | - | | disabled-coupons | 不可用优惠券列表 | `Array` | `[]` | - | +| enabled-title | 可用优惠券列表标题 | `String` | `可使用优惠券` | - | +| disabled-title | 不可用优惠券列表标题 | `String` | `不可使用优惠券` | - | | exchange-button-text | 兑换按钮文字 | `String` | `兑换` | - | | exchange-button-loading | 是否显示兑换按钮加载动画 | `Boolean` | `false` | - | | exchange-button-disabled | 是否禁用兑换按钮 | `Boolean` | `false` | - |