login.html 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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: 300px; border-radius: 0px; transition: all 0.2s; margin-top: 30px;}
  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; width: 380px;}
  29. .login-center-input{width: 260px;}
  30. .login-box .remember-box{color: #888; margin-bottom: 10px;}
  31. .remember-box label{cursor: pointer; }
  32. .remember-box [type=checkbox]{position: relative; top: 2px; margin-right: 2px;}
  33. .remember-box .remark-text{float: right; position: relative; top: 1px; margin-right: 5px;}
  34. </style>
  35. </head>
  36. <body>
  37. <div id="particles-js">
  38. <div class="login-box">
  39. <div class="login">
  40. <div class="login-top">
  41. <img src="" class="logo-img" alt="">
  42. <span class="page-title">登录</span>
  43. </div>
  44. <div class="login-center clearfix">
  45. <div class="login-center-img"><img src="sa-frame/login/name.png" /></div>
  46. <div class="login-center-input">
  47. <input type="text" name="key" value="" placeholder="请输入账号" />
  48. <div class="login-center-input-text">账号</div>
  49. </div>
  50. </div>
  51. <div class="login-center clearfix">
  52. <div class="login-center-img"><img src="sa-frame/login/password.png" /></div>
  53. <div class="login-center-input">
  54. <input type="password" name="password" value="" placeholder="请输入密码" />
  55. <div class="login-center-input-text">密码</div>
  56. </div>
  57. </div>
  58. <div class="login-center clearfix remember-box">
  59. <label><input type="checkbox" id="remember"> 记住我</label>
  60. <!-- <span class="remark-text">测试:sa/123456</span> -->
  61. </div>
  62. <div class="login-button">登录</div>
  63. </div>
  64. </div>
  65. <div class="sk-rotating-plane"></div>
  66. </div>
  67. <!-- scripts -->
  68. <script src="sa-frame/login/particles.min.js"></script>
  69. <script src="sa-frame/login/app.js"></script>
  70. <script src="https://unpkg.com/jquery@3.4.1/dist/jquery.min.js"></script>
  71. <script src="https://www.layuicdn.com/layer-v3.1.1/layer.js"></script>
  72. <script src="static/sa.js"></script>
  73. <script type="text/javascript">
  74. // 你所有要改的代码全在这里 ↓↓↓↓↓
  75. // 所有参考属性
  76. var page_title = '智慧防疫 后台 - 登录'; // 页面标题
  77. var key = ''; // 默认的账号
  78. var password = ''; // 默认的password
  79. var logo = 'sa-frame/admin-logo.png'; // logo地址,为空字符串则不显示
  80. // 点击登录按钮
  81. document.querySelector(".login-button").onclick = function() {
  82. // 1、取值
  83. var p = {
  84. key: $('[name=key]').val(),
  85. password: $('[name=password]').val(),
  86. remember: $('#remember').is(':checked')
  87. }
  88. // 2、判断
  89. if(p.key == '' || p.password == ''){
  90. return layer.msg('请输入账号密码');
  91. }
  92. // 3、请求后台
  93. sa.ajax('/AccAdmin/doLogin', p, function(res){
  94. // 写入token
  95. if(res.data.tokenInfo) {
  96. if(p.remember) {
  97. sessionStorage.removeItem('satoken');
  98. localStorage.setItem('satoken', res.data.tokenInfo.tokenValue);
  99. } else {
  100. localStorage.removeItem('satoken');
  101. sessionStorage.setItem('satoken', res.data.tokenInfo.tokenValue);
  102. }
  103. }
  104. // 写入账号
  105. sa.$sys.setCurrUser(res.data.admin);
  106. // 写入权限码
  107. sa.setAuth(res.data.perList);
  108. // 写入全局配置
  109. sa.$sys.setAppCfg(res.data.appCfg);
  110. // 打个招呼,进入 index.html
  111. sa.msg('登录成功,欢迎你:' + p.key);
  112. setTimeout(function () {
  113. if(parent == window){
  114. location.href = "index.html";
  115. }else{
  116. sa.closeCurrIframe();
  117. parent.location.reload();
  118. }
  119. }, 500);
  120. })
  121. }
  122. // 你所有要改的代码全在这里 ↑↑↑↑↑
  123. </script>
  124. <script type="text/javascript">
  125. // 替换属性
  126. $('.page-title').html(page_title);
  127. $('title').html(page_title);
  128. $('[name=key]').val(key);
  129. $('[name=password]').val(password);
  130. if(logo != null && logo != '') {
  131. $('.logo-img').attr('src', logo);
  132. $('.logo-img').show();
  133. }
  134. // 绑定回车事件
  135. $('[name=password]').bind('keypress', function(event){
  136. if(event.keyCode == "13") {
  137. $('.login-button').click();
  138. }
  139. });
  140. // 去掉透明
  141. setTimeout(function() {
  142. // document.querySelector('.login').style.backgroundColor = 'rgba(256,256,256,1)';
  143. document.querySelector('.login').style.opacity = '1';
  144. }, 0)
  145. console.log('本页面参考于jq22,原作者:http://www.jq22.com/jquery-info20074');
  146. </script>
  147. </body>
  148. </html>