时间:2021-07-01 10:21:17 帮助过:9人阅读
$.ajax({
type: "POST",
url: "/thinkphp/blog/User/Login/login",
dataType: "json",
data: {"user":admin_name,"pwd":admin_pass,"authcode":authcode},
beforeSend: function(){
$('').addClass("loading").html("{:L('login_')}").css("color","#FF0000").appendTo('.login_btn');
},
success: function(json){
if(json.success==1){
$("#msg").remove();
$('').addClass("notice_y").html(json.msg).appendTo('.div_c').fadeOut(3000);
location.href="{:U('Index/index')}";
}else{
$("#msg").remove();
$('').addClass("notice").html(json.msg).css("color","#FF0000").appendTo('.div_c').fadeOut(3000,function(){
return false;
});
//location.href="{:U('Login/index')}";
//return false;
}
}
});
//登陆验证
public function login(){
if(!IS_POST){
$array['msg']='页面不存在';
$array['success']=0;
$this->ajaxReturn($array);
}
$user = I('admin_name','','htmlspecialchars','trim');
$pass = I('pwd','');
$verify = I('authcode','','htmlspecialchars','trim');
//检测验证码
if(!check_verify($verify)){
$array['msg']=L('login_vcode_error');
$array['success']=0;
$this->ajaxReturn($array);
}
$admin = M('admin')->where(array('username'=>$user))->find();
//dump($admin);
//判断密码是否正确
if(!$admin || ($admin['password']) != md5($pass)){
$array['msg']=L('login_fail');
$array['success']=0;
$this->ajaxReturn($array);
}
//判断是否被锁定
elseif($user['IsLock']==1){
$array['msg']=L('login_IsLock');
$array['success']=0;
$this->ajaxReturn($array);
}
}