var app = getApp(); var util = require('../../utils/util.js'); Page({ /** * 页面的初始数据 */ data: { currentTab: 0, pageSize: 10, navList: [{ name: "全部", status: "-1" }, { name: "已完成", status: "1" }, { name: "未完成", status: "0" }, { name: "已取消", status: "2" } ], list: [], loadText: "没有更多记录了~", containerHeight: 0, info: {}, noData: 0, loadMore: true }, page: 1, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { var sysInfo = wx.getSystemInfoSync(); console.log(sysInfo.windowHeight) this.setData({ containerHeight: sysInfo.windowHeight - Math.round(sysInfo.windowHeight / 375 * 48) - 130 }); var that = this; if (!util.check_login()) { this.setData({ needAuth: true }) } else { this.getInfo(); this.getData(); } }, getInfo: function () { wx.showLoading(); var token = wx.getStorageSync('token'); let that = this; app.util.request({ url: 'entry/wxapp/user', data: { controller: 'distribution.get_commission_info', token: token }, dataType: 'json', success: function (res) { wx.hideLoading(); if (res.data.code == 0) { // Todo that.setData({ info: res.data.data }) } else { wx.showModal({ title: '提示', content: res.data.msg, showCancel: false, success(res) { if (res.confirm) { console.log('用户点击确定') wx.reLaunch({ url: '/lionfish_comshop/pages/user/me', }) } } }) } } }) }, getData: function(){ let that = this; let token = wx.getStorageSync('token'); let currentTab = this.data.currentTab; let state = this.data.navList[currentTab].status; wx.showLoading(); app.util.request({ 'url': 'entry/wxapp/index', 'data': { controller: 'distribution.listorder_list', token: token, state: state, page: this.page }, dataType: 'json', success: function (res) { console.log(res) if (res.data.code == 0) { let list = res.data.data; let oldList = that.data.list; list = oldList.concat(list); that.page++; that.setData({ list }) } else { // 无数据 if (that.page == 1) that.setData({ noData: 1 }) that.setData({ loadMore: false }) } wx.hideLoading(); } }) }, getCurrentList: function () { if (!this.data.loadMore) return false; this.getData(); this.setData({ isHideLoadMore: false }) }, bindChange: function (t) { this.page = 1; this.setData({ currentTab: 1 * t.detail.current, list: [], noData: 0, loadMore: true }, () => { console.log('我变啦'); this.getData(); }); }, /** * 切换导航 */ switchNav: function (e) { if (this.data.currentTab === 1 * e.target.dataset.current) return false; this.setData({ currentTab: 1 * e.target.dataset.current }); } })