order.js 6.3 KB

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