var app = getApp() Page({ data: { arr: '', years: '', month: '', total_amount: 0, link: null, index: 0, }, onLoad: function (options) { var that = this; wx.request({ url: 'https://yutang.web.ximengnaikang.com/api/orders', method: 'GET', header: { 'content-type': 'application/x-www-form-urlencoded', 'Authorization':wx.getStorageSync('token') }, success: function (res) { console.log(res.data.data) if(res.statusCode==200){ that.setData({arr:res.data.data.data,link:res.data.data.next_page_url}) } } }) }, onReady: function () { }, // detail: function (e) { // wx.navigateTo({ // url: '../../my_riding/my_riding?order=' + e.currentTarget.dataset.order + '&index=' + this.data.index, // }) // }, onShow: function () { }, onHide: function () { }, onUnload: function () { }, onPullDownRefresh: function () { wx.showNavigationBarLoading(); var that = this; wx.request({ url: 'https://yutang.web.ximengnaikang.com/api/orders', method: 'GET', header: { 'content-type': 'application/x-www-form-urlencoded', 'Authorization':wx.getStorageSync('token') }, success: function (res) { console.log(res.data.data) if(res.statusCode==200){ that.setData({arr:res.data.data.data,link:res.data.data.next_page_url}) wx.hideNavigationBarLoading(); wx.stopPullDownRefresh(); } } }) }, onReachBottom: function () { var that = this; if (that.data.link != null) { wx.showLoading({ title: '加载中...', }) console.log(link) wx.request({ url: that.data.link, method: 'GET', header: { 'content-type': 'application/x-www-form-urlencoded', 'Authorization': wx.getStorageSync('token'), }, success: function (res) { console.log(res) if (res.statusCode == 200) { var arr = res.data.data; that.setData({ arr: that.data.arr.concat(arr), link: res.data.meta.pagination.links.next }) wx.hideLoading() } else { wx.showToast({ title: '没有更多了~', icon:'none' }) } } }) } if (that.data.link == null) { wx.showToast({ title: '暂无更多数据~', icon: 'none' }) } }, onShareAppMessage: function () { } })