ソースを参照

增加微信登陆的测试页

YunaiV 3 年 前
コミット
038c0b87b9

+ 3 - 1
yudao-user-server/src/main/resources/application-local.yaml

@@ -160,9 +160,11 @@ yudao:
 justauth:
   enabled: true
   type:
-    WECHAT_MP: # 微信公众平台 - 移动端H5  https://mp.weixin.qq.com/debug/cgi-bin/sandboxinfo?action=showinfo&t=sandbox/index
+    WECHAT_MP: # 微信公众平台 - 移动端 H5 https://www.yuque.com/docs/share/a795bef6-ee8a-494a-8dc4-2ef41927743b?#%20%E3%80%8A%E5%BE%AE%E4%BF%A1%E5%85%AC%E4%BC%97%E5%8F%B7%E6%B5%8B%E8%AF%95%E3%80%8B
       client-id: wxa5a05b85ac361f96
       client-secret: 247073c7cebb67f27f0e769195c2a57e
+#      client-id: wx5b23ba7a5589ecbb # TODO 芋艿:自己的测试,后续可以删除
+#      client-secret: 2a7b3b20c537e52e74afd395eb85f61f
       ignore-check-redirect-uri: true
   extend:
     enum-class: cn.iocoder.yudao.coreservice.modules.system.compent.justauth.AuthExtendSource

+ 36 - 0
yudao-user-server/src/main/resources/static/social-login.html

@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"/>
+    <title>社交登陆测试页</title>
+    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.js"></script>
+</head>
+<body>
+<div>点击如下按钮,发起登陆的测试</div>
+<div>
+    <button id="wx_pub">微信公众号</button>
+</div>
+</body>
+<script>
+    let server = 'http://127.0.0.1:28080';
+
+    // 微信公众号
+    $( "#wx_pub").on( "click", function() {
+        // 获得授权链接
+        $.ajax({
+            url: server + "/api/social-auth-redirect?type=31&redirectUri=" +
+                encodeURIComponent(server + '/api/social-login-get'),
+            method: 'GET',
+            success: function( result ) {
+                if (result.code !== 0) {
+                    alert('获得授权链接失败,原因:' + result.msg)
+                    return;
+                }
+                // 跳转重定向
+                document.location.href = result.data;
+            }
+        })
+    });
+</script>
+</html>