qq_login.html 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>QQ登录</title>
  6. </head>
  7. <body>
  8. <script>
  9. const user_id = '{$info.user_id}';
  10. const token = '{$info.token}';
  11. localStorage.setItem("user_id", user_id);
  12. localStorage.setItem("token", token);
  13. const expiresDate = new Date();
  14. expiresDate.setDate(expiresDate.getDate() + 7);
  15. const userIdCookie = "user_id=" + user_id + ";expires=" + expiresDate.toUTCString() + ";path=/";
  16. const tokenCookie = "token=" + token + ";expires=" + expiresDate.toUTCString() + ";path=/";
  17. document.cookie = userIdCookie;
  18. document.cookie = tokenCookie;
  19. function isMobileDevice() {
  20. return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
  21. }
  22. let dt = {
  23. type: 'emitter',
  24. message: {user_id: user_id, token: token},
  25. subject: 'loginRefresh',
  26. }
  27. if (window.opener) {
  28. window.opener.postMessage(JSON.stringify(dt), '*')
  29. }
  30. setTimeout(() => {
  31. if (isMobileDevice() || window.innerWidth < 500) {
  32. location.href = "/"
  33. } else {
  34. window.close()
  35. }
  36. }, 300)
  37. </script>
  38. </body>
  39. </html>