login_outData.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456
  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', 'outData'], 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. var outData = layui.outData;
  223. function showData() {
  224. layer.open({
  225. type: 1
  226. , title: false //不显示标题栏
  227. , closeBtn: false
  228. , area: '600px;'
  229. , shade: 0.8
  230. , id: 'LAY_layuipro' //设定一个id,防止重复弹出
  231. , btn: ['点击关闭']
  232. , btnAlign: 'c'
  233. , moveType: 1 //拖拽模式,0或者1
  234. , content: `
  235. <div style="padding: 50px; line-height: 22px; font-size:14px;background-color: #393D49; color: #fff; font-weight: 300;">
  236. <div id="timeShow"></div>
  237. </div>`
  238. , success: function (layero) {
  239. outData.realTimeUpdate('#timeShow');
  240. }
  241. , yes: function () {
  242. if (!outData.timeEnd) {
  243. layer.closeAll()
  244. setTimeout(showData, 5000)
  245. } else {
  246. layer.msg('请注意:请联系供应商解决');
  247. }
  248. }
  249. });
  250. }
  251. if (outData.isShow) {
  252. showData();
  253. }
  254. /**
  255. * @Author: NanKeYang
  256. * @Description: 本地信息Cookie
  257. * @Data: 2020/1/19 11:08
  258. */
  259. var LocalInfoCookie = function () {
  260. this.localInfoKey = 'user_account';
  261. this.accountList = [];
  262. this.init = function () {
  263. this.getLocalInfo();
  264. let accountInfo = this.getDefaultAccount();
  265. if (accountInfo) {
  266. form.val('loginForm', {
  267. username: accountInfo.username,
  268. password: accountInfo.password
  269. });
  270. }
  271. };
  272. /**
  273. * @Author = NanKeYang
  274. * @Description = 获取本地账号信息
  275. * @Data = 2019/12/30 16:55
  276. */
  277. this.getLocalInfo = function () {
  278. let localInfo = localStorage.getItem(this.localInfoKey);
  279. if (localInfo) {
  280. this.accountList = JSON.parse(localInfo);
  281. }
  282. };
  283. /**
  284. * @Author = NanKeYang
  285. * @Description = 更新本地存储数据
  286. * @Data = 2019/12/30 17:09
  287. */
  288. this.updateLocalInfo = function () {
  289. if (this.accountList.length > 0) {
  290. localStorage.setItem(this.localInfoKey, JSON.stringify(this.accountList));
  291. } else {
  292. localStorage.removeItem(this.localInfoKey);
  293. }
  294. };
  295. /**
  296. * @Author = NanKeYang
  297. * @Description = 记住账号
  298. * @Data = 2019/12/30 16:44
  299. */
  300. this.rememberAccount = function (username, password) {
  301. this.removeAccount(username);
  302. let appendData = [{
  303. username: username,
  304. password: password
  305. }]
  306. this.accountList = appendData.concat(this.accountList);
  307. };
  308. /**
  309. * @Author = NanKeYang
  310. * @Description = 删除账号
  311. * @Data = 2019/12/30 17:07
  312. */
  313. this.removeAccount = function (username) {
  314. let removeIndex = null;
  315. for (let i = 0; i < this.accountList.length; i++) {
  316. if (username === this.accountList[i].username) {
  317. removeIndex = i;
  318. break;
  319. }
  320. }
  321. if (removeIndex !== null) {
  322. this.accountList.splice(removeIndex, 1);
  323. }
  324. };
  325. /**
  326. * @Author = NanKeYang
  327. * @Description = 获取账号密码
  328. * @Data = 2019/12/30 17:13
  329. */
  330. this.getAccountPassword = function (username) {
  331. for (let i = 0; i < this.accountList.length; i++) {
  332. if (username === this.accountList[i].username) {
  333. return this.accountList[i].password;
  334. }
  335. }
  336. };
  337. /**
  338. * @Author = NanKeYang
  339. * @Description = 获取默认账号
  340. * @Data = 2019/12/30 17:41
  341. */
  342. this.getDefaultAccount = function () {
  343. return this.accountList.length > 0 ? this.accountList[0] : null;
  344. }
  345. };
  346. var localInfo = new LocalInfoCookie();
  347. localInfo.init();
  348. /**
  349. * @Author: NanKeYang
  350. * @Description: 处理回车登录
  351. * @Data: 2020/1/3 10:39
  352. */
  353. document.onkeydown = (e) => {
  354. const key = window.event.keyCode
  355. if (key == 13) {
  356. $('#btn1').click();
  357. }
  358. }
  359. /**
  360. * @Author: NanKeYang
  361. * @Description: 用户名失去焦点时候获取密码
  362. * @Data: 2020/1/19 11:13
  363. */
  364. $('#username').blur(function (v) {
  365. let username = $(this).val();
  366. let password = localInfo.getAccountPassword(username);
  367. if (password) {
  368. form.val('loginForm', {
  369. password: password
  370. });
  371. } else {
  372. form.val('loginForm', {
  373. password: ''
  374. });
  375. }
  376. })
  377. // 表单提交
  378. uParas.clearCache();
  379. form.on('submit(login)', function (obj) {
  380. admin.btnLoading('#btn1', '登录中。。。。');
  381. admin.req(uParas.baseUrl + '/login', obj.field, function (resp) {
  382. //debugger
  383. if (resp.code == 1) {
  384. if (obj.field.checkbox) {
  385. localInfo.rememberAccount(obj.field.username, obj.field.password)
  386. } else {
  387. localInfo.removeAccount(obj.field.username)
  388. }
  389. localInfo.updateLocalInfo();
  390. uParas.loginCache(resp);
  391. location.href = "./index.html"
  392. } else {
  393. layer.msg(resp.msg)
  394. admin.btnLoading('#btn1', '登录', false);
  395. }
  396. }, 'POST');
  397. return false;
  398. });
  399. // 图形验证码
  400. $('.login-captcha').click(function () {
  401. this.src = this.src + '?t=' + (new Date).getTime();
  402. });
  403. });
  404. </script>
  405. </html>