|
|
import orderService from './orderService.js'
|
|
|
import router from '../../router/index.js'
|
|
|
import Taro from '@tarojs/taro';
|
|
|
import wx from '../../libs/wx';
|
|
|
|
|
|
// const api = new orderService();
|
|
|
/**
|
...
|
...
|
@@ -23,10 +25,22 @@ export const prePay = function (productId, orderCode, fromWhere, isStore) { |
|
|
.then(data => {
|
|
|
if (data) {
|
|
|
callWxPay(data, productId, orderCode, fromWhere, isStore)
|
|
|
} else {
|
|
|
throw new Error('ufo.order.pay fail.')
|
|
|
}
|
|
|
})
|
|
|
.catch(error => {
|
|
|
console.log(error)
|
|
|
.catch(() => {
|
|
|
// 调用出错
|
|
|
Taro.showToast({
|
|
|
title: '订单不可支付',
|
|
|
duration: 2000,
|
|
|
icon: 'none'
|
|
|
});
|
|
|
setTimeout(() => {
|
|
|
wx.redirectTo({
|
|
|
url: '/pages/orderDetail/index?orderCode=' + orderCode
|
|
|
});
|
|
|
}, 2000);
|
|
|
})
|
|
|
} else {
|
|
|
//提示重新登录
|
...
|
...
|
@@ -54,7 +68,7 @@ function callWxPay(data, productId, orderCode, fromWhere ,isStore) { |
|
|
}
|
|
|
if (res.errMsg == 'requestPayment:fail cancel') {
|
|
|
if (fromWhere == 0) {
|
|
|
router.go('orderDetail', params);
|
|
|
router.go('orderDetail', params, 'redirectTo');
|
|
|
}
|
|
|
|
|
|
} else {
|
...
|
...
|
@@ -64,7 +78,7 @@ function callWxPay(data, productId, orderCode, fromWhere ,isStore) { |
|
|
confirmText: "确定",
|
|
|
complete: function (res) {
|
|
|
if (fromWhere == 0) {
|
|
|
router.go('orderDetail', params);
|
|
|
router.go('orderDetail', params, 'redirectTo');
|
|
|
}
|
|
|
}
|
|
|
})
|
...
|
...
|
|