go语言写的人脸本地化程序
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 

394 linhas
10 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. .register_loginTitle {
  27. width: 100vw;
  28. font-size: 8vw;
  29. text-align: center;
  30. }
  31. .register_inputBox {
  32. display: flex;
  33. flex-direction: column;
  34. justify-content: center;
  35. align-items: center;
  36. margin-top: 5vh;
  37. position: relative;
  38. }
  39. .register_phoneInput {
  40. width: 50vw;
  41. height: 5vh;
  42. border-radius: 2vw;
  43. background-color: transparent;
  44. font-size: 3vw;
  45. padding-left: 2vw;
  46. border: 1px solid #000;
  47. margin-bottom: 2vh;
  48. }
  49. .register_nameInput {
  50. width: 50vw;
  51. height: 5vh;
  52. border-radius: 2vw;
  53. background-color: transparent;
  54. font-size: 3vw;
  55. padding-left: 2vw;
  56. border: 1px solid #000;
  57. margin-bottom: 2vh;
  58. }
  59. .reg_button {
  60. width: 40vw;
  61. height: 5vh;
  62. background-color: rgb(101, 161, 255);
  63. border-radius: 10vw;
  64. display: flex;
  65. justify-content: center;
  66. align-items: center;
  67. color:#fff;
  68. font-size: 4vw;
  69. margin: 2vh 0 0 30vw;
  70. }
  71. .register_loginButton {
  72. width: 40vw;
  73. height: 5vh;
  74. background-color: rgb(101, 161, 255);
  75. border-radius: 10vw;
  76. display: flex;
  77. justify-content: center;
  78. align-items: center;
  79. color:#fff;
  80. font-size: 4vw;
  81. margin: 2vh 0 0 30vw;
  82. }
  83. #scroll-to-top-btn {
  84. display: none;
  85. position: fixed;
  86. right: 20px;
  87. bottom: 20px;
  88. width: 7vw;
  89. height: 10vh;
  90. color: #fff;
  91. border: none;
  92. border-radius: 5px;
  93. font-size: 3vw;
  94. cursor: pointer;
  95. }
  96. .uploadImg{
  97. width: 46vw !important;
  98. transform: translate(0%, 0%) !important;
  99. left: 27vw !important;
  100. position: relative;
  101. }
  102. #div-a-login{
  103. margin-top: 3vh;
  104. text-align: center;
  105. }
  106. }
  107. @media screen and (orientation: landscape) {
  108. input:focus {
  109. border: 0.1vw solid #000;
  110. outline: none; /* 可选,用于去除默认的外边框样式 */
  111. }
  112. .login {
  113. width: 100vw;
  114. height: 100vh;
  115. background-image: url("/static/img/phoneBgc_pc.jpg");
  116. background-size: 100% 100%;
  117. background-repeat: no-repeat;
  118. position: relative;
  119. }
  120. .register {
  121. background-image: url("/static/img/registerBgc_pc.jpg") !important;
  122. }
  123. .register_loginTitle {
  124. width: 100vw;
  125. display: flex;
  126. justify-content: center;
  127. font-size: 4vh;
  128. text-align: center;
  129. position: absolute;
  130. z-index: 10;
  131. top: 10vh;
  132. }
  133. .uploadImg {
  134. width: 15vw;
  135. }
  136. .register_inputBox {
  137. width: 100vw;
  138. display: flex;
  139. flex-direction: column;
  140. justify-content: center;
  141. align-items: center;
  142. position: relative;
  143. padding-top: 42vh;
  144. }
  145. .register_phoneInput {
  146. width: 37vh;
  147. height: 6vh;
  148. border-radius: 2vh;
  149. background-color: transparent;
  150. font-size: 3vh;
  151. border: 0.1vw solid #000;
  152. margin-bottom: 5vh;
  153. padding-left:1vw ;
  154. }
  155. .register_nameInput {
  156. width: 37vh;
  157. height: 6vh;
  158. border-radius: 2vh;
  159. background-color: transparent;
  160. font-size: 3vh;
  161. border: 0.1vw solid #000;
  162. padding-left: 1vw ;
  163. margin-bottom: 2vh;
  164. }
  165. .reg_button {
  166. width: 16vw;
  167. height: 3vw;
  168. background-color: rgb(101, 161, 255);
  169. border-radius: 10vh;
  170. display: flex;
  171. justify-content: center;
  172. align-items: center;
  173. color: #fff;
  174. font-size: 2vw;
  175. /* margin: 2vh 0 0 30vh; */
  176. position: absolute;
  177. left: 55vw;
  178. top: 65vh;
  179. }
  180. .register_loginButton {
  181. width: 8vw;
  182. height: 2vw;
  183. background-color: rgb(101, 161, 255);
  184. border-radius: 1vw;
  185. display: flex;
  186. justify-content: center;
  187. align-items: center;
  188. color: #fff;
  189. font-size: 3vh;
  190. position: absolute;
  191. left: 46vw;
  192. top: 65vh;
  193. }
  194. .hand:hover{
  195. cursor: pointer;
  196. }
  197. #scroll-to-top-btn {
  198. display: none;
  199. position: fixed;
  200. right: 20px;
  201. bottom: 20px;
  202. width: 7vh;
  203. height: 10vw;
  204. color: #fff;
  205. border: none;
  206. border-radius: 5px;
  207. font-size: 3vh;
  208. cursor: pointer;
  209. }
  210. .uploadImg{
  211. width: 200px !important;
  212. transform: translate(0%, 0%) !important;
  213. left: 2vw !important;
  214. position: relative;
  215. }
  216. #div-a-login{
  217. margin-top: 10vh;
  218. text-align: center;
  219. font-size: 3vh;
  220. }
  221. }
  222. .upload-img-box {
  223. position: relative;
  224. }
  225. .upload-img-box .input-box {
  226. display: inline-block;
  227. width: 144px;
  228. height: 144px;
  229. /*border: solid black 1px;*/
  230. }
  231. .upload-img-box .befor-img {
  232. display: flex;
  233. /*width: 300px;*/
  234. /*height: 90px;*/
  235. /*border: solid black 1px;*/
  236. position: absolute;
  237. top: 0px;
  238. left: 0px;
  239. /*background: #ffffff;*/
  240. z-index: 30;
  241. align-items: center;
  242. justify-content: center;
  243. }
  244. .upload-img-box .befor-img.hasImg {
  245. display: none;
  246. }
  247. .upload-img-box .after-img {
  248. display: inline-block;
  249. width: 144px;
  250. height: 144px;
  251. border: none;
  252. /*position: absolute;*/
  253. top: 0px;
  254. left: 0px;
  255. /*background: #ffffff;*/
  256. z-index: 20;
  257. }
  258. .after-img img, .uploadImg {
  259. /*position: absolute;*/
  260. width: 100%;
  261. height: 100%;
  262. object-fit: cover; /*根据父容器的尺寸裁剪和缩放图片,以填充整个容器,并保持长宽比例不变。*/
  263. object-position: center; /*指定对象的位置,如果不设置,则默认是center*/
  264. background-size: cover; /*背景图片的大小,如果不设置,则默认是auto*/
  265. background-position: center;
  266. top: 50%;
  267. left: 50%;
  268. transform: translate(-50%, 0%);/*将元素移动到中心*/
  269. border-radius: 50%;
  270. }
  271. </style>
  272. </head>
  273. <body>
  274. <!-- 注册页面 -->
  275. <div class="register login">
  276. <div class="register_loginTitle ">
  277. <div class="upload-img-box">
  278. <div class="input-box">
  279. <input type="file" id="img-file" hidden="hidden" name="选择图片">
  280. </div>
  281. <div class="befor-img">
  282. <img class="uploadImg hand" src="/static/img/upload.png" alt="">
  283. </div>
  284. <div class="after-img">
  285. <img id="img-box" src="" width="30%" height="auto">
  286. </div>
  287. </div>
  288. </div>
  289. <div class="register_inputBox">
  290. <input class="register_nameInput" name="staffName" type="text" placeholder="员工姓名">
  291. <input class="register_phoneInput" name="staffPhone" type="text" placeholder="员工手机号">
  292. </div>
  293. <div class="register_loginButton hand">注册人脸</div>
  294. <div id="div-a-login"><a id="a-login" href="/">去登录</a></div>
  295. </div>
  296. <script src="/static/js/jquery.min.js"></script>
  297. <script src="/static/js/msg-box.js"></script>
  298. <script>
  299. $(function(){
  300. $(".register_loginButton").on("click",function() {
  301. var staffPhone = $(".register_phoneInput").val();
  302. var staffName = $(".register_nameInput").val();
  303. const regex = /^1[3-9]\d{9}$/;
  304. if (staffPhone == "" || !regex.test(staffPhone)){
  305. $.MsgBox.Alert("提示", "手机号为空或不合法,请检查");
  306. return;
  307. }
  308. if (staffName == ""){
  309. $.MsgBox.Alert("提示", "员工姓名为空,请检查");
  310. return;
  311. }
  312. var img = $("#img-box").attr("src");
  313. console.log(img);
  314. $.ajax({
  315. url: "/register",
  316. type: "post",
  317. data: {
  318. staffPhone: staffPhone,
  319. staffName: staffName,
  320. avatar: img
  321. },
  322. success: function(data) {
  323. $.MsgBox.Alert("提示", data.Message);
  324. },
  325. error: function(error) {
  326. console.log(error);
  327. $.MsgBox.Alert("提示", error.responseJSON.Message);
  328. }
  329. })
  330. })
  331. $(document).on("click", ".upload-img-box .befor-img,.upload-img-box .after-img", function (e) {
  332. $(".input-box input").trigger("click");
  333. })
  334. // 使用input 的change事件,监听当文件上传的值进行改变的时候,才触发事件。
  335. $(document).on("change", ".upload-img-box #img-file", function () {
  336. var file = $("#img-file")[0].files[0];
  337. console.log(file);
  338. // file 内容包括: lastModified , lastModifiedDate , name , size , type
  339. var formdata = new FormData();
  340. formdata.append('file', file);
  341. if (window.FileReader) {
  342. var fr = new FileReader();
  343. fr.onloadend = function (e) {
  344. // console.log(this.result);
  345. // document.getElementById("portrait").src = e.target.result;
  346. $("#img-box").attr("src",e.target.result)
  347. $(".upload-img-box .befor-img").addClass("hasImg")
  348. };
  349. //给FileReader对象一个读取完成的方法,
  350. //使用readAsDataURL会返回一个url
  351. //这个值就保存在事件对象的result里
  352. //img通过加载这个地址,完成图片的加载
  353. fr.readAsDataURL(file);
  354. }
  355. //判断图片大小
  356. if (file.size > 3 * 1024 * 1024) {
  357. alert("上传图片不能大于3M");
  358. }
  359. //判断图片数据类型
  360. if (!/.(gif|jpg|jpeg|png|GIF|JPG|bmp)$/.test(file.name)) {
  361. alert("图片类型必须是.gif,jpeg,jpg,png,bmp中的一种");
  362. }
  363. })
  364. })
  365. </script>
  366. </body>
  367. </html>