123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231 |
- $(function(){
-
- var phoneCode = false;
- var ifCode = false;
- var ifpassword = false;
- var state;
- var inviterId = GetQueryString("professorId");
- var username = GetQueryString("professorName");
-
-
-
- $(".inviteTit span").text(username);
-
- function bombox(textt){
- $(".bomb-box").fadeIn("slow");
- $(".bomb-box").text(textt);
- var bombwidth = $(".bomb-box").width();
- $(".bomb-box").css({"marginLeft": -(bombwidth+25)/2 + "px"});
- setTimeout(function(){
- $(".bomb-box").fadeOut("slow");
- },4000);
- }
- $("#changImage").on("click",function(){
- $(this).attr("src","/ajax/PictureVC?"+new Date().getTime());
- })
-
- $('.form-group').on('keyup', "#userphone,#code,#password,#username,#imgCode", function() {
- if($("#userphone").val() == "" || $("#code").val() == "" || $("#password").val() == "" || $("#username").val() == "") {
- $("#regbtn").attr("disabled",true);
- } else {
- $("#regbtn").attr("disabled",false);
- }
- });
-
-
- $("#regbtn").on('click',function() {
- var oStringLength=$("#username").val().length;
- if(oStringLength>10){
- bombox("请输入您的真实姓名");
- return;
- }
- var hunPhone = /^1[3|4|5|7|8]\d{9}$/;
- if(!hunPhone.test($("#userphone").val())) {
- bombox("请输入正确的手机号码");
- return;
- }
- if($("#code").val().length==4) {
- ifCode=true;
- }else{
- bombox("短信验证码4位");
- }
- passwordVal();
- if(ifpassword && ifCode){
- completeReg();
- }
- });
-
-
- $('#obtain-code').on('click',function() {
- phoneVal();
- });
-
-
- function phoneVal() {
- var hunPhone = /^1[3|4|5|7|8]\d{9}$/;
- if(hunPhone.test($("#userphone").val())) {
- isReg();
- } else {
- bombox("请输入正确的手机号码");
- return;
- }
- }
-
-
- function isReg() {
- $.ajax({
- url:"/ajax/isReg?key=" + $("#userphone").val(),
- dataType: 'json',
- type: 'GET',
- timeout: 10000,
- success: function(data) {
- if(data.data == false) {
- bombox("您的手机已被注册");
- return;
- } else {
- phoneCode = true;
- if(phoneCode){
- sendAuthentication();
- }
- }
- },
- error: function() {
- bombox("服务器链接超时");
- return;
- }
- });
- }
-
-
- function sendAuthentication() {
- $.ajax({
- url:"/ajax/regmobilephone",
- data: {
- vcode:$("#imgCode").val(),
- mobilePhone: $("#userphone").val()
- },
- dataType: 'json',
- type: 'GET',
- async: false,
- timeout: 10000,
- success: function(data) {
-
- if(data.success) {
- state = data.data;
- doClick();
- }else{
- bombox("验证码不正确");
- $("#changImage").attr("src","/ajax/PictureVC?"+new Date().getTime());
- }
- },
- error: function() {
- bombox("服务器链接超时");
- return;
- }
- })
- }
-
-
- function doClick() {
- $("#obtain-code").attr("disabled",true);
- $("#obtain-code").text("60s后重新获取");
- var clickTime = new Date().getTime();
- var Timer = setInterval(function() {
- var nowTime = new Date().getTime();
- var second = Math.ceil(60 - (nowTime - clickTime) / 1000);
- if(second > 0) {
- $("#obtain-code").text(second + "s后重新获取");
- } else {
- clearInterval(Timer);
- $("#obtain-code").attr("disabled",false);
- $("#obtain-code").text("获取验证码");
- }
- }, 1000);
- }
-
-
- function codeVal() {
- $.ajax({
- url:"/ajax/validCode",
- data: {
- "state": state,
- "vc": $("#code").val()
- },
- dataType: 'json',
- async: false,
- type: 'POST',
- timeout: 10000,
- success: function(data) {
-
- if(data.success) {
- if(data.data==false) {
- bombox("验证码不正确");
-
- return;
- }else{
- passwordVal();
- ifCode =true;
- return;
- }
- }else{
-
-
- bombox("验证码错误");
-
-
- }
- },
- error: function() {
- bombox("服务器链接超时");
- return;
- }
- })
- }
-
-
- function passwordVal() {
- var passwordv = $("#password").val();
- if(passwordv.length < 6) {
- bombox("请输入由6-24 个字符组成,区分大小写");
- return;
- }else{
- ifpassword = true;
- return;
- }
- }
-
-
- function completeReg() {
- $.ajax({
- url:"/ajax/mobileReg",
- data: {
- state: state,
- mobilePhone: $("#userphone").val(),
- validateCode: $("#code").val(),
- password: $("#password").val(),
- inviterId:inviterId,
- name:$("#username").val()
- },
- dataType: 'json',
- type: 'post',
- async: false,
- success: function(data) {
- if(data.success) {
- bombox("注册成功");
- $(".formblock").hide();
- $(".inviteSucceed").show();
- }else{
- bombox("验证码错误");
- }
- },
- error: function() {
- bombox("服务器链接超时");
- }
- });
- }
-
-
- });
|