作者 xiaohu thinkpad
... ... @@ -39,45 +39,40 @@
<script>
$(function () {
//获取短信验证码
var times = 1;
var validCode = true;
$(".get_code").click(function () {
if (validCode) {
var user_phone = $(".login_phone").val();
console.log(user_phone);
if (!user_phone) {
layer.msg("手机号码格式不正确")
} else {
if (times == 1) {
times++;
$.ajax({
type: "post",
url: "{:url('portal/tool/get_sms_code')}",
data: {
mobile: user_phone
},
success: function () {
var time = 60;
var code = $(".get_code");
if (validCode) {
code.html("60秒");
validCode = false;
code.addClass("msgs1");
var t = setInterval(function () {
if (time >= 0) {
time--;
code.html(time + "秒");
validCode = false;
} else {
validCode = true;
code.html("重新获取");
clearInterval(t);
}
}, 1000)
}
$.ajax({
type: "post",
url: "{:url('portal/tool/get_sms_code')}",
data: {
mobile: user_phone
},
success: function () {
var time = 60;
var code = $(".get_code");
if (validCode) {
code.html("60秒");
validCode = false;
code.addClass("msgs1");
var t = setInterval(function () {
if (time > 0) {
time--;
code.html(time + "秒");
validCode = false;
} else {
code.html("重新获取");
clearInterval(t);
validCode = true;
}
}, 1000)
}
})
}
}
})
}
}
});
... ...