window.οnlοad=function(){
//获取手机输入框var tel=$("#tel");
//获取验证码输入框
var code=$("#code");
//获取密码输入框
var pwd=$("#pwd");
//获取发送验证码按钮
var send=$("#send");
//获取注册按钮
var btn=$("#btn");
var tip=$("#tip");
var timer=null;
var now=60;
//发送验证码接口请求send.click(function(){
var regtel=/^1[3|4|5|7|8]\d{9}$/;
var telval=tel.val();
if(telval==""){
tip.html("手机号码不能为空");
tip.css("opacity",1);
setTimeout(function(){
tip.css("opacity",0);
},2000)
}else if(!regtel.test(telval)){
tip.html("手机号码格式不正确");
tip.css("opacity",1);
setTimeout(function(){
tip.css("opacity",0);
},2000)
}else{
$.ajax({
type:"post",
url:"/sendSmsForSpread.do",
data:{
tel:telval
},
dataType:"json",
success:function(res){
if(res.code==200){
tip.html(res.msg);
timer=setInterval(function(){
if(now!=0){
send.val(now);
now--;
send.attr("disabled",true);
}else{
clearInterval(timer);
send.attr("disabled",false);
send.val("重新发送");
now=60;
}
},1000)
}else if(res.code==500){
tip.html(res.msg);
tip.css("opacity",1);
setTimeout(function(){
tip.css("opacity",0);
},2000)
}
}
})
}
})
function GetQueryString(name){
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if(r!=null)return unescape(r[2]); return null;
}
//注册接口
btn.click(function(){
var regpwd=/^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,16}$/;
var regtel=/^1[3|4|5|7|8]\d{9}$/;
var telval=tel.val();
var codeval=code.val();
var pwdval=pwd.val();
var url=window.location.href;
var userChannel="";
if(url.indexOf("?")==-1){
tip.html("不能注册");
tip.css("opacity",1);
setTimeout(function(){
tip.css("opacity",0);
},2000)
}else{
// userChannel =url.split("?")[1].split("=")[1];
userChannel =GetQueryString("code");
}
if(telval==""){
tip.html("手机号码不能为空");
tip.css("opacity",1);
setTimeout(function(){
tip.css("opacity",0);
},2000)
}else if(!regtel.test(telval)){
tip.html("手机号码格式不正确");
tip.css("opacity",1);
setTimeout(function(){
tip.css("opacity",0);
},2000)
}else if(codeval==""){
tip.html("请输入短信验证码");
tip.css("opacity",1);
setTimeout(function(){
tip.css("opacity",0);
},2000)
}else if(pwdval==""){
tip.html("请输入密码");
tip.css("opacity",1);
setTimeout(function(){
tip.css("opacity",0);
},2000)
}else if(!regpwd.test(pwdval)){
tip.html("密码格式不正确");
tip.css("opacity",1);
setTimeout(function(){
tip.css("opacity",0);
},2000)
}else{
$.ajax({
type:"post",
url:"/registerReviewForSpread.do",
data:{
userAccount:telval,
userPassword:pwdval,
phoneCode:codeval,
userChannel:userChannel
// userChannel:
},
dataType:"json",
success:function(res){
if(res.code==500){
tip.html(res.msg);
tip.css("opacity",1);
setTimeout(function(){
tip.css("opacity",0);
},2000)
}else if(res.code==200){
if(!!window.TuiaAdverter) { //先判断 js 是否引入成功
TuiaAdverter.init(function() {
window.location.href="/activity/spreadAPP/success.html";
})
}else{
window.location.href="/activity/spreadAPP/success.html";
}
}
}
})
}
})
var top=document.getElementById("top");
top.addEventListener("touchend",function(){
$("body,html").animate({
scrollTop:"984px"
},400)
})
var top1=document.getElementById("top1");
top1.addEventListener("touchend",function(){
$("body,html").animate({
scrollTop:"984px"
},400)
})
var top2=document.getElementById("top2");
top2.addEventListener("touchend",function(){
$("body,html").animate({
scrollTop:"984px"
},400)
})
}