own -- 获取验证码的按钮
function sendVerifyCode(own) {
var $this = $(own);
//判断此按钮是否被禁用
if ($this.hasClass("am-disabled")) {
return;
}
var phone = $("#phone").val();
$.ajax({
url: "/public/verifyCode/sendVerifyCode",
type: "post",
data: {phone: phone, type: 1},
dataType: "json",
success: function (response) {
if (!response.success) {
showErrorMessage(response.message);
return;
}
showSuccessMessage("请注意接听语音电话");
//禁用此按钮
$this.addClass("am-disabled");
$this.text("60秒后重新获取");
var second = 60;
var inter = setInterval(function () {
second = second - 1;
$this.text(second + "秒后重新获取");
if (second < 0) {
$this.removeClass("am-disabled");
$this.text("获取验证码");
window.clearInterval(inter);
}
}, 1000)
}
})
}