sae中短信验证码:

; (function($) {
$(document).ready(function() {
if (parent && parent.location.href != location.href) parent.location.href = location.href;
var timelineBox = $('.timeline-box') timelineBox.find('.progress .bar').each(function(k, v) {
$(v).css('width', '25%')
}) var retryBtn = $('#get-vcode');
var codeBox = $('#verify');
retryBtn.addClass('disabled').fadeIn().on('click',
function(e) {
e.preventDefault();
});
var pageTimer = function(limit, interval) {
retryBtn.attr('data-ready', 'loading').addClass('disabled').off('click').on('click',
function(e) {
e.preventDefault();
});
setTimeout(function() {
if (limit > interval) {
limit -= interval;
retryBtn.text('重新获取验证码(' + parseInt(limit / 1000) + 's)');
setTimeout(arguments.callee, interval);
} else {
retryBtn.attr('data-ready', 'ready').text('重新获取验证码').removeClass('disabled').off('click').on('click', retryBtnFunc);
}
},
interval);
}
pageTimer(60000, 1000);
var retryBtnFunc = function(e) {
e.preventDefault();
if (retryBtn.attr('data-ready') == 'ready') {
$.ajax({
url: '/?m=user&a=send_mobile_code',
type: 'POST',
dataType: 'JSON',
success: function(resp, state, xhr) {
var success = xhr.getResponseHeader('reg_ok');
if (success) {
location.href = '/?m=user&a=finish_register';
} else if (xhr.getResponseHeader('sae_ok') || resp.event > 299) {
retryBtn.popover('destroy');
retryBtn.popover({
title: '系统提示',
content: resp.message
}).popover('show');
codeBox[0].select();
pageTimer(60000, 1000);
}
}
}) pageTimer(60000, 1000);
}
}
$('#verify-mobile').on('click',
function(e) {
e.preventDefault();
var ret = $SAETOOLS.trim(codeBox.val());
if (ret.length) {
$.ajax({
url: '/?m=user&a=check_mobile_code',
data: 'vcode=' + ret,
type: 'POST',
dataType: 'JSON',
success: function(data, state, xhr) {
var success = xhr.getResponseHeader('reg_ok');
if (success) {
location.href = '/?m=user&a=finish_register';
} else if (xhr.getResponseHeader('sae_ok') || data.event > 299) {
if (422 == data.event) {
retryBtn.popover('destroy');
$('#verify').popover('destroy').popover({
title: '系统提示',
content: data.message
}).popover('show');
$('#get-vcode').remove();
} else if (data.event <= 299 && data.event >= 200) {
location.href = '/?m=user&a=finish_register';
} else {
retryBtn.popover({
title: '系统提示',
content: data.message
}).popover('show');
codeBox[0].select();
pageTimer(60000, 1000);
}
}
}
})
} else {
codeBox.popover('destroy');
codeBox.popover({
title: '系统提示',
content: '请输入验证码,如果没有收到验证码,可以尝试发送短信到服务器进行手动验证。'
}).popover('show');
codeBox[0].select();
}
});
$('#step-second').on('click',
function(e) {
e.preventDefault();
location.href = '/?m=user&a=security2';
})
})
})(jQuery)
05-06 14:46