72 lines
2.6 KiB
JavaScript
72 lines
2.6 KiB
JavaScript
(function(){
|
|
X.pageLogic['login'] = {
|
|
init : function(){
|
|
|
|
var userinfo = localStorage.getItem('loginData');
|
|
if(userinfo){
|
|
X.DATA["userinfo"] = JSON.parse(userinfo);
|
|
X.loginCache(JSON.parse(userinfo));
|
|
X.gourl("dashboard");
|
|
};
|
|
|
|
$(".login-denglu").click(function(){
|
|
postlogin();
|
|
});
|
|
|
|
document.onkeydown=function(ev){
|
|
var event=ev ||event
|
|
if(event.keyCode==13){
|
|
|
|
postlogin();
|
|
|
|
}
|
|
};
|
|
var timer = null;
|
|
var time = 60;
|
|
$(".get-verification-but").click(function(e){
|
|
var account = $(".login-txt-box .account").val();
|
|
if(account == ""){
|
|
layer.msg('请输入用户名', { icon: 3, time: 1000 });
|
|
return
|
|
}
|
|
if(time != 60){
|
|
return
|
|
}
|
|
X.api('user/send_auth_code','post',{name:account},function(d){
|
|
layer.msg('验证码已发送请在钉钉消息里查看!!!', {
|
|
icon: 1,
|
|
time: 1000
|
|
}, function() {
|
|
timer = setInterval(() => {
|
|
time--
|
|
$(".get-verification-but").html(time + 's');
|
|
if (time == 0) {
|
|
clearInterval(timer);
|
|
$(".get-verification-but").html('获取验证码');
|
|
$('.get-verification-but').removeClass('on-get-verification-but');
|
|
} else {
|
|
$('.get-verification-but').addClass('on-get-verification-but');
|
|
}
|
|
}, 1000)
|
|
});
|
|
})
|
|
|
|
})
|
|
|
|
function postlogin(){
|
|
var account = $(".login-txt-box .account").val();
|
|
var password = $(".login-txt-box .password").val();
|
|
var code = $(".verification").val();
|
|
// X.gourl("dashboard");
|
|
X.api('user/login',"post",{username:account,password:password,scope:code},function (d){
|
|
// console.log(d);
|
|
X.DATA["userinfo"] = d;
|
|
X.loginCache(d);
|
|
X.gourl("dashboard");
|
|
});
|
|
};
|
|
|
|
}
|
|
};
|
|
|
|
})(); |