|
@@ -112,7 +112,8 @@ export default {
|
|
|
launchName: '',
|
|
launchName: '',
|
|
|
launchPath: '',
|
|
launchPath: '',
|
|
|
createOrderTimer: null,
|
|
createOrderTimer: null,
|
|
|
- timerNum: 0
|
|
|
|
|
|
|
+ timerNum: 0,
|
|
|
|
|
+ weixinOptions: {}
|
|
|
};
|
|
};
|
|
|
},
|
|
},
|
|
|
computed: {
|
|
computed: {
|
|
@@ -352,113 +353,140 @@ export default {
|
|
|
});
|
|
});
|
|
|
},
|
|
},
|
|
|
pay() {
|
|
pay() {
|
|
|
- if (this.money) {
|
|
|
|
|
- this.$toast.clear();
|
|
|
|
|
- this.$router.replace({ query: { ...this.$route.query, orderId: this.orderId } });
|
|
|
|
|
- this.$nextTick(() => {
|
|
|
|
|
- if (this.$store.state.review) {
|
|
|
|
|
- window.store.order('358');
|
|
|
|
|
- this.getOrder(true);
|
|
|
|
|
- } else if (this.payType === 'ALIPAY') {
|
|
|
|
|
- if (this.inWeixin) {
|
|
|
|
|
- document.location.replace(
|
|
|
|
|
- resolveUrl(this.$baseUrl, '/payOrder/alipay_wx?id=' + this.orderId)
|
|
|
|
|
- );
|
|
|
|
|
- } else {
|
|
|
|
|
- this.$http
|
|
|
|
|
- .get(`/payOrder/${this.inApp ? 'alipay_app' : 'alipay_h5'}?id=${this.orderId}`)
|
|
|
|
|
- .then(res => {
|
|
|
|
|
- this.$toast.clear();
|
|
|
|
|
- this.hrefUrl = 'alipays://platformapi/startapp?saId=10000007&qrcode=' + res;
|
|
|
|
|
- // window.open(
|
|
|
|
|
- // 'alipays://platformapi/startapp?saId=10000007&qrcode=' + res,
|
|
|
|
|
- // '_blank'
|
|
|
|
|
- // );
|
|
|
|
|
- this.$nextTick(() => {
|
|
|
|
|
- document.getElementById('pay').click();
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ this.paySubmit().then(() => {
|
|
|
|
|
+ if (this.money) {
|
|
|
|
|
+ this.$nextTick(() => {
|
|
|
|
|
+ if (this.$store.state.review) {
|
|
|
|
|
+ window.store.order('358');
|
|
|
|
|
+ this.getOrder(true);
|
|
|
|
|
+ } else if (this.payType === 'ALIPAY') {
|
|
|
|
|
+ if (this.inWeixin) {
|
|
|
|
|
+ document.location.replace(
|
|
|
|
|
+ resolveUrl(this.$baseUrl, '/payOrder/alipay_wx?id=' + this.orderId)
|
|
|
|
|
+ );
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.$nextTick(() => {
|
|
|
|
|
+ document.getElementById('pay').click();
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
- this.$toast.loading({
|
|
|
|
|
- message: '加载中...',
|
|
|
|
|
- forbidClick: true
|
|
|
|
|
- });
|
|
|
|
|
- this.getOrder(true);
|
|
|
|
|
- })
|
|
|
|
|
- .catch(e => {
|
|
|
|
|
- if (e.error) {
|
|
|
|
|
- this.$toast(e.error);
|
|
|
|
|
|
|
+ this.$toast.loading({
|
|
|
|
|
+ message: '加载中...',
|
|
|
|
|
+ forbidClick: true
|
|
|
|
|
+ });
|
|
|
|
|
+ this.getOrder(true);
|
|
|
|
|
+ }
|
|
|
|
|
+ } else if (this.payType === 'WEIXIN') {
|
|
|
|
|
+ this.$toast.loading('加载中');
|
|
|
|
|
+ if ('wx_pub' === this.payChannel) {
|
|
|
|
|
+ wx.chooseWXPay({
|
|
|
|
|
+ ...this.weixinOptions,
|
|
|
|
|
+ success(res) {
|
|
|
|
|
+ this.$toast.success('支付成功');
|
|
|
|
|
+ setTimeout(() => {
|
|
|
|
|
+ this.$router.replace('/orders');
|
|
|
|
|
+ }, 1000);
|
|
|
|
|
+ },
|
|
|
|
|
+ fail(e) {
|
|
|
|
|
+ console.log(e);
|
|
|
|
|
+ this.$toast('支付失败,请稍后再试');
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.$toast.clear();
|
|
|
|
|
+ this.$nextTick(() => {
|
|
|
|
|
+ document.getElementById('pay').click();
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ this.$toast.loading({
|
|
|
|
|
+ message: '加载中...',
|
|
|
|
|
+ forbidClick: true
|
|
|
|
|
+ });
|
|
|
|
|
+ this.getOrder(true);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- } else if (this.payType === 'WEIXIN') {
|
|
|
|
|
- this.$toast.loading('加载中');
|
|
|
|
|
- this.$http
|
|
|
|
|
- .post('/payOrder/weixin', {
|
|
|
|
|
- id: this.orderId,
|
|
|
|
|
- channel: this.payChannel,
|
|
|
|
|
- openId: localStorage.getItem('openId') || 'oWJG55wLnwdVzXoKka1-DzQKOd_Y'
|
|
|
|
|
- })
|
|
|
|
|
- .then(res => {
|
|
|
|
|
- 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.success('支付成功');
|
|
|
|
|
+ setTimeout(() => {
|
|
|
|
|
+ this.$router.replace('/orderDetail?id=' + this.orderId);
|
|
|
|
|
+ }, 1000);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
|
|
+ paySubmit() {
|
|
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
|
|
+ if (this.money) {
|
|
|
|
|
+ this.$toast.clear();
|
|
|
|
|
+ this.$router.replace({ query: { ...this.$route.query, orderId: this.orderId } });
|
|
|
|
|
+ this.$nextTick(() => {
|
|
|
|
|
+ if (this.$store.state.review) {
|
|
|
|
|
+ resolve();
|
|
|
|
|
+ } else if (this.payType === 'ALIPAY') {
|
|
|
|
|
+ if (this.inWeixin) {
|
|
|
|
|
+ resolve();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.$http
|
|
|
|
|
+ .get(`/payOrder/${this.inApp ? 'alipay_app' : 'alipay_h5'}?id=${this.orderId}`)
|
|
|
|
|
+ .then(res => {
|
|
|
|
|
+ this.$toast.clear();
|
|
|
|
|
+ this.hrefUrl = 'alipays://platformapi/startapp?saId=10000007&qrcode=' + res;
|
|
|
|
|
+ resolve();
|
|
|
|
|
+ })
|
|
|
|
|
+ .catch(e => {
|
|
|
|
|
+ if (e.error) {
|
|
|
|
|
+ this.$toast(e.error);
|
|
|
|
|
+ reject();
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
- } else {
|
|
|
|
|
- this.$toast.clear();
|
|
|
|
|
- this.hrefUrl = res.scheme_code;
|
|
|
|
|
- this.$nextTick(() => {
|
|
|
|
|
- document.getElementById('pay').click();
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
- this.$toast.loading({
|
|
|
|
|
- message: '加载中...',
|
|
|
|
|
- forbidClick: true
|
|
|
|
|
- });
|
|
|
|
|
- this.getOrder(true);
|
|
|
|
|
- }
|
|
|
|
|
- // console.log({
|
|
|
|
|
- // ...res,
|
|
|
|
|
- // package: res.package || res.packageValue
|
|
|
|
|
- // });
|
|
|
|
|
- // let _this = this;
|
|
|
|
|
- // wx.chooseWXPay({
|
|
|
|
|
- // ...res,
|
|
|
|
|
- // package: res.package || res.packageValue,
|
|
|
|
|
- // timestamp: res.timeStamp,
|
|
|
|
|
- // success(res) {
|
|
|
|
|
- // _this.$toast.success('支付成功');
|
|
|
|
|
- // setTimeout(() => {
|
|
|
|
|
- // _this.$router.replace('/orders');
|
|
|
|
|
- // }, 1000);
|
|
|
|
|
- // },
|
|
|
|
|
- // fail(e) {
|
|
|
|
|
- // console.log(e);
|
|
|
|
|
- // _this.$toast('支付失败,请稍后再试');
|
|
|
|
|
- // }
|
|
|
|
|
- // });
|
|
|
|
|
- })
|
|
|
|
|
- .catch(e => {
|
|
|
|
|
- this.$toast(e.error || '支付失败请稍后再试');
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- } else {
|
|
|
|
|
- this.$toast.success('支付成功');
|
|
|
|
|
- setTimeout(() => {
|
|
|
|
|
- this.$router.replace('/orderDetail?id=' + this.orderId);
|
|
|
|
|
- }, 1000);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ } else if (this.payType === 'WEIXIN') {
|
|
|
|
|
+ this.$toast.loading('加载中');
|
|
|
|
|
+ this.$http
|
|
|
|
|
+ .post('/payOrder/weixin', {
|
|
|
|
|
+ id: this.orderId,
|
|
|
|
|
+ channel: this.payChannel,
|
|
|
|
|
+ openId: localStorage.getItem('openId') || 'oWJG55wLnwdVzXoKka1-DzQKOd_Y'
|
|
|
|
|
+ })
|
|
|
|
|
+ .then(res => {
|
|
|
|
|
+ if ('wx_pub' === this.payChannel) {
|
|
|
|
|
+ this.weixinOptions = res;
|
|
|
|
|
+ resolve();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.$toast.clear();
|
|
|
|
|
+ this.hrefUrl = res.scheme_code;
|
|
|
|
|
+ resolve();
|
|
|
|
|
+ }
|
|
|
|
|
+ // console.log({
|
|
|
|
|
+ // ...res,
|
|
|
|
|
+ // package: res.package || res.packageValue
|
|
|
|
|
+ // });
|
|
|
|
|
+ // let _this = this;
|
|
|
|
|
+ // wx.chooseWXPay({
|
|
|
|
|
+ // ...res,
|
|
|
|
|
+ // package: res.package || res.packageValue,
|
|
|
|
|
+ // timestamp: res.timeStamp,
|
|
|
|
|
+ // success(res) {
|
|
|
|
|
+ // _this.$toast.success('支付成功');
|
|
|
|
|
+ // setTimeout(() => {
|
|
|
|
|
+ // _this.$router.replace('/orders');
|
|
|
|
|
+ // }, 1000);
|
|
|
|
|
+ // },
|
|
|
|
|
+ // fail(e) {
|
|
|
|
|
+ // console.log(e);
|
|
|
|
|
+ // _this.$toast('支付失败,请稍后再试');
|
|
|
|
|
+ // }
|
|
|
|
|
+ // });
|
|
|
|
|
+ })
|
|
|
|
|
+ .catch(e => {
|
|
|
|
|
+ this.$toast(e.error || '支付失败请稍后再试');
|
|
|
|
|
+ reject();
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ } else {
|
|
|
|
|
+ resolve();
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
},
|
|
},
|
|
|
goCoupon() {
|
|
goCoupon() {
|
|
|
if (!this.orderId) {
|
|
if (!this.orderId) {
|