Authored by weiguang.xie

Merge branch 'fix/issue' into 'develop'

修复注册和绑定手机号时,重复请求验证码的bug

See merge request !56
@@ -20,14 +20,14 @@ var api = require('../api'), @@ -20,14 +20,14 @@ var api = require('../api'),
20 var trim = $.trim; 20 var trim = $.trim;
21 var showErrTip = tip.show; 21 var showErrTip = tip.show;
22 22
23 -var requesting = false; 23 +var requested = false;
24 24
25 function nextStep(url, mobileNo, areaCode) { 25 function nextStep(url, mobileNo, areaCode) {
26 - if (requesting) { 26 + if (requested) {
27 return false; 27 return false;
28 } 28 }
29 29
30 - requesting = true; 30 + requested = true;
31 31
32 $.ajax({ 32 $.ajax({
33 type: 'POST', 33 type: 'POST',
@@ -39,13 +39,10 @@ function nextStep(url, mobileNo, areaCode) { @@ -39,13 +39,10 @@ function nextStep(url, mobileNo, areaCode) {
39 success: function(res) { 39 success: function(res) {
40 console.log(res.data); 40 console.log(res.data);
41 location.href = url; 41 location.href = url;
42 -  
43 - requesting = false;  
44 }, 42 },
45 error: function() { 43 error: function() {
46 tip.show('出错了,请重试!'); 44 tip.show('出错了,请重试!');
47 -  
48 - requesting = false; 45 + requested = false;
49 } 46 }
50 }); 47 });
51 } 48 }
@@ -16,6 +16,8 @@ var tip = require('../../plugin/tip'); @@ -16,6 +16,8 @@ var tip = require('../../plugin/tip');
16 var trim = $.trim; 16 var trim = $.trim;
17 var showErrTip = tip.show; 17 var showErrTip = tip.show;
18 18
  19 +var requested = false;
  20 +
19 api.selectCssHack($('#country-select')); 21 api.selectCssHack($('#country-select'));
20 22
21 api.bindClearEvt(); 23 api.bindClearEvt();
@@ -40,7 +42,15 @@ $btnNext.on('touchstart', function() { @@ -40,7 +42,15 @@ $btnNext.on('touchstart', function() {
40 return; 42 return;
41 } 43 }
42 44
  45 + if (requested) {
  46 + return false;
  47 + }
  48 +
  49 +
43 if (api.phoneRegx[areaCode].test(pn)) { 50 if (api.phoneRegx[areaCode].test(pn)) {
  51 +
  52 + requested = true;
  53 +
44 $.ajax({ 54 $.ajax({
45 url: '/passport/reg/verifymobile', 55 url: '/passport/reg/verifymobile',
46 type: 'POST', 56 type: 'POST',
@@ -53,10 +63,15 @@ $btnNext.on('touchstart', function() { @@ -53,10 +63,15 @@ $btnNext.on('touchstart', function() {
53 location.href = data.data; 63 location.href = data.data;
54 } else { 64 } else {
55 showErrTip(data.message); 65 showErrTip(data.message);
  66 + requested = false;
56 } 67 }
  68 + },
  69 + error: function(err) {
  70 + showErrTip('出错了,请重试');
  71 + requested = false;
57 } 72 }
58 }); 73 });
59 } else { 74 } else {
60 showErrTip('手机号格式不正确,请重新输入'); 75 showErrTip('手机号格式不正确,请重新输入');
61 } 76 }
62 -});  
  77 +});