panhui 4 年 前
コミット
47f0f20d9b
1 ファイル変更81 行追加72 行削除
  1. 81 72
      src/views/Givesubmit.vue

+ 81 - 72
src/views/Givesubmit.vue

@@ -140,7 +140,7 @@ export default {
         }
 
         Promise.all([
-            this.$http.get('/sysConfig/get/gas_fee').then(res => {
+            this.$http.get('/sysConfig/get/gift_gas_fee').then(res => {
                 this.gas = res.value;
                 return Promise.resolve();
             }),
@@ -226,81 +226,90 @@ export default {
                         })
                         .then(res => {
                             this.orderId = res.id;
-                            this.$nextTick(() => {
-                                if (this.payType === 'ALIPAY') {
-                                    // document.location.replace(
-                                    //     resolveUrl(this.$baseUrl, 'payOrder/gift/alipay?id=' + res.id)
-                                    // );
-                                    if (this.inWeixin) {
-                                        document.location.replace(
-                                            resolveUrl(this.$baseUrl, '/payOrder/gift/alipay_wx?id=' + res.id)
-                                        );
-                                    } else {
-                                        this.$http
-                                            .get(
-                                                `/payOrder/gift/${this.inApp ? 'alipay_app' : 'alipay_h5'}?id=${res.id}`
-                                            )
-                                            .then(res => {
-                                                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();
-                                                });
+                            if (this.gas) {
+                                this.$nextTick(() => {
+                                    if (this.payType === 'ALIPAY') {
+                                        // document.location.replace(
+                                        //     resolveUrl(this.$baseUrl, 'payOrder/gift/alipay?id=' + res.id)
+                                        // );
+                                        if (this.inWeixin) {
+                                            document.location.replace(
+                                                resolveUrl(this.$baseUrl, '/payOrder/gift/alipay_wx?id=' + res.id)
+                                            );
+                                        } else {
+                                            this.$http
+                                                .get(
+                                                    `/payOrder/gift/${this.inApp ? 'alipay_app' : 'alipay_h5'}?id=${
+                                                        res.id
+                                                    }`
+                                                )
+                                                .then(res => {
+                                                    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.$toast.loading({
-                                                    message: '加载中...',
-                                                    forbidClick: true
-                                                });
-                                                this.getOrder(true);
-                                            })
-                                            .catch(e => {
-                                                if (e.error) {
-                                                    this.$toast(e.error);
-                                                }
-                                            });
-                                    }
-                                } else if (this.payType === 'WEIXIN') {
-                                    if (this.inWeixin) {
-                                        this.$toast.loading('加载中');
-                                        this.$http
-                                            .post('/payOrder/gift/weixin', {
-                                                id: res.id,
-                                                openId: localStorage.getItem('openId')
-                                            })
-                                            .then(res => {
-                                                console.log({
-                                                    ...res,
-                                                    package: res.package || res.packageValue,
-                                                    timestamp: res.timestamp || res.timeStamp
-                                                });
-                                                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('支付失败,请稍后再试');
+                                                    this.$toast.loading({
+                                                        message: '加载中...',
+                                                        forbidClick: true
+                                                    });
+                                                    this.getOrder(true);
+                                                })
+                                                .catch(e => {
+                                                    if (e.error) {
+                                                        this.$toast(e.error);
                                                     }
                                                 });
-                                            });
-                                    } else {
-                                        document.location.replace(
-                                            resolveUrl(this.$baseUrl, 'payOrder/gift/weixin_h5?id=' + res.id)
-                                        );
+                                        }
+                                    } else if (this.payType === 'WEIXIN') {
+                                        if (this.inWeixin) {
+                                            this.$toast.loading('加载中');
+                                            this.$http
+                                                .post('/payOrder/gift/weixin', {
+                                                    id: res.id,
+                                                    openId: localStorage.getItem('openId')
+                                                })
+                                                .then(res => {
+                                                    console.log({
+                                                        ...res,
+                                                        package: res.package || res.packageValue,
+                                                        timestamp: res.timestamp || res.timeStamp
+                                                    });
+                                                    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('支付失败,请稍后再试');
+                                                        }
+                                                    });
+                                                });
+                                        } else {
+                                            document.location.replace(
+                                                resolveUrl(this.$baseUrl, 'payOrder/gift/weixin_h5?id=' + res.id)
+                                            );
+                                        }
                                     }
-                                }
-                            });
+                                });
+                            } else {
+                                this.$toast.success('转赠成功');
+                                setTimeout(() => {
+                                    this.$router.go(-2);
+                                }, 1500);
+                            }
                         })
                         .catch(e => {
                             if (e) {