login.html 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603
  1. <!DOCTYPE html>
  2. <html lang="en" xmlns:th="http://www.thymeleaf.org">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>后台管理-登陆</title>
  6. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  7. <meta http-equiv="Access-Control-Allow-Origin" content="*">
  8. <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  9. <meta name="apple-mobile-web-app-status-bar-style" content="black">
  10. <meta name="apple-mobile-web-app-capable" content="yes">
  11. <meta name="format-detection" content="telephone=no">
  12. <link rel="icon" th:href="@{/images/logo.ico}">
  13. <link rel="stylesheet" th:href="@{/lib/layui/css/layui.css}" media="all">
  14. <style th:inline="text">
  15. .main-body {
  16. position: absolute;
  17. top: 50%;
  18. left: 50%;
  19. transform: translate(-50%, -50%);
  20. width: 350px;
  21. background: #fff;
  22. border-radius: 20px;
  23. box-shadow: 0 5px 10px rgba(0,0,0,0.2);
  24. -webkit-transform: translate(-50%, -50%);
  25. -moz-transform: translate(-50%, -50%);
  26. -ms-transform: translate(-50%, -50%);
  27. -o-transform: translate(-50%, -50%);
  28. overflow: hidden;
  29. }
  30. .login-main .login-bottom .center .item input {
  31. display: inline-block;
  32. width: 227px;
  33. height: 22px;
  34. padding: 0;
  35. position: absolute;
  36. border: 0;
  37. outline: 0;
  38. font-size: 14px;
  39. letter-spacing: 0;
  40. }
  41. .login-main .login-bottom .center .item .icon-1 {
  42. background: url("/images/icon-login.png") no-repeat 1px 0;
  43. }
  44. .login-main .login-bottom .center .item .icon-2 {
  45. background: url("/images/icon-login.png") no-repeat -54px 0;
  46. }
  47. .login-main .login-bottom .center .item .icon-3 {
  48. background: url("/images/icon-login.png") no-repeat -106px 0;
  49. }
  50. .login-main .login-bottom .center .item .icon-4 {
  51. background: url("/images/icon-login.png") no-repeat 0 -43px;
  52. position: absolute;
  53. right: -10px;
  54. cursor: pointer;
  55. }
  56. .login-main .login-bottom .center .item .icon-5 {
  57. background: url("/images/icon-login.png") no-repeat -55px -43px;
  58. }
  59. .login-main .login-bottom .center .item .icon-6 {
  60. background: url("/images/icon-login.png") no-repeat 0 -93px;
  61. position: absolute;
  62. right: -10px;
  63. margin-top: 8px;
  64. cursor: pointer;
  65. }
  66. .login-main .login-bottom .tip .icon-nocheck {
  67. display: inline-block;
  68. width: 10px;
  69. height: 10px;
  70. border-radius: 2px;
  71. border: solid 1px #9abcda;
  72. position: relative;
  73. top: 2px;
  74. margin: 1px 8px 1px 1px;
  75. cursor: pointer;
  76. }
  77. .login-main .login-bottom .tip .icon-check {
  78. margin: 0 7px 0 0;
  79. width: 14px;
  80. height: 14px;
  81. border: none;
  82. background: url("/images/icon-login.png") no-repeat -111px -48px;
  83. }
  84. .login-main .login-bottom .center .item .icon {
  85. display: inline-block;
  86. width: 33px;
  87. height: 22px;
  88. }
  89. .login-main .login-bottom .center .item {
  90. width: 260px;
  91. height: 35px;
  92. border-bottom: 1px solid #dae1e6;
  93. margin-bottom: 35px;
  94. }
  95. .login-main {
  96. width: 350px;
  97. height: 500px;
  98. position: relative;
  99. float: left;
  100. }
  101. .login-main .login-top {
  102. height: 150px;
  103. margin-top: 40px;
  104. border-radius: 12px 12px 0 0;
  105. font-family: SourceHanSansCN-Regular;
  106. font-size: 30px;
  107. font-weight: 400;
  108. font-stretch: normal;
  109. letter-spacing: 0;
  110. color: #fff;
  111. line-height: 30px;
  112. text-align: center;
  113. overflow: hidden;
  114. -webkit-transform: rotate(0);
  115. -moz-transform: rotate(0);
  116. -ms-transform: rotate(0);
  117. -o-transform: rotate(0);
  118. transform: rotate(0);
  119. }
  120. .login-main .login-top .avatar{
  121. width: 100px;
  122. height: 100px;
  123. border-radius: 50%;
  124. overflow: hidden;
  125. margin: 0 auto 20px;
  126. display: flex;
  127. justify-content: center;
  128. align-items: center;
  129. }
  130. .login-main .login-top .avatar img{
  131. width: 90%;
  132. height: 90%;
  133. object-fit: cover;
  134. }
  135. .login-main .login-top h2{
  136. font-size: 23px;
  137. font-weight: 700;
  138. color: #2980b9;
  139. margin-bottom: 20px;
  140. }
  141. .login-main .login-top .bg1 {
  142. display: inline-block;
  143. width: 74px;
  144. height: 74px;
  145. background: #fff;
  146. opacity: .1;
  147. border-radius: 0 74px 0 0;
  148. position: absolute;
  149. left: 0;
  150. top: 43px;
  151. }
  152. .login-main .login-top .bg2 {
  153. display: inline-block;
  154. width: 94px;
  155. height: 94px;
  156. background: #fff;
  157. opacity: .1;
  158. border-radius: 50%;
  159. position: absolute;
  160. right: -16px;
  161. top: -16px;
  162. }
  163. .login-main .login-bottom {
  164. width: 340px;
  165. background: #fff;
  166. border-radius: 0 0 12px 12px;
  167. padding-bottom: 53px;
  168. }
  169. .login-main .login-bottom .center {
  170. width: 260px;
  171. margin: 0 auto;
  172. padding-top: 40px;
  173. padding-bottom: 15px;
  174. position: relative;
  175. }
  176. .login-main .login-bottom .tip {
  177. clear: both;
  178. height: 16px;
  179. line-height: 16px;
  180. width: 260px;
  181. margin: 0 auto;
  182. }
  183. body {
  184. background: url("/images/logo-v1.png") 0% 0% / cover no-repeat;
  185. position: static;
  186. font-size: 12px;
  187. }
  188. input::-webkit-input-placeholder {
  189. color: #a6aebf;
  190. }
  191. input::-moz-placeholder { /* Mozilla Firefox 19+ */
  192. color: #a6aebf;
  193. }
  194. input:-moz-placeholder { /* Mozilla Firefox 4 to 18 */
  195. color: #a6aebf;
  196. }
  197. input:-ms-input-placeholder { /* Internet Explorer 10-11 */
  198. color: #a6aebf;
  199. }
  200. input:-webkit-autofill { /* 取消Chrome记住密码的背景颜色 */
  201. -webkit-box-shadow: 0 0 0 1000px white inset !important;
  202. }
  203. html {
  204. height: 100%;
  205. }
  206. .login-main .login-bottom .tip {
  207. clear: both;
  208. height: 16px;
  209. line-height: 16px;
  210. width: 260px;
  211. margin: 0 auto;
  212. }
  213. .login-main .login-bottom .tip .login-tip {
  214. font-family: MicrosoftYaHei;
  215. font-size: 12px;
  216. font-weight: 400;
  217. font-stretch: normal;
  218. letter-spacing: 0;
  219. color: #9abcda;
  220. cursor: pointer;
  221. margin-top: 5px;
  222. }
  223. .login-main .login-bottom .tip .forget-password {
  224. font-stretch: normal;
  225. letter-spacing: 0;
  226. color: #2980b9;
  227. text-decoration: none;
  228. position: absolute;
  229. right: 62px;
  230. }
  231. .login-main .login-bottom .login-btn {
  232. width: 260px;
  233. height: 40px;
  234. background-color: #2980b9;
  235. border-radius: 16px;
  236. margin: 24px auto 0;
  237. text-align: center;
  238. line-height: 40px;
  239. color: #fff;
  240. font-size: 14px;
  241. letter-spacing: 0;
  242. cursor: pointer;
  243. border: none;
  244. }
  245. .login-main .login-bottom .center .item .validateImg {
  246. position: absolute;
  247. right: 1px;
  248. cursor: pointer;
  249. height: 36px;
  250. border: 1px solid #fff;
  251. }
  252. .footer {
  253. left: 0;
  254. bottom: 0;
  255. color: #fff;
  256. width: 100%;
  257. position: absolute;
  258. text-align: center;
  259. line-height: 30px;
  260. padding-bottom: 10px;
  261. text-shadow: #000 0.1em 0.1em 0.1em;
  262. font-size: 14px;
  263. }
  264. .padding-5 {
  265. padding: 5px !important;
  266. }
  267. .footer a, .footer span {
  268. color: #fff;
  269. }
  270. .logo{
  271. position: absolute;
  272. top: 50px;
  273. left: 50px;
  274. display: flex;
  275. align-items: center;
  276. }
  277. .logo img{
  278. width: 32px;
  279. height: 32px;
  280. margin-right: 10px;
  281. }
  282. .logo h2{
  283. font-size: 24px;
  284. font-weight: 700;
  285. color: #333;
  286. }
  287. @media screen and (max-width: 428px) {
  288. .login-main {
  289. width: 360px !important;
  290. }
  291. .login-main .login-top {
  292. width: 360px !important;
  293. }
  294. .login-main .login-bottom {
  295. width: 360px !important;
  296. }
  297. }
  298. </style>
  299. </head>
  300. <body>
  301. <div class="logo">
  302. <img src="/images/logo.png" alt="User Icon">
  303. <h2>科研管控平台</h2>
  304. </div>
  305. <div class="main-body">
  306. <div class="login-main">
  307. <div class="login-top">
  308. <div class="avatar">
  309. <img src="/images/logo.png" alt="Avatar">
  310. </div>
  311. <h2>Welcome back</h2>
  312. </div>
  313. <form class="layui-form login-bottom">
  314. <div class="center">
  315. <div class="item">
  316. <span class="icon icon-2"></span>
  317. <input type="text" name="username" id="username" lay-verify="required" placeholder="请输入登录账号"
  318. maxlength="24" autocomplete="current-password" />
  319. </div>
  320. <div class="item">
  321. <span class="icon icon-3"></span>
  322. <input type="password" name="password" id="password" lay-verify="required" placeholder="请输入密码"
  323. maxlength="20" autocomplete="current-password">
  324. <span class="bind-password icon icon-4"></span>
  325. </div>
  326. </div>
  327. <div class="tip">
  328. <span class="icon-nocheck"></span>
  329. <span class="login-tip">记住密码</span>
  330. <!--<a href="javascript:" class="forget-password">忘记密码?</a>-->
  331. </div>
  332. <div class="layui-form-item" style="text-align:center; width:100%;height:100%;margin:0px;">
  333. <button id="btn_login" class="login-btn" lay-submit lay-filter="login">
  334. <span id="btn_msg">登 录</span>&nbsp;
  335. <i id="btn_load" class="layui-icon layui-anim layui-anim-rotate layui-anim-loop"
  336. style="display: none">&#xe63d;</i>
  337. </button>
  338. </div>
  339. </form>
  340. </div>
  341. </div>
  342. <div class="footer">
  343. Copyright© 2023 <span class="padding-5">|</span>
  344. </div>
  345. <script>
  346. const inputs = [
  347. document.getElementById('username'),
  348. document.getElementById('password')
  349. ]
  350. inputs.forEach(input =>{
  351. input.addEventListener('input',function () {
  352. this.value = this.value.replace(/\s+/g,'');
  353. })
  354. })
  355. </script>
  356. <script th:src="@{/lib/jquery-3.4.1/jquery-3.4.1.min.js}" charset="utf-8"></script>
  357. <script th:src="@{/lib/layui/layui.js}" charset="utf-8"></script>
  358. <script th:src="@{/lib/md5/md5.min.js}" charset="utf-8"></script>
  359. <script th:src="@{/js/lay-config.js}" charset="utf-8"></script>
  360. <script type="text/javascript" th:inline="javascript">
  361. AjaxUtil.ctx = /*[[@{/}]]*/'';
  362. // 在页面加载完毕后调用拦截器函数
  363. layui.use(['form', 'layNotify', 'layer'], function () {
  364. var form = layui.form,
  365. layNotify = layui.layNotify;
  366. var layer = layui.layer;
  367. var loginStatus = [[${loginStatus}]];
  368. if (loginStatus === 'redirect') {
  369. Message.error("会话已过期,请重新登录!");/*
  370. layNotify.notice({
  371. title: "登录提示",
  372. type: "warning",
  373. message: "会话已过期,请重新登录"
  374. });*/
  375. return false;
  376. }
  377. // 登录过期的时候,跳出ifram框架
  378. if (top.location != self.location) {
  379. top.location = self.location;
  380. }
  381. // 切换密码显示和隐藏
  382. $('.bind-password').on('click', function () {
  383. if ($(this).hasClass('icon-5')) {
  384. $(this).removeClass('icon-5');
  385. $("input[name='password']").attr('type', 'password');
  386. } else {
  387. $(this).addClass('icon-5');
  388. $("input[name='password']").attr('type', 'text');
  389. }
  390. });
  391. // 切换记住密码的选择
  392. $('.icon-nocheck').on('click', function () {
  393. if ($(this).hasClass('icon-check')) {
  394. $(this).removeClass('icon-check');
  395. } else {
  396. $(this).addClass('icon-check');
  397. }
  398. });
  399. if (localStorage.getItem("wowosign") == "rememberMe") {
  400. console.log("设置成勾选");
  401. // 设置成勾选
  402. $('.icon-nocheck').addClass('icon-check');
  403. }
  404. if (localStorage.getItem("username") && localStorage.getItem("password")) {
  405. console.log("浏览器记住,自动填入账号密码," + localStorage.getItem("username"))
  406. $("#username").val(localStorage.getItem("username"));
  407. $("#password").val(localStorage.getItem("password"));
  408. } else {
  409. console.log("不存在localStorage");
  410. }
  411. // // 验证码初始化
  412. // let kaptcha_key = [[${kaptcha_key}]];
  413. // getKaptcha(kaptcha_key);
  414. // 验证码点击事件
  415. // $("#ver_btn").click(function () {
  416. // let kaptcha_key = [[${kaptcha_key}]];
  417. // getKaptcha(kaptcha_key);
  418. // });
  419. // 进行登录操作
  420. form.on('submit(login)', function (data) {
  421. let formdata = data.field;
  422. if (formdata.username == '') {
  423. layer.msg('用户名不能为空');
  424. return false;
  425. }
  426. if (formdata.password == '') {
  427. layer.msg('密码不能为空');
  428. return false;
  429. }
  430. // if (formdata.captcha == '') {
  431. // layer.msg('验证码不能为空');
  432. // return false;
  433. // }
  434. // 未选中时,formdata.rememberMe的值为undefined
  435. if ($('.icon-nocheck').hasClass('icon-check')) {
  436. localStorage.setItem("username", formdata.username, "7d");
  437. localStorage.setItem("password", formdata.password, "7d");
  438. // localStorage.setItem("wowosign", "rememberMe", "7d");
  439. } else {
  440. localStorage.removeItem("username");
  441. localStorage.removeItem("password");
  442. // localStorage.removeItem("wowosign");
  443. }
  444. // 添加一个条件判断
  445. let password = md5.MD5(formdata.password); // 加密输入的密码
  446. // 设置按钮为登陆中,此时禁止点击
  447. logining();
  448. AjaxUtil.post({
  449. contentType: "application/x-www-form-urlencoded", // 默认就是这个
  450. url: AjaxUtil.ctx + "home/doLogin",
  451. data: {
  452. "username": formdata.username,
  453. "password": password
  454. },
  455. success: function (res) {
  456. console.log(res);
  457. if (res.code === 0) {
  458. layNotify.notice({
  459. title: "登录提示",
  460. type: "success",
  461. message: res.message
  462. });
  463. setTimeout(function () {
  464. window.location.href = AjaxUtil.ctx + "home/index";
  465. }, 1500);
  466. } else {
  467. loginend();
  468. layNotify.notice({
  469. title: "登录提示",
  470. type: "warning",
  471. message: res.message
  472. });
  473. // document.getElementById("ver_btn").click();
  474. // 验证码刷新
  475. /* document.getElementById("captcha").value = '';*/
  476. document.getElementById("password").value = '';
  477. console.log(res.message);
  478. // 阻止后续操作
  479. }
  480. },
  481. error: function (error) {
  482. loginend();
  483. redirection();
  484. layNotify.notice({
  485. title: "登录提示",
  486. type: "error",
  487. message: "请求失败,请联系系统管理员!"
  488. });
  489. }
  490. });
  491. return false; //阻止表单跳转,layui默认是form提交,阻止掉
  492. });
  493. // 键盘回车登录
  494. $('body').keydown(function () {
  495. if (13 == event.keyCode) {
  496. $('#btn_login').trigger('click');
  497. }
  498. });
  499. function redirection() {
  500. window.location.replace("http://10.208.114.107:8081/home/index")
  501. }
  502. // 登陆中
  503. function logining() {
  504. document.getElementById("btn_login").setAttribute("disabled", true);//设置不可点击
  505. document.getElementById("btn_login").style.backgroundColor = '#9abcda';
  506. document.getElementById("btn_msg").innerText = '登 录 中';
  507. document.getElementById("btn_load").style.display = "inline-block";
  508. }
  509. // 登陆后
  510. function loginend() {
  511. document.getElementById("btn_login").removeAttribute("disabled");//去掉不可点击
  512. document.getElementById("btn_login").style.backgroundColor = '#1E9FFF';
  513. document.getElementById("btn_msg").innerText = '登 录';
  514. document.getElementById("btn_load").style.display = "none";
  515. }
  516. // function getKaptcha(kaptcha_key) {
  517. // AjaxUtil.get({
  518. // url: AjaxUtil.ctx + "kaptcha/getImage?kaptcha_key=" + kaptcha_key,
  519. // dataType: "text",
  520. // success: function (result) {
  521. // $("#ver_btn").attr("src", result);
  522. // },
  523. // error: function (error) {
  524. // layNotify.notice({
  525. // title: "提示",
  526. // type: "warning",
  527. // message: "获取验证码错误,请联系系统管理员!"
  528. // });
  529. // }
  530. // });
  531. // }
  532. });
  533. </script>
  534. </body>
  535. </html>