// pages/my/myService/myService.js const App = getApp(); const util = require("../../utils/util"); Page({ /** * 页面的初始数据 */ data: { tabs: [ { i: 0, title: "全部", }, { i: 1, title: "待处理", }, { i: 2, title: "处理中", }, { i: 3, title: "已拒绝", }, { i: 4, title: "已完成", }, ], currentTab: 0, status: 0, list: [], queryParams: { page: 1, limit: 10, }, total: 0, totalPage: 0, currPage: 0, nodata: util.nodata(), }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { if (options && options.status) { this.setData({ status: options.status, currentTab: options.status }) } }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() {}, /** * 生命周期函数--监听页面显示 */ onShow() { this.init(); }, tabChange(e) { console.log(e); if (e.currentTarget.dataset.index == this.data.currentTab) { return; } this.setData({ currentTab: e.currentTarget.dataset.index, status: e.currentTarget.dataset.index, total: 0, totalPage: 0, currPage: 0, }); this.init(); }, init() { this.setData({ list: [], queryParams: { page: 1, limit: 10, }, }); this.getList(); }, // 获取列表数据 getList() { if (this.data.queryParams.page > 1) { if (this.data.total > 0 && this.data.currPage == this.data.totalPage) { wx.showToast({ title: "没有更多了~", icon: "none", }); return false; } } wx.showLoading({ title: "努力加载中...", }); App._get( "expert_workbench/myServicePage", { ...this.data.queryParams, status: this.data.status, memberId: util.getUserId(), }, (res) => { if (res.code === 0) { this.setData({ list: [...this.data.list, ...res.page.list], total: res.page.totalCount, totalPage: res.page.totalPage, currPage: res.page.currPage, }); wx.hideLoading(); } }, (err) => { wx.showToast({ icon: 'error', title: '服务端异常', }) }, (complete) => {} ); }, toServiceDetail(e) { wx.navigateTo({ url: "/workbench/service/service?meetId=" + e.currentTarget.dataset.meetid, }); }, /** * 生命周期函数--监听页面隐藏 */ onHide() {}, /** * 生命周期函数--监听页面卸载 */ onUnload() {}, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() {}, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { this.setData({ queryParams: { page: ++this.data.queryParams.page, limit: 10, }, }); this.getList(); }, /** * 用户点击右上角分享 */ onShareAppMessage() {}, });