From 627cfc4aa0480a737aa856a173a612744dc5ab1d Mon Sep 17 00:00:00 2001 From: ghusermoon <2673031505@qq.com> Date: Wed, 19 Aug 2020 17:55:58 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BC=98=E6=83=A0=E5=88=B8=E5=8A=A0?= =?UTF-8?q?=E5=88=86=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/api/shop.js | 3 ++- pageE/tool/MineCoupon.vue | 44 +++++++++++++++++++++++++++------------ pageE/tool/WashOrder.vue | 8 +++++-- 3 files changed, 39 insertions(+), 16 deletions(-) diff --git a/common/api/shop.js b/common/api/shop.js index 50dd9e5..fccbc0e 100644 --- a/common/api/shop.js +++ b/common/api/shop.js @@ -271,12 +271,13 @@ export default { }); }, // 我的优惠券(已有的) - getMemberCouponList({ store_id, gc_id, type, status }) { + getMemberCouponList({ store_id, gc_id, type, status, page }) { return vm.$u.post('Coupon/getMemberCouponList', { store_id: store_id, gc_id: gc_id, type: type, status: status, + page: page, }); }, // 获取直播列表 diff --git a/pageE/tool/MineCoupon.vue b/pageE/tool/MineCoupon.vue index 3d9febc..5049f0c 100644 --- a/pageE/tool/MineCoupon.vue +++ b/pageE/tool/MineCoupon.vue @@ -3,13 +3,14 @@ - + + @@ -32,6 +33,9 @@ export default { swiperHeight: '', couponList: [], goodsClass: [], + page: 0, + timer: true, + loadStatus: ['loadmore', 'loadmore', 'loadmore'], } }, components: { @@ -46,8 +50,7 @@ export default { }, watch: { current(value) { - let status = value + 1; - this.getMemberCouponList(status); + this.getMemberCouponList(value); } }, methods: { @@ -56,16 +59,31 @@ export default { this.goodsClass = res.data; }) }, - getMemberCouponList(current) { - this.$u.api.getMemberCouponList({ - status: current - }).then(res => { - if(res.errCode == 0) { - this.couponList[this.current] = res.data; - } else { - this.couponList[this.current] = []; - } - this.$forceUpdate(); + async getMemberCouponList({ load = 'reload' }) { + const res = await this.$u.api.getMemberCouponList({ + status: this.current + 1, // 代金券状态 1:未用 2:已用 3:过期 4:收回 + page: this.page, + }) + this.timer = true; + if(res.errCode == 0) { + if(load == 'reload') this.couponList[this.current] = res.data; + else if(load == 'loadmore') this.couponList[this.current].push(...res.data); + } + this.$forceUpdate(); + return res.data.length; + }, + onreachBottom() { + if(!this.timer) return false; + this.timer = false; + this.loadStatus.splice(this.current, 1, "loading"); + this.page++; + this.getMemberCouponList({ load: 'loadmore' }).then(length => { + this.loadStatus.splice(this.current, 1, "nomore"); + if(length == 0) this.page--; + }).catch(() => { + this.loadStatus.splice(this.current, 1, "nomore"); + console.log(this.loadStatus[this.current]); + this.page--; }) }, useCoupon(coupon) { diff --git a/pageE/tool/WashOrder.vue b/pageE/tool/WashOrder.vue index 513c6f5..e3c46de 100644 --- a/pageE/tool/WashOrder.vue +++ b/pageE/tool/WashOrder.vue @@ -293,8 +293,12 @@ export default { this.loadStatu = "loading"; this.page++; this.getOrderList({ load: 'loadmore' }).then(length => { - this.loadStatu = "nomore"; - if(length == 0) this.page--; + if(length == 0) { + this.page--; + this.loadStatu = "nomore"; + } else { + this.loadStatu = "loadmore"; + } }).catch(() => { this.loadStatu = "nomore"; this.page--; -- 2.45.2 From 4e842b127c66c90e53bc5af003fb9245315463f3 Mon Sep 17 00:00:00 2001 From: ghusermoon <2673031505@qq.com> Date: Wed, 19 Aug 2020 18:04:32 +0800 Subject: [PATCH 2/2] fixing bug coupon --- pageE/tool/MineCoupon.vue | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pageE/tool/MineCoupon.vue b/pageE/tool/MineCoupon.vue index 5049f0c..103c1bc 100644 --- a/pageE/tool/MineCoupon.vue +++ b/pageE/tool/MineCoupon.vue @@ -10,7 +10,7 @@ - + @@ -33,6 +33,7 @@ export default { swiperHeight: '', couponList: [], goodsClass: [], + pageSize: 6, page: 0, timer: true, loadStatus: ['loadmore', 'loadmore', 'loadmore'], @@ -65,11 +66,10 @@ export default { page: this.page, }) this.timer = true; - if(res.errCode == 0) { - if(load == 'reload') this.couponList[this.current] = res.data; - else if(load == 'loadmore') this.couponList[this.current].push(...res.data); - } + if(load == 'reload') this.couponList[this.current] = res.data; + else if(load == 'loadmore') this.couponList[this.current].push(...res.data); this.$forceUpdate(); + // console.log(this.couponList); return res.data.length; }, onreachBottom() { @@ -87,7 +87,7 @@ export default { }) }, useCoupon(coupon) { - console.log(coupon); + // console.log(coupon); // if(coupon.type == 1) { // this.$u.route({ // type: 'switchTab', -- 2.45.2