From 664f7b2957de76b5ecab3fe73230f1447868805f Mon Sep 17 00:00:00 2001 From: meo <18801474720@163.com> Date: Tue, 25 Dec 2018 13:08:21 +0800 Subject: [PATCH] =?UTF-8?q?[=E6=88=90=E9=95=BF=E5=80=BC=E5=88=86=E9=A1=B5?= =?UTF-8?q?=E6=98=BE=E7=A4=BA]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/czdetail/czdetail.js | 104 +++++++++++++++++------------------ pages/czdetail/czdetail.wxml | 3 + pages/czdetail/czdetail.wxss | 7 +++ 3 files changed, 59 insertions(+), 55 deletions(-) diff --git a/pages/czdetail/czdetail.js b/pages/czdetail/czdetail.js index 2807596..78efb33 100644 --- a/pages/czdetail/czdetail.js +++ b/pages/czdetail/czdetail.js @@ -9,6 +9,10 @@ Page({ */ data: { score: 10, + pageNum:1, + list:[], + showcontent:false, + loading:"" }, /** @@ -22,24 +26,52 @@ Page({ url: '/pages/grade/grade', }) }, - record: function() { + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + let that = this; + that.getScore(); + let pageNum = that.data.pageNum; + let pageSize = that.data.pageSize; + that.record(pageNum, pageSize); + }, + record: function (pageNum) { let that = this; Http.get({ url: config.api.scoreHistory, data: { - pageNum: 1, - pageSize: 100 + pageNum: pageNum, + pageSize: 15 } }) .then(res => { console.log(res) - if (res.data.list.length > 0) { - res.data.list.map(file=>{ + if (res.data.list.length > 0 && res.data.pageNum >= pageNum) { + var tmpArr = that.data.list.concat(res.data.list); + + tmpArr.map(file => { file.createDate = util.formatTime(file.createDate, "yyyy-MM-dd hh:mm:ss") }); that.setData({ - list:res.data.list + list:tmpArr }) + setTimeout(function(){ + wx.hideLoading() + },1200) + } + else if (res.data.list.length == 0){ + that.setData({ + loading:"暂无数据" + }) + setTimeout(function () { + wx.hideLoading() + }, 1200) + } + else{ + setTimeout(function () { + wx.hideLoading() + }, 1200) } }) .catch(err => { @@ -64,54 +96,16 @@ Page({ }) }) }, - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function() { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function() { - let that = this; - that.getScore(); - that.record(); - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function() { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function() { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function() { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function() { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function() { - + onReachBottom: function () { + var that = this; + wx.showLoading({ + title: '', + mask:true + }) + that.data.pageNum++; + that.setData({ + pageNum: that.data.pageNum + }); + that.record(that.data.pageNum); } }) \ No newline at end of file diff --git a/pages/czdetail/czdetail.wxml b/pages/czdetail/czdetail.wxml index 4cb3dae..15ecbc1 100644 --- a/pages/czdetail/czdetail.wxml +++ b/pages/czdetail/czdetail.wxml @@ -24,4 +24,7 @@ {{item.scoreAmount}}分 + + + {{loading}} \ No newline at end of file diff --git a/pages/czdetail/czdetail.wxss b/pages/czdetail/czdetail.wxss index 8ecec23..7fb7573 100644 --- a/pages/czdetail/czdetail.wxss +++ b/pages/czdetail/czdetail.wxss @@ -99,4 +99,11 @@ } .fr text{ color: #FF3535; +} +.loading{ + text-align: center; + height: 80rpx; + line-height: 80rpx; + color: #999; + font-size: 26rpx; } \ No newline at end of file