123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- 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 () {
-
- }
- })
|