social-login.html 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"/>
  6. <title>社交登陆测试页</title>
  7. <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.js"></script>
  8. </head>
  9. <body>
  10. <div>点击如下按钮,发起登陆的测试</div>
  11. <div>
  12. <button id="wx_pub">微信公众号</button>
  13. </div>
  14. </body>
  15. <script>
  16. // let server = 'http://127.0.0.1:28080';
  17. let server = 'http://192.168.1.2:28080';
  18. // 微信公众号
  19. $( "#wx_pub").on( "click", function() {
  20. // 获得授权链接
  21. $.ajax({
  22. url: server + "/api/social-auth-redirect?type=31&redirectUri=" +
  23. encodeURIComponent(server + '/static/social-login2.html'), //重定向地址
  24. method: 'GET',
  25. success: function( result ) {
  26. if (result.code !== 0) {
  27. alert('获得授权链接失败,原因:' + result.msg)
  28. return;
  29. }
  30. // 跳转重定向
  31. document.location.href = result.data;
  32. }
  33. })
  34. });
  35. </script>
  36. </html>