login1.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  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_one.png");
  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: 2.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 id="page-video-bg" class="video_back" src="./login/img/background.mp4" type="video/mp4" muted
  156. autoplay="autoplay" loop="loop">
  157. </video>
  158. <div class="index-box">
  159. <div class="logo">
  160. <img src="./login/img/logo.png" alt="">
  161. </div>
  162. <form class="layui-form" lay-filter="loginForm">
  163. <div class="logo-box">
  164. <img src="./login/img/login_bg.png" alt="">
  165. <div class="main">
  166. <p class="title">
  167. 账号
  168. <span>安全登录</span>
  169. </p>
  170. <div class="username">
  171. <div class="user-top">
  172. <img src="./login/img/icon_common_user.png" alt="">
  173. <span>用户名</span>
  174. </div>
  175. <div class="bottom">
  176. <input type="text" id="username" name="username" placeholder="请输入用户名" lay-verType="tips"
  177. lay-verify="required" required>
  178. </div>
  179. </div>
  180. <div class="username pwd">
  181. <div class="user-top">
  182. <img src="./login/img/icon_common_user.png" alt="">
  183. <span>密 &nbsp;&nbsp;&nbsp;码</span>
  184. </div>
  185. <div class="bottom">
  186. <input type="password" name="password" placeholder="请输入密码" lay-verType="tips"
  187. lay-verify="required" required>
  188. </div>
  189. </div>
  190. <div class="btn">
  191. <div class="btn-left">
  192. <input type="checkbox" name="checkbox" lay-skin="primary" title="记住密码" checked="">
  193. </div>
  194. <div class="btn-right">
  195. <p id="btn1" lay-filter="login" lay-submit>登录</p>
  196. <!-- <button lay-filter="login" id="btn1" class="layui-btn layui-btn-fluid" lay-submit>登 录</button>-->
  197. </div>
  198. </div>
  199. <div class="tip">
  200. <p>
  201. @2019陕西云康电子信息技术有限公司
  202. </p>
  203. </div>
  204. </div>
  205. </div>
  206. </form>
  207. </div>
  208. </div>
  209. </body>
  210. <script type="text/javascript" src="assets/libs/layui/layui.js"></script>
  211. <script type="text/javascript" src="./assets/js/common.js?v=312"></script>
  212. <script type="text/javascript">
  213. document.getElementById("page-video-bg").playbackRate = .5;
  214. </script>
  215. <script>
  216. layui.use(['layer', 'form', 'uParas', 'admin'], function () {
  217. var $ = layui.jquery;
  218. var layer = layui.layer;
  219. var form = layui.form;
  220. var uParas = layui.uParas;
  221. var admin = layui.admin;
  222. /**
  223. * @Author: NanKeYang
  224. * @Description: 本地信息Cookie
  225. * @Data: 2020/1/19 11:08
  226. */
  227. var LocalInfoCookie = function () {
  228. this.localInfoKey = 'user_account';
  229. this.accountList = [];
  230. this.init = function () {
  231. this.getLocalInfo();
  232. let accountInfo = this.getDefaultAccount();
  233. if (accountInfo) {
  234. form.val('loginForm', {
  235. username: accountInfo.username,
  236. password: accountInfo.password
  237. });
  238. }
  239. };
  240. /**
  241. * @Author = NanKeYang
  242. * @Description = 获取本地账号信息
  243. * @Data = 2019/12/30 16:55
  244. */
  245. this.getLocalInfo = function () {
  246. let localInfo = localStorage.getItem(this.localInfoKey);
  247. if (localInfo) {
  248. this.accountList = JSON.parse(localInfo);
  249. }
  250. };
  251. /**
  252. * @Author = NanKeYang
  253. * @Description = 更新本地存储数据
  254. * @Data = 2019/12/30 17:09
  255. */
  256. this.updateLocalInfo = function () {
  257. if (this.accountList.length > 0) {
  258. localStorage.setItem(this.localInfoKey, JSON.stringify(this.accountList));
  259. } else {
  260. localStorage.removeItem(this.localInfoKey);
  261. }
  262. };
  263. /**
  264. * @Author = NanKeYang
  265. * @Description = 记住账号
  266. * @Data = 2019/12/30 16:44
  267. */
  268. this.rememberAccount = function (username, password) {
  269. this.removeAccount(username);
  270. let appendData = [{
  271. username: username,
  272. password: password
  273. }]
  274. this.accountList = appendData.concat(this.accountList);
  275. };
  276. /**
  277. * @Author = NanKeYang
  278. * @Description = 删除账号
  279. * @Data = 2019/12/30 17:07
  280. */
  281. this.removeAccount = function (username) {
  282. let removeIndex = null;
  283. for (let i = 0; i < this.accountList.length; i++) {
  284. if (username === this.accountList[i].username) {
  285. removeIndex = i;
  286. break;
  287. }
  288. }
  289. if (removeIndex !== null) {
  290. this.accountList.splice(removeIndex, 1);
  291. }
  292. };
  293. /**
  294. * @Author = NanKeYang
  295. * @Description = 获取账号密码
  296. * @Data = 2019/12/30 17:13
  297. */
  298. this.getAccountPassword = function (username) {
  299. for (let i = 0; i < this.accountList.length; i++) {
  300. if (username === this.accountList[i].username) {
  301. return this.accountList[i].password;
  302. }
  303. }
  304. };
  305. /**
  306. * @Author = NanKeYang
  307. * @Description = 获取默认账号
  308. * @Data = 2019/12/30 17:41
  309. */
  310. this.getDefaultAccount = function () {
  311. return this.accountList.length > 0 ? this.accountList[0] : null;
  312. }
  313. };
  314. var localInfo = new LocalInfoCookie();
  315. localInfo.init();
  316. /**
  317. * @Author: NanKeYang
  318. * @Description: 处理回车登录
  319. * @Data: 2020/1/3 10:39
  320. */
  321. document.onkeydown = (e) => {
  322. const key = window.event.keyCode
  323. if (key == 13) {
  324. $('#btn1').click();
  325. }
  326. }
  327. /**
  328. * @Author: NanKeYang
  329. * @Description: 用户名失去焦点时候获取密码
  330. * @Data: 2020/1/19 11:13
  331. */
  332. $('#username').blur(function (v) {
  333. let username = $(this).val();
  334. let password = localInfo.getAccountPassword(username);
  335. if (password) {
  336. form.val('loginForm', {
  337. password: password
  338. });
  339. } else {
  340. form.val('loginForm', {
  341. password: ''
  342. });
  343. }
  344. })
  345. // 表单提交
  346. uParas.clearCache();
  347. form.on('submit(login)', function (obj) {
  348. admin.btnLoading('#btn1', '登录中。。。。');
  349. admin.req(uParas.baseUrl + '/login', obj.field, function (resp) {
  350. //debugger
  351. if (resp.code == 1) {
  352. if (obj.field.checkbox) {
  353. localInfo.rememberAccount(obj.field.username, obj.field.password)
  354. } else {
  355. localInfo.removeAccount(obj.field.username)
  356. }
  357. localInfo.updateLocalInfo();
  358. uParas.loginCache(resp);
  359. location.href = "./index.html"
  360. } else {
  361. layer.msg(resp.msg)
  362. admin.btnLoading('#btn1', '登录', false);
  363. }
  364. }, 'POST');
  365. return false;
  366. });
  367. // 图形验证码
  368. $('.login-captcha').click(function () {
  369. this.src = this.src + '?t=' + (new Date).getTime();
  370. });
  371. });
  372. </script>
  373. </html>