var util = require('../../utils/util.js'); Page({ data: { currentIndex: 0, orderList:[], limit:10, offset:0, refresh:false, orderShow:false, noMore:false, }, onUnload: function () { // wx.reLaunch({ // url: '../customerCenter/customerCenter' // }) }, onLoad: function (options) { var status = options.status; if (status!=undefined){ this.setData({ currentIndex: status }) } this.getOrderInfo(this.data.currentIndex); this.goTap(); }, onShow:function(){ if(this.data.refresh){ this.getOrderInfo(this.data.currentIndex); } }, //获取滚动条当前位置 onPageScroll: function (e) { // console.log(e) if (e.scrollTop > 400) { this.setData({ floorstatus: true }); } else { this.setData({ floorstatus: false }); } }, //一键回到顶部 goTap(){ util.goTap(); }, onTabsItemEvent(e){ var index = e.currentTarget.dataset.index; this.setData({ currentIndex:index, offset: 0 }) this.setData({ noMore:false }); this.getOrderInfo(index); }, // 根据状态获取订单信息 getOrderInfo:function(status){ var _this = this; var limit = _this.data.limit; var offset = _this.data.offset; util.request({ api:"/wxapi/erpOrder/findUserOrderList", data: { "limit": limit, "orderStatus": status, "offset": offset}, callback: function (data) { console.log("订单信息") console.log(data.rows) _this.setData({ orderList: data.rows, currentIndex: status }); var orderList = _this.data.orderList; console.log(orderList) if (orderList.length == 0) { _this.setData({ orderShow: true, }) } else { _this.setData({ orderShow: false }) } }}); }, toDetail(e){ var id = e.currentTarget.dataset.id console.log(id) wx.navigateTo({ url: '../purchaseRecords/detail?id='+id, }) }, // 上拉加载 onReachBottom: function () { var _this = this; var offset = _this.data.offset; var limit = _this.data.limit; var orderList = _this.data.orderList; var status = _this.data.currentIndex; _this.setData({ offset: offset + limit }); offset = _this.data.offset; util.request({api:"/wxapi/erpOrder/findUserOrderList",data: { "limit": limit, "orderStatus": status, "offset": offset }, callback: function (data) { if(data.rows.length>0){ _this.setData({ noMore:false }); }else{ _this.setData({ noMore:true }); } for (var i = 0; i < data.rows.length; i++) { orderList.push(data.rows[i]); } _this.setData({ orderList: orderList }); }}); }, })