order.js 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  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. var that=this;
  87. if (event.target.dataset.orderBizType=='10'){
  88. //校验获取用户id上次活体人脸核身时间是否在可调用范围内
  89. util.request(api.CheckFaceTimeByUserId, {
  90. userId: wx.getStorageSync('userId'),
  91. storeId: wx.getStorageSync('storeId')
  92. }, 'POST').then(function (checkRes) {
  93. if (checkRes.errno === 0) {
  94. //根据用户上次活体人脸核身时间判断出,该用户可以调起人脸接口
  95. if (checkRes.data === true) {
  96. //根据订单号获取是否认证成功,认证成功则调起支付,否则提示
  97. that.checkFace(event);
  98. } else {
  99. //调起支付
  100. wx.redirectTo({
  101. url: '/pages/pay/pay?orderIds=' + event.target.dataset.orderId
  102. + '&actualPrice=' + event.target.dataset.actualPrice + '&isMergePay=0&orderBizType10=true'//此处提交支付属于单笔支付
  103. })
  104. }
  105. }
  106. });
  107. } else {
  108. wx.redirectTo({
  109. url: '/pages/pay/pay?orderIds=' + event.target.dataset.orderId
  110. + '&actualPrice=' + event.target.dataset.actualPrice + '&isMergePay=0'//此处提交支付属于单笔支付
  111. })
  112. }
  113. },
  114. checkFace(event){
  115. util.request(api.GetIsFaceCheckByOrderId, {
  116. orderIds: event.target.dataset.orderId
  117. }).then(function (res) {
  118. if (res.errno === 0) {
  119. if (res.data.isFaceCheck === '1') {
  120. wx.redirectTo({
  121. url: '/pages/pay/pay?orderIds=' + event.target.dataset.orderId
  122. + '&actualPrice=' + event.target.dataset.actualPrice + '&isMergePay=0&orderBizType10=true'//此处提交支付属于单笔支付
  123. })
  124. } else {
  125. wx.showToast({
  126. title: '现场速递商品购买需先认证身份信息再进行支付',
  127. icon: 'none',
  128. duration: 4000
  129. })
  130. }
  131. }
  132. });
  133. },
  134. applyRefund(event) {
  135. wx.navigateTo({
  136. url: '/pages/ucenter/applyRefund/applyRefund?orderId=' + event.target.dataset.orderId
  137. + '&refundMoney=' + event.target.dataset.actualPrice + '&merchOrderSn=' + event.target.dataset.merchOrderSn
  138. })
  139. },
  140. againBuy(event) {
  141. let orderId = event.target.dataset.orderId;
  142. // let goodType = event.target.dataset.goodType;
  143. // if (goodType!= '00'){
  144. // wx.showModal({
  145. // title: '提示信息',
  146. // content: '非保税仓商品不允许再来一单,需门店扫描二维码进行购买',
  147. // showCancel: false
  148. // });
  149. // return;
  150. // }
  151. util.request(api.CartAddByOrder, { orderId: orderId }).then(function (res) {
  152. if (res.errno === 0) {
  153. app.globalData.appCheckCart = '00';
  154. wx.switchTab({
  155. url: '/pages/cart/cart',
  156. });
  157. } else {
  158. wx.showToast({
  159. title: res.errmsg,
  160. image: '/static/images/icon_error.png',
  161. duration: 2000
  162. });
  163. }
  164. });
  165. },
  166. againBuyDisabel(event) {
  167. let goodsType = event.target.dataset.goodsType;
  168. let isStore = event.target.dataset.isStore;
  169. console.log(goodsType);
  170. if (goodsType != '00' && isStore) {
  171. wx.showModal({
  172. title: '提示信息',
  173. content: '非保税仓商品不允许再来一单,需门店扫描二维码进行购买',
  174. showCancel: false
  175. });
  176. }
  177. if (!isStore) {
  178. wx.showModal({
  179. title: '',
  180. content: '该订单非当前门店订单,不允许再来一单,需切换门店进行购买',
  181. showCancel: false
  182. });
  183. }
  184. },
  185. switchOrderType(tabIndex) {
  186. let that = this;
  187. if (tabIndex == 0) {
  188. that.setData({
  189. order_status: '',
  190. evaluate_status: '',
  191. });
  192. } else if (tabIndex == 1) {
  193. that.setData({
  194. order_status: 0,
  195. evaluate_status: '',
  196. });
  197. } else if (tabIndex == 2) {
  198. that.setData({
  199. order_status: 201,
  200. evaluate_status: '',
  201. });
  202. } else if (tabIndex == 3) {
  203. that.setData({
  204. order_status: 300,
  205. evaluate_status: 0,
  206. });
  207. } else if (tabIndex == 4) {
  208. that.setData({
  209. order_status: 301,
  210. evaluate_status: 0,
  211. });
  212. } else if (tabIndex == 5) {
  213. that.setData({
  214. order_status: 401,
  215. evaluate_status: 0,
  216. });
  217. }
  218. that.getOrderList();
  219. },
  220. onReady: function () {
  221. // 页面渲染完成
  222. },
  223. onShow: function () {
  224. let that = this;
  225. // 页面显示
  226. if (wx.getStorageSync('userInfo') && wx.getStorageSync('token')) {
  227. if (wx.getStorageSync('storeId')) {
  228. util.request(api.ChooseStoreId, {
  229. storeId: wx.getStorageSync('storeId'),
  230. merchSn: wx.getStorageSync('merchSn'),
  231. isRefusedLogin: wx.getStorageSync('isRefusedLogin')
  232. }, 'POST').then(function (res) {
  233. if (res.errno === 0) {
  234. wx.setStorageSync('storeId', wx.getStorageSync('storeId'));
  235. wx.setStorageSync('merchSn', wx.getStorageSync('merchSn'));
  236. }
  237. });
  238. that.setData({ orderList: [] });//初始化列表
  239. that.switchOrderType(that.data.tabIndex);
  240. that.setData({
  241. currentStoreId: wx.getStorageSync('storeId')
  242. });
  243. }
  244. } else {
  245. // wx.navigateTo({
  246. // url: '/pages/auth/btnAuth/btnAuth',
  247. // })
  248. }
  249. },
  250. onHide: function () {
  251. // 页面隐藏
  252. },
  253. onUnload: function () {
  254. // 页面关闭
  255. },
  256. onReachBottom() {
  257. var that = this;
  258. if (that.data.page <= that.data.totalPages) {
  259. that.setData({
  260. page: that.data.page + 1,
  261. });
  262. that.getOrderList();
  263. }
  264. },
  265. getWuliuList(event) {
  266. let shippingNo = event.target.dataset.shippingNo;
  267. let shippingCode = event.target.dataset.shippingCode;
  268. let orderId = event.target.dataset.orderId;
  269. let goodsType = event.target.dataset.goodsType;
  270. wx.navigateTo({
  271. url: '/pages/ucenter/wuliu/wuliu?id=' + shippingNo + '&code=' + shippingCode + '&orderId=' + orderId + '&goodsType=' + goodsType,
  272. });
  273. }
  274. })