order.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. var util = require('../../../utils/util.js');
  2. var api = require('../../../config/api.js');
  3. Page({
  4. data:{
  5. orderList: [],
  6. page: 1,
  7. size: 10,
  8. loadmoreText: '正在加载更多数据',
  9. nomoreText: '全部加载完成',
  10. nomore: false,
  11. totalPages: 1,
  12. activeIdx:-1,
  13. header:[
  14. {
  15. icon: 'ct1',
  16. name: '全部订单',
  17. id: -1
  18. },
  19. {
  20. icon: 'ct2',
  21. name: '待付款',
  22. id: 0
  23. },
  24. {
  25. icon: 'ct3',
  26. name: '待发货',
  27. id: 201
  28. },
  29. {
  30. icon: 'ct4',
  31. name: '待收货',
  32. id: 300
  33. },
  34. {
  35. icon: 'ct5',
  36. name: '已完成',
  37. id: 301
  38. }
  39. ]
  40. },
  41. onLoad:function(options){
  42. let {id} = options
  43. this.setData({
  44. activeIdx:id
  45. })
  46. // 页面初始化 options为页面跳转所带来的参数
  47. // 页面显示
  48. },
  49. refresh: function(){
  50. wx.showLoading({
  51. title: '加载中...',
  52. success: function () {
  53. }
  54. });
  55. this.setData({
  56. orderList: [],
  57. page: 1
  58. })
  59. this.getOrderList();
  60. },
  61. onPullDownRefresh() {
  62. this.refresh()
  63. },
  64. /**
  65. * 页面上拉触底事件的处理函数
  66. */
  67. onReachBottom: function () {
  68. this.getOrderList()
  69. },
  70. tabHeader:function(e){
  71. let {id} = e.currentTarget.dataset
  72. this.setData({
  73. activeIdx: id
  74. })
  75. this.refresh()
  76. },
  77. getOrderList(id){
  78. let that = this;
  79. console.log('this.data', this.data.activeIdx)
  80. util.request(api.OrderList, { page: that.data.page, size: that.data.size, orderStatus: that.data.activeIdx}).then(function (res) {
  81. if (res.errno === 0) {
  82. that.setData({
  83. orderList: that.data.orderList.concat(res.data.data),
  84. page: res.data.currentPage + 1,
  85. totalPages: res.data.totalPages
  86. });
  87. wx.hideLoading();
  88. if (res.data.data.length <= 0) {
  89. that.setData({
  90. nomore: true
  91. })
  92. return;
  93. }
  94. }
  95. });
  96. },
  97. gotoLogti: function(e){
  98. let {no,id} = e.currentTarget.dataset
  99. wx.navigateTo({
  100. url: '/pages/logistics/index?no=' + no + '&id=' + id
  101. })
  102. },
  103. payOrder(event){
  104. let that = this;
  105. let orderIndex = event.currentTarget.dataset.orderIndex;
  106. let order = that.data.orderList[orderIndex];
  107. wx.redirectTo({
  108. url: '/pages/pay/pay?orderId=' + order.id + '&actualPrice=' + order.actual_price,
  109. })
  110. },
  111. onReady:function(){
  112. // 页面渲染完成
  113. },
  114. onShow:function(){
  115. this.refresh()
  116. },
  117. onHide:function(){
  118. // 页面隐藏
  119. },
  120. onUnload:function(){
  121. // 页面关闭
  122. }
  123. })