record.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. var app = getApp()
  2. Page({
  3. data: {
  4. arr: '',
  5. years: '',
  6. month: '',
  7. total_amount: 0,
  8. link: null,
  9. index: 0,
  10. },
  11. onLoad: function (options) {
  12. var that = this;
  13. wx.request({
  14. url: 'https://yutang.web.ximengnaikang.com/api/orders',
  15. method: 'GET',
  16. header: {
  17. 'content-type': 'application/x-www-form-urlencoded',
  18. 'Authorization':wx.getStorageSync('token')
  19. },
  20. success: function (res) {
  21. console.log(res.data.data)
  22. if(res.statusCode==200){
  23. that.setData({arr:res.data.data.data,link:res.data.data.next_page_url})
  24. }
  25. }
  26. })
  27. },
  28. onReady: function () {
  29. },
  30. // detail: function (e) {
  31. // wx.navigateTo({
  32. // url: '../../my_riding/my_riding?order=' + e.currentTarget.dataset.order + '&index=' + this.data.index,
  33. // })
  34. // },
  35. onShow: function () {
  36. },
  37. onHide: function () {
  38. },
  39. onUnload: function () {
  40. },
  41. onPullDownRefresh: function () {
  42. wx.showNavigationBarLoading();
  43. var that = this;
  44. wx.request({
  45. url: 'https://yutang.web.ximengnaikang.com/api/orders',
  46. method: 'GET',
  47. header: {
  48. 'content-type': 'application/x-www-form-urlencoded',
  49. 'Authorization':wx.getStorageSync('token')
  50. },
  51. success: function (res) {
  52. console.log(res.data.data)
  53. if(res.statusCode==200){
  54. that.setData({arr:res.data.data.data,link:res.data.data.next_page_url})
  55. wx.hideNavigationBarLoading();
  56. wx.stopPullDownRefresh();
  57. }
  58. }
  59. })
  60. },
  61. onReachBottom: function () {
  62. var that = this;
  63. if (that.data.link != null) {
  64. wx.showLoading({
  65. title: '加载中...',
  66. })
  67. console.log(link)
  68. wx.request({
  69. url: that.data.link,
  70. method: 'GET',
  71. header: {
  72. 'content-type': 'application/x-www-form-urlencoded',
  73. 'Authorization': wx.getStorageSync('token'),
  74. },
  75. success: function (res) {
  76. console.log(res)
  77. if (res.statusCode == 200) {
  78. var arr = res.data.data;
  79. that.setData({
  80. arr: that.data.arr.concat(arr),
  81. link: res.data.meta.pagination.links.next
  82. })
  83. wx.hideLoading()
  84. } else {
  85. wx.showToast({
  86. title: '没有更多了~',
  87. icon:'none'
  88. })
  89. }
  90. }
  91. })
  92. }
  93. if (that.data.link == null) {
  94. wx.showToast({
  95. title: '暂无更多数据~',
  96. icon: 'none'
  97. })
  98. }
  99. },
  100. onShareAppMessage: function () {
  101. }
  102. })