order.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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. getApp().checkNetStatu();
  43. let {id} = options
  44. this.setData({
  45. activeIdx:id
  46. })
  47. // 页面初始化 options为页面跳转所带来的参数
  48. // 页面显示
  49. },
  50. refresh: function(){
  51. wx.showLoading({
  52. title: '加载中...',
  53. success: function () {
  54. }
  55. });
  56. this.setData({
  57. orderList: [],
  58. page: 1
  59. })
  60. this.getOrderList();
  61. },
  62. onPullDownRefresh() {
  63. this.refresh()
  64. getApp().onPullDownRefresh()
  65. },
  66. /**
  67. * 页面上拉触底事件的处理函数
  68. */
  69. onReachBottom: function () {
  70. this.getOrderList()
  71. },
  72. tabHeader:function(e){
  73. let {id} = e.currentTarget.dataset
  74. this.setData({
  75. activeIdx: id
  76. })
  77. this.refresh()
  78. },
  79. getOrderList(id){
  80. let that = this;
  81. this.setData({loadding: true})
  82. util.request(api.OrderList, { page: that.data.page, size: that.data.size, orderStatus: that.data.activeIdx}).then(function (res) {
  83. if (res.errno === 0) {
  84. that.setData({
  85. orderList: that.data.orderList.concat(res.data.data),
  86. page: res.data.currentPage + 1,
  87. totalPages: res.data.totalPages
  88. });
  89. that.setData({loadding: false})
  90. wx.hideLoading();
  91. if (res.data.data.length <= 0) {
  92. that.setData({
  93. nomore: true
  94. })
  95. return;
  96. }
  97. }
  98. });
  99. },
  100. gotoLogti: function(e){
  101. let {no,id} = e.currentTarget.dataset
  102. wx.navigateTo({
  103. url: '/pages/logistics/index?no=' + no + '&id=' + id
  104. })
  105. },
  106. payOrder(event){
  107. let that = this;
  108. let orderIndex = event.currentTarget.dataset.orderIndex;
  109. let order = that.data.orderList[orderIndex];
  110. wx.redirectTo({
  111. url: '/pages/pay/pay?orderId=' + order.id + '&actualPrice=' + order.actual_price,
  112. })
  113. },
  114. onReady:function(){
  115. // 页面渲染完成
  116. },
  117. onShow:function(){
  118. this.refresh()
  119. },
  120. onHide:function(){
  121. // 页面隐藏
  122. },
  123. onUnload:function(){
  124. // 页面关闭
  125. }
  126. })