login.html 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  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. }
  35. .login-top {
  36. margin-top: 0px;
  37. margin-bottom: 30px;
  38. }
  39. .lg {
  40. background: #F2F4F9;
  41. border-radius: 8px;
  42. padding: 15px;
  43. margin-bottom: 17px;
  44. position: relative;
  45. }
  46. .logo-img {
  47. width: 50px;
  48. height: 50px;
  49. vertical-align: middle;
  50. position: relative;
  51. top: -3px;
  52. border-radius: 50%;
  53. margin-left: -10px;
  54. margin-right: 10px;
  55. }
  56. .logo-img {
  57. display: none;
  58. }
  59. .login-button {
  60. width: 300px;
  61. border-radius: 0px;
  62. transition: all 0.2s;
  63. margin-top: 30px;
  64. }
  65. .login-button:hover {
  66. background-color: #0E80eF;
  67. }
  68. .page-title {
  69. font-size: 22px;
  70. }
  71. .sk-rotating-plane {}
  72. /* 动画相关 */
  73. /* .login{background-color: rgba(0,0,0,0); } */
  74. .login {
  75. opacity: 0;
  76. width: 380px;
  77. }
  78. .login-center-input {
  79. width: 260px;
  80. }
  81. .login-box .remember-box {
  82. color: #888;
  83. margin-bottom: 10px;
  84. }
  85. .remember-box label {
  86. cursor: pointer;
  87. }
  88. .remember-box [type=checkbox] {
  89. position: relative;
  90. top: 2px;
  91. margin-right: 2px;
  92. }
  93. .remember-box .remark-text {
  94. float: right;
  95. position: relative;
  96. top: 1px;
  97. margin-right: 5px;
  98. }
  99. </style>
  100. </head>
  101. <body>
  102. <div id="particles-js">
  103. <div class="login-box">
  104. <div class="login">
  105. <div class="login-top">
  106. <!-- <img src="" class="logo-img" alt=""> -->
  107. <span class="page-title">登录</span>
  108. </div>
  109. <div class="login-center clearfix">
  110. <div class="login-center-img"><img src="sa-frame/login/name.png" /></div>
  111. <div class="login-center-input">
  112. <input type="text" name="key" value="" placeholder="请输入账号" />
  113. <div class="login-center-input-text">账号</div>
  114. </div>
  115. </div>
  116. <div class="login-center clearfix">
  117. <div class="login-center-img"><img src="sa-frame/login/password.png" /></div>
  118. <div class="login-center-input">
  119. <input type="password" name="password" value="" placeholder="请输入密码" />
  120. <div class="login-center-input-text">密码</div>
  121. </div>
  122. </div>
  123. <div class="login-center clearfix">
  124. <div class="login-center-img"><img src="sa-frame/login/code.png" class="icon" /></div>
  125. <div class="login-center-input" style="display: flex;">
  126. <input type="text" name="verCode" value="" placeholder="请输入验证码" />
  127. <img id="captcha" style="width: 100px;"/>
  128. </div>
  129. </div>
  130. <div class="login-center clearfix remember-box">
  131. <label><input type="checkbox" id="remember"> 记住我</label>
  132. <!-- <span class="remark-text">测试:sa/123456</span> -->
  133. </div>
  134. <span style="color: red;margin-left: 70px;" id="notice"></span>
  135. <div class="login-button">登录</div>
  136. </div>
  137. </div>
  138. <div class="sk-rotating-plane"></div>
  139. <div style="text-align: center;bottom: 0;background-color: white;padding: 5px;position: fixed;width: 100%;">
  140. <a href="https://beian.miit.gov.cn/" target="_blank">
  141. 备案号:桂ICP备09007209号-1
  142. <img src="static/img/gongan.png" style="width: 15px;height: 15px;margin-left: 10px;">桂公网安备
  143. 45068102000040号</a>
  144. </div>
  145. </div>
  146. <!-- scripts -->
  147. <script src="sa-frame/login/particles.min.js"></script>
  148. <script src="sa-frame/login/app.js"></script>
  149. <script src="static/kj/jquery.min.js"></script>
  150. <script src="static/kj/layer/layer.js"></script>
  151. <script src="static/sa.js"></script>
  152. <script src="static/kj/jsencrypt.js"></script>
  153. <script type="text/javascript">
  154. // 你所有要改的代码全在这里 ↓↓↓↓↓
  155. // 所有参考属性
  156. var page_title = '智慧来访系统'; // 页面标题
  157. var key = ''; // 默认的账号
  158. var password = ''; // 默认的password
  159. var codeKey = '';
  160. var pKey = '';
  161. var logo = 'sa-frame/admin-logo.png'; // logo地址,为空字符串则不显示
  162. function getCaptcha() {
  163. sa.ajaxNoLoading('/AccAdmin/captcha', {}, function(res) {
  164. let data = res.data;
  165. $('#captcha').attr('src', data.image);
  166. codeKey = data.key;
  167. pKey = data.pKey;
  168. })
  169. }
  170. $(function() {
  171. $('#notice').html('')
  172. getCaptcha();
  173. });
  174. $('#captcha').click(function() {
  175. getCaptcha()
  176. })
  177. // 点击登录按钮
  178. document.querySelector(".login-button").onclick = function() {
  179. var encrypt = new JSEncrypt();
  180. encrypt.setPublicKey(pKey);
  181. // 1、取值
  182. var p = {
  183. key: $('[name=key]').val(),
  184. password: $('[name=password]').val(),
  185. verCode: $('[name=verCode]').val(),
  186. code: codeKey
  187. }
  188. // 2、判断
  189. if (p.key == '' || p.password == '') {
  190. return layer.msg('请输入账号密码');
  191. }
  192. if (p.verCode == '') {
  193. return layer.msg('请输入验证码');
  194. }
  195. let res = encrypt.encrypt(p.password);
  196. let s = encrypt.decrypt(res);
  197. p.password = res;
  198. // 3、请求后台
  199. $.ajax({
  200. url: sa.cfg.api_url + '/AccAdmin/doLogin',
  201. data: p,
  202. method: 'post',
  203. success: function(res) {
  204. // 写入token
  205. if (res.data.tokenInfo) {
  206. if (p.remember) {
  207. sessionStorage.removeItem('satoken');
  208. localStorage.setItem('satoken', res.data.tokenInfo.tokenValue);
  209. } else {
  210. localStorage.removeItem('satoken');
  211. sessionStorage.setItem('satoken', res.data.tokenInfo.tokenValue);
  212. }
  213. }
  214. // 写入账号
  215. sa.$sys.setCurrUser(res.data.admin);
  216. // 写入权限码
  217. sa.setAuth(res.data.perList);
  218. sa.setDepartmentId(res.data.admin.departmentId);
  219. // 写入全局配置
  220. sa.$sys.setAppCfg(res.data.appCfg);
  221. // 打个招呼,进入 index.html
  222. sa.msg('登录成功,欢迎你:' + p.key);
  223. setTimeout(function() {
  224. if (parent == window) {
  225. location.href = "index.html";
  226. } else {
  227. sa.closeCurrIframe();
  228. parent.location.reload();
  229. }
  230. }, 500);
  231. }
  232. })
  233. }
  234. // 你所有要改的代码全在这里 ↑↑↑↑↑
  235. </script>
  236. <script type="text/javascript">
  237. // 替换属性
  238. $('.page-title').html(page_title);
  239. $('title').html(page_title);
  240. $('[name=key]').val(key);
  241. $('[name=password]').val(password);
  242. if (logo != null && logo != '') {
  243. $('.logo-img').attr('src', logo);
  244. $('.logo-img').show();
  245. }
  246. // 绑定回车事件
  247. $('[name=password]').bind('keypress', function(event) {
  248. if (event.keyCode == "13") {
  249. $('.login-button').click();
  250. }
  251. });
  252. // 去掉透明
  253. setTimeout(function() {
  254. // document.querySelector('.login').style.backgroundColor = 'rgba(256,256,256,1)';
  255. document.querySelector('.login').style.opacity = '1';
  256. }, 0)
  257. </script>
  258. </body>
  259. </html>