From 734e48231065b98bcc6d56552f4bbd7eb2f36e94 Mon Sep 17 00:00:00 2001 From: meo <958484406@qq.com> Date: Mon, 27 Aug 2018 19:53:33 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=88=B8=E5=8C=85:=E6=88=91=E7=9A=84=E4=BC=98?= =?UTF-8?q?=E6=83=A0=E5=88=B8][=E5=A2=9E=E5=8A=A0]:=E5=88=B8=E5=8C=85?= =?UTF-8?q?=E6=88=91=E7=9A=84=E4=BC=98=E6=83=A0=E5=88=B8=E4=B8=8D=E5=90=8C?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E7=9A=84=E4=BC=98=E6=83=A0=E5=88=B8=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E9=A1=B5=E9=9D=A2=E4=B8=8D=E5=90=8C=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E5=AF=B9=E5=BA=94=E7=9A=84=E5=90=8D=E7=A7=B0=E4=B8=8D=E5=90=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/couponorder/detail/index.js | 4 +- pages/couponorder/detail/index.wxml | 12 +++-- pages/couponorder/index/index.js | 78 +++++++++++++++++++++-------- pages/index/coupons/index.js | 8 +-- pages/rushToBuy/index.js | 8 +-- 5 files changed, 78 insertions(+), 32 deletions(-) diff --git a/pages/couponorder/detail/index.js b/pages/couponorder/detail/index.js index a22ea5f..94be8c2 100644 --- a/pages/couponorder/detail/index.js +++ b/pages/couponorder/detail/index.js @@ -8,7 +8,8 @@ Page({ code: "", data: {}, createDate: "", - expiredTime: "" + expiredTime: "", + updateDate:'' }, onLoad: function(options) { console.log(options); @@ -34,6 +35,7 @@ Page({ }); that.setData({ expiredTime: util.fmtDate(that.data.data.expiredTime), + updateDate: util.fmtDate(that.data.data.updateDate), createDate: util.fmtDate(that.data.data.createDate) }); }); diff --git a/pages/couponorder/detail/index.wxml b/pages/couponorder/detail/index.wxml index a78e1a2..03da9ca 100644 --- a/pages/couponorder/detail/index.wxml +++ b/pages/couponorder/detail/index.wxml @@ -7,7 +7,8 @@ ¥{{data.salePrice/100}} ¥{{data.price/100}} - 满{{data.usePrice/100}}元可用 + 满{{data.usePrice/100}}元可用 + 仅限本店使用 @@ -49,9 +50,14 @@ - 下单时间{{createDate}} + + 下单时间{{createDate}} + 核销时间{{updateDate}} + 过期时间{{updateDate}} + 退款时间{{updateDate}} + 订单编号{{data.orderId}} - + 手机号2018.05.25 实付金额{{data.couponPrice/100}}元 diff --git a/pages/couponorder/index/index.js b/pages/couponorder/index/index.js index d8288dc..a1243bf 100644 --- a/pages/couponorder/index/index.js +++ b/pages/couponorder/index/index.js @@ -24,7 +24,9 @@ Page({ ], list: [], current: "0", - current_scroll: "0" + current_scroll: "0", + page: 1, + allow_load: true }, onLoad() { this.getList(0, 0); @@ -54,25 +56,47 @@ Page({ var that = this; console.log(key); console.log(pageNum); - Http.get({ - url: config.api.couponOrderList, - data: { - pageNum: pageNum, - pageSize: 10, - couponOrderStatus: key - } - }).then(res => { - console.log(res); - res.data.list.map(file => { - file.expiredTime = format.formatTime( - file.expiredTime, - "yyyy-MM-dddd hh:mm:ss" - ); + if (that.data.allow_load) { + wx.showLoading({ + title: "加载中" }); - that.setData({ - list: res.data.list + Http.get({ + url: config.api.couponOrderList, + data: { + pageNum: pageNum, + pageSize: 8, + couponOrderStatus: key + } + }).then(res => { + console.log(res); + res.data.list.map(file => { + file.expiredTime = format.formatTime( + file.expiredTime, + "yyyy-MM-dddd hh:mm:ss" + ); + }); + console.log("姐姐的订单列表"); + setTimeout(function() { + wx.hideLoading(); + }, 1200); + if (pageNum >= res.data.pages) { + that.setData({ + allow_load: false + }); + } + /** + * 先赋值后渲染页面 + * concat 不会改变原数组值 + * push 会改变原数组值,但不会一条一条插入,而是整个数组插入 + */ + that.data.list = that.data.list.concat(res.data.list); + that.setData({ + list: that.data.list + }); }); - }); + } else { + console.log("加载完成allow_load设置成false"); + } }, handleChange({ detail }) { console.log(detail); @@ -81,11 +105,25 @@ Page({ }); }, handleChangeScroll({ detail }) { - console.log(detail.key); - console.log("0000"); + this.setData({ + list: [], + allow_load: true, + current_scroll: detail.key + }); this.getList(detail.key, 1); this.setData({ current_scroll: detail.key }); + }, + onReachBottom: function() { + var that = this; + console.log(that.data.page); + that.data.page++; + console.log(that.data.page); + that.setData({ + page: that.data.page + }); + console.info("after++ " + that.data.page); + that.getList(that.data.current_scroll, that.data.page); } }); diff --git a/pages/index/coupons/index.js b/pages/index/coupons/index.js index b7387e8..e8b0c2c 100644 --- a/pages/index/coupons/index.js +++ b/pages/index/coupons/index.js @@ -93,10 +93,10 @@ Component({ }).then(res => { console.log(res); if (pageNum >= res.data.pages) { - wx.showToast({ - title: "加载完成喽", - icon: "success" - }); + // wx.showToast({ + // title: "加载完成喽", + // icon: "success" + // }); that.setData({ allow_load: false }); diff --git a/pages/rushToBuy/index.js b/pages/rushToBuy/index.js index 02f03bb..28af078 100644 --- a/pages/rushToBuy/index.js +++ b/pages/rushToBuy/index.js @@ -49,10 +49,10 @@ Page({ console.log(that.data.day); if (page >= res.data.pages) { - wx.showToast({ - title: "加载完成喽", - icon: "success" - }); + // wx.showToast({ + // title: "加载完成喽", + // icon: "success" + // }); that.setData({ allow_load: false });