const app = getApp() Page({ data: { frameStyle: { useTop: true, name: '比赛场地', leftArrow: false, useBar: false }, oldList: [], list: [], limit: 5, skip: 0, page: 0, }, // 详细信息 toView: function (e) { let { item } = e.currentTarget.dataset; wx.navigateTo({ url: `/pages/user/info?id=${item._id}` }) }, // 分页 upcroll: function () { const that = this; let page = that.data.page + 1; that.setData({ page }) const skip = page * that.data.limit; that.setData({ skip }); that.watchLogin() }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { }, // 监听用户是否登录 watchLogin: async function () { const that = this; // 监听用户是否登录, wx.getStorage({ key: 'user', success: async res => { let info = { skip: that.data.skip, limit: that.data.limit }; let arr; arr = await app.$get(`/newCourt/api/user`, { ...info }); if (arr.errcode == '0') { if (arr.data && arr.data.length > 0) that.setData({ list: [...that.data.list, ...arr.data] }) else wx.showToast({ title: `没有更多数据`, icon: 'success', duration: 2000 }) } else { wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 }) } }, fail: async res => { wx.redirectTo({ url: '/pages/index/index' }) } }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { const that = this; // 监听用户是否登录 that.watchLogin(); }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { console.log('1'); }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { console.log('2'); }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })