// pages/wdjb/wdjb.js const app = getApp() Page({ /** * 页面的初始数据 */ data: { loading: app.globalData.imgUrl + '/image/loading.svg', navbar: ['未检举报', '线索举报'], currentTab: 0, size: 10, size1: 10, content: '------加载中------', hasMoreData: true, createTime: '', dataSet: [] }, navbarTap: function (e) { this.setData({ currentTab: e.currentTarget.dataset.idx }) this.showList(this.data.currentTab) }, showList: function (tab) { var userinfo = wx.getStorageSync("user"); var that = this; var id = userinfo.id var str; var sizeQty; switch (tab) { case 0: str = "&businessType=1"; sizeQty = 'size'; break; case 1: str = "&businessType=2"; sizeQty = 'size1'; break; } wx.showLoading(); wx.request({ url: app.globalData.url + '/api/tipoff/query?page=1&rows=' + that.data[sizeQty] + '&createId=' + id+ str, success: function (res) { wx.hideLoading(); console.log(res) if (res.data.code == 0) { let content = res.data.data.rows.map(({ createTime, ...i }) => ({ ...i, createTime: app.formatDate(createTime), })); if (res.data.data.total < that.data[sizeQty]) { that.setData({ dataSet: content, hasMoreData: false, content: '------我是有底线的------' }) } else { that.setData({ dataSet: content, hasMoreData: true, content: '------加载更多------', size: that.data[sizeQty] + 10 }) } } else { wx.showToast({ title: res.data.msg, }) } } }) }, businessSchedule: function (event) { var id = event.currentTarget.dataset.id; console.log(id) console.log(event); wx.navigateTo({ url: '../xsjb/xsjb?id=' + id, }) }, onLoad: function () { this.showList(0) }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { if (this.data.hasMoreData) { this.showList(this.data.currentTab) this.setData({ content: '------加载更多------' }) } else { this.setData({ content: '------我是有底线的------' }) } }, })