login.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. $(document).ready(function() {
  2. initData();
  3. initSelectClick();
  4. });
  5. function initSelectClick() {
  6. $("#moduleSelect").click();
  7. if(isQuickLogin) {
  8. $("#moduleSelect").next("ul").on("click", "a", function() {
  9. setTimeout(() => {
  10. $("#submitBtn").click();
  11. }, 200);
  12. })
  13. }
  14. }
  15. /**
  16. * 解密字符串
  17. */
  18. function uncompileStr(str) {
  19. str = unescape(str);
  20. var c = String.fromCharCode(str.charCodeAt(0) - str.length);
  21. for (var i = 1; i < str.length; i++) {
  22. c += String.fromCharCode(str.charCodeAt(i) - c.charCodeAt(i - 1));
  23. }
  24. return c;
  25. }
  26. // 是否快速登录标记,为真代表是,反之不是
  27. var isQuickLogin = false;
  28. function initData() {
  29. var y = layui.data("95187");
  30. var l = layui.data("35624");
  31. var x = layui.data("13691");
  32. var t = layui.data("05926");
  33. if (y.y && l.l && x.x && t.t) {
  34. $("#iconImg").attr("src", uncompileStr(t.t));
  35. $("#iconImg").onload = loadIconBorder();
  36. $("#iconName").html("欢迎,&nbsp;" + uncompileStr(x.x));
  37. $("#inputUser").val(uncompileStr(y.y));
  38. $("#inputPassword").remove();
  39. $("#inputToken").val(uncompileStr(l.l));
  40. $("#icon").show();
  41. $("div[group='input']").hide();
  42. $("button[type='submit']").css("margin-top", "0px");
  43. isQuickLogin = true;
  44. } else {
  45. $("div[group='input']").removeClass("displayHide");
  46. }
  47. $("#login-form").fadeIn(200);
  48. }
  49. function loadIconBorder() {
  50. var randomNum = Math.floor(Math.random() * 83);
  51. if (randomNum > 10 && randomNum.toString().startsWith("4")) {
  52. randomNum = "A" + randomNum.toString().substring(1);
  53. }
  54. $("#iconIndex").val(randomNum);
  55. var border = "bili_" + randomNum + ".png";
  56. $("#icon-border").attr("style", "background-image: url(/dev/images/icon-border/" + border + ");");
  57. $("#icon-border")[0].onclick = exit;
  58. }
  59. function exit() {
  60. layui.data("95187", null);
  61. layui.data("35624", null);
  62. layui.data("13691", null);
  63. layui.data("05926", null);
  64. location.href = "/dev";
  65. }