瀏覽代碼

支付二维码重定向

zhengjinyi 3 年之前
父節點
當前提交
0be35d92e8

+ 11 - 0
src/main/java/com/caimei/www/controller/authorized/PayController.java

@@ -36,6 +36,9 @@ public class PayController extends BaseController {
     /** 维沙网银支付链接页 */
     private static final String CAIMAI_WISAPAY = "pay/caimei-wisapay";
 
+    /** 维沙网银支付链接页 */
+    private static final String CAIMAI_CODE = "pay/caimei-code";
+
     /**
      * 微信小程序网银支付链接页
      */
@@ -44,6 +47,14 @@ public class PayController extends BaseController {
         return CAIMAI_PAY;
     }
 
+    /**
+     * 微信小程序网银支付链接页
+     */
+    @GetMapping("/wxcode.html")
+    public String wxcode() {
+        return CAIMAI_CODE;
+    }
+
     /**
      * 订单支付初始化页面
      */

+ 34 - 0
src/main/resources/static/js/pay/caimei-code.js

@@ -0,0 +1,34 @@
+/**
+ *Created by ZHJY on 2020/7/14.
+ */
+var payContainer = new Vue({
+    el:"#payContainer",
+    data: {
+        loginLoading:true,
+        orderInfo:{}
+    },
+    methods: {
+        authRedirect:function (orderInfo) {
+            console.log('orderInfo=====>',orderInfo)
+            var wechatPayUrl = 'https://open.weixin.qq.com/connect/oauth2/authorize'
+            var appId = 'wx91c4152b60ca91a3'
+            var redirect_uri = 'https://www-b.caimei365.com/pay/wechatpay.html'
+            var url =
+                wechatPayUrl +
+                '?appid=' +
+                appId +
+                '&redirect_uri=' +
+                redirect_uri +
+                '&response_type=code&scope=snsapi_base&state=' +
+                JSON.stringify(orderInfo) +
+                '#wechat_redirect'
+            console.log('url=====>',url)
+            window.location.href = url
+        }
+    },
+    mounted: function () {
+        var _self = this;
+        var orderInfo = CAIMEI.getUrlParam('orderInfo');
+        _self.authRedirect(orderInfo)
+    }
+});

+ 2 - 1
src/main/resources/static/js/pay/caimei-paymobile.js

@@ -151,7 +151,8 @@ var payContainer = new Vue({
                     payAmount:_self.payAmount
                 };
             }
-            _self.payInfo.payMobileUrl = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx91c4152b60ca91a3&redirect_uri=https://www-b.caimei365.com/pay/wechatpay.html&response_type=code&scope=snsapi_base&state="+JSON.stringify(orderInfo)+"#wechat_redirect";
+            // _self.payInfo.payMobileUrl = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx91c4152b60ca91a3&redirect_uri=https://www-b.caimei365.com/pay/wechatpay.html&response_type=code&scope=snsapi_base&state="+JSON.stringify(orderInfo)+"#wechat_redirect";
+            _self.payInfo.payMobileUrl = 'https://www-b.caimei365.com/wxcode.html?orderInfo='+orderInfo;
             console.log(_self.payInfo.payMobileUrl);
             var qrcode = new QRCode(document.getElementById("wx_pay_container"), {
                 render: "canvas", //也可以替换为table

+ 35 - 0
src/main/resources/templates/pay/caimei-code.html

@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html lang="zh-CN" xmlns:th="https://www.thymeleaf.org" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+      xsi:schemaLocation="https://www.thymeleaf.org ">
+<head>
+    <template th:replace="pay/components/pay-link"></template>
+    <link th:href="@{/css/pay/caimei-paymobile.css(v=${version})}" rel="stylesheet" type="text/css">
+    <template th:replace="components/analysis"></template>
+</head>
+<body>
+<div class="head-wrap">
+    <div class="inner clear">
+        <div class="logo"><a href="/index.html"><img src="/img/base/index_logo.png" alt=""></a></div>
+        <div class="text">收银台</div>
+        <input type="hidden" th:value="${coreServer}" id="coreServer">
+        <input type="hidden" th:value="${agent}" id="userAgent">
+    </div>
+</div>
+<div class="pay-container weixin clear" id="payContainer" >
+    <div v-if="loginLoading" class="loading" :style="{opacity: loginLoading ? '1' :'0'}">
+        <img src="/img/base/loading.gif">
+    </div>
+    <div class="container" :class="{active: isRequest}" v-show="isRequest">
+
+    </div>
+</div>
+<!-- 引入底部 -->
+<template th:replace="components/footer"></template>
+<template th:replace="components/foot-link"></template>
+<script src="https://res.wx.qq.com/connect/zh_CN/htmledition/js/wxLogin.js"></script>
+<script charset="utf-8" type="text/javascript" th:src="@{/js/common/serviceapi/pay.service.js(v=${version})}"></script>
+<script charset="utf-8" type="text/javascript" th:src="@{/lib/qrcode.min.js(v=${version})}"></script>
+<script charset="utf-8" type="text/javascript" th:src="@{/js/pay/caimei-paymobile.js(v=${version})}"></script>
+
+</body>
+</html>