xiongzhu 4 лет назад
Родитель
Сommit
0f113b3efd

+ 5 - 1
src/main/java/com/izouma/nineth/service/OrderService.java

@@ -311,7 +311,6 @@ public class OrderService {
             Map<String, Object> expend = new HashMap<>();
             expend.put("open_id", openId);
             expend.put("limit_pay", "1");
-            expend.put("wx_app_id", adapayProperties.getWxAppId());
             paymentParams.put("expend", expend);
         }
 
@@ -333,6 +332,11 @@ public class OrderService {
                 return MapUtils.getString(MapUtils.getMap(response, "expend"), "pay_info");
             case "alipay_qr":
                 return MapUtils.getString(MapUtils.getMap(response, "expend"), "qrcode_url");
+            case "wx_pub":
+                JSONObject payParams = JSON.parseObject(MapUtils.getString(MapUtils.getMap(response, "expend"), "pay_info"));
+                payParams.put("timestamp", payParams.get("timeStamp"));
+                payParams.remove("timeStamp");
+                return payParams;
             default:
                 return MapUtils.getMap(response, "expend");
         }

+ 8 - 0
src/main/java/com/izouma/nineth/service/SysConfigService.java

@@ -70,5 +70,13 @@ public class SysConfigService {
                     .value("FALSE")
                     .build());
         }
+        if (!sysConfigRepo.findByName("enable_wx_lite").isPresent()) {
+            sysConfigRepo.save(SysConfig.builder()
+                    .name("enable_wx_lite")
+                    .desc("使用小程序支付")
+                    .type(SysConfig.ValueType.BOOLEAN)
+                    .value("FALSE")
+                    .build());
+        }
     }
 }

+ 1 - 1
src/main/java/com/izouma/nineth/web/OrderPayController.java

@@ -83,7 +83,7 @@ public class OrderPayController {
     public String payGiftOrderAlipay(Long id, Model model, @RequestHeader(value = "User-Agent") String userAgent) {
         detectUA(userAgent, model);
         giftOrderService.payOrderAlipay(id, model);
-        return "AlipayHtml";
+        return "AlipayHtml1";
     }
 
     @RequestMapping(value = "/gift/weixin_h5")

+ 2 - 0
src/main/nine-space/public/index.html

@@ -28,5 +28,7 @@
         </noscript>
         <div id="app"></div>
         <!-- built files will be auto injected -->
+        <script src="//cdn.jsdelivr.net/npm/eruda"></script>
+        <script>eruda.init();</script>
     </body>
 </html>

+ 3 - 0
src/main/nine-space/src/router/index.js

@@ -5,6 +5,9 @@ import { Dialog } from 'vant';
 import http from '../plugins/http';
 
 function jsapiSign() {
+    if (/micromessenger/i.test(navigator.userAgent) && !/localhost|(192\.168)/i.test(location.host)) {
+        return;
+    }
     setTimeout(() => {
         if (/micromessenger/i.test(navigator.userAgent)) {
             let isIOS = /iphone|ipad/i.test(navigator.userAgent);

+ 64 - 20
src/main/nine-space/src/views/Submit.vue

@@ -72,18 +72,19 @@ export default {
         return {
             info: {},
             message: '',
-            payType: inWeixin ? 'ALIPAY' : 'ALIPAY',
+            payType: inWeixin ? 'WEIXIN' : 'ALIPAY',
+            payChannel: null,
             payInfos: [
                 {
                     icon: require('@assets/svgs/zhifubao.svg'),
                     name: '支付宝',
                     type: 'ALIPAY'
                 },
-                // {
-                //     icon: require('@assets/svgs/wechat.svg'),
-                //     name: '微信',
-                //     type: 'WEIXIN'
-                // }
+                {
+                    icon: require('@assets/svgs/wechat.svg'),
+                    name: '微信',
+                    type: 'WEIXIN'
+                }
                 // {
                 //   icon: require("@assets/svgs/png-decp.svg"),
                 //   name: "DCEP",
@@ -98,7 +99,9 @@ export default {
             couponList: [],
             collectionId: 0,
             timer: null,
-            hrefUrl: ''
+            hrefUrl: '',
+            enable_wx_lite: false,
+            enable_wx_pub: false
         };
     },
     computed: {
@@ -123,8 +126,30 @@ export default {
         next();
     },
     mounted() {
-        this.$http.get('/sysConfig/get/gas_fee').then(res => {
-            this.gas = res.value;
+        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.$toast.loading({
             message: '加载中...',
@@ -193,6 +218,10 @@ export default {
                 });
         },
         submit() {
+            if (!this.payType) {
+                this.$toast('请选择支付方式');
+                return;
+            }
             this.$toast.loading('加载中');
             let url = '/order/create?collectionId=' + this.$route.query.id + '&qty=1';
             if (this.couponInfo) {
@@ -242,16 +271,33 @@ export default {
                                 this.$toast.loading('加载中');
                                 this.$http
                                     .post('/payOrder/weixin', {
-                                        id: res.id
+                                        id: res.id,
+                                        channel: this.payChannel,
+                                        openId: localStorage.getItem('openId') || 'oWJG55wLnwdVzXoKka1-DzQKOd_Y'
                                     })
                                     .then(res => {
-                                        this.$toast.clear();
-                                        this.hrefUrl = res.scheme_code;
-                                        this.$nextTick(() => {
-                                            document.getElementById('pay').click();
-                                        });
-                                        if (this.inWeixin) {
-                                            this.getOrder(true);
+                                        this.getOrder(true);
+                                        if ('wx_pub' === this.payChannel) {
+                                            console.log('wxPayParams', res);
+                                            wx.chooseWXPay({
+                                                ...res,
+                                                success(res) {
+                                                    this.$toast.success('支付成功');
+                                                    setTimeout(() => {
+                                                        this.$router.replace('/orders');
+                                                    }, 1000);
+                                                },
+                                                fail(e) {
+                                                    console.log(e);
+                                                    this.$toast('支付失败,请稍后再试');
+                                                }
+                                            });
+                                        } else {
+                                            this.$toast.clear();
+                                            this.hrefUrl = res.scheme_code;
+                                            this.$nextTick(() => {
+                                                document.getElementById('pay').click();
+                                            });
                                         }
                                         // console.log({
                                         //     ...res,
@@ -275,9 +321,7 @@ export default {
                                         // });
                                     })
                                     .catch(e => {
-                                        if (e.error) {
-                                            this.$toast(e.error);
-                                        }
+                                        this.$toast(e.error || '支付失败请稍后再试');
                                     });
                             }
                         });

+ 1 - 2
src/main/vue/src/components/RichText.vue

@@ -29,7 +29,6 @@ import 'tinymce/plugins/code';
 import 'tinymce/plugins/help';
 import 'tinymce/plugins/imagetools';
 import 'tinymce/skins/ui/oxide/skin.css';
-import 'tinymce/skins/ui/oxide-dark/skin.css';
 import 'tinymce/icons/default/index';
 
 export default {
@@ -40,7 +39,7 @@ export default {
             init: {
                 language: 'zh_CN',
                 theme: 'silver',
-                skin: 'oxide-dark',
+                skin: 'oxide',
                 menubar: false,
                 branding: false,
                 statusbar: false,