document.onkeydown = function(e) { e = e || window.event; if (e.keyCode == 13) { $('#forgetpwd_button').trigger('click'); } }; $(function(){ $('#messagetab').css("display","block"); $('#problemtab').css("display","none"); $('#messageDiv').css('background-color','rgb(5, 114, 206)'); $('#aa1').css("color","white"); $('#problemDiv').css('background',''); $('#problemDiv').click(function(){ $('#messagetab').css("display","none"); $('#problemtab').css("display","block"); $('#messageDiv').css('background',''); $('#problemDiv').css('background-color','rgb(5, 114, 206)'); $('#aa2').css("color","white"); $('#aa1').css("color",""); }); $('#messageDiv').click(function(){ $('#messagetab').css("display","block"); $('#problemtab').css("display","none"); $('#messageDiv').css('background-color','rgb(5, 114, 206)'); $('#aa1').css("color","white"); $('#aa2').css("color",""); $('#problemDiv').css('background',''); }); $("#account").focus(); $("#msg").html(""); $('#account').focus(function() { $("#msg").html(""); }); $('#forgetpwd_button').click(function(){ var uid=$.trim($("#uid").val()); var mobile=$.trim($("#mobile").val()); var code =$.trim($("#code").val()); var account=$.trim($("#account").val()); if(account.length==0 ||account==""){ $("#msg").html("请输入用户名!"); return false; }else if(code.length==0 || code==""){ $("#msg").html("请输入验证码!"); return false; }else{ $("#msg").html(""); $("#forgetpwd_button").attr({disabled: "disabled"}); $("#forgetpwd_button").val("正在提交..."); $("#forgetpwd_button").removeClass(); $("#forgetpwd_button").attr("class","forgetpwd_button_on"); $.ajax({ url : '/yilisso/forgetpwd.do', data : { account:account, uid:uid, mobile:mobile, code:code }, type : 'post', dataType : 'text', async : true, success : function(data){ if (data == "Success") { $("#forgetpwd_button").val("已 提 交"); $("#forgetpwd_button").removeClass(); $("#forgetpwd_button").attr("class", "forgetpwd_button"); $("#msg").attr("class", "msg_success"); $("#msg").html("密码重置成功,新密码已发送至您的手机!"); var sign = ''; //--------------------------------------------------------- $.ajax({ type: 'GET', url: '/yiliewxsso/KickUser.do?account='+account+'&sign='+sign, data: {}, async: false, success: function (data) { window.close(); }, error: function (XmlHttpRequest, textStatus, errorThrown) { return false; } }); //========================================================= }else { $("#forgetpwd_button").val("提 交"); $("#forgetpwd_button").removeClass(); $("#forgetpwd_button").attr("class", "forgetpwd_button"); $("#forgetpwd_button").removeAttr("disabled"); if(data=="None"){ $("#msg").html('用户不存在!'); return false; }else if(data=="Disabled"){ $("#msg").html('用户已禁用!'); return false; }else if(data=="Notequal"){ $("#msg").html('请重新获取验证码!'); return false; }else if(data=="Wrong"){ $("#msg").html("验证码错误!"); return false; }else if(data=="Expire"){ $("#msg").html("验证码失效!"); return false; }else{ $("#msg").html("重置密码出错!"); return false; } } }, error : function() { $("#msg").html("系统异常!"); return false; } }); } }); }); function sendBtn(){ var account=$.trim($("#account").val()); if(account.length==0 || account==""){ $("#msg").html("请输入用户名!"); }else{ sendCode(); } } function sendCode() { var account = $('#account').val(); //将按钮禁用 $("#sendBt").attr({disabled: "disabled"}); $.ajax({ url : '/yilisso/sendcode.do', data : { account:account }, type : 'post', dataType : 'json', async : true, success : function(data){ if (data.result=="Success") { $("#mobile").val(data.mobile); $("#uid").val(data.uid); var time=60; var hander = setInterval(function () { if (time <= 0) { clearInterval(hander); $('#sendBt').val('重新获取'); $("#sendBt").removeClass(); $("#sendBt").attr("class","sendBt"); $('#sendBt').removeAttr('disabled'); }else { time=time-1; $("#sendBt").removeClass(); $("#sendBt").attr("class","sendBt_on"); $('#sendBt').val('重新获取('+time+')'); } }, 1000); //手机号加密 var mb=$('#mobile').val(); if (mb.length >= 7) { var secret = mb.substr(3, 4); mb = mb.replace(secret, "****"); } $("#msg").html("已向您系统中登记的手机号码"+mb+"发送验证码!"); }else{ $('#sendBt').val('获取验证码'); $("#sendBt").removeClass(); $("#sendBt").attr("class","sendBt"); $('#sendBt').removeAttr('disabled'); if(data.result=="None"){ $("#msg").html('用户不存在!'); return false; }else if(data.result=="Disabled"){ $("#msg").html('用户已禁用!'); return false; }else if(data.result=="Locked"){ $("#msg").html('用户已锁定!'); return false; }else if(data.result=="Lack"){ $("#msg").html('用户未录入手机号!'); return false; }else if(data.result="Error"){ $("#msg").html('发送失败!'); return false; } } }, error : function() { $("#msg").html('发送异常!'); } }); } //$(function(){ // $('#messagetab').css("display","block"); // $('#problemtab').css("display","none"); // $('#messageBtn').css('background','#1E90FF'); // $('#problemBtn').css('background',''); //}); function messagetab(){ $('#messagetab').css("display","block"); $('#problemtab').css("display","none"); $('#messageDiv').css('background-color','rgb(5, 114, 206)'); $('#aa1').css("color","white"); $('#aa2').css("color",""); $('#problemDiv').css('background',''); } function problemtab(){ $('#messagetab').css("display","none"); $('#problemtab').css("display","block"); $('#messageDiv').css('background',''); $('#problemDiv').css('background','rgb(5, 114, 206)'); $('#aa2').css("color","white"); $('#aa1').css("color",""); } function verificateAccount(){ $('#accountP').focus(function(){ $("#msg3").html(""); }); var account = $.trim($("#accountP").val()); if(account == "" || account.length == 0){ $('#msg3').html("请输入用户名!"); return false; } $.ajax({ url:'/yilisso/verificateAccount.do', data:{ account:account }, type:'post', dataType:'json', async:true, success:function(data){ if(data.result=="Success"){ $("#select_text1").html(data.q1); $("#select_text2").html(data.q2); $("#select_text3").html(data.q3); $("#firstDiv").css("display","none"); $("#secondDiv").css("display","block"); $("#thirdDiv").css("display","none"); }else if(data.result=="None"){ $("#msg3").html('用户不存在!'); return false; }else if(data.result=='Disabled'){ $("#msg3").html('用户已禁用!'); return false; }else if(data.result=='Fail'){ $("#msg3").html('该用户没有设置过密保!'); return false; }else{ $("#msg3").html('用户查询失败,请重试!'); return false; } }, error:function(){ $("#msg3").html('用户查询异常,稍后再试!'); return false; } }); } function verificateProblem(){ var name = $.trim($('#accountP').val()); $('#text1').focus(function(){ $("#msg2").html(""); }); $('#text2').focus(function(){ $("#msg2").html(""); }); $('#text3').focus(function(){ $("#msg2").html(""); }); var text1 = $.trim($('#text1').val()); var text2 = $.trim($('#text2').val()); var text3 = $.trim($('#text3').val()); if(text1.length == 0 || text1 == ""){ $('#msg2').html("请输入问题1的答案!"); return false; } if(text2.length == 0 || text2 == ""){ $('#msg2').html("请输入问题2的答案!"); return false; } if(text3.length == 0 || text3 == ""){ $('#msg2').html("请输入问题3的答案!"); return false; } $.ajax({ url:'/yilisso/validateQuestion.do', data:{ name:name, answerText1:text1, answerText2:text2, answerText3:text3 }, type:'post', dataType:'text', async:true, success:function(data){ if(data == "None"){ ("#msg2").html("请返回第一步!"); return false; } if(data == "error1" || data=="error1error2" || data=="error1error2error3"){ $("#msg2").html("问题一的答案不正确!"); return false; } if(data == "error2" || data == "error2error3"){ $("#msg2").html("问题二的答案不正确!"); return false; } if(data == "error3"){ $("#msg2").html("问题三的答案不正确!"); return false; } $("#firstDiv").css("display","none"); $("#secondDiv").css("display","none"); $("#thirdDiv").css("display","block"); }, error:function(){ $("#msg2").html("查询用户出错!"); return false; } }); } function btnFunc(){ $('#pwd1').focus(function(){ $("#msg1").html(""); }); $('#pwd2').focus(function(){ $("#msg1").html(""); }); var accountP = $.trim($("#accountP").val()); var pwd1 = $.trim($("#pwd1").val()); var pwd2 = $.trim($("#pwd2").val()); if(pwd1.length==0 || pwd1==""){ $("#msg1").html("请输入新密码!"); return false; }else if(pwd2.length==0 || pwd2==""){ $("#msg1").html("请再次输入新密码!"); return false; }else if(pwd1 != pwd2){ $("#msg1").html("两次输入的密码不一致!"); return false; }else if(!checkNewPwd(pwd1)){ $("#msg1").html("新密码至少8位,必须包含字母,数字,符号!"); return false; }else{ $("#newPwdBtn").val("正在提交......"); $("#newPwdBtn").attr('disabled',true); $.ajax({ url:'/yilisso/foundPassword.do', data:{ newpwd:pwd1, accountP:accountP }, type:'post', dataType:'text', async:true, success:function(data){ if(data=="Success"){ $("#newPwdBtn").val("已 提 交"); $("#msg1").html("密码重置成功!"); $("#msg1").css("color","green"); $("#newPwdBtn").attr('disabled',true); //--------------------------------------------------------- var sign=''; $.ajax({ type: 'GET', url: '/yiliewxsso/KickUser.do?account='+accountP+'&sign='+sign, data: {}, async: false, success: function (data) { window.close(); }, error: function (XmlHttpRequest, textStatus, errorThrown) { return false; } }); //========================================================= }else{ $("#newPwdBtn").attr('disabled',false); $("#newPwdBtn").val("提 交"); if(data=="Error"){ $("#msg1").html("新密码与上次密码相同,请重新设置!"); return false; }else if(data="Notequal"){ $("#msg1").html("请返回第一步!"); return false; }; }; }, error:function(){ $("#msg1").html("密码设置异常,请稍后再试!"); return false; } }); } //密码必须包含数字,大写字母,小写字母,特殊字符 //var regex = new RegExp('^(?![a-zA-Z]+$)(?![A-Z0-9]+$)(?![A-Z\W_!@#$%^&*`~()-+=]+$)(?![a-z0-9]+$)(?![a-z\W_!@#$%^&*`~()-+=]+$)(?![0-9\W_!@#$%^&*`~()-+=]+$)[a-zA-Z0-9\W_!@#$%^&*`~()-+=]{8,30}$'); //var regex = new RegExp('^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$%^&*-]).{8,30}$'); } function checkNewPwd(value) { var flag = true; var upper = new RegExp(/[A-Z]/); var lower = new RegExp(/[a-z]/); var number = new RegExp(/\d/); var sign = new RegExp(/\W/); var sign1 = new RegExp(/\_/); var length = value.length; if (length < 8) { flag = false; return flag; } if (!(upper.test(value) || lower.test(value))) { flag = false; return flag; } if (!number.test(value)) { flag = false; return flag; } if (!(sign.test(value)||sign1.test(value))) { flag = false; return flag; } return flag; } function lastStep(){ $("#firstDiv").css("display","block"); $("#secondDiv").css("display","none"); $("#thirdDiv").css("display","none"); }