// pages/my/myInvite/myInvite.js const App = getApp() const util = require('../../../utils/util') Page({ /** * 页面的初始数据 */ data: { array: [{ label: '全部', i: '0' }, { label: '今天', i: '1' }, { label: '本周', i: '2' }, { label: '本月', i: '3' }, { label: '今年', i: '4' } ], currentTab: 0, queryParams: { page: 1, limit: 10 }, list: [], page: { total: null, currPage: null, totalPage: null, }, detail: {}, headerHeight: 0, user: wx.getStorageSync('USER'), nodata: util.nodata(), }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { this.getList() this.getDetail() }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { const query = wx.createSelectorQuery() query.select('#header').boundingClientRect() query.exec((res) => { console.log(res, 11111) this.setData({ headerHeight: res[0].height }) }) }, /** * 生命周期函数--监听页面显示 */ onShow() { }, getList() { if (this.data.queryParams.page > 1) { if (this.data.page.currPage == this.data.page.totalPage) { wx.showToast({ icon: 'none', title: '没有更多哦~', }) return false } } wx.showLoading({ title: '努力加载中...', }) App._get('myInvitation/myInvitationPage', { ...this.data.queryParams, id: this.data.user.id, myInvitationType: this.data.currentTab }, res => { if (res.code === 0) { this.setData({ list: res.page.list, page: { total: res.page.totalCount, currPage: res.page.currPage, totalPage: res.page.totalPage } }) } }, err => {}, complete => { setTimeout(() => { wx.hideLoading() }, 500) }) }, getDetail() { App._get('myInvitation/myInvitationStatistics', { id: this.data.user.id, myInvitationType: this.data.currentTab }, res => { if (res.code === 0) { this.setData({ detail: res.data }) } }, err => {}, complete => {}) }, bindPickerChange(e) { console.log('picker发送选择改变,携带值为', e.detail.value) this.setData({ currentTab: e.detail.value }) this.setData({ queryParams: { page: 1, limit: 10 } }) this.getList() this.getDetail() }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { this.setData({ queryParams: { page: ++this.data.queryParams, limit: 10 } }) this.getList() this.getDetail() }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })