Commit f6fc6e4e247bffde6dc7541bced4cf330c9d3538
1 parent
1694089d
首页登录代码还原
Showing
1 changed file
with
95 additions
and
10 deletions
WebRoot/WEB-INF/jsp/system/index/login.jsp
| ... | ... | @@ -61,11 +61,25 @@ |
| 61 | 61 | </div> |
| 62 | 62 | <div class="content_b"> |
| 63 | 63 | <div class="form_box"> |
| 64 | - <form action="" method="post" name="loginbox" id="loginbox"> | |
| 65 | - <input type="text" name="loginname" id="loginname" value="" | |
| 66 | - placeholder="用户名" autocomplete = "off"/> <input type="password" name="password" | |
| 67 | - id="password" placeholder="密 码" value="" autocomplete = "off"/> <a href="#" | |
| 68 | - onclick="severCheck();" class="login_btn">登录</a> | |
| 64 | + <form action="" method="post" name="loginbox" id="loginbox" > | |
| 65 | + <div class="name_box"> | |
| 66 | + <input type="text" name="loginname" id="loginname" value="" placeholder="用户名" autoComplete="off"/> | |
| 67 | + <svg t="1554790328236" class="icon_down" style="" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2161" xmlns:xlink="http://www.w3.org/1999/xlink" width="32" height="32"><defs><style type="text/css"></style></defs><path d="M863.321996 251.674996 194.108395 251.674996 528.677333 621.186771Z" p-id="2162" fill="#333333"></path></svg> | |
| 68 | + </div> | |
| 69 | + <div class="psw_box"> | |
| 70 | + <input type="password" name="password" id="password" placeholder="密 码" value="" autoComplete="off"/> | |
| 71 | + <div class="rember"> | |
| 72 | + <input type="checkbox" id="rem_flag"/> | |
| 73 | + <span>记住密码</span> | |
| 74 | + </div> | |
| 75 | + </div> | |
| 76 | + <a href="#" onclick="severCheck();" class="login_btn">登录</a> | |
| 77 | + | |
| 78 | + <div class="history"> | |
| 79 | + <ul> | |
| 80 | + | |
| 81 | + </ul> | |
| 82 | + </div> | |
| 69 | 83 | </form> |
| 70 | 84 | |
| 71 | 85 | </div> |
| ... | ... | @@ -87,6 +101,33 @@ |
| 87 | 101 | severCheck(); |
| 88 | 102 | } |
| 89 | 103 | } |
| 104 | + | |
| 105 | + $(".icon_down").click(function(){ | |
| 106 | + $("#loginname").focus(); | |
| 107 | + | |
| 108 | + }); | |
| 109 | + $("#loginname").focus(function(){ | |
| 110 | + var _html=""; | |
| 111 | + var u_list=JSON.parse(storage.getItem('userNameList')); | |
| 112 | + for(var i=0;i<u_list.length;i++){ | |
| 113 | + _html+='<li>'+u_list[i]+'</li>'; | |
| 114 | + } | |
| 115 | + $(".history ul").html(_html); | |
| 116 | + $(".history").toggle(); | |
| 117 | + }); | |
| 118 | + | |
| 119 | + | |
| 120 | + $(document).on('hover','.history li',function(){ | |
| 121 | + var p_list=JSON.parse(storage.getItem('passWordList')); | |
| 122 | + $("#loginname").val($(this).text()); | |
| 123 | + $("#password").val(p_list[$(this).index()]); | |
| 124 | + //$(".history").hide(); | |
| 125 | + }) | |
| 126 | + $("#loginname").blur(function(){ | |
| 127 | + $(".history").hide(); | |
| 128 | + }) | |
| 129 | + | |
| 130 | + | |
| 90 | 131 | //客户端校验 |
| 91 | 132 | function check() { |
| 92 | 133 | |
| ... | ... | @@ -139,7 +180,8 @@ |
| 139 | 180 | cache: false, |
| 140 | 181 | success: function(data){ |
| 141 | 182 | if("success" == data.result){ |
| 142 | - saveCookie(); | |
| 183 | + if($("#rem_flag").prop("checked")) //如果选择了记住密码 | |
| 184 | + saveCookie(); | |
| 143 | 185 | if(data.teacher != null){ |
| 144 | 186 | window.location.href="main/teacher"; |
| 145 | 187 | }else if(data.admin != null){ |
| ... | ... | @@ -180,15 +222,58 @@ |
| 180 | 222 | } |
| 181 | 223 | } |
| 182 | 224 | |
| 225 | + var storage=window.localStorage; | |
| 226 | + var userNameList=[]; | |
| 227 | + var passWordList=[]; | |
| 228 | + | |
| 229 | + //console.log(JSON.parse(storage.getItem('userNameList'))); | |
| 230 | + | |
| 183 | 231 | function saveCookie() { |
| 184 | - if ($("#saveid").attr("checked")) { | |
| 185 | - $.cookie('loginname', $("#loginname").val(), { | |
| 232 | + if(!window.localStorage){ | |
| 233 | + alert("浏览器不支持localstorage"); | |
| 234 | + | |
| 235 | + }else{ | |
| 236 | + //主逻辑业务 | |
| 237 | + | |
| 238 | + userNameList=JSON.parse(storage.getItem('userNameList')); | |
| 239 | + passWordList=JSON.parse(storage.getItem('passWordList')); | |
| 240 | + | |
| 241 | + | |
| 242 | + if(userNameList==null){ | |
| 243 | + var userNameList=[]; | |
| 244 | + var passWordList=[]; | |
| 245 | + userNameList.push($("#loginname").val()); | |
| 246 | + passWordList.push($("#password").val()); | |
| 247 | + | |
| 248 | + storage.setItem('userNameList',JSON.stringify(userNameList)); | |
| 249 | + storage.setItem('passWordList',JSON.stringify(passWordList)); | |
| 250 | + }else{ | |
| 251 | + | |
| 252 | + if(userNameList.indexOf($("#loginname").val())>-1){ | |
| 253 | + return false; | |
| 254 | + }else{ | |
| 255 | + userNameList.push($("#loginname").val()); | |
| 256 | + passWordList.push($("#password").val()); | |
| 257 | + storage.setItem('userNameList',JSON.stringify(userNameList)); | |
| 258 | + storage.setItem('passWordList',JSON.stringify(passWordList)); | |
| 259 | + } | |
| 260 | + } | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + //console.log(userNameList); | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + } | |
| 269 | + | |
| 270 | + /*$.cookie('loginname', $("#loginname").val(), { | |
| 186 | 271 | expires : 7 |
| 187 | 272 | }); |
| 188 | 273 | $.cookie('password', $("#password").val(), { |
| 189 | 274 | expires : 7 |
| 190 | - }); | |
| 191 | - } | |
| 275 | + });*/ | |
| 276 | + | |
| 192 | 277 | } |
| 193 | 278 | </script> |
| 194 | 279 | <script type="text/javascript" | ... | ... |