login_shuili.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8"/>
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  6. <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  7. <title>登录</title>
  8. <link rel="icon" href="assets/images/favicon.ico" type="image/x-icon"/>
  9. <link rel="shortcut icon" href="assets/images/favicon.ico" type="image/x-icon"/>
  10. <link rel="stylesheet" href="assets/libs/layui/css/layui.css"/>
  11. </head>
  12. <style>
  13. * {
  14. margin: 0px;
  15. padding: 0px;
  16. }
  17. html, body {
  18. width: 100%;
  19. height: 100%;
  20. font-size: 10px;
  21. }
  22. img {
  23. display: block;
  24. }
  25. .index {
  26. width: 100%;
  27. height: 100%;
  28. background: url("./login/img/bg_login_shuili.jpg");
  29. }
  30. video {
  31. width: 100%;
  32. height: 100%;
  33. object-fit: fill;
  34. position: fixed;
  35. z-index: 10;
  36. }
  37. .index-box {
  38. width: 100%;
  39. height: 100%;
  40. position: fixed;
  41. z-index: 20;
  42. }
  43. .logo {
  44. margin: 1rem 2rem;
  45. }
  46. .logo img {
  47. width: 26rem;
  48. }
  49. .logo-box {
  50. position: absolute;
  51. top: 50%;
  52. left: 50%;
  53. width: 70rem;
  54. height: 44rem;
  55. margin-top: -22rem;
  56. margin-left: -35rem;
  57. }
  58. .logo-box > img {
  59. width: 100%;
  60. position: absolute;
  61. }
  62. .main {
  63. width: 34.5rem;
  64. height: 41rem;
  65. position: absolute;
  66. z-index: 30;
  67. /*background: red;*/
  68. right: 1.4rem;
  69. bottom: 0px;
  70. }
  71. .title {
  72. font-size: 2rem;
  73. color: #222222;
  74. text-align: center;
  75. margin-top: 2rem;
  76. margin-bottom: 6rem;
  77. }
  78. .title span {
  79. color: #00A8FF;
  80. }
  81. .username {
  82. margin-left: 3.5rem;
  83. }
  84. .username .user-top {
  85. display: flex;
  86. font-size: 1.4rem;
  87. color: #555555;
  88. }
  89. .username .user-top img {
  90. width: 1.4rem;
  91. height: 1.6rem;
  92. margin-right: 1rem;
  93. }
  94. .username input {
  95. width: 25rem;
  96. height: 3.5rem;
  97. background: rgba(242, 242, 242, 1);
  98. border-radius: 0.4rem;
  99. border: none;
  100. font-size: 1.4rem;
  101. margin-top: 0.5rem;
  102. text-indent: 1rem;
  103. color: #555;
  104. }
  105. input::-webkit-input-placeholder {
  106. color: #999999;
  107. }
  108. .pwd {
  109. margin-top: 1.5rem;
  110. }
  111. .btn {
  112. margin-top: 4rem;
  113. margin-left: 3.5rem;
  114. overflow: hidden;
  115. }
  116. .btn-left {
  117. display: flex;
  118. align-items: center;
  119. float: left;
  120. margin-top: 1rem;
  121. }
  122. .btn-left input {
  123. width: 2rem;
  124. height: 2rem;
  125. }
  126. .btn-left span {
  127. margin-left: 0.5rem;
  128. font-size: 1.4rem;
  129. }
  130. .btn-right {
  131. float: right;
  132. margin-right: 5.8rem;
  133. }
  134. .btn-right p {
  135. width: 10rem;
  136. height: 3.5rem;
  137. background: linear-gradient(135deg, rgba(0, 168, 255, 1), rgba(26, 92, 225, 1));
  138. box-shadow: 0.1rem 0.1rem 1.6rem 0px rgba(34, 98, 225, 0.45);
  139. border-radius: 0.4rem;
  140. font-size: 1.4rem;
  141. color: #FFFFFF;
  142. text-align: center;
  143. line-height: 3.5rem;
  144. }
  145. .tip {
  146. margin-top: 4rem;
  147. text-align: center;
  148. font-size: 1.2rem;
  149. color: #999999;
  150. margin-right: 2.5rem;
  151. }
  152. </style>
  153. <body>
  154. <div class="index">
  155. <!--<video class="video_back" src="./login/img/background.mp4" type="video/mp4" muted autoplay="autoplay" loop="loop">-->
  156. <!--</video>-->
  157. <div class="index-box">
  158. <div class="logo">
  159. <img src="./login/img/logo_shuili.png" style="width: auto" alt="">
  160. </div>
  161. <form class="layui-form" lay-filter="loginForm">
  162. <div class="logo-box">
  163. <img src="./login/img/login_bg.png" alt="">
  164. <div class="main">
  165. <p class="title">
  166. 账号<span>安全登录</span>
  167. </p>
  168. <div class="username">
  169. <div class="user-top">
  170. <img src="./login/img/icon_common_user.png" alt="">
  171. <span>用户名</span>
  172. </div>
  173. <div class="bottom">
  174. <input type="text" id="username" name="username" placeholder="请输入用户名" lay-verType="tips"
  175. lay-verify="required" required>
  176. </div>
  177. </div>
  178. <div class="username pwd">
  179. <div class="user-top">
  180. <!--<img src="./login/img/icon_common_user.png" alt="">-->
  181. <i class="layui-icon layui-icon-password"></i> &nbsp;&nbsp;
  182. <span>密 &nbsp;&nbsp;&nbsp;码</span>
  183. </div>
  184. <div class="bottom">
  185. <input type="password" name="password" placeholder="请输入密码" lay-verType="tips"
  186. lay-verify="required" required>
  187. </div>
  188. </div>
  189. <div class="btn">
  190. <div class="btn-left">
  191. <input type="checkbox" name="checkbox" lay-skin="primary" title="记住密码" checked="">
  192. </div>
  193. <div class="btn-right">
  194. <p id="btn1" lay-filter="login" lay-submit>登录</p>
  195. <!-- <button lay-filter="login" id="btn1" class="layui-btn layui-btn-fluid" lay-submit>登 录</button>-->
  196. </div>
  197. </div>
  198. <!--<div class="tip">-->
  199. <!--<p>-->
  200. <!--@2019陕西云康电子信息技术有限公司-->
  201. <!--</p>-->
  202. <!--</div>-->
  203. </div>
  204. </div>
  205. </form>
  206. </div>
  207. </div>
  208. </body>
  209. <script type="text/javascript" src="assets/libs/layui/layui.js"></script>
  210. <script type="text/javascript" src="./assets/js/common.js?v=312"></script>
  211. <script>
  212. layui.use(['layer', 'form', 'uParas', 'admin'], function () {
  213. var $ = layui.jquery;
  214. var layer = layui.layer;
  215. var form = layui.form;
  216. var uParas = layui.uParas;
  217. var admin = layui.admin;
  218. /**
  219. * @Author: NanKeYang
  220. * @Description: 本地信息Cookie
  221. * @Data: 2020/1/19 11:08
  222. */
  223. var LocalInfoCookie = function () {
  224. this.localInfoKey = 'user_account';
  225. this.accountList = [];
  226. this.init = function () {
  227. this.getLocalInfo();
  228. let accountInfo = this.getDefaultAccount();
  229. if (accountInfo) {
  230. form.val('loginForm', {
  231. username: accountInfo.username,
  232. password: accountInfo.password
  233. });
  234. }
  235. };
  236. /**
  237. * @Author = NanKeYang
  238. * @Description = 获取本地账号信息
  239. * @Data = 2019/12/30 16:55
  240. */
  241. this.getLocalInfo = function () {
  242. let localInfo = localStorage.getItem(this.localInfoKey);
  243. if (localInfo) {
  244. this.accountList = JSON.parse(localInfo);
  245. }
  246. };
  247. /**
  248. * @Author = NanKeYang
  249. * @Description = 更新本地存储数据
  250. * @Data = 2019/12/30 17:09
  251. */
  252. this.updateLocalInfo = function () {
  253. if (this.accountList.length > 0) {
  254. localStorage.setItem(this.localInfoKey, JSON.stringify(this.accountList));
  255. } else {
  256. localStorage.removeItem(this.localInfoKey);
  257. }
  258. };
  259. /**
  260. * @Author = NanKeYang
  261. * @Description = 记住账号
  262. * @Data = 2019/12/30 16:44
  263. */
  264. this.rememberAccount = function (username, password) {
  265. this.removeAccount(username);
  266. let appendData = [{
  267. username: username,
  268. password: password
  269. }]
  270. this.accountList = appendData.concat(this.accountList);
  271. };
  272. /**
  273. * @Author = NanKeYang
  274. * @Description = 删除账号
  275. * @Data = 2019/12/30 17:07
  276. */
  277. this.removeAccount = function (username) {
  278. let removeIndex = null;
  279. for (let i = 0; i < this.accountList.length; i++) {
  280. if (username === this.accountList[i].username) {
  281. removeIndex = i;
  282. break;
  283. }
  284. }
  285. if (removeIndex !== null) {
  286. this.accountList.splice(removeIndex, 1);
  287. }
  288. };
  289. /**
  290. * @Author = NanKeYang
  291. * @Description = 获取账号密码
  292. * @Data = 2019/12/30 17:13
  293. */
  294. this.getAccountPassword = function (username) {
  295. for (let i = 0; i < this.accountList.length; i++) {
  296. if (username === this.accountList[i].username) {
  297. return this.accountList[i].password;
  298. }
  299. }
  300. };
  301. /**
  302. * @Author = NanKeYang
  303. * @Description = 获取默认账号
  304. * @Data = 2019/12/30 17:41
  305. */
  306. this.getDefaultAccount = function () {
  307. return this.accountList.length > 0 ? this.accountList[0] : null;
  308. }
  309. };
  310. var localInfo = new LocalInfoCookie();
  311. localInfo.init();
  312. /**
  313. * @Author: NanKeYang
  314. * @Description: 处理回车登录
  315. * @Data: 2020/1/3 10:39
  316. */
  317. document.onkeydown = (e) => {
  318. const key = window.event.keyCode
  319. if (key == 13) {
  320. $('#btn1').click();
  321. }
  322. }
  323. /**
  324. * @Author: NanKeYang
  325. * @Description: 用户名失去焦点时候获取密码
  326. * @Data: 2020/1/19 11:13
  327. */
  328. $('#username').blur(function (v) {
  329. let username = $(this).val();
  330. let password = localInfo.getAccountPassword(username);
  331. if (password) {
  332. form.val('loginForm', {
  333. password: password
  334. });
  335. } else {
  336. form.val('loginForm', {
  337. password: ''
  338. });
  339. }
  340. })
  341. // 表单提交
  342. uParas.clearCache();
  343. form.on('submit(login)', function (obj) {
  344. admin.btnLoading('#btn1', '登录中。。。。');
  345. admin.req(uParas.baseUrl + '/login', obj.field, function (resp) {
  346. //debugger
  347. if (resp.code == 1) {
  348. if (obj.field.checkbox) {
  349. localInfo.rememberAccount(obj.field.username, obj.field.password)
  350. } else {
  351. localInfo.removeAccount(obj.field.username)
  352. }
  353. localInfo.updateLocalInfo();
  354. localStorage.setItem('atoken', resp.data.token);
  355. uParas.loginCache(resp);
  356. location.href = "../page/company_page/index.html"
  357. } else {
  358. layer.msg(resp.msg)
  359. admin.btnLoading('#btn1', '登录', false);
  360. }
  361. }, 'POST');
  362. return false;
  363. });
  364. // 图形验证码
  365. $('.login-captcha').click(function () {
  366. this.src = this.src + '?t=' + (new Date).getTime();
  367. });
  368. });
  369. </script>
  370. </html>