// pages/Incomelog/Incomelog.js import api from '../../utils/api.js' import util from '../../utils/util.js' const app = getApp() Page({ /** * 页面的初始数据 */ data: { IncomeParams: {}, IncomeLog: [], IncomeLogCount: 99, mpType: app.globalData.mpType }, /** * 生命周期函数--监听页面加载 */ onLoad: function(opt) { this.setData({ IncomeParams: { page: 1, offset: 10, tmem_id: opt.memid } }) this.getIncomeLog() }, getIncomeLog: function() { api.getMemIncomeList(this.data.IncomeParams).then(res => { res.data.list.forEach((item, ids) => { item.amount = (item.amount || 0).toFixed(2) item.create_time = util.formatTime(item.create_time, 'yyyy/MM/dd') }) this.setData({ IncomeLog: this.data.IncomeLog.concat(res.data.list), IncomeLogCount: res.data.count }) }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function() { if (this.data.IncomeLogCount <= this.data.IncomeLog.length) { return false } this.data.IncomeParams.page = ++this.data.IncomeParams.page this.setData({ IncomeParams: this.data.IncomeParams }) this.getIncomeLog() } })