go语言写的人脸本地化程序
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 

599 righe
15 KiB

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>页面登录</title>
  7. <style>
  8. body{
  9. margin: 0;
  10. }
  11. li {
  12. list-style-type: none;
  13. }
  14. @media screen and (orientation: portrait) {
  15. .login {
  16. width: 100vw;
  17. height: 100vh;
  18. background-image: url("/static/img/phoneBgc.jpg");
  19. background-size: 100% 100%;
  20. background-repeat: no-repeat;
  21. }
  22. .register {
  23. background-image: url("/static/img/registerBgc.jpg") !important;
  24. padding-top: 15vh;
  25. }
  26. .logo {
  27. width: 15vw;
  28. margin: 4vw 0 0 4vw;
  29. }
  30. .login_title {
  31. width: 100vw;
  32. font-size: 8vw;
  33. text-align: center;
  34. margin-top: 15vh;
  35. }
  36. .input_box {
  37. width: 100vw;
  38. height: 25vw;
  39. display: flex;
  40. flex-direction: column;
  41. justify-content: center;
  42. align-items: center;
  43. margin-top: 5vh;
  44. position: relative;
  45. }
  46. .phone_input, .account_input{
  47. width: 50vw;
  48. height: 11vw;
  49. border-radius: 2vw;
  50. background-color: transparent;
  51. font-size: 3vw;
  52. padding-left: 2vw;
  53. border: 1px solid #000;
  54. position: absolute;
  55. top: 0vw;
  56. }
  57. .code_input, .password_input{
  58. width: 50vw;
  59. height: 11vw;
  60. margin-top: 2vh;
  61. border-radius: 2vw;
  62. padding-left: 2vw;
  63. font-size: 3vw;
  64. background-color: transparent;
  65. border: 1px solid #000;
  66. position: absolute;
  67. top: 10vw;
  68. }
  69. .login_button {
  70. width: 40vw;
  71. height: 5vh;
  72. background-color: rgb(101, 161, 255);
  73. border-radius: 10vw;
  74. display: flex;
  75. justify-content: center;
  76. align-items: center;
  77. color:#fff;
  78. font-size: 4vw;
  79. margin: 2vh 0 0 30vw;
  80. }
  81. #sendCodeBtn {
  82. position: absolute;
  83. font-size: 2.5vw;
  84. top: 18.5vw;
  85. right: 30vw;
  86. border-left: 2px solid;
  87. padding-left: 2vw;
  88. border: none;
  89. background: transparent;
  90. }
  91. .employee {
  92. display: flex;
  93. align-items: center;
  94. }
  95. .administrator {
  96. display: flex;
  97. align-items: center;
  98. margin-left: 5vw;
  99. }
  100. .choose_employee {
  101. width: 2vw;
  102. height: 2vw;
  103. border-radius: 50%;
  104. border: 2px solid #000;
  105. margin-right: 1vw;
  106. }
  107. .choose_administrator {
  108. width: 2vw;
  109. height: 2vw;
  110. border-radius: 50%;
  111. border: 2px solid #000;
  112. margin-right: 1vw;
  113. }
  114. .login_style {
  115. display: flex;
  116. justify-content: center;
  117. align-items: center;
  118. font-size: 2.5vw;
  119. margin-top: 2vh;
  120. }
  121. .hidden {
  122. display: none;
  123. }
  124. .active {
  125. display: flex;
  126. }
  127. .background {
  128. background-color: #000;
  129. }
  130. .password-container {
  131. position: relative;
  132. }
  133. .password_toggle {
  134. position: absolute;
  135. width: 5vw;
  136. top: 18vw;
  137. right: 26vw;
  138. }
  139. #div-a-reg{
  140. margin-top: 3vh;
  141. text-align: center;
  142. }
  143. }
  144. @media screen and (orientation: landscape) {
  145. input:focus {
  146. border: 0.1vw solid #000;
  147. outline: none; /* 可选,用于去除默认的外边框样式 */
  148. }
  149. .login {
  150. width: 100vw;
  151. height: 100vh;
  152. background-image: url("/static/img/phoneBgc_pc.jpg");
  153. background-size: 100% 100%;
  154. background-repeat: no-repeat;
  155. position: relative;
  156. }
  157. .PC_img {
  158. width: 52.6vw;
  159. height: 64.44vh;
  160. background-image: url("/static/img/loginBox.png");
  161. background-size: 100% 100%;
  162. background-repeat: no-repeat;
  163. position: absolute;
  164. top: 18.88vh;
  165. left: 23.7vw;
  166. }
  167. .register {
  168. background-image: url("/static/img/registerBgc_pc.jpg") !important;
  169. }
  170. .logo {
  171. width: 15vh;
  172. margin: 4vh 0 0 4vh;
  173. }
  174. .login_title {
  175. /* width: 100vw; */
  176. font-size: 4vh;
  177. text-align: center;
  178. position: absolute;
  179. z-index: 10;
  180. top: 28vh;
  181. margin-left: 58vw;
  182. /* margin-top: 15vh;*/
  183. }
  184. .input_box {
  185. flex-direction: column;
  186. justify-content: center;
  187. align-items: center;
  188. margin-top: 15vh;
  189. position: relative;
  190. }
  191. .phone_input, .account_input {
  192. width: 15vw;
  193. height: 6.66vh;
  194. border-radius: 2vh;
  195. background-color: transparent;
  196. font-size: 1.5vw;
  197. padding-left: 2vh;
  198. padding-right: 5vw;
  199. border: 0.1vw solid #000;
  200. margin-left: 25vw;
  201. }
  202. .code_input, .password_input {
  203. width: 15vw;
  204. height: 6.66vh;
  205. margin-top: 2vw;
  206. border-radius: 2vh;
  207. padding-left: 2vh;
  208. font-size: 1.5vw;
  209. padding-right: 5vw;
  210. background-color: transparent;
  211. border: 0.1vw solid #000;
  212. margin-left: 25vw;
  213. }
  214. .login_button {
  215. width: 16vw;
  216. height: 3vw;
  217. background-color: rgb(101, 161, 255);
  218. border-radius: 10vh;
  219. display: flex;
  220. justify-content: center;
  221. align-items: center;
  222. color: #fff;
  223. font-size: 2vw;
  224. /* margin: 2vh 0 0 30vh; */
  225. position: absolute;
  226. left: 55vw;
  227. top: 65vh;
  228. }
  229. #sendCodeBtn {
  230. position: absolute;
  231. font-size: 1.5vh;
  232. top: 11.5vh;
  233. right: 27.3vw;
  234. border-left: 0.1vw solid;
  235. padding-left: 1vh;
  236. display: flex;
  237. align-items: center;
  238. height: 3vw;
  239. border: none;
  240. background: transparent;
  241. }
  242. .employee {
  243. display: flex;
  244. align-items: center;
  245. }
  246. .administrator {
  247. display: flex;
  248. align-items: center;
  249. margin-left: 3vw;
  250. }
  251. .hand:hover {
  252. cursor: pointer;
  253. }
  254. .choose_employee {
  255. width: 2vh;
  256. height: 2vh;
  257. border-radius: 50%;
  258. border: 0.1vw solid #000;
  259. margin-right: 1vh;
  260. }
  261. .choose_administrator {
  262. width: 2vh;
  263. height: 2vh;
  264. border-radius: 50%;
  265. border: 0.1vw solid #000;
  266. margin-right: 1vh;
  267. }
  268. .login_style {
  269. display: flex;
  270. justify-content: center;
  271. align-items: center;
  272. font-size: 1vw;
  273. margin-top: 2vw;
  274. position: absolute;
  275. left: 54.8vw;
  276. }
  277. .hidden {
  278. display: none;
  279. }
  280. .active {
  281. display: flex;
  282. }
  283. .background {
  284. background-color: #000;
  285. }
  286. .password-container {
  287. position: relative;
  288. }
  289. .password_toggle {
  290. width: 3vw;
  291. position: absolute;
  292. font-size: 1.5vh;
  293. top: 11.5vh;
  294. right: 28.5vw;
  295. padding-left: 0.5vh;
  296. }
  297. #scroll-to-top-btn {
  298. display: none;
  299. position: fixed;
  300. right: 20px;
  301. bottom: 20px;
  302. width: 7vh;
  303. height: 10vw;
  304. color: #fff;
  305. border: none;
  306. border-radius: 5px;
  307. font-size: 3vh;
  308. cursor: pointer;
  309. }
  310. #div-a-reg{
  311. width: 16vw;
  312. height: 3vw;
  313. background-color:transparent;
  314. border-radius: 10vh;
  315. display: flex;
  316. justify-content: center;
  317. align-items: center;
  318. color: #fff;
  319. font-size: 2vh;
  320. position: absolute;
  321. left: 55vw;
  322. top: 72vh;
  323. }
  324. }
  325. button:disabled {
  326. color: black !important;
  327. }
  328. </style>
  329. </head>
  330. <body>
  331. <!-- 登录页面 -->
  332. <div class="login">
  333. <img class="logo" src="/static/img/logo.png" alt="">
  334. <div class="PC_img"></div>
  335. <div class="login_title">请 登 录</div>
  336. <div id="employeeForm" class="input_box hidden active">
  337. <input class="phone_input" type="text" placeholder="请输入手机号">
  338. <input class="code_input" type="text" placeholder="请输入验证码">
  339. <button id="sendCodeBtn" class="btn">发送验证码</button>
  340. </div>
  341. <div id="adminForm" class="input_box hidden password-container">
  342. <input class="account_input" type="text" placeholder="请输入账号">
  343. <input id="password_input" class="password_input" type="password" placeholder="请输入密码">
  344. <img id="password_toggle" class="password_toggle hand" src="/static/img/close.png" alt="">
  345. </div>
  346. <div class="login_style">
  347. <div id="employeeBtn" class="employee hand">
  348. <div id="choose_employee" class="choose_employee background"></div>
  349. <div>员工登录</div>
  350. </div>
  351. <div id="adminBtn" class="administrator hand">
  352. <div id="choose_administrator" class="choose_administrator"></div>
  353. <div>管理员登录</div>
  354. </div>
  355. </div>
  356. <div class="login_button hand">登 录</div>
  357. <div id="div-a-reg"><a id="a-reg" href="/reg">去注册</a></div>
  358. </div>
  359. <script src="/static/js/jquery.min.js"></script>
  360. <script src="/static/js/msg-box.js"></script>
  361. <script>
  362. $(function(){
  363. console.log("{{.type}}");
  364. if ("{{.type}}" == "mgr") {
  365. $("#adminBtn").click();
  366. }
  367. $.MsgBox = {
  368. Alert: function(title, msg) {
  369. GenerateHtml("alert", title, msg);
  370. btnOk(); //alert只是弹出消息,因此没必要用到回调函数callback
  371. btnNo();
  372. },
  373. Confirm: function(title, msg, callback) {
  374. GenerateHtml("confirm", title, msg);
  375. btnOk(callback);
  376. btnNo();
  377. }
  378. }
  379. const sendCodeBtn = $('#sendCodeBtn');
  380. let countdown = 30;
  381. let timer;
  382. function startCountdown() {
  383. sendCodeBtn.attr("disabled", "disabled");
  384. sendCodeBtn.html(`${countdown}秒`);
  385. timer = setInterval(() => {
  386. console.log(countdown);
  387. countdown--;
  388. sessionStorage.setItem('countdown',countdown);
  389. sendCodeBtn.html(`${countdown}秒`);
  390. if (countdown <= 0) {
  391. clearInterval(timer);
  392. sendCodeBtn.html('发送验证码');
  393. sendCodeBtn.removeAttr("disabled");
  394. countdown = 30;
  395. }
  396. }, 1000);
  397. }
  398. $("#sendCodeBtn").on("click",function(){
  399. if (!phoneValid()){
  400. $.MsgBox.Alert("提示", "手机号为空或不合法,请检查");
  401. return;
  402. }
  403. countdown = 30;
  404. startCountdown();
  405. sessionStorage.setItem('countdown',countdown);
  406. // ajax发送验证码
  407. $.ajax({
  408. url: '/send_validation_code',
  409. type: 'POST',
  410. dataType: 'json',
  411. data: {
  412. phone: $(".phone_input").val(),
  413. },
  414. success: function (response) {
  415. console.log(response);
  416. response = JSON.parse(response)
  417. if (response.code == 200) {
  418. $.MsgBox.Alert("提示", "验证码发送成功");
  419. } else {
  420. $.MsgBox.Alert("提示", response.msg ? response.msg : "验证码发送失败");
  421. }
  422. },
  423. error: function () {
  424. }
  425. });
  426. })
  427. function initCountdown() {
  428. const storedCountdown = sessionStorage.getItem('countdown');
  429. if (storedCountdown) {
  430. countdown = parseInt(storedCountdown, 10);
  431. if (countdown > 0) {
  432. startCountdown();
  433. }
  434. }
  435. }
  436. initCountdown();
  437. function phoneValid() {
  438. const regex = /^1[3-9]\d{9}$/;
  439. var phone = $(".phone_input").val();
  440. if (phone == "" || !regex.test(phone)){
  441. return false;
  442. }
  443. return true;
  444. }
  445. $(".login_button").on("click",function(){
  446. if ($("#employeeForm").hasClass("active")) {
  447. if (!phoneValid()){
  448. $.MsgBox.Alert("提示", "手机号为空或不合法,请检查");
  449. return;
  450. }
  451. const codeRegex = /^\d{4}$/;
  452. var code = $(".code_input").val();
  453. if (code == "" || !codeRegex.test(code)){
  454. $.MsgBox.Alert("提示", "验证码为4位数字,请检查");
  455. return;
  456. }
  457. $.ajax({
  458. url: '/valid_code',
  459. type: 'POST',
  460. dataType: 'json',
  461. data: {
  462. phone: $(".phone_input").val(),
  463. code: code,
  464. },
  465. success: function (response) {
  466. console.log(response);
  467. response = JSON.parse(response)
  468. if (response.status == 0) {
  469. $.ajax({
  470. url: '/phone_login',
  471. type: 'POST',
  472. dataType: 'json',
  473. data: {
  474. phone: $(".phone_input").val(),
  475. },
  476. success: function (response) {
  477. console.log(response);
  478. console.log(response.data);
  479. console.log(response.data.staffId);
  480. // response = JSON.parse(response)
  481. if (response.code == 200) {
  482. window.location.href = '/info?staffId='+response.data.staffId;
  483. } else {
  484. $.MsgBox.Alert("提示", response.msg);
  485. }
  486. },
  487. error: function () {
  488. }
  489. });
  490. } else {
  491. $.MsgBox.Alert("提示", response.err);
  492. }
  493. },
  494. error: function () {
  495. }
  496. });
  497. } else {
  498. if ($(".account_input").val() == "") {
  499. $.MsgBox.Alert("提示", "请输入账号!");
  500. return;
  501. }
  502. if ($(".password_input").val() == "") {
  503. $.MsgBox.Alert("提示", "请输入密码!");
  504. return;
  505. }
  506. $.ajax({
  507. url: '/mgr_login',
  508. type: 'POST',
  509. dataType: 'json',
  510. data: {
  511. userName: $(".account_input").val(),
  512. password: $(".password_input").val(),
  513. },
  514. success: function (response) {
  515. console.log(response);
  516. response = JSON.parse(response)
  517. if (response.code == 200) {
  518. console.log(response.data.access_token);
  519. console.log(response.type);
  520. sessionStorage.setItem('token',response.type);
  521. window.location.href = '/mgr';
  522. } else {
  523. $.MsgBox.Alert("提示", response.msg);
  524. }
  525. },
  526. error: function () {
  527. }
  528. });
  529. }
  530. })
  531. })
  532. // 切换登陆页面
  533. document.getElementById("employeeBtn").addEventListener("click", function() {
  534. document.getElementById("employeeForm").classList.add("active");
  535. document.getElementById("adminForm").classList.remove("active");
  536. document.getElementById("choose_administrator").classList.remove("background");
  537. document.getElementById("choose_employee").classList.add("background");
  538. });
  539. document.getElementById("adminBtn").addEventListener("click", function() {
  540. document.getElementById("employeeForm").classList.remove("active");
  541. document.getElementById("adminForm").classList.add("active");
  542. document.getElementById("choose_employee").classList.remove("background");
  543. document.getElementById("choose_administrator").classList.add("background");
  544. });
  545. document.getElementById("password_toggle").addEventListener("click", function() {
  546. let passwordInput = document.getElementById("password_input")
  547. if (passwordInput.type === 'password') {
  548. passwordInput.type ='text';
  549. document.getElementById("password_toggle").src = "/static/img/open.png"
  550. } else {
  551. passwordInput.type = "password";
  552. document.getElementById("password_toggle").src = "/static/img/close.png"
  553. }
  554. });
  555. </script>
  556. </body>
  557. </html>