This commit is contained in:
2020-02-17 22:34:34 +08:00
parent 58d999ed73
commit 259d232d89
109 changed files with 10344 additions and 89 deletions

View File

@@ -9,6 +9,7 @@
namespace app\controller\admin;
use app\controller\Admin;
use app\model\Member;
/**
* @title 后端公共模块
@@ -24,18 +25,79 @@ class Index extends Admin {
}
/**
* @title 后台登录
* @return html [description]
* @title 用户登录
* @return html
*/
public function login() {
return $this->fetch();
public function login(Member $user, $username = '', $password = '', $verify = '') {
if ($this->request->isPost()) {
if (!$username || !$password) {
return $this->error('用户名或者密码不能为空!', '');
}
//验证码验证
if (!captcha_check($verify)) {
return $this->error('验证码错误!', '');
}
$userinfo = $user->login($this->request);
if ($userinfo) {
// return $this->success('登录成功!', url('admin/index/index'));
} else {
print_r($user->error);
// switch ($uid) {
// case -1:$error = '用户不存在或被禁用!';
// break; //系统级别禁用
// case -2:$error = '密码错误!';
// break;
// default:$error = '未知错误!';
// break; // 0-接口参数错误(调试阶段使用)
// }
return $this->error($error, '');
}
} else {
return $this->fetch();
}
}
/**
* @title 后台退出
* @return html [description]
* @return html
*/
public function logout() {
return $this->fetch();
$user = model('Member');
$user->logout();
$this->redirect('admin/index/login');
}
/**
* @title 清除缓存
* @return html
*/
public function clear() {
if ($this->request->isPost()) {
$clear = input('post.clear/a', array());
foreach ($clear as $key => $value) {
if ($value == 'cache') {
\think\Cache::clear(); // 清空缓存数据
} elseif ($value == 'log') {
\think\Log::clear();
}
}
return $this->success("更新成功!", url('admin/index/index'));
} else {
$keylist = array(
array('name' => 'clear', 'title' => '更新缓存', 'type' => 'checkbox', 'help' => '', 'option' => array(
'cache' => '缓存数据',
'log' => '日志数据',
),
),
);
$data = array(
'keyList' => $keylist,
);
$this->assign($data);
$this->setMeta("更新缓存");
return $this->fetch('public/edit');
}
}
}