let config = require("../../../config/config.js"); let Http = require("../../../utils/HttpBasics"); const util = require("../../../utils/util"); let app = getApp(); Page({ data: { tabs: [ { key: "all", name: "全部" }, { key: 0, name: "待付款" }, { key: 1, name: "已完成" } ], list: [], current: "", current_scroll: "1", page: 1, allow_load: true }, onLoad(e) { this.getList(e.id, 1); this.setData({ current_scroll: e.id }); }, gotopay:function(e){ console.log("orderId"+e.currentTarget.dataset.id); wx.navigateTo({ url: `/pages/order/detail/index?orderId=${e.currentTarget.dataset.id}&flag='pay'`, success: function(res){ // success }, fail: function() { // fail }, complete: function() { // complete } }) }, getList(key, pageNum) { let that = this; console.log(key); /** * key==0 * 不发送该字段 */ if (key == 'all') { var variable = { pageNum: pageNum, pageSize: 5, paymentType:0 }; } else { var variable = { pageNum: pageNum, pageSize: 5, orderStatus: key, paymentType:0 }; } if (that.data.allow_load) { wx.showLoading({ title: "加载中" }); Http.get({ url: config.api.orderList, data: variable }).then(res => { console.log(res); console.log("姐姐的订单列表"); setTimeout(function() { wx.hideLoading(); }, 1200); if (pageNum >= res.data.pages) { that.setData({ allow_load: false }); } /** * 先赋值后渲染页面 * concat 不会改变原数组值 * push 会改变原数组值,但不会一条一条插入,而是整个数组插入 */ that.data.list = that.data.list.concat(res.data.list); that.setData({ list: that.data.list }); for(let i=0; i