|
|
@@ -72,18 +72,19 @@ export default {
|
|
|
return {
|
|
|
info: {},
|
|
|
message: '',
|
|
|
- payType: inWeixin ? 'ALIPAY' : 'ALIPAY',
|
|
|
+ payType: inWeixin ? 'WEIXIN' : 'ALIPAY',
|
|
|
+ payChannel: null,
|
|
|
payInfos: [
|
|
|
{
|
|
|
icon: require('@assets/svgs/zhifubao.svg'),
|
|
|
name: '支付宝',
|
|
|
type: 'ALIPAY'
|
|
|
},
|
|
|
- // {
|
|
|
- // icon: require('@assets/svgs/wechat.svg'),
|
|
|
- // name: '微信',
|
|
|
- // type: 'WEIXIN'
|
|
|
- // }
|
|
|
+ {
|
|
|
+ icon: require('@assets/svgs/wechat.svg'),
|
|
|
+ name: '微信',
|
|
|
+ type: 'WEIXIN'
|
|
|
+ }
|
|
|
// {
|
|
|
// icon: require("@assets/svgs/png-decp.svg"),
|
|
|
// name: "DCEP",
|
|
|
@@ -98,7 +99,9 @@ export default {
|
|
|
couponList: [],
|
|
|
collectionId: 0,
|
|
|
timer: null,
|
|
|
- hrefUrl: ''
|
|
|
+ hrefUrl: '',
|
|
|
+ enable_wx_lite: false,
|
|
|
+ enable_wx_pub: false
|
|
|
};
|
|
|
},
|
|
|
computed: {
|
|
|
@@ -123,8 +126,30 @@ export default {
|
|
|
next();
|
|
|
},
|
|
|
mounted() {
|
|
|
- this.$http.get('/sysConfig/get/gas_fee').then(res => {
|
|
|
- this.gas = res.value;
|
|
|
+ Promise.all([
|
|
|
+ this.$http.get('/sysConfig/get/gas_fee').then(res => {
|
|
|
+ this.gas = res.value;
|
|
|
+ return Promise.resolve();
|
|
|
+ }),
|
|
|
+ inWeixin
|
|
|
+ ? this.$http.get('/sysConfig/get/enable_wx_pub').then(res => {
|
|
|
+ this.enable_wx_pub = res.value === '1';
|
|
|
+ return Promise.resolve();
|
|
|
+ })
|
|
|
+ : Promise.resolve(),
|
|
|
+ this.$http.get('/sysConfig/get/enable_wx_lite').then(res => {
|
|
|
+ this.enable_wx_lite = res.value === '1';
|
|
|
+ return Promise.resolve();
|
|
|
+ })
|
|
|
+ ]).then(() => {
|
|
|
+ if (!(this.enable_wx_lite || this.enable_wx_pub)) {
|
|
|
+ this.payInfos.splice(1, 1);
|
|
|
+ this.payType = 'ALIPAY';
|
|
|
+ } else if (this.enable_wx_pub) {
|
|
|
+ this.payChannel = 'wx_pub';
|
|
|
+ } else {
|
|
|
+ this.payChannel = 'wx_lite';
|
|
|
+ }
|
|
|
});
|
|
|
this.$toast.loading({
|
|
|
message: '加载中...',
|
|
|
@@ -193,6 +218,10 @@ export default {
|
|
|
});
|
|
|
},
|
|
|
submit() {
|
|
|
+ if (!this.payType) {
|
|
|
+ this.$toast('请选择支付方式');
|
|
|
+ return;
|
|
|
+ }
|
|
|
this.$toast.loading('加载中');
|
|
|
let url = '/order/create?collectionId=' + this.$route.query.id + '&qty=1';
|
|
|
if (this.couponInfo) {
|
|
|
@@ -242,16 +271,33 @@ export default {
|
|
|
this.$toast.loading('加载中');
|
|
|
this.$http
|
|
|
.post('/payOrder/weixin', {
|
|
|
- id: res.id
|
|
|
+ id: res.id,
|
|
|
+ channel: this.payChannel,
|
|
|
+ openId: localStorage.getItem('openId') || 'oWJG55wLnwdVzXoKka1-DzQKOd_Y'
|
|
|
})
|
|
|
.then(res => {
|
|
|
- this.$toast.clear();
|
|
|
- this.hrefUrl = res.scheme_code;
|
|
|
- this.$nextTick(() => {
|
|
|
- document.getElementById('pay').click();
|
|
|
- });
|
|
|
- if (this.inWeixin) {
|
|
|
- this.getOrder(true);
|
|
|
+ this.getOrder(true);
|
|
|
+ if ('wx_pub' === this.payChannel) {
|
|
|
+ console.log('wxPayParams', res);
|
|
|
+ wx.chooseWXPay({
|
|
|
+ ...res,
|
|
|
+ success(res) {
|
|
|
+ this.$toast.success('支付成功');
|
|
|
+ setTimeout(() => {
|
|
|
+ this.$router.replace('/orders');
|
|
|
+ }, 1000);
|
|
|
+ },
|
|
|
+ fail(e) {
|
|
|
+ console.log(e);
|
|
|
+ this.$toast('支付失败,请稍后再试');
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ this.$toast.clear();
|
|
|
+ this.hrefUrl = res.scheme_code;
|
|
|
+ this.$nextTick(() => {
|
|
|
+ document.getElementById('pay').click();
|
|
|
+ });
|
|
|
}
|
|
|
// console.log({
|
|
|
// ...res,
|
|
|
@@ -275,9 +321,7 @@ export default {
|
|
|
// });
|
|
|
})
|
|
|
.catch(e => {
|
|
|
- if (e.error) {
|
|
|
- this.$toast(e.error);
|
|
|
- }
|
|
|
+ this.$toast(e.error || '支付失败请稍后再试');
|
|
|
});
|
|
|
}
|
|
|
});
|