feat: migrate CouponList component

This commit is contained in:
chenjiahan
2020-08-17 19:46:34 +08:00
parent 41796b0616
commit 579a9ebb78
8 changed files with 23 additions and 110 deletions
+1 -1
View File
@@ -88,7 +88,7 @@ export default {
| 参数 | 说明 | 类型 | 默认值 |
| --- | --- | --- | --- |
| v-model | 当前输入的兑换码 | _string_ | - |
| v-model:code | 当前输入的兑换码 | _string_ | - |
| chosen-coupon | 当前选中优惠券的索引 | _number_ | `-1` |
| coupons | 可用优惠券列表 | _Coupon[]_ | `[]` |
| disabled-coupons | 不可用优惠券列表 | _Coupon[]_ | `[]` |
+1 -2
View File
@@ -6,9 +6,8 @@
:chosen-coupon="chosenCoupon"
@click="showList = true"
/>
<van-popup
v-model="showList"
v-model:show="showList"
round
position="bottom"
style="height: 90%; padding-top: 4px;"
+8 -10
View File
@@ -12,16 +12,12 @@ const [createComponent, bem, t] = createNamespace('coupon-list');
const EMPTY_IMAGE = 'https://img.yzcdn.cn/vant/coupon-empty.png';
export default createComponent({
model: {
prop: 'code',
},
props: {
code: String,
closeButtonText: String,
inputPlaceholder: String,
enabledTitle: String,
disabledTitle: String,
closeButtonText: String,
inputPlaceholder: String,
exchangeButtonText: String,
exchangeButtonLoading: Boolean,
exchangeButtonDisabled: Boolean,
@@ -67,6 +63,8 @@ export default createComponent({
},
},
emits: ['change', 'exchange', 'update:code'],
data() {
return {
tab: 0,
@@ -98,7 +96,7 @@ export default createComponent({
},
currentCode(code) {
this.$emit('input', code);
this.$emit('update:code', code);
},
displayedCouponIndex: 'scrollToShowCoupon',
@@ -194,9 +192,9 @@ export default createComponent({
ref="card"
key={coupon.id}
coupon={coupon}
currency={this.currency}
chosen={index === this.chosenCoupon}
nativeOnClick={onChange(index)}
currency={this.currency}
onClick={onChange(index)}
/>
))}
{!coupons.length && this.genEmpty()}
@@ -234,8 +232,8 @@ export default createComponent({
<Button
vShow={this.showCloseButton}
round
type="danger"
block
type="danger"
class={bem('close')}
text={this.closeButtonText || t('close')}
onClick={onChange(-1)}