...
|
...
|
@@ -3,6 +3,7 @@ var tip = require('plugin/tip'); |
|
|
var $resendBtn,
|
|
|
$nextBtn,
|
|
|
$smsCode,
|
|
|
$resetBtn,
|
|
|
mobile, area;
|
|
|
|
|
|
var page = {
|
...
|
...
|
@@ -23,6 +24,7 @@ var page = { |
|
|
domInit: function() {
|
|
|
$resendBtn = $('#resend-sms');
|
|
|
$nextBtn = $('#btn-next');
|
|
|
$resetBtn = $('.clear-input');
|
|
|
$smsCode = $('#sms-code');
|
|
|
mobile = $('#mobile').val();
|
|
|
area = $('#area').val();
|
...
|
...
|
@@ -40,11 +42,18 @@ var page = { |
|
|
var hasVal = Boolean($.trim(this.value));
|
|
|
|
|
|
$nextBtn.toggleClass('disable', !hasVal);
|
|
|
$nextBtn.prop('disabled', !hasVal);
|
|
|
$resetBtn.toggle(hasVal);
|
|
|
});
|
|
|
|
|
|
$nextBtn.on('click', function() {
|
|
|
!self.disableAjax && self.submit();
|
|
|
});
|
|
|
|
|
|
$resetBtn.on('click', function() {
|
|
|
$smsCode.val('');
|
|
|
$resetBtn.hide();
|
|
|
});
|
|
|
},
|
|
|
|
|
|
|
...
|
...
|
@@ -67,7 +76,7 @@ var page = { |
|
|
self.timerId = null;
|
|
|
$resendBtn.prop('disable', false);
|
|
|
} else {
|
|
|
txt = second + 's';
|
|
|
txt = '重新发送(' + second + '秒)';
|
|
|
}
|
|
|
|
|
|
$resendBtn.text(txt);
|
...
|
...
|
@@ -104,13 +113,14 @@ var page = { |
|
|
var self = this;
|
|
|
var code = $.trim($smsCode.val());
|
|
|
|
|
|
this.disableAjax = true;
|
|
|
$nextBtn.prop('disabled', this.disableAjax = true);
|
|
|
$.get('/passport/sms_login/check.json', {
|
|
|
code: code
|
|
|
})
|
|
|
.done(function(res) {
|
|
|
if (res.code === 200) {
|
|
|
location.href = res.redirect;
|
|
|
self.disableAjax = true; // 成功后 disabled, 执行跳转
|
|
|
return;
|
|
|
}
|
|
|
|
...
|
...
|
@@ -118,9 +128,10 @@ var page = { |
|
|
})
|
|
|
.fail(function() {
|
|
|
tip.show('出错了, 请重试');
|
|
|
self.disableAjax = false; // 失败后 允许再次 请求
|
|
|
})
|
|
|
.always(function() {
|
|
|
self.disableAjax = false;
|
|
|
$nextBtn.prop('disabled', self.disableAjax);
|
|
|
});
|
|
|
}
|
|
|
};
|
...
|
...
|
|