Просмотр исходного кода

Merge branch 'yuan' of panhui/lasuo_nft_front into dev

yuanyuan 3 лет назад
Родитель
Сommit
b954e823ae
1 измененных файлов с 143 добавлено и 109 удалено
  1. 143 109
      src/views/Givesubmit.vue

+ 143 - 109
src/views/Givesubmit.vue

@@ -169,33 +169,33 @@ export default {
             });
         }
 
-        // Promise.all([
-        //     this.$http.get('/sysConfig/get/gas_fee').then(res => {
-        //         this.gas = res.value;
-        //         return Promise.resolve();
-        //     }),
-        //     inWeixin
-        //         ? this.$http.get('/sysConfig/get/enable_wx_pub').then(res => {
-        //               this.enable_wx_pub = res.value === '1';
-        //               return Promise.resolve();
-        //           })
-        //         : Promise.resolve(),
-        //     this.$http.get('/sysConfig/get/enable_wx_lite').then(res => {
-        //         this.enable_wx_lite = res.value === '1';
-        //         return Promise.resolve();
-        //     })
-        // ]).then(() => {
-        //     if (!(this.enable_wx_lite || this.enable_wx_pub)) {
-        //         this.payInfos.splice(1, 1);
-        //         this.payType = 'ALIPAY';
-        //     } else if (this.enable_wx_pub) {
-        //         this.payChannel = 'wx_pub';
-        //     } else {
-        //         this.payChannel = 'wx_lite';
-        //     }
+        Promise.all([
+            this.$http.get('/sysConfig/get/gas_fee').then(res => {
+                this.gas = res.value;
+                return Promise.resolve();
+            }),
+            inWeixin
+                ? this.$http.get('/sysConfig/get/enable_wx_pub').then(res => {
+                      this.enable_wx_pub = res.value === '1';
+                      return Promise.resolve();
+                  })
+                : Promise.resolve(),
+            this.$http.get('/sysConfig/get/enable_wx_lite').then(res => {
+                this.enable_wx_lite = res.value === '1';
+                return Promise.resolve();
+            })
+        ]).then(() => {
+            if (!(this.enable_wx_lite || this.enable_wx_pub)) {
+                this.payInfos.splice(1, 1);
+                this.payType = 'ALIPAY';
+            } else if (this.enable_wx_pub) {
+                this.payChannel = 'wx_pub';
+            } else {
+                this.payChannel = 'wx_lite';
+            }
 
-        //     this.passFn();
-        // });
+            this.passFn();
+        });
     },
     methods: {
         getGiverInformation() {
@@ -279,96 +279,130 @@ export default {
                                     // document.location.replace(
                                     //     resolveUrl(this.$baseUrl, 'payOrder/gift/alipay?id=' + res.id)
                                     // );
-                                    if (this.gas === '0') {
-                                        this.$http
-                                            .get(
-                                                `/payOrder/gift/${this.inApp ? 'alipay_app' : 'alipay_h5'}?id=${res.id}`
-                                            )
-                                            .then(res => {
-                                                this.$toast.success('转赠成功');
-                                                this.getOrder(true);
-                                                // setTimeout(() => {
-                                                // this.$router.push({
-                                                //     path: '/orderDetail',
-                                                //     query: {
-                                                //         id: res.id,
-                                                //     }
-                                                // });
-                                                // this.$router.replace('/giftOrder/' + order.getId());
-                                                // this.$router.replace('/orders');
-                                                // document.location.replace("https://www.adcs.vip/9th/giftOrder/223639");
-                                                // }, 1000);
-                                            })
-                                            .catch(e => {
-                                                if (e.error) {
-                                                    this.$toast(e.error);
-                                                }
-                                            });
+                                    if (this.inWeixin) {
+                                        if (this.gas === '0') {
+                                            this.$http
+                                                .get('/payOrder/gift/alipay_wx?id=' + res.id)
+                                                .then(res => {
+                                                    this.$toast.success('转赠成功');
+                                                    this.getOrder(true);
+                                                    // setTimeout(() => {
+                                                    // this.$router.push({
+                                                    //     path: '/orderDetail',
+                                                    //     query: {
+                                                    //         id: res.id,
+                                                    //     }
+                                                    // });
+                                                    // this.$router.replace('/orders');
+                                                    // document.location.replace("https://www.adcs.vip/9th/giftOrder/223639");
+                                                    // this.$router.replace('/giftOrder/' + order.getId());
+                                                    // }, 1000);
+                                                })
+                                                .catch(e => {
+                                                    if (e.error) {
+                                                        this.$toast(e.error);
+                                                    }
+                                                });
+                                        } else {
+                                            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 === '0') {
+                                            this.$http
+                                                .get(
+                                                    `/payOrder/gift/${this.inApp ? 'alipay_app' : 'alipay_h5'}?id=${
+                                                        res.id
+                                                    }`
+                                                )
+                                                .then(res => {
+                                                    this.$toast.success('转赠成功');
+                                                    this.getOrder(true);
+                                                    // setTimeout(() => {
+                                                    // this.$router.push({
+                                                    //     path: '/orderDetail',
+                                                    //     query: {
+                                                    //         id: res.id,
+                                                    //     }
+                                                    // });
+                                                    // this.$router.replace('/giftOrder/' + order.getId());
+                                                    // this.$router.replace('/orders');
+                                                    // document.location.replace("https://www.adcs.vip/9th/giftOrder/223639");
+                                                    // }, 1000);
+                                                })
+                                                .catch(e => {
+                                                    if (e.error) {
+                                                        this.$toast(e.error);
+                                                    }
                                                 });
+                                        } 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.$toast.loading({
+                                                        message: '加载中...',
+                                                        forbidClick: true
+                                                    });
+                                                    this.getOrder(true);
+                                                })
+                                                .catch(e => {
+                                                    if (e.error) {
+                                                        this.$toast(e.error);
+                                                    }
                                                 });
-                                                this.getOrder(true);
+                                        }
+                                    }
+                                } else if (this.payType === 'WEIXIN') {
+                                    if (this.inWeixin) {
+                                        this.$toast.loading('加载中');
+                                        this.$http
+                                            .post('/payOrder/gift/weixin', {
+                                                id: res.id,
+                                                openId: localStorage.getItem('openId')
                                             })
-                                            .catch(e => {
-                                                if (e.error) {
-                                                    this.$toast(e.error);
-                                                }
+                                            .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 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)
-                                    //         );
-                                    //     }
-                                    // }
                                 }
                             });
                         })