// pages/myRecord/myRecord.js import { chargeList } from "../../api/my"; Page({ /** * 页面的初始数据 */ data: { navItemActive: 0, chargeRecordList: [], destoryRecordList: [], currentPage: 1, hasNext: false }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { this.setData({ navItemActive: 0 }) this.getChargeList() }, // 获取充值记录 getChargeList () { var data = { currentPage: this.data.currentPage } chargeList(data).then(res => { this.setData({ hasNext: res.data.hasNext, chargeRecordList: res.data.vos }) }) }, onReachBottom () { if (this.data.hasNext) { var _currentPag = this.data.currentPage + 1 this.setData({ currentPage: _currentPag }) if (this.data.navItemActive == 0) { this.getChargeList() } } }, /** * 切换nav */ handleChangeNav(e) { var navItemActive = e.currentTarget.dataset.index this.setData({ navItemActive: navItemActive, currentPage: 1 }) if (navItemActive == 0) { this.getChargeList() } }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })