123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- (function($) {
- $(document).ready(function() {
- var state;
- function Init() {
- this.id = s64to16(GetQueryString("i"));
- if(GetQueryString("d")) {
- this.inviteId =s64to16(GetQueryString("d"));
- }else{
- this.inviteId ="";
- }
- this.flag = GetQueryString("f");
- this.passCode=false;
- this.ajax({
- url: (this.flag)?"/ajax/ppaper/qo":"/ajax/ppatent/qo",
- obj: {
- "id":this.id
- },
- type: "get",
- status:true,
- oFun: this.title
- });
- this.bindEvent(this);
- }
- Init.prototype.ajax = function(objec) {
- $.ajax({
- url: objec.url,
- data: objec.obj,
- dataType: 'json',
- type: objec.type,
- timeout: 10000,
- async:objec.status,
- traditional: true,
- success: function(data) {
- objec.oFun(data);
- },
- error: function(e) {
- console.log(e);
- bombox("服务器链接超时");
- return;
- }
- });
- }
- Init.prototype.title = function($data) {
- console.log($data);
- if($data.success) {
- $(".formTit").html("《"+$data.data.name+"》")
- }
- console.log($data);
- }
- Init.prototype.sendAuthentication = function($data) {
- if($data.success) {
- state = $data.data;
- doClick();
- }
-
- }
- Init.prototype.code = function(data) {
- if(data.success) {
- if(data.data==false) {
- bombox("验证码错误,请检查后重新输入");
- return;
- }else{
- init.passCode=true;
- return;
- }
- }else{
- if(data.msg=="验证超时"){
- bombox("验证码已过期,请重新获取");
- return;
- }else{
- bombox("请填写正确的手机号,验证码");
- return;
- }
-
- }
- }
- Init.prototype.completeReg = function(data) {
- if (data.success) {
- if(init.flag) {
- location.href="../ekexiu/InviteResult.html?flag=1&code="+data.data
- }else{
- location.href="../ekexiu/InviteResult.html?code="+data.data
- }
- }
- }
- Init.prototype.bindEvent = function(sel) {
-
- $('.form-group').on('keyup', "#userphone,#code,#username", function() {
- if($("#userphone").val() == "" || $("#code").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;
- }
- sel.ajax({
- url: "/ajax/validCode",
- obj: {
- "state": state,
- "vc": $("#code").val()
- },
- status:false,
- type: "post",
- oFun: sel.code
- });
-
- if(sel.passCode) {
- sel.ajax({
- url: (sel.flag)?"/ajax/regAndAssPaper":"/ajax/regAndAssPatent",
- obj: (sel.flag)?{
- "state":state,
- "vc":$("#code").val(),
- "phone":$("#userphone").val(),
- "inviterId":sel.inviteId,
- "name":$("#username").val(),
- "paper":sel.id
- }:{
- "state":state,
- "vc":$("#code").val(),
- "phone":$("#userphone").val(),
- "inviterId":sel.inviteId,
- "name":$("#username").val(),
- "patent":sel.id
- },
- status:true,
- type: "post",
- oFun: sel.completeReg
- });
- }
- });
-
- $('#obtain-code').on('click', function() {
- var hunPhone = /^1[3|4|5|7|8]\d{9}$/;
- if(hunPhone.test($("#userphone").val())) {
- sel.ajax({
- url: "/ajax/phoneValidCode",
- obj: {
- "phone":$("#userphone").val(),
- },
- status:true,
- type: "get",
- oFun: sel.sendAuthentication
- });
- } else {
- bombox("请输入正确的手机号码");
- return;
- }
- });
- }
-
- 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);
- }
-
- 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);
- }
- var init=new Init();
- })
- })(jQuery);
|