function register(){ var loginName = $("#redisterUsername"); var introducerName = $("#introducerUsername"); var Mobile = $("#redisterMobile"); var cPassword = $("#redisterPassowrd"); var rePassword = $("#redisterRePassword"); var VerifyCode = $("#mobileVerifyCode"); if(loginName.val() == ""){ alert("请输入用户名"); loginName.focus(); return; }else if(checkEmail($.trim(loginName.val())) == false){ alert('用户名必须以邮箱格式'); loginName.focus(); return; }else if(introducerName.val()!=""){ if(checkEmail($.trim(introducerName.val()))==false){ alert('介绍人必须以邮箱格式'); introducerName.focus(); return; } } /** if(Mobile.val() == ""){ alert("请输入手机号码"); Mobile.focus(); return; } if(!checkMobile($.trim(Mobile.val()))){ alert("请输入正确的手机号码"); Mobile.focus(); return; }**/ if(cPassword.val() == ""){ alert("请输入密码"); cPassword.focus(); return; } if(cPassword.val().length < 6){ alert("密码最少6位"); cPassword.focus(); return; } if(rePassword.val() == ""){ alert("请再次输入密码"); rePassword.focus(); return; } if(VerifyCode.val() == ""){ alert("请输入验证码"); VerifyCode.focus(); return; } if(cPassword.val() != rePassword.val()){ alert("两次输入的密码不一致"); rePassword.focus(); return; } $.post(path+"servlet/CustomerServlet?CUST_FLAG=2", {"comCode": '0',"loginName":loginName.val(),"Mobile":Mobile.val(),"cPassword":cPassword.val(),"introducerName":introducerName.val(),"VerifyCode":VerifyCode.val()},function(dat){ if(dat == 'success'){ alert("注册成功"); $("#registerForm").submit(); }else if(dat!=""){ alert(dat); }else{ alert("注册失败"); } },'text'); } function clearMessage(){ $("#messageUserName").html(""); } function checkPassword(){ var cPassword = $("#redisterPassowrd").val(); var rePassword = $("#redisterRePassword").val(); if(cPassword != rePassword){ $("#messageRedister").html("两次输入的密码不一致"); } } function clearRePassword(){ $("#messageRedister").html(""); } function checkRegisterMoile(){ var Mobile = $.trim($("#redisterMobile").val()); if(!checkMobile(Mobile)){ $("#messageMobile").html("请输入正确的手机号码"); } } function clearMobileMessage(){ $("#messageMobile").html(""); } function exists(){ var loginName = $.trim($("#redisterUsername").val()); if(loginName!=""){ if(checkEmail(loginName) == false){ $("#messageUserName").html("用户名要以邮箱格式"); $("#redisterUsername").focus(); return ; } $.post(path+"servlet/CustomerServlet?CUST_FLAG=3", {"comCode": "0","loginName":loginName},function(dat){ if(dat == 'exists'){ $("#messageUserName").html("用户名已经存在"); }else{ $("#messageUserName").html("用户名可以使用"); } },'text'); } } function existIntroducer(){ var loginName = $.trim($("#introducerUsername").val()); if(loginName!=""){ if(checkEmail(loginName) == false){ $("#introducerUsername").focus(); $("#messageIntroducerName").html("介绍人要以邮箱格式"); return ; } $.post(path+"servlet/CustomerServlet?CUST_FLAG=3", {"comCode": "0","loginName":loginName},function(dat){ if(dat == 'exists'){ $("#messageIntroducerName").html("用户名存在"); }else{ $("#messageIntroducerName").html("用户名不存在"); } },'text'); } } function userNameExit(){ var userName = $('#loginName').val(); if(userName == ''){ alert('请输入用户名'); $('#loginName').focus(); return ; }else if(checkEmail(userName) == false){ alert('用户名必须以邮箱格式'); $('#loginName').focus(); return ; } } function login(){ var comCode = $("#comCode").val(); var loginName = $("#loginName"); var cPassword = $("#cPassword"); var VerifyCode = $("#VerifyCode"); if(loginName.val() == ""){ alert("请输入用户名"); loginName.focus(); return; } if(cPassword.val() == ""){ alert("请输入密码"); cPassword.focus(); return; } if(VerifyCode.val() == ""){ alert("请输入验证码"); VerifyCode.focus(); return; } $.post(path+"servlet/CustomerServlet?CUST_FLAG=0", {"comCode": comCode,"ep": "ep","loginName":$.trim(loginName.val()),"cPassword":cPassword.val(),"VerifyCode":VerifyCode.val()},function(dat){ if(dat == 'success' || dat == 'fail'){ saveCookie(); //$("#loginForm").submit(); window.location.href=path + '/servlet/CustomerServlet?CUST_FLAG=1'; }else if (dat == 'success_ep') { window.location.href=path + '/epIns/productList.jsp?pt=006&page=1'; }else{ alert(dat); $("#VerifyCode").focus(); changeImage(); } },'text'); } function changeImage(){ alert("11111"); $("#loginImage").attr("src",path+"/customer/image.jsp?id="+Math.random()); } function changeRegisterImage(){ $("#RegisterImage").attr("src",path+"/customer/RegisterImage.jsp?id="+Math.random()); } //发送手机验证码 var count = 0; function getVerifyNum(){ if(count == 0){ var mobile = $('#redisterMobile').val(); if(mobile == ''){ alert('请输入手机号码'); return ; } if(!checkMobile(mobile)){ alert("请输入正确的手机号码"); $('#mobileVerifyCode').focus(); return; } send(mobile); var data='Mobile='+mobile; $.post(path+'servlet/CustomerServlet?CUST_FLAG=8', data); } } function send(mobile){ //alert('已经成功发送到你的手机上'); $('#mobileMessage').html('我们已向手机:'+mobile+'发送了验证码 '); $('#btnVerify').removeClass(); $('#btnVerify').addClass('count_num'); count = 60; $('#btnVerify').html(count+'秒后重新发送'); window.setTimeout("countDown()",1000); } function countDown(){ count--; $('#btnVerify').html(count+'秒后重新发送'); if(count<=0){ count=0; $('#btnVerify').removeClass(); $('#btnVerify').addClass('count_num_yan'); $('#btnVerify').html('发送'); $('#mobileMessage').html(''); return; }else{ window.setTimeout("countDown()",1000); } } //找回密码 function getBackPassword(type){ var userName=''; var comCode=''; var mobile=''; var email=''; var rt=''; if(type=='1'){ //邮箱 userName=$('#E_UserName').val(); comCode=$('#emailCom').val(); email=$('#email').val(); rt='2'; if(userName == ''){ alert('用户名不能为空'); $('#E_UserName').focus(); return ; } if(email ==''){ alert('电子邮箱不能为空'); $('#email').focus(); return ; } if(!checkEmail(email)){ alert('电子邮箱格式不正确'); $('#email').focus(); return ; } }else if(type=='2'){ //手机 userName=$('#M_UserName').val(); comCode=$('#mobileCom').val(); mobile=$('#mobile').val(); rt='1'; if(userName == ''){ alert('用户名不能为空'); $('#M_UserName').focus(); return ; } if(mobile ==''){ alert('手机号不能为空'); $('#mobile').focus(); return ; } if(!checkMobile(mobile)){ alert('手机号格式不正确'); $('#mobile').focus(); return ; } }else{ return; } $.post(path+"servlet/CustomerServlet?CUST_FLAG=13", {"RT":rt,"comCode": comCode,"loginName":userName,"mobile":mobile,"email":email},function(dat){ if(dat.resultCode == '1'){ alert('修改成功'); return ; }else{ alert(dat.resultInfo); return ; } },'json'); } //恢复手机验证码发送功能 function sendMobileCode(){ $('.count_num').html('发送'); flag = 0; }