mirror of
https://gitee.com/apiadmin/ApiAdmin.git
synced 2025-05-25 14:29:25 +08:00
modified Ajax提交的状态码识别异常的BUG
finish 数据模型自动完成和数据增删改查的适配
This commit is contained in:
parent
9a957a4692
commit
848a121689
@ -10,7 +10,7 @@ use think\Controller;
|
|||||||
|
|
||||||
class Base extends Controller {
|
class Base extends Controller {
|
||||||
|
|
||||||
protected $primaryKey;
|
public $primaryKey;
|
||||||
|
|
||||||
public function _initialize(){
|
public function _initialize(){
|
||||||
$this->primaryKey = config('SQL_PRIMARY_KEY');
|
$this->primaryKey = config('SQL_PRIMARY_KEY');
|
||||||
|
@ -32,21 +32,18 @@ class User extends Base {
|
|||||||
return $this->error('用户名或者密码错误!');
|
return $this->error('用户名或者密码错误!');
|
||||||
}else{
|
}else{
|
||||||
if( $userInfo['status'] ){
|
if( $userInfo['status'] ){
|
||||||
|
|
||||||
//保存用户信息和登录凭证
|
//保存用户信息和登录凭证
|
||||||
cache($userInfo[$this->primaryKey], session_id(), config('online_time'));
|
|
||||||
session('uid', $userInfo[$this->primaryKey]);
|
session('uid', $userInfo[$this->primaryKey]);
|
||||||
|
cache($userInfo[$this->primaryKey], session_id(), config('online_time'));
|
||||||
//获取跳转链接,做到从哪来到哪去
|
//获取跳转链接,做到从哪来到哪去
|
||||||
if( $request->has('from', 'get') ){
|
if( $request->has('from', 'get') ){
|
||||||
$url = $request->get('from');
|
$url = $request->get('from');
|
||||||
}else{
|
}else{
|
||||||
$url = url('Index/index');
|
$url = url('Index/index');
|
||||||
}
|
}
|
||||||
|
|
||||||
//更新用户数据
|
//更新用户数据
|
||||||
$userData = UserData::get(['uid' => $userInfo[$this->primaryKey]]);
|
$userData = UserData::get(['uid' => $userInfo[$this->primaryKey]]);
|
||||||
if( $userData->uid ){
|
if( $userData ){
|
||||||
$userData->loginTimes += 1;
|
$userData->loginTimes += 1;
|
||||||
$userData->save();
|
$userData->save();
|
||||||
}else{
|
}else{
|
||||||
@ -55,7 +52,6 @@ class User extends Base {
|
|||||||
$newUserData->uid = $userInfo[$this->primaryKey];
|
$newUserData->uid = $userInfo[$this->primaryKey];
|
||||||
$newUserData->save();
|
$newUserData->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->success('登录成功', $url);
|
return $this->success('登录成功', $url);
|
||||||
}else{
|
}else{
|
||||||
return $this->error('用户已被封禁,请联系管理员');
|
return $this->error('用户已被封禁,请联系管理员');
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="login-box-body">
|
<div class="login-box-body">
|
||||||
<p class="login-box-msg">
|
<p class="login-box-msg">
|
||||||
<span class="label label-info">请填写您的账号和密码</span>
|
<span class="label label-info">请填写您的账号和密码(admin/123123)</span>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<form action="{:url('User/login')}" id="form-login">
|
<form action="{:url('User/login')}" id="form-login">
|
||||||
|
9
public/static/admin/dist/js/template.js
vendored
9
public/static/admin/dist/js/template.js
vendored
@ -31,7 +31,7 @@
|
|||||||
});
|
});
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
dialog.modal('hide');
|
dialog.modal('hide');
|
||||||
}, 2000);
|
}, 3000);
|
||||||
};
|
};
|
||||||
|
|
||||||
$.buildDom = function ( jsonStr ) {
|
$.buildDom = function ( jsonStr ) {
|
||||||
@ -87,20 +87,21 @@
|
|||||||
query = form.serialize();
|
query = form.serialize();
|
||||||
target = form.attr('action');
|
target = form.attr('action');
|
||||||
$.post(target, query).success(function(data) {
|
$.post(target, query).success(function(data) {
|
||||||
if (data.status == 1) {
|
if (data.code == 1) {
|
||||||
if (data.url) {
|
if (data.url) {
|
||||||
message = data.msg + ' 页面即将自动跳转~';
|
message = data.msg + ' 页面即将自动跳转...';
|
||||||
} else {
|
} else {
|
||||||
message = data.msg;
|
message = data.msg;
|
||||||
}
|
}
|
||||||
$.alertMsg(message);
|
$.alertMsg(message);
|
||||||
|
var wait = 1000*data.wait;
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
if (data.url) {
|
if (data.url) {
|
||||||
location.href = data.url;
|
location.href = data.url;
|
||||||
} else {
|
} else {
|
||||||
location.reload();
|
location.reload();
|
||||||
}
|
}
|
||||||
}, 2000);
|
}, wait);
|
||||||
} else {
|
} else {
|
||||||
$.alertMsg(data.msg);
|
$.alertMsg(data.msg);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user