From b120cff8f14141b5e39c8863de6dfa2098468576 Mon Sep 17 00:00:00 2001 From: meo <18801474720@163.com> Date: Thu, 13 Sep 2018 18:54:40 +0800 Subject: [PATCH] =?UTF-8?q?[=E6=88=91=E7=9A=84=E5=88=B8=E5=8C=85=20?= =?UTF-8?q?=E6=88=91=E7=9A=84=E8=AE=A2=E5=8D=95][=E4=BF=AE=E6=94=B9]:?= =?UTF-8?q?=E6=88=91=E7=9A=84=E5=88=B8=E5=8C=85=20=E6=88=91=E7=9A=84?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E4=B8=8A=E6=8B=89=E5=8A=A0=E8=BD=BD=E7=9A=84?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/coupon/detail/index.js | 1 - pages/couponorder/index/index.js | 75 ++++++++++++-------------------- pages/order/index/index.js | 22 +++++----- pages/order/index/index.wxml | 5 ++- pages/rushToBuy/index.js | 67 +++++++++++++--------------- pages/rushToBuy/index.wxml | 6 ++- 6 files changed, 80 insertions(+), 96 deletions(-) diff --git a/pages/coupon/detail/index.js b/pages/coupon/detail/index.js index db6b648..20e67a5 100644 --- a/pages/coupon/detail/index.js +++ b/pages/coupon/detail/index.js @@ -172,7 +172,6 @@ Page({ // 领取 5.停车券 // TODO 选取用户下的车牌 - console.log(1111111111111) } else { Http.post({ url: config.api.checkPhoneStatus, diff --git a/pages/couponorder/index/index.js b/pages/couponorder/index/index.js index ae9a851..ef9ec8f 100644 --- a/pages/couponorder/index/index.js +++ b/pages/couponorder/index/index.js @@ -3,8 +3,7 @@ const config = require("../../../config/config.js"); const Http = require("../../../utils/HttpBasics"); Page({ data: { - tabs: [ - { + tabs: [{ key: 0, name: "未使用" }, @@ -28,10 +27,10 @@ Page({ allow_load: true, loading: true, //"上拉加载"的变量,默认false,隐藏 content: "", - mystatus:'' + mystatus: '' }, onLoad() { - this.getList(0, 0); + this.getList(0, 1); }, onShow: function () { wx.setStorage({ @@ -40,16 +39,13 @@ Page({ }) }, //点击跳转到券详情页面 - gotouse: function(e) { + gotouse: function (e) { console.log(e.currentTarget.dataset.couponorderstatus); - console.log("点击跳转到券详情"); - if(this.data.mystatus==''||this.data.mystatus=='undefined'){ + if (this.data.mystatus == '' || this.data.mystatus == 'undefined') { var mystatus = e.currentTarget.dataset.couponorderstatus; - }else{ + } else { var mystatus = this.data.mystatus; } - console.log(mystatus); - wx.navigateTo({ url: `/pages/couponorder/detail/index?quancode=${ e.currentTarget.dataset.quancode}&couponorderstatus=${mystatus}` @@ -57,12 +53,10 @@ Page({ }, getList(key, pageNum) { var that = this; - // console.log(key); - // console.log(pageNum); if (that.data.allow_load) { that.setData({ loading: true, - content: "小主,我在玩命加载中...", + content: "小主,我在玩命加载中...", }); Http.get({ url: config.api.couponOrderList, @@ -76,70 +70,59 @@ Page({ res.data.list.map(file => { file.expiredTime = util.fmtDate(file.expiredTime); }); - setTimeout(function() { + setTimeout(function () { that.setData({ loading: false }); }, 1400); - if (pageNum > res.data.pages) { + console.log(pageNum); + if (pageNum >= res.data.pages) { that.setData({ allow_load: false }); - setTimeout(function() { - that.setData({ - loading: false - }); - }, 1400); } - /** - * 先赋值后渲染页面 - * concat 不会改变原数组值 - * push 会改变原数组值,但不会一条一条插入,而是整个数组插入 - */ - that.data.list = that.data.list.concat(res.data.list); + if (pageNum == 1) { + that.setData({ + list: [] + }) + } + var tmpArr = that.data.list; + tmpArr.push.apply(tmpArr, res.data.list); that.setData({ - list: that.data.list - }); + list: tmpArr + }) }); } else { - console.log("加载完成allow_load设置成false"); that.setData({ loading: true, content: "——— 在拉裤子就掉了啦 ———" }); - setTimeout(function() { + setTimeout(function () { that.setData({ loading: false }); }, 1400); } }, - handleChange({ detail }) { - console.log(detail); - this.setData({ - current: detail.key - }); - }, - handleChangeScroll({ detail }) { + handleChangeScroll({ + detail + }) { this.setData({ list: [], allow_load: true, - current_scroll: detail.key + current_scroll: detail.key, + page:1, }); this.getList(detail.key, 1); - this.setData({ - current_scroll: detail.key - }); }, - onReachBottom: function() { + 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); + console.log(that.data.page+"页数"); + console.log(that.data.current_scroll+"点击的tab数") that.getList(that.data.current_scroll, that.data.page); } -}); +}); \ No newline at end of file diff --git a/pages/order/index/index.js b/pages/order/index/index.js index 43f556a..b5da7fd 100644 --- a/pages/order/index/index.js +++ b/pages/order/index/index.js @@ -72,7 +72,7 @@ Page({ data: variable }).then(res => { console.log(res); - if (pageNum > res.data.pages) { + if (pageNum >= res.data.pages) { that.setData({ allow_load: false }); @@ -87,15 +87,16 @@ Page({ loading: false, }) }, 1400); - /** - * 先赋值后渲染页面 - * concat 不会改变原数组值 - * push 会改变原数组值,但不会一条一条插入,而是整个数组插入 - */ - that.data.list = that.data.list.concat(res.data.list); + if (pageNum == 1) { + that.setData({ + list: [] + }) + } + var tmpArr = that.data.list; + tmpArr.push.apply(tmpArr, res.data.list); that.setData({ - list: that.data.list - }); + list: tmpArr + }) for (let i = 0; i < that.data.list.length; i++) { that.setData({ createDate: util.fmtDate(that.data.list[i].createDate) @@ -128,7 +129,8 @@ Page({ this.setData({ list: [], allow_load: true, - current_scroll: detail.key + current_scroll: detail.key, + page:1 }) this.getList(detail.key, 1); }, diff --git a/pages/order/index/index.wxml b/pages/order/index/index.wxml index 313090e..3937595 100644 --- a/pages/order/index/index.wxml +++ b/pages/order/index/index.wxml @@ -12,6 +12,7 @@ {{item.title}} 待付款 + 已退款 免费领取 已付款 已过期 @@ -42,7 +43,9 @@ 已过期 - + + 已退款 + diff --git a/pages/rushToBuy/index.js b/pages/rushToBuy/index.js index dc6211b..e55fd22 100644 --- a/pages/rushToBuy/index.js +++ b/pages/rushToBuy/index.js @@ -14,34 +14,26 @@ Page({ hour: "", minute: "", loading: true, //"上拉加载"的变量,默认false,隐藏 - content:"", + content: "", }, /** * 生命周期函数--监听页面加载 */ - onLoad: function(options) {}, + onLoad: function (options) {}, //列表 - getList: function(page) { + getList: function (page) { let that = this; - app.couponChannelListCallback = token => { Http.setToken(token); /** * 判断用户是否加载完成 */ if (that.data.allow_load) { - // wx.showLoading({ - // title: "加载中" - // }); that.setData({ - loading:true, - content:'小主,我在玩命加载中...' + loading: true, + content: '小主,我在玩命加载中...' }) - - // setTimeout(function() { - // wx.hideLoading(); - // }, 1200); Http.get({ url: config.api.couponChannelList, data: { @@ -51,30 +43,33 @@ Page({ } }).then(res => { console.log(res); - if (page > res.data.pages) { + if (page >= res.data.pages) { that.setData({ allow_load: false }); - setTimeout(function() { + setTimeout(function () { that.setData({ - loading:false, + loading: false, }) }, 1400); } else { - setTimeout(function() { + setTimeout(function () { that.setData({ - loading:false, + loading: false, }) }, 1400); - /** - * 页面上显示的时间 - */ - console.log(that.data.list); - that.data.list = that.data.list.concat(res.data.list); + console.log(pageNum); + if (pageNum == 1) { + that.setData({ + list: [] + }) + } + var tmpArr = that.data.list; + tmpArr.push.apply(tmpArr, res.data.list); that.setData({ - list: that.data.list - }); - console.log(that.data.list); + list: tmpArr + }) + console.log(tmpArr); for (let i = 0; i < that.data.list.length; i++) { var startTime = util.fmtDate(that.data.list[i].endTime); util.timechuo(startTime); @@ -93,14 +88,14 @@ Page({ } else { console.info("allow_load==false 已禁止加载"); that.setData({ - loading:true, + loading: true, content: "——— 在拉裤子就掉了啦 ———" }) - setTimeout(function(){ + setTimeout(function () { that.setData({ - loading:false, + loading: false, }) - },1400) + }, 1400) } }; if (app.globalData.token && app.globalData.token != null) { @@ -108,7 +103,7 @@ Page({ app.couponChannelListCallback(app.globalData.token); } }, - onReady: function() { + onReady: function () { let that = this; that.setData({ list: [] @@ -116,7 +111,7 @@ Page({ that.getList(2); }, //限时抢购的详情页面 - gotodetail: function(e) { + gotodetail: function (e) { wx.navigateTo({ url: `/pages/coupon/detail/index?couponChannelId=${ e.currentTarget.dataset.couponchannelid @@ -126,12 +121,12 @@ Page({ /** * 页面相关事件处理函数--监听用户下拉动作 */ - onPullDownRefresh: function() {}, + onPullDownRefresh: function () {}, /** * 页面上拉触底事件的处理函数 */ - onReachBottom: function() { + onReachBottom: function () { let that = this; that.data.page++; console.log(that.data.page); @@ -142,5 +137,5 @@ Page({ /** * 用户点击右上角分享 */ - onShareAppMessage: function() {} -}); + onShareAppMessage: function () {} +}); \ No newline at end of file diff --git a/pages/rushToBuy/index.wxml b/pages/rushToBuy/index.wxml index 341db25..9c4bcf1 100644 --- a/pages/rushToBuy/index.wxml +++ b/pages/rushToBuy/index.wxml @@ -1,6 +1,7 @@ - + @@ -34,5 +35,6 @@ - {{content}} + {{content}} + \ No newline at end of file