Commit 2a880654d281ed414edada48232176bd76a8d543

Authored by jack
1 parent 05dfd5ca

1、登录界面添加记住密码功能

WebRoot/WEB-INF/jsp/sunvote/homework/homework_report.jsp
@@ -64,7 +64,7 @@ @@ -64,7 +64,7 @@
64 <td><div style="width:150px;text-align:center;">课程统计: ${fn:length(var.HOMEWORKS)}</div></td> 64 <td><div style="width:150px;text-align:center;">课程统计: ${fn:length(var.HOMEWORKS)}</div></td>
65 <td><div style="width:150px;text-align:center;">班级名册: ${var.CLASS_NAME}</div></td> 65 <td><div style="width:150px;text-align:center;">班级名册: ${var.CLASS_NAME}</div></td>
66 66
67 - <td><div style="width:150px;text-align:center;"><span>学生人数: ${INDE.STUDENT_NUM}</span></div></td> 67 + <td><div style="width:150px;text-align:center;"><span>学生人数: ${var.STUDENT_NUM}</span></div></td>
68 <td></td> 68 <td></td>
69 69
70 70
@@ -125,22 +125,20 @@ @@ -125,22 +125,20 @@
125 <td class="center"><div style="width:150px;"></div></td> 125 <td class="center"><div style="width:150px;"></div></td>
126 <td class="center"><div style="width:80px;"></div></td> 126 <td class="center"><div style="width:80px;"></div></td>
127 <c:forEach items="${var.HOMEWORKS}" var="var_h" varStatus="vs"> 127 <c:forEach items="${var.HOMEWORKS}" var="var_h" varStatus="vs">
128 - <td class="center"><div style="width:80px;margin:0 auto;">${var.AVG_SCORE}</div></td> 128 + <td class="center"><div style="width:80px;margin:0 auto;">${var_h.GET_SCORE}</div></td>
129 </c:forEach> 129 </c:forEach>
130 </tr> 130 </tr>
131 <tr> 131 <tr>
132 <td class="center"><div style="width:150px;">班级课程平均得分率</div></td> 132 <td class="center"><div style="width:150px;">班级课程平均得分率</div></td>
133 <td class="center"><div style="width:150px;"></div></td> 133 <td class="center"><div style="width:150px;"></div></td>
134 <td class="center"><div style="width:80px;"></div></td> 134 <td class="center"><div style="width:80px;"></div></td>
135 - <c:forEach items="${testpaperList}" var="var" varStatus="vs">  
136 - <td class="center"><div style="width:80px;margin:0 auto;"><fmt:formatNumber type="number"  
137 - value="${var.TOTAL_SCORE == 0 ? 0: (var.AVG_SCORE / var.TOTAL_SCORE * 100)}"  
138 - maxFractionDigits="2" />%</div></td> 135 + <c:forEach items="${var.HOMEWORKS}" var="var_h" varStatus="vs">
  136 + <td class="center"><div style="width:80px;margin:0 auto;">${var_h.GET_SCORE_PERSENT }</div></td>
139 </c:forEach> 137 </c:forEach>
140 </tr> 138 </tr>
141 139
142 <c:choose> 140 <c:choose>
143 - <c:when test="${not empty studentList}"> 141 + <c:when test="${not empty $var.HOMEWORKS}">
144 <c:forEach items="${studentList}" var="var" varStatus="vs"> 142 <c:forEach items="${studentList}" var="var" varStatus="vs">
145 <tr> 143 <tr>
146 <%-- <td class="center"><a 144 <%-- <td class="center"><a
WebRoot/WEB-INF/jsp/system/index/login.jsp
@@ -61,11 +61,25 @@ @@ -61,11 +61,25 @@
61 </div> 61 </div>
62 <div class="content_b"> 62 <div class="content_b">
63 <div class="form_box"> 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="用户名" /> <input type="password" name="password"  
67 - id="password" placeholder="密 码" value="" /> <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 </form> 83 </form>
70 84
71 </div> 85 </div>
@@ -87,6 +101,33 @@ @@ -87,6 +101,33 @@
87 severCheck(); 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 function check() { 132 function check() {
92 133
@@ -139,7 +180,8 @@ @@ -139,7 +180,8 @@
139 cache: false, 180 cache: false,
140 success: function(data){ 181 success: function(data){
141 if("success" == data.result){ 182 if("success" == data.result){
142 - saveCookie(); 183 + if($("#rem_flag").prop("checked")) //如果选择了记住密码
  184 + saveCookie();
143 if(data.teacher != null){ 185 if(data.teacher != null){
144 window.location.href="main/teacher"; 186 window.location.href="main/teacher";
145 }else if(data.admin != null){ 187 }else if(data.admin != null){
@@ -180,15 +222,58 @@ @@ -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 function saveCookie() { 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 expires : 7 271 expires : 7
187 }); 272 });
188 $.cookie('password', $("#password").val(), { 273 $.cookie('password', $("#password").val(), {
189 expires : 7 274 expires : 7
190 - });  
191 - } 275 + });*/
  276 +
192 } 277 }
193 </script> 278 </script>
194 <script type="text/javascript" 279 <script type="text/javascript"
WebRoot/static/login/style_login.css
@@ -22,7 +22,17 @@ color: #666666; @@ -22,7 +22,17 @@ color: #666666;
22 .content{width:100%;height:100%;} 22 .content{width:100%;height:100%;}
23 .content_t{background:#01a5a6;height:40%;position:relative;} 23 .content_t{background:#01a5a6;height:40%;position:relative;}
24 .content_t img{position:absolute;bottom:0;width:30%;left:35%;display:block;} 24 .content_t img{position:absolute;bottom:0;width:30%;left:35%;display:block;}
25 -.content_b .form_box{width:25%;margin:0 auto;margin-top:3%;} 25 +.content_b .form_box {width:25%;margin:0 auto;margin-top:3%;}
  26 +.content_b .form_box #loginbox{position:relative;}
  27 +.content_b .form_box .name_box{position:relative;}
  28 +.content_b .form_box .icon_down{position:absolute;right:10px;top:9px;width:20px;}
26 .content_b input{display:block;width:100%;height:50px;background:#f2f2f2;border:1px solid #cccccc;line-height:50px;box-sizing:border-box;padding:0 12px;outline-style:none;font-size:20px;} 29 .content_b input{display:block;width:100%;height:50px;background:#f2f2f2;border:1px solid #cccccc;line-height:50px;box-sizing:border-box;padding:0 12px;outline-style:none;font-size:20px;}
27 .content_b input:nth-child(2){margin-top:15px;} 30 .content_b input:nth-child(2){margin-top:15px;}
28 .content_b .login_btn{display:block;width:100%;background:#13b5b1;color:#fff;font-size:24px;text-align:center;padding:2% 0;margin-top:10%;text-decoration:none;} 31 .content_b .login_btn{display:block;width:100%;background:#13b5b1;color:#fff;font-size:24px;text-align:center;padding:2% 0;margin-top:10%;text-decoration:none;}
  32 +.history{width:100%;position:absolute;top:50px;height:auto;max-height:240px;background:#fff;overflow:auto;border:1px solid #ccc;display:none;}
  33 +.history ul{padding:0;margin:0;}
  34 +.history li{height:40px;border-bottom:1px solid #ccc;list-style:none;line-height:40px;padding:0 12px;font-size:20px;}
  35 +.history li:hover{background:#ccc;}
  36 +.rember{text-align:right;}
  37 +.rember input{width:16px;height:16px;display:inline;vertical-align:middle;margin:0;}
  38 +.rember span{vertical-align:middle;}
29 \ No newline at end of file 39 \ No newline at end of file