You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.3 KiB

$(function () {
function bindCaptchaBtnClick() {
$("#captcha-btn").click(function (event) {
let $this = $(this);
let email = $("input[name='email']").val();
if (!email) {
alert("请输入邮箱");
return;
}
$this.off("click");
$.ajax('/auth/captcha?email='+email,{
method: "GET",
success: function (result) {
if (result.code === 200) {
alert("验证码发送成功");
}else {
alert(result['message']);
}
console.log(result);
},
fail: function (error) {
console.log(error);
}
})
let countdown = 6;
let timer = setInterval(function () {
if (countdown <= 0) {
$this.text("发送验证码");
clearInterval(timer);
bindCaptchaBtnClick();
} else {
countdown--;
$this.text(countdown + "s");
}
}, 1000);
})
}
bindCaptchaBtnClick();
});