Browse Source

Merge branch 'master' of http://git.izouma.com/xiongzhu/9th

xuqiang 4 years ago
parent
commit
beeba8dcfe
1 changed files with 42 additions and 29 deletions
  1. 42 29
      src/main/nine-space/src/views/Submit.vue

+ 42 - 29
src/main/nine-space/src/views/Submit.vue

@@ -100,7 +100,8 @@ export default {
             inWeixin,
             inApp,
             couponList: [],
-            collectionId: 0
+            collectionId: 0,
+            timer: null
         };
     },
     computed: {
@@ -144,34 +145,43 @@ export default {
             });
             this.getCouponList();
         } else {
-            this.$http.get('/order/get/' + this.$route.query.orderId).then(res => {
-                this.info = res;
-                this.orderId = res.id;
-                setTimeout(() => {
-                    this.bs.value.refresh();
-                }, 100);
-                this.$dialog
-                    .alert({
-                        title: '提示',
-                        message:
-                            res.status === 'NOT_PAID' || res.status === 'CANCELLED'
-                                ? '订单支付失败,点击重新下单'
-                                : '订单已支付,点击查看订单详情'
-                    })
-                    .then(() => {
-                        if (res.status === 'NOT_PAID' || res.status === 'CANCELLED') {
-                            this.$router.back();
-                        } else {
-                            this.$router.replace('/orderDetail?id' + res.id);
-                        }
-                        // on close
-                    });
-            });
+            this.orderId = this.$route.query.orderId;
+            this.getOrder();
         }
 
         this.bottom = this.$refs.bottom;
     },
     methods: {
+        refreashOrder() {
+            this.getOrder();
+            if (this.timer) {
+                clearTimeout(this.timer);
+            }
+            this.timer = setTimeout(() => {
+                this.refreashOrder();
+            }, 1000);
+        },
+        getOrder() {
+            this.$http.get('/order/get/' + this.orderId).then(res => {
+                this.info = res;
+                if (res.status === 'PROCESSING' || res.status === 'CANCELLED') {
+                    this.$dialog
+                        .alert({
+                            title: '提示',
+                            message:
+                                res.status === 'CANCELLED' ? '订单支付失败,点击重新下单' : '订单已支付,点击查看订单详情'
+                        })
+                        .then(() => {
+                            if (res.status === 'CANCELLED') {
+                                this.$router.back();
+                            } else {
+                                this.$router.replace('/orderDetail?id' + res.id);
+                            }
+                            // on close
+                        });
+                }
+            });
+        },
         getCouponList() {
             this.$http
                 .post(
@@ -207,16 +217,19 @@ export default {
                         this.$nextTick(() => {
                             if (this.payType === 'ALIPAY') {
                                 if (this.inWeixin) {
-                                    document.location.replace(
-                                        path.resolve(this.$baseUrl, '/payOrder/alipay_wx?id=' + res.id)
+                                    document.location.href = path.resolve(
+                                        this.$baseUrl,
+                                        '/payOrder/alipay_wx?id=' + res.id
                                     );
                                 } else {
                                     this.$http
                                         .get(`/payOrder/${this.inApp ? 'alipay_app' : 'alipay_h5'}?id=${res.id}`)
                                         .then(res => {
-                                            document.location.replace(
-                                                'alipays://platformapi/startapp?saId=10000007&qrcode=' + res
-                                            );
+                                            document.open('alipays://platformapi/startapp?saId=10000007&qrcode=' + res);
+
+                                            if (!this.inApp) {
+                                                this.refreashOrder();
+                                            }
                                         });
                                 }
                             } else if (this.payType === 'WEIXIN') {