go语言写的人脸本地化程序
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 
 

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