order.js 7.1 KB

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