From e8e891f5c6d219536b62652af9b6dc80ded6a7eb Mon Sep 17 00:00:00 2001 From: y112102@qq.com <y112102@qq.com> Date: Fri, 2 Feb 2024 14:39:04 +0800 Subject: [PATCH] 登入页面删除多余的代码 --- web/WebMvc/Controllers/LoginController.cs | 40 +++++----------------------------------- web/WebMvc/Views/Login/Index.cshtml | 27 ++------------------------- web/WebMvc/wwwroot/baseJs/login.js | 81 +-------------------------------------------------------------------------------- web/WebMvc/wwwroot/css/login.css | 15 --------------- 4 files changed, 8 insertions(+), 155 deletions(-) diff --git a/web/WebMvc/Controllers/LoginController.cs b/web/WebMvc/Controllers/LoginController.cs index f0dfb8c..c837e8f 100644 --- a/web/WebMvc/Controllers/LoginController.cs +++ b/web/WebMvc/Controllers/LoginController.cs @@ -2,13 +2,10 @@ using Hh.Mes.Common.config; using Hh.Mes.Common.Json; using Hh.Mes.POJO.Entity; -using Hh.Mes.POJO.EnumEntitys; using Hh.Mes.POJO.Response; using Hh.Mes.Service; -using Hh.Mes.Service.Configure; using Hh.Mes.Service.Logs; using Hh.Mes.Service.SystemAuth; -using Hh.Mes.Service.WebService.Base; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.Net.Http.Headers; @@ -16,7 +13,6 @@ using System; using System.Linq; using System.Reflection; using System.Text; -using WebMvc.Common; namespace WebMvc { @@ -25,32 +21,20 @@ namespace WebMvc #region 属性 private readonly string _appKey = "hhweb"; private readonly IAuth _authUtil; - private readonly SysCompanyService sysCompanyService; private readonly FaceLoginService faceLoginService; - private readonly SysAppService sysAppService; private readonly LogService logService; #endregion - public LoginController(IAuth authUtil, SysCompanyService sysCompanyService, FaceLoginService faceLoginService, SysAppService sysAppService,LogService logService) + public LoginController(IAuth authUtil, LogService logService, FaceLoginService faceLoginService) { _authUtil = authUtil; - - this.sysCompanyService = sysCompanyService; this.faceLoginService = faceLoginService; - this.sysAppService = sysAppService; this.logService = logService; } public ActionResult Index() { - //var company = sysCompanyService.GetSysCompanyOne(); - //var sysFile = sysCompanyService.GetSysFile(company.companyId); - ViewBag.filePath = sysAppService.Download(); - // ViewBag.ver = company.ver; - //ViewBag.keyStr = JsEncrypt._keyStr; - // ViewBag.Url = sysFile.FirstOrDefault(x => x.position == "home")?.url; ViewBag.copyright = "Copyright © " + DateTime.Now.ToString("yyyy ") + AppSettings.GetAppSeting("copyright"); - return View(); } @@ -77,20 +61,6 @@ namespace WebMvc password = Encryption.Decrypt(faceResult.Result.password); #endregion } - else if (!string.IsNullOrEmpty(webcam)) - { - #region 人脸登入 - Response faceResult = faceLoginService.FaceSearchService(webcam); - if (faceResult.Code == -100 || faceResult.Code == -200) - { - resp.Code = 500; - resp.Message = faceResult.Message; - return JsonHelper.Instance.Serialize(resp); - } - username = faceResult.Result.account; - password = Encryption.Decrypt(faceResult.Result.password); - #endregion - } password = JsEncrypt.DecodeBase64(Encoding.Default, password); var result = _authUtil.Login(_appKey, username, password); if (result.Code == 200) @@ -145,13 +115,13 @@ namespace WebMvc ViewBag.msgInfo = loginResponseResult.Message + "--" + userInfo; return View(); } - var herf= sysCompanyService.GetDictionaryDictValue(MethodBase.GetCurrentMethod().Name); + //var herf= sysCompanyService.GetDictionaryDictValue(MethodBase.GetCurrentMethod().Name); var cookieOptions = new CookieOptions(); Response.Cookies.Append(SSOAuthAttribute.token, loginResponseResult.Token, cookieOptions); //javascript 输出到页面 写入缓存跳转页面 - ViewBag.js = $@"localStorage.setItem('Account', '{loginResponseResult.Result.Account}'); - localStorage.setItem('Name', '{loginResponseResult.Result.Name}') - window.location.href = '{herf}'"; + //ViewBag.js = $@"localStorage.setItem('Account', '{loginResponseResult.Result.Account}'); + // localStorage.setItem('Name', '{loginResponseResult.Result.Name}') + // window.location.href = '{herf}'"; return View(); } diff --git a/web/WebMvc/Views/Login/Index.cshtml b/web/WebMvc/Views/Login/Index.cshtml index 58a724b..7e7d8a5 100644 --- a/web/WebMvc/Views/Login/Index.cshtml +++ b/web/WebMvc/Views/Login/Index.cshtml @@ -1,5 +1,4 @@ @using Hh.Mes.Common.config -@model List<SelectListItem> @{ Layout = null; } @@ -23,19 +22,12 @@ color: black; } - /* .layui-form-select dl dd.layui-select-tips { - color: black; - }*/ </style> </head> <body class="main"> <div id="mainBody"> <div id="cloud1" class="cloud" style="background-position: 891.1px 100px;"></div> <div id="cloud2" class="cloud" style="background-position: 401px 460px;"></div> - <div class="LoginQrCode"> - <h1 style="color:#FFFFFF">PDA 浏览器扫码打开地址</h1> - <img src="~/images/login/LoginQRCode.png" alt="" /> - </div> </div> <div class="logintop"> @@ -44,21 +36,17 @@ </ul> <ul> <li><b><lable style="font-size:30px;color: white;">@ConfigRead.GetInstance.GetAppsetConnection().LoginTitle</lable></b></li> - <li><b><lable style="font-size:30px;color: white;"><a href="@ViewBag.filePath">PDA</a> </lable></b></li> - <li><b><lable style="font-size:30px;color: white;"><a href="~/app/kanbanv1.0.100.apk">看板</a> </lable></b></li> - <li><b><lable style="font-size:30px;color: white;"><a href="https://www.google.cn/chrome/thank-you.html?platform=win64&standalone=1&statcb=0&installdataindex=empty&defaultbrowser=0">Google</a> </lable></b></li> + <li><b><lable style="font-size:30px;color: white;"><a target="_blank" href="https://www.google.cn/chrome/thank-you.html?platform=win64&standalone=1&statcb=0&installdataindex=empty&defaultbrowser=0">Google浏览器下载</a> </lable></b></li> </ul> </div> <div class="loginbody"> <span class="systemlogo"></span> <div class="loginbox" style="position: absolute; left: 40%;top:25%"> - <lable class="ver">@ViewBag.ver</lable> <div class="layui-tab layui-tab-brief" style="margin-top:10px; width:320px" lay-filter="loginWebcam"> <ul class="layui-tab-title"> <li class="layui-this" lay-id="1">默认</li> - <li lay-id="2">人脸识别</li> - <li lay-id="3">刷卡登入</li> + <li lay-id="2">刷卡登入</li> </ul> <div class="layui-tab-content"> <div class="layui-tab-item layui-show"> @@ -71,20 +59,12 @@ <input name="password" type="password" autocomplete="new-password" class="loginpwd ipt" placeholder="请输入密码" lay-verify="required"> </li> <li> - <select name="lineCode" asp-items="@Model"></select> - </li> - <li> <button class="layui-btn loginbtn" style="width: 105px; margin-top: 30px" lay-submit lay-filter="login">登录</button> </li> </ul> </form> </div> <div class="layui-tab-item"> - <div id="webcam"></div> - <button class="layui-btn loginbtn" style="width: 105px; margin-top: 10px" id="btnTakeSnapshot">拍照登入</button> - </div> - <div id="ccvMessage" style="color: #009688;margin-top: 7px;"> </div> - <div class="layui-tab-item"> <form><input id="IdCard" name="IdCard" type="password" autocomplete="off" class="loginpwd ipt" placeholder="请输入卡号" lay-verify="required"> </form> </div> </div> @@ -96,9 +76,6 @@ <div class="loginbm">@ViewBag.copyright</div> <script type="text/javascript" src="/layui/layui.js"></script> - <script src="~/js/face/webcam.js"></script> - <script src="~/js/face/ccv.js"></script> - <script src="~/js/face/face.js"></script> <script src="~/baseJs/JsEncrypt.js"></script> <script type="text/javascript" src="/basejs/login.js" asp-append-version="true"></script> </body> diff --git a/web/WebMvc/wwwroot/baseJs/login.js b/web/WebMvc/wwwroot/baseJs/login.js index 28ee879..1097529 100644 --- a/web/WebMvc/wwwroot/baseJs/login.js +++ b/web/WebMvc/wwwroot/baseJs/login.js @@ -1,32 +1,11 @@ var layer = null, $ = null, IdCard = document.getElementById("IdCard"), - canvas=document.createElement("canvas"), - btnTakeSnapshot = document.getElementById("btnTakeSnapshot"), - isSendFlag = false, - tabIndex=0, - WebcamObj = null; + tabIndex=0; var login = { - initWebCam: () => { - Webcam.set({ - width: 320, - height: 240, - image_format: "jpeg", - jpeg_quality: 90 - }); - Webcam.attach("#webcam"); - WebcamObj = true; - }, - - //销毁摄像头 - cancalCloseVideo: () => { - Webcam.reset("#webcam"); - Webcam.reset(); - }, //登入方法 LoginMethod: (bodyValue) => { - isSendFlag = true; var index = 0; if (tabIndex != 1) index = layer.load(); @@ -39,7 +18,6 @@ var login = { }).then(function (res) { return res.json(); }).then(function (data) { - isSendFlag = false; if (data.Code === 200) { layer.msg(data.Result.Account + " " + data.Result.Name, { icon: 6, shade: 0.4, time: 10000 }); localStorage.setItem("Account", data.Result.Account); @@ -52,63 +30,15 @@ var login = { } layer.close(index); }).catch(function (error) { - isSendFlag = false; if (layer != null) document.getElementById("loginMessage").innerHTML = "登入失败"; }); }, - //自动刷脸登入 - initWebcamLogin: () => { - setInterval(() => { - if (WebcamObj == null) return; - if (isSendFlag) { - console.log("请求中 "); - return; - }; - if (tabIndex != 1) return; - var v = document.querySelector('#webcam video'); - if (v == null) return; - var ctx = canvas.getContext('2d'); - var height = v.videoHeight; - var width = v.videoWidth; - if (height == 0 || width == 0) return; - canvas.height = height; - canvas.width = width; - ctx.drawImage(v, 0, 0, width, height); - - var comp = ccv.detect_objects({ - "canvas": ccv.grayscale(ccv.pre(canvas)), - "cascade": cascade, - "interval": 5, - "min_neighbors": 1 - }); - if (comp.length > 0) { - btnTakeSnapshot.click(); - } - document.getElementById("ccvMessage").innerHTML = "检测图片结果: " + (comp.length ? '有人脸' : "没人脸"); - }, 1500); - }, //注册事件 initEvents: () => { //刷卡登入 IdCard.addEventListener('input', debounce(handle, 500)); - - //拍照 - btnTakeSnapshot.addEventListener("click", function () { - if (WebcamObj == null) { - alert("请等待摄像启动完成后再拍照登入"); - return; - } - Webcam.snap(function (data_uri) { - if (data_uri == null) { - alert("请等待摄像启动完成后再拍照登入"); - return; - } - var value = `username=''&password=''&webcam=${data_uri}&idcard=`; - login.LoginMethod(value); - }); - }); } } var isChrome = window.navigator.userAgent.indexOf("Chrome") > -1; @@ -116,7 +46,6 @@ if (!isChrome) { alert("推荐使用谷歌浏览器登录使用,以免产生浏览器不兼容出现的错误"); } login.initEvents(); -login.initWebcamLogin(); // 防抖 function debounce(fn, delay) { @@ -147,20 +76,12 @@ layui.config({ base: "/js/" }).use(["form", "layer", "element"], function () { element.on("tab(loginWebcam)", function (data) { tabIndex = data.index; if (data.index===1) { - login.initWebCam(); - } else if (data.index === 2) { IdCard.focus(); } else { document.getElementById("loginMessage").innerHTML = ""; } }); - localStorage.setItem("sysWhereLineSelect","all"); - form.on("select", function (data) { - localStorage.setItem("sysWhereLineSelect", data.value); - }); - - //登录按钮事件 form.on("submit(login)", function (data) { diff --git a/web/WebMvc/wwwroot/css/login.css b/web/WebMvc/wwwroot/css/login.css index 9586f7c..5f48b64 100644 --- a/web/WebMvc/wwwroot/css/login.css +++ b/web/WebMvc/wwwroot/css/login.css @@ -35,7 +35,6 @@ h2{font-weight:normal;} .loginbody{ width:80%; height:600px; overflow:hidden; position:fixed;left:20%;top:10%;} .systemlogo{background:url(/images/login/logo.png) no-repeat center;width:100%; height:70px; margin-top:40px;} .loginbox{width:400px; height:330px; margin-top:10px;margin-left:10%;background:rgba(255,255,255,0.03);border-radius:30px;} -.ver {font-size: 20px;} .loginbox ul li {margin-bottom: 25px;} .loginbox ul li label{color:#687f92; padding-left:25px;} .loginbox ul li label a{color:#687f92;} @@ -77,17 +76,3 @@ h2{font-weight:normal;} font-family: "Helvetica Neue","Hiragino Sans GB","Microsoft YaHei","\9ED1\4F53",Arial,sans-serif;color:#DDD;font-size: 12px; } .loginbox {color: #fff;} - -.LoginQrCode {display: none} - -/*手机*/ -@media screen and (max-width:600px) { - .loginbody { - display: none - } - - .LoginQrCode { - display: block; - padding-top: 200px; - } -} \ No newline at end of file -- libgit2 0.22.2