Authored by biao

update for prevent duplicate submit for requesting mobile verify code. code review by XWG

... ... @@ -20,14 +20,14 @@ var api = require('../api'),
var trim = $.trim;
var showErrTip = tip.show;
var requesting = false;
var requested = false;
function nextStep(url, mobileNo, areaCode) {
if (requesting) {
if (requested) {
return false;
}
requesting = true;
requested = true;
$.ajax({
type: 'POST',
... ... @@ -39,13 +39,10 @@ function nextStep(url, mobileNo, areaCode) {
success: function(res) {
console.log(res.data);
location.href = url;
requesting = false;
},
error: function() {
tip.show('出错了,请重试!');
requesting = false;
requested = false;
}
});
}
... ...
... ... @@ -16,6 +16,8 @@ var tip = require('../../plugin/tip');
var trim = $.trim;
var showErrTip = tip.show;
var requested = false;
api.selectCssHack($('#country-select'));
api.bindClearEvt();
... ... @@ -40,7 +42,15 @@ $btnNext.on('touchstart', function() {
return;
}
if (requested) {
return false;
}
if (api.phoneRegx[areaCode].test(pn)) {
requested = true;
$.ajax({
url: '/passport/reg/verifymobile',
type: 'POST',
... ... @@ -53,10 +63,15 @@ $btnNext.on('touchstart', function() {
location.href = data.data;
} else {
showErrTip(data.message);
requested = false;
}
},
error: function(err) {
showErrTip('出错了,请重试');
requested = false;
}
});
} else {
showErrTip('手机号格式不正确,请重新输入');
}
});
\ No newline at end of file
});
... ...