login.html 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <!DOCTYPE html>
  2. <html lang="zh">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>登录</title>
  6. <meta name="description" content="particles.js is a lightweight JavaScript library for creating particles.">
  7. <meta name="author" content="Vincent Garreau" />
  8. <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
  9. <link rel="stylesheet" media="screen" href="sa-frame/login/style.css">
  10. <link rel="stylesheet" href="static/sa.css">
  11. <style type="text/css">
  12. /* 背景图片 */
  13. #particles-js{
  14. background-image: url(sa-frame/login/bg.jpg);
  15. }
  16. /* 样式调整 */
  17. .login-box{display: flex; justify-content: center; align-items: center; position: fixed; width: inherit; height: 100%; pointer-events: none;}
  18. .login{height: auto; padding: 50px 50px; position: static; margin: 0 auto !important; pointer-events: all; border-radius: 0px;}
  19. .login-top{margin-top: 0px; margin-bottom: 30px;}
  20. .logo-img{width: 50px; height: 50px; vertical-align: middle; position: relative; top: -3px; border-radius: 50%; margin-left: -10px; margin-right: 10px;}
  21. .logo-img{display: none;}
  22. .login-button{width: 270px; border-radius: 0px; transition: all 0.2s;}
  23. .login-button:hover{background-color: #0E80eF;}
  24. /* .page-title{line-height: 50px;} */
  25. .sk-rotating-plane{}
  26. /* 动画相关 */
  27. /* .login{background-color: rgba(0,0,0,0); } */
  28. .login{opacity: 0;}
  29. </style>
  30. </head>
  31. <body>
  32. <div id="particles-js">
  33. <div class="login-box">
  34. <div class="login">
  35. <div class="login-top">
  36. <img src="" class="logo-img" alt="">
  37. <span class="page-title">登录</span>
  38. </div>
  39. <div class="login-center clearfix">
  40. <div class="login-center-img"><img src="sa-frame/login/name.png" /></div>
  41. <div class="login-center-input">
  42. <input type="text" name="key" value="" placeholder="请输入账号" />
  43. <div class="login-center-input-text">账号</div>
  44. </div>
  45. </div>
  46. <div class="login-center clearfix">
  47. <div class="login-center-img"><img src="sa-frame/login/password.png" /></div>
  48. <div class="login-center-input">
  49. <input type="password" name="password" value="" placeholder="请输入密码" />
  50. <div class="login-center-input-text">密码</div>
  51. </div>
  52. </div>
  53. <div class="login-button">登录</div>
  54. </div>
  55. </div>
  56. <div class="sk-rotating-plane"></div>
  57. </div>
  58. <!-- scripts -->
  59. <script src="sa-frame/login/particles.min.js"></script>
  60. <script src="sa-frame/login/app.js"></script>
  61. <script src="https://unpkg.com/jquery@3.4.1/dist/jquery.min.js"></script>
  62. <script src="https://www.layuicdn.com/layer-v3.1.1/layer.js"></script>
  63. <script src="static/sa.js"></script>
  64. <script type="text/javascript">
  65. // 你所有要改的代码全在这里 ↓↓↓↓↓
  66. // 所有参考属性
  67. var page_title = '互市管理 后台登录'; // 页面标题
  68. var key = 'sa'; // 默认的账号
  69. var password = '123456'; // 默认的password
  70. var logo = 'sa-frame/admin-logo.png'; // logo地址,为空字符串则不显示
  71. // 点击登录按钮
  72. document.querySelector(".login-button").onclick = function() {
  73. // 1、取值
  74. var p = {
  75. key: $('[name=key]').val(),
  76. password: $('[name=password]').val()
  77. }
  78. // 2、判断
  79. if(p.key == '' || p.password == ''){
  80. return layer.msg('请输入账号密码');
  81. }
  82. // 3、请求后台
  83. sa.ajax('/AccAdmin/doLogin', p, function(res){
  84. // 写入token
  85. if(res.data.tokenInfo) {
  86. localStorage.tokenName = res.data.tokenInfo.tokenName;
  87. localStorage.tokenValue = res.data.tokenInfo.tokenValue;
  88. }
  89. // 写入权限码
  90. sa.setAuth(res.data.per_list);
  91. // 打个招呼,进入 index.html
  92. sa.msg('登录成功,欢迎你:' + p.key);
  93. setTimeout(function () {
  94. if(parent == window){
  95. location.href = "index.html";
  96. }else{
  97. sa.closeCurrIframe();
  98. parent.location.reload();
  99. }
  100. }, 500);
  101. })
  102. }
  103. // 你所有要改的代码全在这里 ↑↑↑↑↑
  104. </script>
  105. <script type="text/javascript">
  106. // 替换属性
  107. $('.page-title').html(page_title);
  108. $('title').html(page_title);
  109. $('[name=key]').val(key);
  110. $('[name=password]').val(password);
  111. if(logo != null && logo != '') {
  112. $('.logo-img').attr('src', logo);
  113. $('.logo-img').show();
  114. }
  115. // 绑定回车事件
  116. $('[name=password]').bind('keypress', function(event){
  117. if(event.keyCode == "13") {
  118. $('.login-button').click();
  119. }
  120. });
  121. // 去掉透明
  122. setTimeout(function() {
  123. // document.querySelector('.login').style.backgroundColor = 'rgba(256,256,256,1)';
  124. document.querySelector('.login').style.opacity = '1';
  125. }, 0)
  126. console.log('本页面参考于jq22,原作者:http://www.jq22.com/jquery-info20074');
  127. </script>
  128. </body>
  129. </html>