|
@@ -62,6 +62,7 @@
|
|
|
const path = require('path');
|
|
const path = require('path');
|
|
|
import { add } from 'mathjs';
|
|
import { add } from 'mathjs';
|
|
|
import product from '../mixins/product';
|
|
import product from '../mixins/product';
|
|
|
|
|
+let inWeixin = /micromessenger/i.test(navigator.userAgent);
|
|
|
export default {
|
|
export default {
|
|
|
name: 'Submit',
|
|
name: 'Submit',
|
|
|
mixins: [product],
|
|
mixins: [product],
|
|
@@ -69,7 +70,7 @@ export default {
|
|
|
return {
|
|
return {
|
|
|
info: {},
|
|
info: {},
|
|
|
message: '',
|
|
message: '',
|
|
|
- payType: 'ALIPAY',
|
|
|
|
|
|
|
+ payType: inWeixin ? 'WEIXIN' : 'ALIPAY',
|
|
|
payInfos: [
|
|
payInfos: [
|
|
|
{
|
|
{
|
|
|
icon: require('../assets/svgs/zhifubao.svg'),
|
|
icon: require('../assets/svgs/zhifubao.svg'),
|
|
@@ -89,7 +90,8 @@ export default {
|
|
|
icons: [require('../assets/svgs/icon_gouxuan_huise.svg'), require('../assets/svgs/icon_gouxuan_pre.svg')],
|
|
icons: [require('../assets/svgs/icon_gouxuan_huise.svg'), require('../assets/svgs/icon_gouxuan_pre.svg')],
|
|
|
bottom: null,
|
|
bottom: null,
|
|
|
orderId: 0,
|
|
orderId: 0,
|
|
|
- gas: 1
|
|
|
|
|
|
|
+ gas: 1,
|
|
|
|
|
+ inWeixin
|
|
|
};
|
|
};
|
|
|
},
|
|
},
|
|
|
computed: {
|
|
computed: {
|
|
@@ -160,21 +162,27 @@ export default {
|
|
|
if (this.payType === 'ALIPAY') {
|
|
if (this.payType === 'ALIPAY') {
|
|
|
document.location.replace(path.resolve(this.$baseUrl, 'payOrder/alipay?id=' + res.id));
|
|
document.location.replace(path.resolve(this.$baseUrl, 'payOrder/alipay?id=' + res.id));
|
|
|
} else if (this.payType === 'WEIXIN') {
|
|
} else if (this.payType === 'WEIXIN') {
|
|
|
- if (/MicroMessenger/i.test(navigator.userAgent)) {
|
|
|
|
|
|
|
+ if (this.inWeixin) {
|
|
|
this.$toast.loading('加载中');
|
|
this.$toast.loading('加载中');
|
|
|
this.$http
|
|
this.$http
|
|
|
.post('/payOrder/weixin', { id: res.id, openId: localStorage.getItem('openId') })
|
|
.post('/payOrder/weixin', { id: res.id, openId: localStorage.getItem('openId') })
|
|
|
.then(res => {
|
|
.then(res => {
|
|
|
|
|
+ console.log({
|
|
|
|
|
+ ...res,
|
|
|
|
|
+ package: res.package || res.packageValue
|
|
|
|
|
+ });
|
|
|
wx.chooseWXPay({
|
|
wx.chooseWXPay({
|
|
|
...res,
|
|
...res,
|
|
|
package: res.package || res.packageValue,
|
|
package: res.package || res.packageValue,
|
|
|
- success: function (res) {
|
|
|
|
|
|
|
+ timestamp: res.timeStamp,
|
|
|
|
|
+ success(res) {
|
|
|
this.$toast.success('支付成功');
|
|
this.$toast.success('支付成功');
|
|
|
setTimeout(() => {
|
|
setTimeout(() => {
|
|
|
this.$router.replace('/orders');
|
|
this.$router.replace('/orders');
|
|
|
}, 1000);
|
|
}, 1000);
|
|
|
},
|
|
},
|
|
|
- fail() {
|
|
|
|
|
|
|
+ fail(e) {
|
|
|
|
|
+ console.log(e);
|
|
|
this.$toast('支付失败,请稍后再试');
|
|
this.$toast('支付失败,请稍后再试');
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|