// pointExchange/pages/center/center.js const app = getApp(); import util from '../../../utils/util.js' Page({ /** * 页面的初始数据 */ data: { appAssetsUrl:app.appAssetsUrl, statusBarHeight: 0, statusBarMH: 0, nodata: util.nodata(), params: { pageNum: 1, pageSize: 10, stuId: util.getUserId() }, total:{ currPage: 0, totalPage: 0 }, noMore:false, totalScore: '--', listData:[] }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.height(); this.loadList(true); this.setData({ totalScore: options.totalScore }) }, bindscrolltolower(){ this.loadList(); }, loadList(isRefresh) { let that = this; if (!isRefresh && this.data.noMore) { wx.showToast({ title: '没有更多了~', icon: 'none' }) return false; } this.setData({ listData: isRefresh ? [] : this.data.listData, noMore: isRefresh ? false : this.data.noMore, params: { ...this.data.params, pageNum: isRefresh?1:this.data.params.pageNum+1 } }) wx.showLoading({ title: '努力加载中...', }) app._post_form('scoreStu/page', '', this.data.params, function(res) { if (res.code == 0) { if(res.page.list.length>0 && that.data.listData.length>0 && res.page.list[0].id == that.data.listData[0].id){ return ; } let listData = that.data.listData; listData.push(...res.page.list); that.setData({ listData, currPage: res.page.currPage, totalPage: res.page.totalPage, noMore: res.page.totalPage == res.page.currPage }) } }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { }, // 自定义高度处理 height() { const { platform, statusBarHeight } = wx.getSystemInfoSync() let height = statusBarHeight + 4 //ios 24px let mH = statusBarHeight + 4 if (platform.toLowerCase() == "android") { height += 4 //android 28px mH += 4 } height = height + 38 // 胶囊高度 32px 下边框6px height 状态栏高度 this.setData({ statusBarHeight: height + 'px', statusBarMH: mH + 'px' }) }, back(){ wx.navigateBack(); } })