var app = getApp() Page({ data: { order: [], links: null, id: '', curPage: 1, }, onLoad: function(options) { this.setData({ id: options.id }) this.getList(); }, //获取列表 getList() { wx.showLoading({ title: '加载中...', }) let url = ''; if (this.data.curPage == 1) { url = 'bike/latelyOrders?page = 1'; } else { url = 'bike/latelyOrderRent?page = 1' } let data = { bike_id: this.data.id } app.request(url, data, 'POST').then(res => { wx.hideLoading(); if (res.statusCode == 200) { console.log(res); this.setData({ order: res.data.data, links: res.data.links.next }) } }) }, //跳转到详情页 skipDetail(e) { let index = e.currentTarget.dataset.index wx.navigateTo({ url: '/pages/orderDetail/orderDetail?id=' + this.data.order[index].id + '&index=' + this.data.curPage, //普通订单和日租订单 }) }, //tab切换 choose(e) { this.setData({ curPage: e.currentTarget.dataset.idx }) this.getList(); }, onPullDownRefresh: function() { let self = this; wx.showLoading({ title: '加载中...', }) let url = ""; if (self.data.curPage == 1) { url = 'bike/latelyOrders?page = 1' } else { url = 'bike/latelyOrderRent?page =1 ' } let data = { bike_id: self.data.id } app.request(url, data, 'POST').then(res => { if (res.statusCode == 200) { wx.showToast({ title: '刷新成功', icon: 'none' }) wx.hideLoading(); wx.stopPullDownRefresh(); self.setData({ order: res.data.data, links: res.data.links.next }) } }) }, onReachBottom: function() { var that = this; if (that.data.links != null) { wx.request({ url: that.data.links, header: { 'content-type': 'application/x-www-form-urlencoded', 'Authorization': 'bearer' + ' ' + wx.getStorageSync('token'), }, method: 'POST', data: { bike_id: that.data.id }, success: function(res) { console.log(res) wx.hideLoading() that.setData({ order: that.data.order.concat(res.data.data), links: res.data.links.next }) } }) } else { wx.hideLoading() wx.showToast({ title: '没数据了~', icon: 'none' }) } }, })