// pages/myBalance/myBalance.js Page({ /** * 页面的初始数据 */ data: { type : "balance ", //卡类型 number : '', //账户余额 accounts : '', //账户列表 page : {}, //分页信息 lodingStats : false, //加载状态 }, /** * 生命周期函数--监听页面加载 */ onLoad (options) { // 获取余额数量 wx.$api.user.logs().then(res=>{ this.setData({ number : res.data.account.balance }) }).catch(err => {}); }, /** * 生命周期函数--监听页面显示 */ onShow () { // 获取收益订单记录 this.accountInfo(); }, /** * 收益订单记录 */ accountInfo(page) { wx.$api.user.profits(page).then(res=>{ console.log(res.data.data) let listArr = this.data.accounts, newData = [] if(page == 1 || page == undefined) listArr = [] newData = listArr.concat(res.data.data) this.setData({ accounts : newData, page : res.data.page }) }).catch(err => {}); }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { // 获取账变记录 this.accountInfo(); }, /** * 上拉加载 */ onReachBottom(){ this.setData({ lodingStats: true }) let pageNumber = this.data.page.current if(this.data.page.has_more){ pageNumber++ // 获取账变记录 this.accountInfo(pageNumber); } } })