增加微信登陆的测试页

This commit is contained in:
YunaiV
2021-10-30 09:43:26 +08:00
parent c3aa2acddf
commit 038c0b87b9
2 changed files with 39 additions and 1 deletions

View File

@@ -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>