xiongzhu пре 4 година
родитељ
комит
cdcadb9a0d
1 измењених фајлова са 24 додато и 1 уклоњено
  1. 24 1
      src/main/nine-space/src/views/Submit.vue

+ 24 - 1
src/main/nine-space/src/views/Submit.vue

@@ -149,16 +149,39 @@ export default {
     },
     methods: {
         submit() {
+            this.$toast.loading('加载中');
             this.$http
                 .post('/order/create?collectionId=' + this.$route.query.id + '&qty=1')
                 .then(res => {
+                    this.$toast.clear();
                     this.orderId = res.id;
                     this.$router.replace('/submit?orderId=' + res.id);
                     this.$nextTick(() => {
                         if (this.payType === 'ALIPAY') {
                             document.location.replace(path.resolve(this.$baseUrl, 'payOrder/alipay?id=' + res.id));
                         } else if (this.payType === 'WEIXIN') {
-                            document.location.replace(path.resolve(this.$baseUrl, 'payOrder/weixin_h5?id=' + res.id));
+                            if (/MicroMessenger/i.test(navigator.userAgent)) {
+                                this.$toast.loading('加载中');
+                                this.$http.post('/payOrder/weixin', { id: res.id }).then(res => {
+                                    wx.chooseWXPay({
+                                        ...res,
+                                        package: res.package || res.packageValue,
+                                        success: function (res) {
+                                            this.$toast.success('支付成功');
+                                            setTimeout(() => {
+                                                this.$router.replace('/orders');
+                                            }, 1000);
+                                        },
+                                        fail() {
+                                            this.$toast('支付失败,请稍后再试');
+                                        }
+                                    });
+                                });
+                            } else {
+                                document.location.replace(
+                                    path.resolve(this.$baseUrl, 'payOrder/weixin_h5?id=' + res.id)
+                                );
+                            }
                         }
                     });
                 })