login.html 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  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"
  9. content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
  10. <link rel="stylesheet" media="screen" href="sa-frame/login/style.css">
  11. <link rel="stylesheet" href="static/sa.css">
  12. <style type="text/css">
  13. /* 背景图片 */
  14. #particles-js {
  15. background-image: url(sa-frame/login/bg.jpg);
  16. }
  17. /* 样式调整 */
  18. .login-box {
  19. display: flex;
  20. justify-content: center;
  21. align-items: center;
  22. position: fixed;
  23. width: inherit;
  24. height: 100%;
  25. pointer-events: none;
  26. }
  27. .login {
  28. height: auto;
  29. padding: 50px 50px;
  30. position: static;
  31. margin: 0 auto !important;
  32. pointer-events: all;
  33. border-radius: 0px;
  34. border-radius: 10px;
  35. }
  36. .login-top {
  37. margin-top: 0px;
  38. margin-bottom: 30px;
  39. }
  40. .logo-img {
  41. width: 50px;
  42. height: 50px;
  43. vertical-align: middle;
  44. position: relative;
  45. top: -3px;
  46. border-radius: 50%;
  47. margin-left: -10px;
  48. margin-right: 10px;
  49. }
  50. .logo-img {
  51. display: none;
  52. }
  53. .login-button {
  54. width: 270px;
  55. border-radius: 0px;
  56. transition: all 0.2s;
  57. border-radius: 10px;
  58. }
  59. .login-button:hover {
  60. background-color: #0E80eF;
  61. }
  62. /* .page-title{line-height: 50px;} */
  63. .sk-rotating-plane {}
  64. /* 动画相关 */
  65. /* .login{background-color: rgba(0,0,0,0); } */
  66. .login {
  67. opacity: 0;
  68. }
  69. .captcha-input {
  70. height: 40px;
  71. border-radius: 5px;
  72. border: 1px solid #e2e2e2;
  73. width: 110px;
  74. margin-left: 40px;
  75. position: relative;
  76. right: 10px;
  77. font-size: 14px;
  78. padding-left: 5px;
  79. }
  80. .captcha-img {
  81. height: 30px;
  82. border: 1px solid #e2e2e2;
  83. border-radius: 5px;
  84. cursor: pointer;
  85. }
  86. </style>
  87. </head>
  88. <body>
  89. <div id="particles-js">
  90. <div class="login-box">
  91. <div class="login">
  92. <div class="login-top">
  93. <img src="" class="logo-img" alt="">
  94. <span class="page-title">登录</span>
  95. </div>
  96. <div class="login-center clearfix">
  97. <div class="login-center-img"><img src="sa-frame/login/name.png" /></div>
  98. <div class="login-center-input">
  99. <input type="text" name="key" value="" placeholder="请输入账号" />
  100. <div class="login-center-input-text">账号</div>
  101. </div>
  102. </div>
  103. <div class="login-center clearfix">
  104. <div class="login-center-img"><img src="sa-frame/login/password.png" /></div>
  105. <div class="login-center-input">
  106. <input type="password" name="password" value="" placeholder="请输入密码" />
  107. <div class="login-center-input-text">密码</div>
  108. </div>
  109. </div>
  110. <div class="login-center clearfix">
  111. <div style="display: flex;">
  112. <div>
  113. <input class="captcha-input" name="verCode" placeholder="验证码" />
  114. </div>
  115. <div class="captcha-img"><img id="captcha" />
  116. </div>
  117. </div>
  118. </div>
  119. <span style="color: red;margin-left: 70px;" id="notice"></span>
  120. <div class="login-button">登录</div>
  121. </div>
  122. </div>
  123. <div class="sk-rotating-plane"></div>
  124. </div>
  125. <div style="text-align: center;position: relative;bottom: 20px;background-color: #000000;padding: 5px;">
  126. <a href="https://beian.miit.gov.cn/" target="_blank" style="color: #FFFFFF;">桂ICP备12007573号-1</a>
  127. </div>
  128. <!-- scripts -->
  129. <script src="sa-frame/login/particles.min.js"></script>
  130. <script src="sa-frame/login/app.js"></script>
  131. <script src="static/kj/jquery.min.js"></script>
  132. <script src="static/kj/layer/layer.js"></script>
  133. <script src="static/sa.js"></script>
  134. <script type="text/javascript">
  135. // 你所有要改的代码全在这里 ↓↓↓↓↓
  136. // 所有参考属性
  137. var page_title = '场站管理系统 后台登录'; // 页面标题
  138. var key = ''; // 默认的账号
  139. var password = ''; // 默认的password
  140. var codeKey = '';
  141. var logo = ''; // logo地址,为空字符串则不显示
  142. function getCaptcha() {
  143. sa.ajaxNoLoading('/AccAdmin/captcha', function(res) {
  144. let data = res.data;
  145. $('#captcha').attr('src', data.image);
  146. codeKey = data.key;
  147. })
  148. }
  149. $(function() {
  150. $('#notice').html('')
  151. getCaptcha();
  152. });
  153. $('#captcha').click(function() {
  154. getCaptcha()
  155. })
  156. // 点击登录按钮
  157. document.querySelector(".login-button").onclick = function() {
  158. // 1、取值
  159. var p = {
  160. key: $('[name=key]').val(),
  161. password: $('[name=password]').val(),
  162. verCode: $('[name=verCode]').val(),
  163. code: codeKey
  164. }
  165. // 2、判断
  166. if (p.key == '' || p.password == '') {
  167. return layer.msg('请输入账号密码');
  168. }
  169. if (p.verCode == '') {
  170. return layer.msg('请输入验证码');
  171. }
  172. // 3、请求后台
  173. $.ajax({
  174. url: sa.cfg.api_url + '/AccAdmin/doLogin',
  175. data: p,
  176. method: 'post',
  177. success: function(res) {
  178. let code = res.code;
  179. if (code == 200) {
  180. $('#notice').html('')
  181. // 写入token
  182. if (res.data.tokenInfo) {
  183. localStorage.tokenName = res.data.tokenInfo.tokenName;
  184. localStorage.tokenValue = res.data.tokenInfo.tokenValue;
  185. }
  186. // 写入权限码
  187. sa.setAuth(res.data.per_list);
  188. // 打个招呼,进入 index.html
  189. sa.msg('登录成功,欢迎你:' + p.key);
  190. setTimeout(function() {
  191. if (parent == window) {
  192. location.href = "index.html";
  193. } else {
  194. sa.closeCurrIframe();
  195. parent.location.reload();
  196. }
  197. }, 500);
  198. } else {
  199. $('#notice').html(res.msg);
  200. getCaptcha();
  201. }
  202. }
  203. })
  204. }
  205. // 你所有要改的代码全在这里 ↑↑↑↑↑
  206. </script>
  207. <script type="text/javascript">
  208. // 替换属性
  209. $('.page-title').html(page_title);
  210. $('title').html(page_title);
  211. $('[name=key]').val(key);
  212. $('[name=password]').val(password);
  213. if (logo != null && logo != '') {
  214. $('.logo-img').attr('src', logo);
  215. $('.logo-img').show();
  216. }
  217. // 绑定回车事件
  218. $('[name=password]').bind('keypress', function(event) {
  219. if (event.keyCode == "13") {
  220. $('.login-button').click();
  221. }
  222. });
  223. // 去掉透明
  224. setTimeout(function() {
  225. // document.querySelector('.login').style.backgroundColor = 'rgba(256,256,256,1)';
  226. document.querySelector('.login').style.opacity = '1';
  227. }, 0)
  228. </script>
  229. <script type="text/javascript">
  230. </script>
  231. </body>
  232. </html>