recentOrder.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. var app = getApp()
  2. Page({
  3. data: {
  4. order: [],
  5. links: null,
  6. id: '',
  7. // curPage: 1,
  8. },
  9. onLoad: function(options) {
  10. this.setData({
  11. id: options.id
  12. })
  13. this.getList();
  14. },
  15. //获取列表
  16. getList() {
  17. // let url = '';
  18. // if (this.data.curPage == 1) {
  19. // url = 'bike/latelyOrders?page = 1';
  20. // } else {
  21. // url = 'bike/latelyOrderRent?page = 1'
  22. // }
  23. let data = {
  24. bike_id: this.data.id
  25. }
  26. app.request('bike/latelyOrders?page = 1', data, 'POST').then(res => {
  27. if (res.statusCode == 200) {
  28. console.log(res);
  29. this.setData({
  30. order: res.data.data,
  31. links: res.data.links.next
  32. })
  33. }
  34. })
  35. },
  36. //跳转到详情页
  37. skipDetail(e) {
  38. let index = e.currentTarget.dataset.index
  39. wx.navigateTo({
  40. // url: '/pages/orderDetail/orderDetail?id=' + this.data.order[index].id + '&index=' + this.data.curPage,
  41. url: '/pages/orderDetail/orderDetail?id=' + this.data.order[index].id,
  42. })
  43. },
  44. //tab切换
  45. // choose(e) {
  46. // let url = '';
  47. // this.setData({
  48. // curPage: e.currentTarget.dataset.idx
  49. // })
  50. // this.getList();
  51. // },
  52. //
  53. onReady: function() {
  54. },
  55. onShow: function() {
  56. },
  57. onHide: function() {
  58. },
  59. onUnload: function() {
  60. },
  61. onPullDownRefresh: function() {
  62. let self = this;
  63. wx.showLoading({
  64. title: '加载中...',
  65. })
  66. // let url = "";
  67. // if (self.data.curPage == 1) {
  68. // url = 'bike/latelyOrders?page = 1'
  69. // } else {
  70. // url = 'bike/latelyOrderRent?page =1 '
  71. // }
  72. let data = {
  73. bike_id: self.data.id
  74. }
  75. app.request('bike/latelyOrders?page = 1', data, 'POST').then(res => {
  76. if (res.statusCode == 200) {
  77. wx.showToast({
  78. title: '刷新成功',
  79. icon: 'none'
  80. })
  81. wx.hideLoading();
  82. wx.stopPullDownRefresh();
  83. self.setData({
  84. order: res.data.data,
  85. links: res.data.links.next
  86. })
  87. }
  88. })
  89. },
  90. onReachBottom: function() {
  91. var that = this;
  92. if (that.data.links != null) {
  93. wx.request({
  94. url: that.data.links,
  95. header: {
  96. 'content-type': 'application/x-www-form-urlencoded',
  97. 'Authorization': 'bearer' + ' ' + wx.getStorageSync('token'),
  98. },
  99. method: 'POST',
  100. data: {
  101. bike_id: that.data.id
  102. },
  103. success: function(res) {
  104. console.log(res)
  105. wx.hideLoading()
  106. that.setData({
  107. order: that.data.order.concat(res.data.data),
  108. links: res.data.links.next
  109. })
  110. }
  111. })
  112. } else {
  113. wx.hideLoading()
  114. wx.showToast({
  115. title: '没数据了~',
  116. icon: 'none'
  117. })
  118. }
  119. },
  120. onShareAppMessage: function() {
  121. }
  122. })