|
|
@@ -250,32 +250,55 @@ export default {
|
|
|
});
|
|
|
});
|
|
|
},
|
|
|
- submit() {
|
|
|
+ createOrder() {
|
|
|
if (!this.payType) {
|
|
|
this.$toast('请选择支付方式');
|
|
|
return;
|
|
|
}
|
|
|
- this.$toast.loading('加载中');
|
|
|
- let url = '/order/create?collectionId=' + this.$route.query.id + '&qty=1';
|
|
|
- if (this.couponInfo) {
|
|
|
- url += '&couponId=' + this.couponInfo.id;
|
|
|
- }
|
|
|
- let invitor = sessionStorage.getItem('invitor');
|
|
|
- if (invitor) {
|
|
|
- url += '&invitor=' + invitor;
|
|
|
- }
|
|
|
- this.$http
|
|
|
- .post(url)
|
|
|
+ this.$toast.loading('请不要离开当前页面');
|
|
|
+
|
|
|
+ let params = {
|
|
|
+ collectionId: this.$route.query.id,
|
|
|
+ qty: 1,
|
|
|
+ couponId: (this.couponInfo || {}).id || '',
|
|
|
+ invitor: sessionStorage.getItem('invitor')
|
|
|
+ };
|
|
|
+ return this.$http.post('/order/mqCreate', params).then(res => {
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ let checkOrder = () => {
|
|
|
+ this.$http
|
|
|
+ .get('/order/createResult', { id: res.id })
|
|
|
+ .then(res => {
|
|
|
+ if (res) {
|
|
|
+ clearInterval(this.createOrderTimer);
|
|
|
+ this.createOrderTimer = null;
|
|
|
+ if (res.success) {
|
|
|
+ resolve(res.data);
|
|
|
+ } else {
|
|
|
+ reject({ error: res.data });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(e => {
|
|
|
+ clearInterval(this.createOrderTimer);
|
|
|
+ this.createOrderTimer = null;
|
|
|
+ reject(e);
|
|
|
+ });
|
|
|
+ };
|
|
|
+ setTimeout(checkOrder, 500);
|
|
|
+ this.createOrderTimer = setInterval(checkOrder, 2000);
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+ submit() {
|
|
|
+ this.createOrder()
|
|
|
.then(res => {
|
|
|
if (this.money) {
|
|
|
this.$toast.clear();
|
|
|
this.orderId = res.id;
|
|
|
- this.$router.replace({ query: { ...this.$route.query, orderId: res.id } });
|
|
|
+ this.$router.replace('/submit?orderId=' + res.id);
|
|
|
this.$nextTick(() => {
|
|
|
- if (this.$store.state.review) {
|
|
|
- window.store.order('358');
|
|
|
- this.getOrder(true);
|
|
|
- } else if (this.payType === 'ALIPAY') {
|
|
|
+ if (this.payType === 'ALIPAY') {
|
|
|
if (this.inWeixin) {
|
|
|
document.location.replace(
|
|
|
resolveUrl(this.$baseUrl, '/payOrder/alipay_wx?id=' + res.id)
|
|
|
@@ -293,12 +316,9 @@ export default {
|
|
|
this.$nextTick(() => {
|
|
|
document.getElementById('pay').click();
|
|
|
});
|
|
|
-
|
|
|
- this.$toast.loading({
|
|
|
- message: '加载中...',
|
|
|
- forbidClick: true
|
|
|
- });
|
|
|
- this.getOrder(true);
|
|
|
+ if (!this.inApp) {
|
|
|
+ this.getOrder(true);
|
|
|
+ }
|
|
|
})
|
|
|
.catch(e => {
|
|
|
if (e.error) {
|
|
|
@@ -317,17 +337,18 @@ export default {
|
|
|
.then(res => {
|
|
|
if ('wx_pub' === this.payChannel) {
|
|
|
console.log('wxPayParams', res);
|
|
|
+ let _this = this;
|
|
|
wx.chooseWXPay({
|
|
|
...res,
|
|
|
success(res) {
|
|
|
- this.$toast.success('支付成功');
|
|
|
+ _this.$toast.success('支付成功');
|
|
|
setTimeout(() => {
|
|
|
- this.$router.replace('/orders');
|
|
|
+ _this.$router.replace('/orderDetail?id=' + _this.orderId);
|
|
|
}, 1000);
|
|
|
},
|
|
|
fail(e) {
|
|
|
console.log(e);
|
|
|
- this.$toast('支付失败,请稍后再试');
|
|
|
+ _this.$toast('支付失败,请稍后再试');
|
|
|
}
|
|
|
});
|
|
|
} else {
|
|
|
@@ -336,11 +357,6 @@ export default {
|
|
|
this.$nextTick(() => {
|
|
|
document.getElementById('pay').click();
|
|
|
});
|
|
|
-
|
|
|
- this.$toast.loading({
|
|
|
- message: '加载中...',
|
|
|
- forbidClick: true
|
|
|
- });
|
|
|
this.getOrder(true);
|
|
|
}
|
|
|
// console.log({
|