function sendemail(){
var email = document.getElementById('email').value;
requestAPI("userBaseInfo/sendEmailCode.do", "email="+email, "POST", function(data) {
if("0" != data.code){
$('#bbb').modal('show');
return false;
}
$('#aaa').modal('show');
return false;
});
}
function sendPhoneMsg(){
var phone = document.getElementById('phone').value;
requestAPI("sms/getValidCode.do", "mobile="+phone+"&code_type=9", "POST", function(data) {
if("0" != data.code){
$('#bbb').modal('show');
}
$('#aaa').modal('show');
});
/* $.ajax({
type : "post",
url : basePath+"/sendPhoneByFindPwd.do",
data: {'phone':phone},
dataType : "json",
error : function() {
// alert("发送短信失败!");
$('#bbb').modal('show');
},
success : function(data) {
if(data[0]=='success'){
//alert("发送短信成功!");
$('#aaa').modal('show');
}else{
//alert("发送短信失败!");
$('#bbb').modal('show');
}
}
});*/
}
function checkDiv(self){
var _divChild=self.parentNode.getElementsByTagName('div')[0];
if(_divChild){
self.parentNode.removeChild(_divChild);
}
}
function createDiv(self){
var _divNew=document.createElement('div');
_divNew.className='reg_ok';
self.parentNode.appendChild(_divNew);
}
function checkP(self,flag){
var f = true;
if(null == flag || flag=='null' || flag.length==0){
f = true;
}else{
f = false;
}
var _pChild=self.parentNode.getElementsByTagName('p')[0];
if(_pChild && f){
self.parentNode.removeChild(_pChild);
}
}
function changeCode(){
document.getElementById("rc").src=basePath+"/newImgCode?r="+ Math.random();
}
//鼠标移入显示重新发送验证按钮
function showSend(t){
t.children[0].style.display='block';
t.children[1].style.display='block';
}
function hideSend(t){
t.children[0].style.display='none';
t.children[1].style.display='none';
}
var _gPwd=false;
var _gPwd2=false;
function checkFindPwd(){
if(_gPwd && _gPwd2){
return true;
}
if(!_gPwd){
return false;
}
if(!_gPwd2){
return false;
}
blurPwd();
blurPwd2();
}
function blurPwd(){
var _pwd=document.getElementById("resetpwd");
var _val=_pwd.value;
var _reg=/^[\s\S]{6,20}$/
var _notNull='此项不能为空';
var _len='密码长度只能在6-20位字符之间';
checkP(_pwd);
//checkDiv(_pwd);
if(!_val){
_pwd.style.border='1px solid red';
createP(_pwd,_notNull);
$(".gray").empty();
_gPwd=false;
}
else if(_reg.test(_val))
{
_pwd.style.border='1px solid #bebebe';
//createDiv(_pwd);
checkP(_pwd);
_gPwd=true;
}
else
{
_pwd.style.border='1px solid red';
createP(_pwd,_len);
$(".gray").empty();
_gPwd=false;
}
}
function blurPwd2(){
var _pwd=document.getElementById("resetpwd");
var _val=_pwd.value;
var _pwd2=document.getElementById("resetpwd2");
var _val2=_pwd2.value;
var _sub=document.getElementById("v_sub");
var _notNull='此项不能为空';
var _same='两次输入密码不一致';
checkP(_pwd2);
checkDiv(_pwd2);
if(!_val || !_pwd){
blurPwd();
_gPwd=false;
}else{
if(!_val2){
_pwd2.style.border='1px solid red';
createP(_pwd2,_notNull);
_gPwd2=false;
}
else if(_val2 ==_val){
_gPwd2=true;
createDiv(_pwd2);
checkP(_pwd2);
_pwd2.style.border='1px solid #bebebe';
_sub.style.marginTop='0';
}
else{
_pwd2.style.border='1px solid red';
createP(_pwd2,_same);
_sub.style.marginTop='10px';
_gPwd2=false;
}
}
}
var _tmn=false;
var _verf=false;
function blurTMN(){
var _tmnval=document.getElementById("tmnval");
var _val= _tmnval.value;
var _notNull='此处为必填项';
var _errPhone='该登录帐号不存在';
var _errEmail='该登录帐号不存在';
var _err='请正确填写手机或邮箱';
var _regP=/^1\d{10}$/;
var _regE=/^[A-Za-z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z]+)+$/;
checkP(_tmnval);
if(!_val){
createP(_tmnval,_notNull); //创建p元素,提示错误
checkDiv(_tmnval); //检查是否有验证正确提示,并删除
_tmn=false;
}else{
if(_regP.test(_val)){
document.getElementById("type").value="2";
//填写内容为手机号
//start 9/12
requestAPI('userRegister/validatePhoneOrEmail.do', "codePE="+ _val, "POST",
function(e){
if(e.code == '0' && e.data){
createDiv(_tmnval); // 显示验证通过
checkP(_tmnval); //检查错误提示,并删除
_tmn=true;
userId = e.data.id;
}else{
createP(_tmnval,_errPhone); //创建p元素,提示错误
checkDiv(_tmnval); //检查是否有验证正确提示,并删除
_tmn=false;
}
}
);
//end 9/12
}else if(_regE.test(_val)){
document.getElementById("type").value="3";
//填写内容为邮箱
//createDiv(_tmnval); // 显示验证通过
checkP(_tmnval); //检查错误提示,并删除
//start 9/12
requestAPI('userRegister/validatePhoneOrEmail.do', "codePE="+ _val, "POST",
function(e){
if(e.code == '0' && e.data){
createDiv(_tmnval); // 显示验证通过
checkP(_tmnval); //检查错误提示,并删除
_tmn=true;
}else{
createP(_tmnval,_errPhone); //创建p元素,提示错误
checkDiv(_tmnval); //检查是否有验证正确提示,并删除
_tmn=false;
}
}
);
//end 9/12
}else{
createP(_tmnval,_err); //创建p元素,提示错误
checkDiv(_tmnval); //检查是否有验证正确提示,并删除
_tmn=false;
}
}
}
function blurVerf(){
var v_verf=document.getElementById('v_verf');
var _val= v_verf.value;
var _notNull='请填写验证码';
var _err='验证码错误,请重新输入';
checkP(v_verf);
if(!_val){
createP(v_verf,_notNull); //创建p元素,提示错误
checkDiv(v_verf); //检查是否有验证正确提示,并删除
_verf=false;
}else{
requestAPI("filemgr/imgCodeValidate.do", {'userImgCode':_val}, "POST", function(data) {
if("0" != data.code){
createP(v_verf,_err); //创建p元素,提示错误
_verf=false;
alert(data.details);
}else{
createShortDiv(v_verf); //提示正确
_verf=true;
}
});
}
}
function subTMN(){
blurTMN();
blurVerf();
if(_tmn && _verf){
return true;
}
if(!_tmn){
return false;
}
if(!_verf){
return false;
}
// blurTMN();
// blurVerf();
}
function yanzVerf(t){
var _nextS=document.getElementById('vtips');
var display='style.display';
if(_nextS.display!='none'){_nextS.display='none'}
t.focus();
t.value='';
t.style.border='1px solid #0095ff';
checktip();
checkDiv(t);
}
function checktip(){
var _nextS=document.getElementById('vtips');
if(_nextS.style.color=='red'){
_nextS.style.color='#727171';
_nextS.innerHTML="验证码已发送到您的手机,30分钟内有效,请勿泄露";//_tips;
}
}
var _yanz=false;
function subApply(){
checkMsg();
if(_yanz){
return true;
}
if(!_yanz){
return false;
}
}
//只用来校验pc手机验证码 byJPMiao
function checkMsg(){
var t=document.getElementById('yanzverf');
var _val= t.value;
var _nextS=document.getElementById('vtips');
var phone = document.getElementById('phone').value;
var _tips='验证码错误,请重新输入';
var _reg=/^\d$/;//模拟验证码
checktip();
checkDiv(t);
if(!_val){
//t.focus();
t.style.border='1px solid red';
_nextS.style.display='block';
_nextS.style.color='red';
_nextS.innerHTML=""+_tips+"";//_tips;
_yanz=false;
}else{
var reg = new RegExp("^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$");
var type = 1;
if(reg.test(phone)){type =2;}
if(1 == type){
requestAPI("sms/validSmsCode.do", "code="+_val+"&mobile="+phone+"&code_type=9", "POST",function(data) {
if("0" != data.code){
t.style.border='1px solid red';
_nextS.style.display='block';
_nextS.style.color='red';
_nextS.innerHTML=""+_tips+"";//_tips;
_yanz=false;
}else{
_yanz=true;
createShortDiv(t);
}
});
}else{
//待续...
}
}
}
//触发input框效果
function clickInput(t,id){
var _tnm=document.getElementById(id);
t.style.border='1px solid #0095ff';
if(_tnm){
_tnm.style.display='none';
}
t.focus();
checkP(t);
checkDiv(t);
}
function clickSpan(t,id){
var _pId=document.getElementById(id);
t.style.display='none';
_pId.style.border='1px solid #0095ff';
_pId.focus();
checkP(_pId,false);
checkDiv(_pId);
}
function createShortDiv(self){
var _divNew=document.createElement('div');
_divNew.className='reg_ok_short';
self.parentNode.appendChild(_divNew);
}
function createP(self,tip){
var _pNew=document.createElement('p');
_pNew.className='reg_tips';
_pNew.innerHTML=""+tip+"";
self.parentNode.appendChild(_pNew);
self.style.border='1px solid #e60012';
}
function logout(){
requestAPI("user/logout.do", "", "POST", function(_data){redirectUrl("initParameter.do");});
}