1
0

order.js 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  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 + '&isMergePay=0'//此处提交支付属于单笔支付
  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 + '&merchOrderSn=' + event.target.dataset.merchOrderSn
  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 {
  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 goodsType = event.target.dataset.goodsType;
  122. let isStore = event.target.dataset.isStore;
  123. console.log(goodsType);
  124. if (goodsType != '00' && isStore) {
  125. wx.showModal({
  126. title: '提示信息',
  127. content: '非保税仓商品不允许再来一单,需门店扫描二维码进行购买',
  128. showCancel: false
  129. });
  130. }
  131. if (!isStore) {
  132. wx.showModal({
  133. title: '',
  134. content: '该订单非当前门店订单,不允许再来一单,需切换门店进行购买',
  135. showCancel: false
  136. });
  137. }
  138. },
  139. switchOrderType(tabIndex) {
  140. let that = this;
  141. if (tabIndex == 0) {
  142. that.setData({
  143. order_status: '',
  144. evaluate_status: '',
  145. });
  146. } else if (tabIndex == 1) {
  147. that.setData({
  148. order_status: 0,
  149. evaluate_status: '',
  150. });
  151. } else if (tabIndex == 2) {
  152. that.setData({
  153. order_status: 201,
  154. evaluate_status: '',
  155. });
  156. } else if (tabIndex == 3) {
  157. that.setData({
  158. order_status: 300,
  159. evaluate_status: 0,
  160. });
  161. } else if (tabIndex == 4) {
  162. that.setData({
  163. order_status: 301,
  164. evaluate_status: 0,
  165. });
  166. } else if (tabIndex == 5) {
  167. that.setData({
  168. order_status: 401,
  169. evaluate_status: 0,
  170. });
  171. }
  172. that.getOrderList();
  173. },
  174. onReady: function () {
  175. // 页面渲染完成
  176. },
  177. onShow: function () {
  178. let that = this;
  179. // 页面显示
  180. if (wx.getStorageSync('userInfo') || wx.getStorageSync('token')) {
  181. if (wx.getStorageSync('storeId')) {
  182. util.request(api.ChooseStoreId, {
  183. storeId: wx.getStorageSync('storeId'),
  184. merchSn: wx.getStorageSync('merchSn')
  185. }, 'POST').then(function (res) {
  186. if (res.errno === 0) {
  187. wx.setStorageSync('storeId', wx.getStorageSync('storeId'));
  188. wx.setStorageSync('merchSn', wx.getStorageSync('merchSn'));
  189. }
  190. });
  191. that.setData({ orderList: [] });//初始化列表
  192. that.switchOrderType(that.data.tabIndex);
  193. that.setData({
  194. currentStoreId: wx.getStorageSync('storeId')
  195. });
  196. }
  197. } else {
  198. // wx.navigateTo({
  199. // url: '/pages/auth/btnAuth/btnAuth',
  200. // })
  201. }
  202. },
  203. onHide: function () {
  204. // 页面隐藏
  205. },
  206. onUnload: function () {
  207. // 页面关闭
  208. },
  209. onReachBottom() {
  210. var that = this;
  211. if (that.data.page <= that.data.totalPages) {
  212. that.setData({
  213. page: that.data.page + 1,
  214. });
  215. that.getOrderList();
  216. }
  217. },
  218. getWuliuList(event) {
  219. let shippingNo = event.target.dataset.shippingNo;
  220. let shippingCode = event.target.dataset.shippingCode;
  221. let orderId = event.target.dataset.orderId;
  222. let goodsType = event.target.dataset.goodsType;
  223. wx.navigateTo({
  224. url: '/pages/ucenter/wuliu/wuliu?id=' + shippingNo + '&code=' + shippingCode + '&orderId=' + orderId + '&goodsType=' + goodsType,
  225. });
  226. }
  227. })