From 6d003c88a12226b8c36324fb6931dce28c0644be Mon Sep 17 00:00:00 2001 From: Li Chuangbo Date: Wed, 27 Dec 2017 19:04:48 +1300 Subject: [PATCH] [Doc] Coupon: fix exchange coupons (#486) --- docs/demos/views/coupon.vue | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/docs/demos/views/coupon.vue b/docs/demos/views/coupon.vue index 54ecc661b..05d94ce14 100644 --- a/docs/demos/views/coupon.vue +++ b/docs/demos/views/coupon.vue @@ -43,13 +43,14 @@ export default { data() { return { showList: false, - chosenCoupon: -1 + chosenCoupon: -1, + exchangedCoupons: [] }; }, computed: { coupons() { - return [this.coupon, this.discountCoupon]; + return [this.coupon, this.discountCoupon, ...this.exchangedCoupons]; }, disabledCoupons() { @@ -108,7 +109,13 @@ export default { }, onExchange(code) { 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 } } };