modified Ajax提交的状态码识别异常的BUG

finish 数据模型自动完成和数据增删改查的适配
This commit is contained in:
zhaoxiang 2016-11-06 01:11:50 +08:00
parent 9a957a4692
commit 848a121689
4 changed files with 9 additions and 12 deletions

View File

@ -10,7 +10,7 @@ use think\Controller;
class Base extends Controller {
protected $primaryKey;
public $primaryKey;
public function _initialize(){
$this->primaryKey = config('SQL_PRIMARY_KEY');

View File

@ -32,21 +32,18 @@ class User extends Base {
return $this->error('用户名或者密码错误!');
}else{
if( $userInfo['status'] ){
//保存用户信息和登录凭证
cache($userInfo[$this->primaryKey], session_id(), config('online_time'));
session('uid', $userInfo[$this->primaryKey]);
cache($userInfo[$this->primaryKey], session_id(), config('online_time'));
//获取跳转链接,做到从哪来到哪去
if( $request->has('from', 'get') ){
$url = $request->get('from');
}else{
$url = url('Index/index');
}
//更新用户数据
$userData = UserData::get(['uid' => $userInfo[$this->primaryKey]]);
if( $userData->uid ){
if( $userData ){
$userData->loginTimes += 1;
$userData->save();
}else{
@ -55,7 +52,6 @@ class User extends Base {
$newUserData->uid = $userInfo[$this->primaryKey];
$newUserData->save();
}
return $this->success('登录成功', $url);
}else{
return $this->error('用户已被封禁,请联系管理员');

View File

@ -20,7 +20,7 @@
</div>
<div class="login-box-body">
<p class="login-box-msg">
<span class="label label-info">请填写您的账号和密码</span>
<span class="label label-info">请填写您的账号和密码admin/123123</span>
</p>
<form action="{:url('User/login')}" id="form-login">

View File

@ -31,7 +31,7 @@
});
setTimeout(function(){
dialog.modal('hide');
}, 2000);
}, 3000);
};
$.buildDom = function ( jsonStr ) {
@ -87,20 +87,21 @@
query = form.serialize();
target = form.attr('action');
$.post(target, query).success(function(data) {
if (data.status == 1) {
if (data.code == 1) {
if (data.url) {
message = data.msg + ' 页面即将自动跳转~';
message = data.msg + ' 页面即将自动跳转...';
} else {
message = data.msg;
}
$.alertMsg(message);
var wait = 1000*data.wait;
setTimeout(function() {
if (data.url) {
location.href = data.url;
} else {
location.reload();
}
}, 2000);
}, wait);
} else {
$.alertMsg(data.msg);
}