// pages/ucenter/chargemoneylog/chargemoneylog.js Page({ /** * 页面的初始数据 */ data: { chargemoneylogs: [], userInfo: {}, isLogin: false, pagesize:15, pagenum:1, total:-1, loadTotal: 0, dataLoading: false, finishedLoadTap: 0, finishedLoadShowTimes: 0, }, /** * 生命周期函数--监听页面加载 */ onLoad: function(options) { let userInfo = wx.getStorageSync('userInfo'); let isLogin = wx.getStorageSync('isLogin'); this.setData({ userInfo:userInfo, isLogin:isLogin }); let that = this; // 页面显示 if (userInfo && isLogin) { this.getPage() } }, getPage(){ if(this.data.chargemoneylogs.length == this.data.total){ this.setData({ finishedLoadTap:this.data.finishedLoadTap+1 }) if(this.data.finishedLoadTap>0 && this.data.finishedLoadShowTimes==0){ this.setData({ finishedLoadShowTimes:this.data.finishedLoadShowTimes+1 }) wx.showToast({ title: '全部加载完毕', icon: 'success', duration: 2000 }) } return } if(this.data.dataLoading){ return } this.setData({ dataLoading: true }) wx.showLoading({ title: '数据加载中....', }) let that = this; wx.request({ url: getApp().globalData.postHeadAgreement +'/restapi/wechat/rechargeList', data: { userId: wx.getStorageSync('userInfo').userId, pagenum: this.data.pagenum++, pagesize: 15, }, method: 'POST', success(res) { console.log(res); let chargemoneylogs = res.data.rows; for (var i = 0; i < chargemoneylogs.length ; i++){ chargemoneylogs[i].rechargeTimeDate = chargemoneylogs[i].rechargeTime.split(" ")[0]; chargemoneylogs[i].rechargeTimeTime =chargemoneylogs[i].rechargeTime.split(" ")[1]; } // that.rechargeTimeOrder(chargemoneylogs); wx.hideLoading() that.setData({ chargemoneylogs: that.data.chargemoneylogs.concat(chargemoneylogs), total: res.data.total, dataLoading: false }); } }); }, rechargeTimeOrder(chargemoneylogs) { if (chargemoneylogs && 0 != chargemoneylogs.length) { chargemoneylogs.sort(function(ma, mb) { return mb.rechargeTime.localeCompare(ma.rechargeTime); }); } }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function() { }, /** * 生命周期函数--监听页面显示 */ onShow: function() { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function() { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function() { }, bindScrollTolowerEvent: function(){ this.getPage(); }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function() { }, /** * 用户点击右上角分享 */ onShareAppMessage: function() { } })