login.html 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  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" autocomplete="new-password" value="" placeholder="请输入密码" /> -->
  107. <input type="password" name="password" value="" placeholder="请输入密码" />
  108. <div class="login-center-input-text">密码</div>
  109. </div>
  110. </div>
  111. <div class="login-center clearfix">
  112. <div style="display: flex;">
  113. <div>
  114. <input class="captcha-input" name="verCode" placeholder="验证码" />
  115. </div>
  116. <div class="captcha-img"><img id="captcha" />
  117. </div>
  118. </div>
  119. </div>
  120. <span style="color: red;margin-left: 70px;" id="notice"></span>
  121. <div class="login-button">登录</div>
  122. </div>
  123. </div>
  124. <div class="sk-rotating-plane"></div>
  125. <div style="display: none;" id="pKey"></div>
  126. </div>
  127. <div style="text-align: center;position: relative;bottom: 20px;background-color: #000000;padding: 5px;">
  128. <a href="https://beian.miit.gov.cn/" target="_blank" style="color: #FFFFFF;">桂ICP备12007573号-1</a>
  129. </div>
  130. <!-- scripts -->
  131. <script src="sa-frame/login/particles.min.js"></script>
  132. <script src="sa-frame/login/app.js"></script>
  133. <script src="static/kj/jquery.min.js"></script>
  134. <script src="static/kj/layer/layer.js"></script>
  135. <script src="static/sa.js"></script>
  136. <script src="static/kj/jsencrypt.js"></script>
  137. <script type="text/javascript">
  138. // 你所有要改的代码全在这里 ↓↓↓↓↓
  139. // 所有参考属性
  140. var page_title = '场站管理系统 后台登录'; // 页面标题
  141. var key = ''; // 默认的账号
  142. var password = ''; // 默认的password
  143. var codeKey = '';
  144. var logo = ''; // logo地址,为空字符串则不显示
  145. var pKey = '';
  146. function getCaptcha() {
  147. sa.ajaxNoLoading('/AccAdmin/captcha', function(res) {
  148. let data = res.data;
  149. $('#captcha').attr('src', data.image);
  150. codeKey = data.key;
  151. pKey = data.pKey;
  152. })
  153. }
  154. $(function() {
  155. $('#notice').html('')
  156. getCaptcha();
  157. });
  158. $('#captcha').click(function() {
  159. getCaptcha()
  160. })
  161. // 点击登录按钮
  162. document.querySelector(".login-button").onclick = function() {
  163. var encrypt = new JSEncrypt();
  164. encrypt.setPublicKey(pKey);
  165. // 1、取值
  166. var p = {
  167. key: $('[name=key]').val(),
  168. password: $('[name=password]').val(),
  169. verCode: $('[name=verCode]').val(),
  170. code: codeKey
  171. }
  172. // 2、判断
  173. if (p.key == '' || p.password == '') {
  174. return layer.msg('请输入账号密码');
  175. }
  176. if (p.verCode == '') {
  177. return layer.msg('请输入验证码');
  178. }
  179. let res = encrypt.encrypt(p.password);
  180. let s=encrypt.decrypt(res);
  181. p.password = res;
  182. // 3、请求后台
  183. $.ajax({
  184. url: sa.cfg.api_url + '/AccAdmin/doLogin',
  185. data: p,
  186. method: 'post',
  187. success: function(res) {
  188. let code = res.code;
  189. if (code == 200) {
  190. let data=res.data;
  191. if(!data.sameCity){
  192. sa.confirm('异地提醒:上次登录城市【'+data.lastCity+'】', function() {
  193. successLogin(res)
  194. });
  195. return;
  196. }
  197. successLogin(res)
  198. } else {
  199. $('#notice').html(res.msg);
  200. getCaptcha();
  201. }
  202. }
  203. })
  204. }
  205. function successLogin(res){
  206. $('#notice').html('')
  207. // 写入token
  208. if (res.data.tokenInfo) {
  209. localStorage.tokenName = res.data.tokenInfo.tokenName;
  210. localStorage.tokenValue = res.data.tokenInfo.tokenValue;
  211. }
  212. // 写入权限码
  213. sa.setAuth(res.data.per_list);
  214. // 打个招呼,进入 index.html
  215. sa.msg('登录成功');
  216. setTimeout(function() {
  217. if (parent == window) {
  218. location.href = "index.html";
  219. } else {
  220. sa.closeCurrIframe();
  221. parent.location.reload();
  222. }
  223. }, 500);
  224. }
  225. // 你所有要改的代码全在这里 ↑↑↑↑↑
  226. </script>
  227. <script type="text/javascript">
  228. // 替换属性
  229. $('.page-title').html(page_title);
  230. $('title').html(page_title);
  231. $('[name=key]').val(key);
  232. $('[name=password]').val(password);
  233. if (logo != null && logo != '') {
  234. $('.logo-img').attr('src', logo);
  235. $('.logo-img').show();
  236. }
  237. // 绑定回车事件
  238. $('[name=password]').bind('keypress', function(event) {
  239. if (event.keyCode == "13") {
  240. $('.login-button').click();
  241. }
  242. });
  243. // 去掉透明
  244. setTimeout(function() {
  245. // document.querySelector('.login').style.backgroundColor = 'rgba(256,256,256,1)';
  246. document.querySelector('.login').style.opacity = '1';
  247. }, 0)
  248. </script>
  249. <script type="text/javascript">
  250. </script>
  251. </body>
  252. </html>