// subpackage/parent/history-train/history-train.js const { getSportList } = require("../../../utils/serve/parent"); const utils = require("../../../utils/utils"); Page({ /** * 页面的初始数据 */ data: { page:1, sportList:[], haveMore:true }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { this.getSports() }, async getSports(){ const that = this const res = await getSportList({ PageIndex:this.data.page, PageSize :50 }) that.setData({ haveMore:res.data.total > that.data.page * 50, page:that.data.page + 1, sportList:[...that.data.sportList,...res.data.datas] }) }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { if(this.data.haveMore){ this.getSports() } }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })