// pages/myRecord/myRecord.js import { chargeList, getExaminationOrderList } from "../../api/my"; Page({ /** * 页面的初始数据 */ data: { navItemActive: 0, chargeRecordList: [], destoryRecordList: [], currentPage: 1, hasNext: false }, /** * 生命周期函数--监听页面显示 */ onShow() { this.setData({ navItemActive: 0 }) this.getChargeList() }, // 获取充值记录 getChargeList () { var data = { currentPage: this.data.currentPage } wx.showLoading({ title: '加载中...', mask: true }) chargeList(data).then(res => { wx.hideLoading() this.setData({ hasNext: res.data.hasNext, chargeRecordList: res.data.vos }) }).catch(e => { wx.hideLoading() wx.showModal({ content: e, confirmColor: '#333', showCancel: false }) }) }, // 获取核销记录 getExaminationOrderListFn () { var data = { currentPage: this.data.currentPage } wx.showLoading({ title: '加载中...', mask: true }) getExaminationOrderList(data).then(res => { wx.hideLoading() this.setData({ hasNext: res.data.hasNext, destoryRecordList: res.data.vos }) }).catch(e => { wx.hideLoading() wx.showModal({ content: e, confirmColor: '#333', showCancel: false }) }) }, onReachBottom () { if (this.data.hasNext) { var _currentPag = this.data.currentPage + 1 this.setData({ currentPage: _currentPag }) if (this.data.navItemActive == 0) { this.getChargeList() } else { this.getExaminationOrderListFn() } } }, /** * 切换nav */ handleChangeNav(e) { var navItemActive = e.currentTarget.dataset.index this.setData({ navItemActive: navItemActive, currentPage: 1, hasNext: false }) if (navItemActive == 0) { this.getChargeList() } else { this.getExaminationOrderListFn() } } })