完善登录登出操作

This commit is contained in:
Anyon 2017-02-13 01:28:39 -05:00
parent f674acc31c
commit 335d3c279b
3 changed files with 38 additions and 22 deletions

View File

@ -1,17 +1,26 @@
<?php
namespace app\admin\controller;
use think\Controller;
use controller\BasicAdmin;
use think\Db;
/**
* 系统登录控制器
* Class Login
*
* @package app\admin\controller
* @author Anyon <zoujingli@qq.com>
* @date 2017/02/10 13:59
*/
class Login extends Controller {
class Login extends BasicAdmin {
/**
* 控制器基础方法
*/
public function _initialize() {
if ($this->isLogin() && $this->request->action() !== 'out') {
$this->redirect('@admin');
}
}
/**
* 用户登录

View File

@ -4,16 +4,33 @@ namespace controller;
use think\Controller;
/**
* 后台权限基础控制器
*
* @package controller
* @author Anyon <zoujingli@qq.com>
* @date 2017/02/13 14:24
*/
class BasicAdmin extends Controller {
/**
* 后台权限控制初始化方法
*/
public function _initialize() {
parent::_initialize();
if (!$this->isLogin()) {
$this->redirect('@admin/login');
}
}
/**
* 判断用户是否登录
* @return bool
*/
public function isLogin() {
return false;
$user = session('user');
if (empty($user) || empty($user['id'])) {
return false;
}
return true;
}
}

View File

@ -161,25 +161,15 @@ define(['zeroclipboard', 'jquery', 'layui'], function (ZeroClipboard) {
*/
msg.prototype.auto = function (data, time) {
var self = this;
if (data.code === 1) {
self.success(data.msg, time, function () {
if (data.url === 'back') {
window.history.back();
} else if (data.url === 'reload') {
$.form.reload();
} else if (data.url) {
window.location.href = data.url;
} else {
$.form.reload();
}
});
} else {
self.error(data.msg, 3000, function () {
if (data.url) {
window.location.href = data.url;
}
if (parseInt(data.code) === 1) {
return self.success(data.msg, time, function () {
alert(data.url);
!!data.url ? (window.location.href = data.url) : $.form.reload();
});
}
self.error(data.msg, 3000, function () {
!!data.url && (window.location.href = data.url);
});
};
/**