[Doc] Coupon: fix exchange coupons (#486)

This commit is contained in:
Li Chuangbo 2017-12-27 19:04:48 +13:00 committed by neverland
parent 6b563b2e5a
commit 6d003c88a1

View File

@ -43,13 +43,14 @@ export default {
data() { data() {
return { return {
showList: false, showList: false,
chosenCoupon: -1 chosenCoupon: -1,
exchangedCoupons: []
}; };
}, },
computed: { computed: {
coupons() { coupons() {
return [this.coupon, this.discountCoupon]; return [this.coupon, this.discountCoupon, ...this.exchangedCoupons];
}, },
disabledCoupons() { disabledCoupons() {
@ -108,7 +109,13 @@ export default {
}, },
onExchange(code) { onExchange(code) {
Toast(this.$t('exchange')); Toast(this.$t('exchange'));
this.coupons.push(coupon); this.exchangedCoupons.push({
...this.coupon,
id: this.randomId()
});
},
randomId(max = 999999) {
return Math.floor(Math.random() * max) + 1
} }
} }
}; };