Authored by 李奇

0元订单提示添加

1 import orderService from './orderService.js' 1 import orderService from './orderService.js'
2 import router from '../../router/index.js' 2 import router from '../../router/index.js'
  3 +import Taro from '@tarojs/taro';
  4 +import wx from '../../libs/wx';
3 5
4 // const api = new orderService(); 6 // const api = new orderService();
5 /** 7 /**
@@ -23,10 +25,22 @@ export const prePay = function (productId, orderCode, fromWhere, isStore) { @@ -23,10 +25,22 @@ export const prePay = function (productId, orderCode, fromWhere, isStore) {
23 .then(data => { 25 .then(data => {
24 if (data) { 26 if (data) {
25 callWxPay(data, productId, orderCode, fromWhere, isStore) 27 callWxPay(data, productId, orderCode, fromWhere, isStore)
  28 + } else {
  29 + throw new Error('ufo.order.pay fail.')
26 } 30 }
27 }) 31 })
28 - .catch(error => {  
29 - console.log(error) 32 + .catch(() => {
  33 + // 调用出错
  34 + Taro.showToast({
  35 + title: '订单不可支付',
  36 + duration: 2000,
  37 + icon: 'none'
  38 + });
  39 + setTimeout(() => {
  40 + wx.redirectTo({
  41 + url: '/pages/orderDetail/index?orderCode=' + orderCode
  42 + });
  43 + }, 2000);
30 }) 44 })
31 } else { 45 } else {
32 //提示重新登录 46 //提示重新登录
@@ -54,7 +68,7 @@ function callWxPay(data, productId, orderCode, fromWhere ,isStore) { @@ -54,7 +68,7 @@ function callWxPay(data, productId, orderCode, fromWhere ,isStore) {
54 } 68 }
55 if (res.errMsg == 'requestPayment:fail cancel') { 69 if (res.errMsg == 'requestPayment:fail cancel') {
56 if (fromWhere == 0) { 70 if (fromWhere == 0) {
57 - router.go('orderDetail', params); 71 + router.go('orderDetail', params, 'redirectTo');
58 } 72 }
59 73
60 } else { 74 } else {
@@ -64,7 +78,7 @@ function callWxPay(data, productId, orderCode, fromWhere ,isStore) { @@ -64,7 +78,7 @@ function callWxPay(data, productId, orderCode, fromWhere ,isStore) {
64 confirmText: "确定", 78 confirmText: "确定",
65 complete: function (res) { 79 complete: function (res) {
66 if (fromWhere == 0) { 80 if (fromWhere == 0) {
67 - router.go('orderDetail', params); 81 + router.go('orderDetail', params, 'redirectTo');
68 } 82 }
69 } 83 }
70 }) 84 })