// pages/account/account.js Page({ /** * 页面的初始数据 */ data: { type : '', //卡类型 number : '', //账户余额 accounts : '', //账户列表 blockeds : '', //待发放余额 page : {}, //分页信息 lodingStats : false, //加载状态 }, /** * 生命周期函数--监听页面加载 */ onLoad (options) { this.setData({ type : options.type }) }, onShow() { // 获取账变记录 this.accountInfo(); }, /** * 账变记录 */ accountInfo(page) { wx.$api.user.logs(this.data.type, page).then(res=>{ //判断金卡、银卡、钻石卡 let number if(this.data.type == "silver") { number = res.data.account.silver } else if(this.data.type == "gold") { number = res.data.account.gold } else if(this.data.type == "drill") { number = res.data.account.drill } else { return } let listArr = this.data.accounts, newData = [] if(page == 1 || page == undefined) listArr = [] newData = listArr.concat(res.data.data) this.setData({ number : number, blockeds : res.data.blockeds, accounts : newData, page : res.data.page }) }) }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { // 获取账变记录 this.accountInfo(); }, /** * 上拉加载 */ onReachBottom(){ this.setData({ lodingStats: true }) let pageNumber = this.data.page.current if(this.data.page.has_more){ pageNumber++ // 获取账变记录 this.accountInfo(pageNumber); } } })