//处理IE7/8不支持trim方法 String.prototype.trim = function () { return this .replace(/^\s\s*/, '' ).replace(/\s\s*$/, '' ); } document.onkeydown = function(e) { e=e||window.event; if (e.keyCode == 13) { validate(); } } $(function() { $('#select_id').focus(function() { $('#s1').hide(); $('#s2').hide(); }); $('#select_id').blur(function() { var account=$('#select_id').val().trim(); if(select_id==null||select_id==''){ $('#s1').hide(); $('#s2').html('选项不能为空'); $('#s2').show(); } }); $('#account').focus(function() { $('#s3').hide(); $('#s4').hide(); }); $('#account').blur(function() { var idcard=$('#account').val().trim(); if(idcard==null||idcard==''){ $('#s3').hide(); $('#s4').html('输入账号不能为空'); $('#s4').show(); } /*else if (!(/^(\d{14}|\d{17})(\d|[xX])$/.test(idcard))) { $('#s3').hide(); $('#s4').html('身份证格式不正确'); $('#s4').show(); }*/ }); $('#mobile_input').focus(function() { $('#s5').hide(); $('#s6').hide(); }); $('#mobile_input').blur(function() { var mobile_input=$('#mobile_input').val().trim(); if(mobile_input==null||mobile_input==''){ $('#s5').hide(); $('#s6').html('手机号码不能为空'); $('#s6').show(); } }); }); function sendBtn() { var account=$('#select_id').val().trim(); if(account==null||account==''){ $('#s1').hide(); $('#s2').html('用户名不能为空'); $('#s2').show(); }else{ var idcard=$('#account').val().trim(); var mobile_input=$('#mobile_input').val().trim(); if(idcard==null||idcard==''){ $('#s3').hide(); $('#s4').html('账号不能为空'); $('#s4').show(); }else if(mobile_input==null||mobile_input==''){ $('#s5').hide(); $('#s6').html('手机号码不能为空'); $('#s6').show(); /*else if (!(/^(\d{14}|\d{17})(\d|[xX])$/.test(idcard))) { $('#s3').hide(); $('#s4').html('身份证格式不正确'); $('#s4').show(); }*/ }else{ //先根据用户名和身份证查出用户手机号,第二步才发送 getMobile(); // var mobile = $('#mobile').val(); // if (mobile != null && mobile != "") { // sendMessage();//发送短信 // }else{ // $('#sendBt').removeAttr('disabled'); // } } } } function getMobile() { var account = $('#account').val(); var select_id = $('#select_id').val(); var mobile_input = $('#mobile_input').val(); $('#sendBt').attr('disabled',true); var aj = $.ajax( { url : 'getPhone.do', data : { account : encodeURI(account), select_id : encodeURI(select_id), mobile_input : encodeURI(mobile_input) }, type : 'post', cache : false, dataType : 'json', async : false, success : function(data) { if (data.result == "success") { $('#mobile').val(data.mobile); // $('#lastname').val(data.lastname); $('#usr_login').val(data.account); var time=60; var hander = setInterval(function () { if (time <= 0) { clearInterval(hander); $('#sendBt').val('重新获取'); $('#sendBt').removeAttr('disabled'); //$('#sendText').html(''); }else{ time=time-1; $('#sendBt').val('重新获取('+time+')'); //$('#sendText').html(time + "秒后可重新获取"); } }, 1000); //手机号加密 var mb=$('#mobile').val(); var usr_login =$('#usr_login').val(); $("#dialog").html("已向您系统中登记的手机号码"+mb+"发送验证码,您的账号为"+usr_login+"。"); } else { if(data.result=="lack mobile"){ $("#dialog").html('未登记手机号'); $('#sendBt').removeAttr('disabled'); }else if(data.result=="mul_emp_error"){ $("#dialog").html('您的员工编号信息异常,请联系IT服务台:021-22331777!'); $('#sendBt').removeAttr('disabled'); }else if(data.result=="mul_ino_error"){ $("#dialog").html('您的身份证信息异常,请联系IT服务台:021-22331777!'); $('#sendBt').removeAttr('disabled'); }else if(data.result=="mul_fly_error"){ $("#dialog").html('您的飞行网账号信息异常,请联系IT服务台!'); $('#sendBt').removeAttr('disabled'); }else if(data.result=="error"){ $("#dialog").html('发送失败,请尝试重新发送。'); $('#sendBt').removeAttr('disabled'); }else{ $("#dialog").html('验证码发送失败,请检查当前输入的账号(或工号、身份证号)与手机号是否正确!
如有问题请联系IT服务台:021-22331777'); $('#sendBt').removeAttr('disabled'); } } }, error : function() { $("#dialog").html('发送失败'); $('#sendBt').removeAttr('disabled'); } }); } //function sendMessage() { // var lastname = $('#lastname').val(); // var usr_login = $('#usr_login').val(); // var account1 = $('#account').val(); // $('#sendTd').html(''); // $('#sendBt').attr('disabled',true); // $('#account').attr("disabled",true); // var aj = $.ajax( { // url : 'sendCode.do',// 跳转到 action // data : { // lastname : encodeURI(lastname), // account : encodeURI(usr_login), // account1 : encodeURI(account1) // }, // type : 'post', // cache : false, // dataType : 'json', // success : function(data) { // if (data.result == "success") { // var time=60; // var hander = setInterval(function () { // if (time <= 0) { // clearInterval(hander); // $('#sendBt').val('重新获取'); // $('#sendBt').removeAttr('disabled'); // //$('#sendText').html(''); // } // else { // time=time-1; // $('#sendBt').val('重新获取('+time+')'); // //$('#sendText').html(time + "秒后可重新获取"); // } // }, 1000); // //手机号加密 // var mb=$('#mobile').val(); // if (mb.length >= 7) { // var secret = mb.substr(3, 4); // mb = mb.replace(secret, "****"); // } // $("#dialog").html("已向您系统中登记的手机号码"+mb+"发送验证码,您的账号为"+usr_login+"。"); // } else { // $('#sendBt').removeAttr('disabled'); // ("#dialog").html("发送失败,请尝试重新发送。"); // } //}, //error : function() { // $('#sendBt').removeAttr('disabled'); // $("#dialog").html("发送失败,请尝试重新发送。"); //} // }); //} function validate() { var account = $('#account').val(); var mobile_input = $('#mobile_input').val(); var confirm = $('#confirm').val(); if(account==null|account==''){ $("#dialog").html("账号不能为空"); return; }else if(mobile_input==null|mobile_input==''){ $("#dialog").html("手机号码不能为空"); return; }else if(confirm==null||confirm==''){ $("#dialog").html("请先获取并填写验证码"); return; } $("#dialog").html("正在验证,请稍后..."); var val_account=$('#account').val(); var select_id=$('#select_id').val(); var idcard=$('#idcard').val(); var mb=$('#mobile').val(); $.ajax( { url : 'forgetPwd.do',// 跳转到 action data : { confirm : confirm, val_account : val_account, select_id : encodeURI(select_id), idcard : encodeURI(idcard) }, type : 'post', cache : false, async : false, dataType : 'text', success : function(data) { if(data == "null"){ $("#dialog").html("请先获取验证码"); }else if(data == "none"){ $("#dialog").html("用户不存在"); }else if(data == "illegal"){ $("#dialog").html("操作异常!"); }else if(data == "expire"){ $("#dialog").html("验证码已失效,请重新获取"); }else if(data == "wrong"){ $("#dialog").html("验证码不正确"); }else if (data == "send failed") { $("#dialog").html("信息发送失败"); }else if (data == "not valid") { $("#dialog").html("用户信息不匹配"); }else if (data == "changepwd failed") { $("#dialog").html("重置密码失败"); }else if(data == "send success") { $("#noteMsg").html('已向您系统中登记的手机号码'+mb+'发送密码,点击下面的按钮以关闭当前页。'); $(".defaultC").hide(); $(".hiddenC").show(); }else{ $("#dialog").html("系统异常!"); } }, error : function() { $("#dialog").html("验证失败"); } }); } function closeWindow() { var sUserAgent = navigator.userAgent.toLowerCase(); var bIsIpad = sUserAgent.match(/ipad/i) == "ipad"; var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os"; var bIsMidp = sUserAgent.match(/midp/i) == "midp"; var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4"; var bIsUc = sUserAgent.match(/ucweb/i) == "ucweb"; var bIsAndroid = sUserAgent.match(/android/i) == "android"; var bIsCE = sUserAgent.match(/windows ce/i) == "windows ce"; var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile"; if (!(bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM) ){//web端 if (sUserAgent.indexOf("firefox") != -1 || sUserAgent.indexOf("presto") != -1) { window.location.replace("about:blank"); } else { window.opener = null; window.open("", "_self"); window.close(); } } else{ window.location.replace("about:blank");//移动端 } }