|
// JavaScript Document
/**复选框**/
$('.agreeNotice').click(function(){
var formbox = $(this).closest("form");
if(formbox.find('.gree').prop('checked')){
formbox.find('.agreeNotice em').css('background-position','0px 0px');
formbox.find('.gree').prop('checked',false);
formbox.find('.agreeNotice').next('span').show();
}else{
formbox.find('.gree').prop('checked',true);
formbox.find('.agreeNotice').next('span').hide();
formbox.find('.agreeNotice em').css('background-position','0px -12px');
}
});
//手机、邮箱切换
$(".phone").click(function(){
$(this).find("img").attr("src","images/phoneIcon2.png");
$(".mail").find("img").attr("src","images/mailIcon.png");
$(".mail").removeClass("active");
$(this).addClass("active");
$(".styleline").animate({left:"0px"});
$("#mail_form").hide();
$('#phone_form').show();
});
$(".mail").click(function(){
$(this).find("img").attr("src","images/mailIcon2.png");
$(".phone").find("img").attr("src","images/phoneIcon.png");
$(".phone").removeClass("active");
$(this).addClass("active");
$(".styleline").animate({left:"151px"});
$("#phone_form").hide();
$("#mail_form").show();
});
//手机注册模块
//验证手机号
var phonePass = false;
function phoneVal(){
var phone= $("#lp_phone").val();
if(phone.length==0){
$(".msgphone1").text("请输入您的手机号码");
}else{
var hunPhone=/^1[3|4|5|7|8]\d{9}$/;
if(hunPhone.test(phone.trim())){
$(".msgphone1").text("");
phonePass = true;
}else{
phonePass = false;
$(".msgphone1").text("手机格式正确,请输入正确的手机号码");
}
}
}
$("#lp_phone").blur(function(){
phoneVal();
});
//验证随机验证码
var phoneCode=false;
$("#lp_yzm").blur(function(){
var authCode=$("#lp_yzm").val();
if(authCode.length==0){
$(".msgphone2").text("请输入您的验证码");
phoneCode=false;
}else{
var d=/^[0-9a-zA-Z]{4}$/;
if(d.test(authCode.trim())){
$(".msgphone2").text("");
phoneCode=true;
}
else{
$(".msgphone2").text("请输入您的验证码不正确");
phoneCode=false;
}
}
});
//获取手机验证码
var setTime;
$(".getcode1").click(function(){
$(".coderli span").removeClass("getcode1").addClass("getcode2");;
setTime=setInterval(Countdown,1000);
phoneVerificationCode();
})
var j=60;
function Countdown(){
j--;
$(".getcode2").text(j);
if(j==0){
$(".coderli span").removeClass("getcode2").addClass("getcode1").text("请重新获取验证码");
clearInterval(setTime);
j=60;
}
}
var state;
function phoneVerificationCode(){
if(phonePass){
$.ajax("/ajax/regmobilephone",
{
type: "get",
async: true,
success: function(data) {
if(data.success) {
state=data.data;
}
},
error: function() {
$.MsgBox.Alert('message', 'fail')
},
data: {
"mobilePhone": $("#lp_phone").val()
},
dataType: 'json'
});
}
};
//验证手机验证码
var setpass1= false;
function setPhoneCode(){
var pass= $("#lp_coder").val();
if(pass.length==0){
$(".msgphone3").text("请输入您的验证码");
}else{
var hunPhone=/^[0-9]{4}$/;
if(hunPhone.test(pass.trim())){
$(".msgphone3").text("");
setpass1 = true;
}else{
$(".msgphone3").text("验证码4位");
}
}
}
$("#lp_coder").blur(function(){
setPhoneCode();
});
//设置密码
var password;
var setpass = false;
function setPassword(){
password= $("#phone_password").val();
if(password.length==0){
$(".msgphone4").text("请输入您的密码");
}else{
var hunPhone=/^[0-9a-zA-Z]{6,}$/;
if(hunPhone.test(password.trim())){
$(".msgphone4").text("");
setpass = true;
}else{
$(".msgphone4").text("密码6到16位");
}
}
}
$("#phone_password").blur(function(){
setPassword();
});
//再次确定密码
var setpassagain = false;
function setPasswordAgain(){
var passwordAgain= $("#phone_password2").val();
if(passwordAgain.length==0){
$(".msgphone5").text("请再次输入您的密码");
}else{
var hunPhone=/^[0-9a-zA-Z]{6,}$/;
if(hunPhone.test(password.trim())&&passwordAgain==password){
$(".msgphone5").text("");
setpassagain= true;
}else{
$(".msgphone5").text("密码错误");
}
}
}
$("#phone_password2").blur(function(){
setPasswordAgain();
});
//手机注册提交
$("#btnn").click(function(){
if(phonePass&&setpass1&&setpassagain)
{
$.ajax("/ajax/regmobile",{
type:"POST",
async: false,
success:function(data){
if(data.success){
loginagain();//调用登录的接口
// $(".completedcover").css("display","block");
// $("#afterSay").click(function(){
// location.href="index.html";
// });
// $("#todayPerfect").click(function(){
// location.href="information-add.html?id="+data.data;
// });
location.href="information-add.html?id="+data.data;
}
},
error:function(){$.MsgBox.Alert('message','fail')},
data:{"state":state,"mobilePhone":$("#lp_phone").val(),
"validateCode":$("#lp_coder").val(),"password":$("#phone_password").val(),
dataType: 'json'}
});
}
});
function loginagain(){
$.ajax("/ajax/login",{
type:"POST",
async: false,
success:function(data){
},
error:function(){$.MsgBox.Alert('message','fail')},
data:{"pw":$("#phone_password").val(),"lk":$("#lp_phone").val()},
dataType: 'json'
});
}
//邮箱注册模块
//邮箱验证
var emailPass = false;
function valEmail()
{
var email = $("#lp_email").val();
var gunf=/^\w+@\w+\.((cn)|(com)|(com\.cn))$/;
if(gunf.test(email.trim())){
$(".msgema1 span").text("");
emailPass = true;
}else{
/*alert("请输入正确是邮箱地址");*/
$(".msgema1 span").text("请输入正确是邮箱地址");
emailPass = false;
}
}
$("#lp_email").blur(function(){
valEmail();
});
//输入密码及确认密码
var oldPass = false;
var isPass = false;
function valOld()
{
var oldPassword = $("#mail_password").val();
if(oldPassword.length==0)
{
$(".msgema2 span").text("请输入密码");
oldPass = false;
}else if(oldPassword.length < 6)
{
$(".msgema2 span").text("密码不少于6位,请输入正确的密码");
}else
{
$(".msgema2 span").text("");
oldPass = true;
}
}
$("#mail_password").blur(function(){
valOld();
})
function valNew()
{
var newPassword = $("#mail_password").val();
var oldPassword = $("#mail_password1").val();
if(oldPassword.length==0)
{
$(".msgema3 span").text("密码不能为空");
}
else if(oldPassword.length<6)
{
$(".msgema3 span").text("密码长度过短,至少六位");
}else if(oldPassword != newPassword)
{
$(".msgema3 span").text("两次密码不一致");
} else
{
isPass = true;
$(".msgema3 span").text("");
}
}
$("#mail_password1").blur(function(){
valNew();
})
//邮箱注册提交
//$("#btnn1").click(function(){
// if(isPass&& emailPass)
// {
// $.ajax("/ajax/reg",{
// type:"POST",
// async: false,
// success:function(data){
// location.href="information-add.html?id="+data.data;
// },
// error:function(){$.MsgBox.Alert('message','fail')},
// data:{"email":$("#lp_email").val(),"password":$("#mail_password1").val()},
// dataType: 'json'}
// );
// }
//});
$("#btnn1").click(function(){
if(isPass&& emailPass)
{
$.ajax("/ajax/regmail",{
type:"GET",
async: false,
success:function(data){
location.href="bind-mail.html";
},
error:function(){$.MsgBox.Alert('message','fail')},
data:{"mail":$("#lp_email").val()},
dataType: 'json'}
);
}
});
|