Authored by lore-w

注册逻辑修改 code review by liuyue

1 <div class="register-page"> 1 <div class="register-page">
2 - <form id="register-form" class="register-form" method="POST" action="{{actionUrl}}" autocomplete="off"> 2 + <!--<form id="register-form" class="register-form" method="POST" action="{{actionUrl}}" autocomplete="off">-->
3 <ul> 3 <ul>
4 <li class="clearfix"> 4 <li class="clearfix">
5 <select id="region" class="region" name="region"> 5 <select id="region" class="region" name="region">
@@ -64,5 +64,5 @@ @@ -64,5 +64,5 @@
64 <span></span> 64 <span></span>
65 <b></b> 65 <b></b>
66 </div> 66 </div>
67 - </form> 67 + <!--</form>-->
68 </div> 68 </div>
@@ -97,8 +97,8 @@ function phoneAjaxFn(callback) { @@ -97,8 +97,8 @@ function phoneAjaxFn(callback) {
97 validateResult[0].message = ''; 97 validateResult[0].message = '';
98 validateResult[0].status = true; 98 validateResult[0].status = true;
99 break; 99 break;
100 - case 404:  
101 - validateResult[0].message = '改账号已经存在'; 100 + case 400:
  101 + validateResult[0].message = data.message;
102 validateResult[0].status = false; 102 validateResult[0].status = false;
103 break; 103 break;
104 } 104 }
@@ -464,7 +464,48 @@ $registerBtn.click(function() { @@ -464,7 +464,48 @@ $registerBtn.click(function() {
464 if ($(this).hasClass('disable')) { 464 if ($(this).hasClass('disable')) {
465 return; 465 return;
466 } else { 466 } else {
467 - ('#register-form').submit(); 467 +
  468 + //ajax提交
  469 + $.ajax({
  470 + type: 'POST',
  471 + url: '/passport/register/mobileregister',
  472 + data: {
  473 + area: $region.text().split('+')[1],
  474 + mobile: $pn.val(),
  475 + captcha: $ca.val(),
  476 + code: $mc.val(),
  477 + password: $pwd.val()
  478 + }
  479 + }).then(function(data) {
  480 +
  481 + var time = 0,
  482 + t,
  483 + refer = data.href;
  484 +
  485 + t = setTimeout(function() {
  486 + time++;
  487 + }, 1000);
  488 +
  489 + $.ajax({
  490 + type: 'POST',
  491 + url: '/passport/register/mobileregister',
  492 + data: {
  493 + session: data.session
  494 + }
  495 + }).then(function(data) {
  496 +
  497 + if (data.code === 200 && t < 3) {
  498 + clearInterval(t);
  499 + location.href = refer;
  500 + }
  501 + });
  502 +
  503 + if (t >= 3) {
  504 + clearInterval(t);
  505 + location.href = refer;
  506 + }
  507 +
  508 + });
468 } 509 }
469 }); 510 });
470 511
@@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@
11 color: #b9b9b9; 11 color: #b9b9b9;
12 } 12 }
13 13
14 - .register-form { 14 + .register-page {
15 height: auto; 15 height: auto;
16 16
17 li { 17 li {