order.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. var util = require('../../../utils/util.js');
  2. var api = require('../../../config/api.js');
  3. Page({
  4. data: {
  5. order_status: '',
  6. evaluate_status: '',
  7. orderList: [],
  8. page: 1,
  9. size: 10,
  10. totalPages:0,
  11. tabList: ['全部', '待付款', '待收货', '待评价'],
  12. tabIndex: 0,
  13. orderIds:[]
  14. // markers: [{
  15. // iconPath: "/static/images/rider.png",
  16. // id: 0,
  17. // latitude: 31.834082,
  18. // longitude: 117.232939,
  19. // width: 40,
  20. // height: 40,
  21. // callout: {
  22. // content: '距离你2.77km',
  23. // color: '#fe7200',
  24. // display: 'ALWAYS',
  25. // padding: 10,
  26. // borderRadius: 30
  27. // }
  28. // }]
  29. },
  30. toggleTab(e) {
  31. this.setData({
  32. tabIndex: e.currentTarget.dataset.index,
  33. orderList: [],
  34. page: 1,
  35. });
  36. this.switchOrderType(e.currentTarget.dataset.index);
  37. },
  38. swiperChange(e) {
  39. this.setData({
  40. tabIndex: e.detail.current
  41. });
  42. this.switchOrderType(e.detail.current);
  43. },
  44. onLoad: function (options) {
  45. // 页面初始化 options为页面跳转所带来的参数
  46. if (options.tabIndex) {
  47. this.setData({
  48. tabIndex: options.tabIndex
  49. });
  50. }
  51. },
  52. getOrderList() {
  53. let that = this;
  54. wx.showLoading({
  55. title: '加载中...',
  56. });
  57. util.request(api.OrderList,
  58. {
  59. order_status: that.data.order_status,
  60. evaluate_status: that.data.evaluate_status,
  61. page: that.data.page,
  62. size: that.data.size
  63. }).then(function (res) {
  64. if (res.errno === 0) {
  65. let orderList = that.data.orderList.concat(res.data.data);
  66. // console.log(orderList);
  67. that.setData({
  68. orderList: orderList,
  69. totalPages: res.data.totalPages
  70. }, () => {
  71. //获取待付款倒计时
  72. that.data.orderList.forEach((item, num) => {
  73. if (item.pay_status == 0 || item.pay_status == 1) {
  74. util.countdown(that, that.data.orderList, 'orderList', num)
  75. }
  76. })
  77. });
  78. wx.hideLoading();
  79. }
  80. });
  81. },
  82. payOrder(event) {
  83. wx.redirectTo({
  84. url: '/pages/pay/pay?orderIds=' + event.target.dataset.orderId
  85. + '&actualPrice=' + event.target.dataset.actualPrice
  86. })
  87. },
  88. againBuy(event) {
  89. let orderId = event.target.dataset.orderId;
  90. // let goodType = event.target.dataset.goodType;
  91. // if (goodType!= '00'){
  92. // wx.showModal({
  93. // title: '提示信息',
  94. // content: '非保税仓商品不允许再来一单,需门店扫描二维码进行购买',
  95. // showCancel: false
  96. // });
  97. // return;
  98. // }
  99. util.request(api.CartAddByOrder, {orderId: orderId}).then(function (res) {
  100. if (res.errno === 0) {
  101. wx.switchTab({
  102. url: '/pages/cart/cart',
  103. });
  104. } else if (res.errno === 0) {
  105. wx.showToast({
  106. title: res.errmsg,
  107. image: '/static/images/icon_error.png',
  108. duration: 2000
  109. });
  110. }
  111. });
  112. },
  113. switchOrderType(tabIndex) {
  114. let that = this;
  115. if (tabIndex == 0) {
  116. that.setData({
  117. order_status: '',
  118. evaluate_status: '',
  119. });
  120. } else if (tabIndex == 1) {
  121. that.setData({
  122. order_status: 0,
  123. evaluate_status: '',
  124. });
  125. } else if (tabIndex == 2) {
  126. that.setData({
  127. order_status: 300,
  128. evaluate_status: '',
  129. });
  130. } else if (tabIndex == 3) {
  131. that.setData({
  132. order_status: 301,
  133. evaluate_status: 0,
  134. });
  135. }
  136. that.getOrderList();
  137. },
  138. onReady: function () {
  139. // 页面渲染完成
  140. },
  141. onShow: function () {
  142. // 页面显示
  143. let that = this;
  144. that.switchOrderType(that.data.tabIndex);
  145. },
  146. onHide: function () {
  147. // 页面隐藏
  148. },
  149. onUnload: function () {
  150. // 页面关闭
  151. },
  152. onReachBottom() {
  153. var that = this;
  154. if (that.data.page <= that.data.totalPages) {
  155. that.setData({
  156. page: that.data.page + 1,
  157. });
  158. that.getOrderList();
  159. }
  160. },
  161. getWuliuList(event) {
  162. let shippingNo = event.target.dataset.shippingNo;
  163. let shippingCode = event.target.dataset.shippingCode;
  164. let orderId = event.target.dataset.orderId;
  165. wx.navigateTo({
  166. url: '/pages/ucenter/wuliu/wuliu?id=' + shippingNo + '&code=' + shippingCode + '&orderId=' + orderId,
  167. });
  168. }
  169. })