...
|
...
|
@@ -41,21 +41,29 @@ var page = { |
|
|
$smsCode.on('input', function() {
|
|
|
var hasVal = Boolean($.trim(this.value));
|
|
|
|
|
|
$nextBtn.toggleClass('disable', !hasVal);
|
|
|
$nextBtn.prop('disabled', !hasVal);
|
|
|
$nextBtn.trigger('toggleDisable', !hasVal);
|
|
|
$resetBtn.toggle(hasVal);
|
|
|
});
|
|
|
|
|
|
$nextBtn.on('click', function() {
|
|
|
!self.disableAjax && self.submit();
|
|
|
self.submit();
|
|
|
});
|
|
|
|
|
|
$resetBtn.on('click', function() {
|
|
|
$smsCode.val('');
|
|
|
$resetBtn.hide();
|
|
|
$nextBtn.trigger('toggleDisable');
|
|
|
});
|
|
|
},
|
|
|
|
|
|
$nextBtn.on('toggleDisable', function(event, bool) {
|
|
|
if (bool === void 0) {
|
|
|
bool = true;
|
|
|
}
|
|
|
|
|
|
$nextBtn.toggleClass('disable', bool);
|
|
|
$nextBtn.prop('disabled', bool);
|
|
|
});
|
|
|
},
|
|
|
|
|
|
countDown: function() {
|
|
|
var self = this;
|
...
|
...
|
@@ -65,7 +73,8 @@ var page = { |
|
|
return;
|
|
|
}
|
|
|
|
|
|
$resendBtn.prop('disable', true);
|
|
|
$resendBtn.prop('disabled', true);
|
|
|
$resendBtn.text('重新发送(' + second + ')');
|
|
|
this.timerId = setInterval(function() {
|
|
|
var txt = self.resendText;
|
|
|
|
...
|
...
|
@@ -74,7 +83,7 @@ var page = { |
|
|
if (second < 0) {
|
|
|
clearInterval(self.timerId);
|
|
|
self.timerId = null;
|
|
|
$resendBtn.prop('disable', false);
|
|
|
$resendBtn.prop('disabled', false);
|
|
|
} else {
|
|
|
txt = '重新发送(' + second + '秒)';
|
|
|
}
|
...
|
...
|
@@ -88,7 +97,7 @@ var page = { |
|
|
resendSMS: function() {
|
|
|
var self = this;
|
|
|
|
|
|
if ($resendBtn.prop('disable')) {
|
|
|
if ($resendBtn.prop('disabled')) {
|
|
|
return;
|
|
|
}
|
|
|
|
...
|
...
|
@@ -110,17 +119,20 @@ var page = { |
|
|
},
|
|
|
|
|
|
submit: function() {
|
|
|
var self = this;
|
|
|
var code = $.trim($smsCode.val());
|
|
|
|
|
|
$nextBtn.prop('disabled', this.disableAjax = true);
|
|
|
if ($nextBtn.prop('disabled')) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
$nextBtn.prop('disabled', true);
|
|
|
$.get('/passport/sms_login/check.json', {
|
|
|
code: code
|
|
|
})
|
|
|
.done(function(res) {
|
|
|
if (res.code === 200) {
|
|
|
location.href = res.redirect;
|
|
|
self.disableAjax = true; // 成功后 disabled, 执行跳转
|
|
|
$nextBtn.off();
|
|
|
return;
|
|
|
}
|
|
|
|
...
|
...
|
@@ -128,10 +140,9 @@ var page = { |
|
|
})
|
|
|
.fail(function() {
|
|
|
tip.show('出错了, 请重试');
|
|
|
self.disableAjax = false; // 失败后 允许再次 请求
|
|
|
})
|
|
|
.always(function() {
|
|
|
$nextBtn.prop('disabled', self.disableAjax);
|
|
|
$nextBtn.prop('disabled', false);
|
|
|
});
|
|
|
}
|
|
|
};
|
...
|
...
|
|