From 77abc59125fb40f7b7a19875400011b4b3c2e758 Mon Sep 17 00:00:00 2001 From: augushong Date: Fri, 23 Aug 2019 13:35:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E8=B4=A6=E6=88=B7=E7=AE=A1?= =?UTF-8?q?=E7=90=86;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- app/admin/controller/Admin.php | 72 ++++++++++++++++++++ app/admin/controller/Common.php | 3 + app/admin/controller/Login.php | 7 ++ app/common.php | 7 +- app/model/Admin.php | 5 ++ database/seeds/InitSystemConfig.php | 42 ++++++++++++ view/admin/admin/edit.html | 100 ++++++++++++++++++++++++++++ view/admin/admin/password.html | 68 +++++++++++++++++++ view/admin/common/_header.html | 10 +-- view/admin/common/left_admin.html | 13 ++++ view/admin/login/index.html | 2 +- 12 files changed, 323 insertions(+), 8 deletions(-) create mode 100644 app/admin/controller/Admin.php create mode 100644 database/seeds/InitSystemConfig.php create mode 100644 view/admin/admin/edit.html create mode 100644 view/admin/admin/password.html create mode 100644 view/admin/common/left_admin.html diff --git a/README.md b/README.md index 8dc90eb..6dcbb52 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ - 服务器信息(已完成) - 系统配置(已完成) - 管理员管理 -- 账户管理 +- 账户管理(已完成) - 用户管理 - 权限管理 - 文件管理 diff --git a/app/admin/controller/Admin.php b/app/admin/controller/Admin.php new file mode 100644 index 0000000..a8534e0 --- /dev/null +++ b/app/admin/controller/Admin.php @@ -0,0 +1,72 @@ +adminInfo['id']); + + View::assign('admin',$model_admin); + + return View::fetch(); + } + + public function password() + { + return View::fetch(); + } + + public function passwordUpdate() + { + + $post_data = $this->request->post(); + + if(empty($post_data['new_password'])){ + return $this->error('新密码不能为空'); + } + $model_admin = AppAdmin::find($this->adminInfo['id']); + + if(md5($post_data['original_password'].$model_admin->getData('salt')) != $model_admin->getData('password')){ + return $this->error('原密码错误'); + } + + if($post_data['new_password'] != $post_data['check_password']){ + return $this->error('新密码与确认密码不一致'); + } + + + $model_admin->password = md5($post_data['new_password'].$model_admin->getData('salt')); + + $model_admin->save(); + + return $this->success('修改成功'); + + } + + public function update() + { + $post_data = $this->request->post(); + $model_admin = AppAdmin::find($this->adminInfo['id']); + + if($model_admin->getData('avatar') != $post_data['avatar']){ + UploadFiles::destroy(['save_name'=>$model_admin->getData('avatar')]); + UploadFiles::update(['used_time'=>time()],['save_name'=>$post_data['avatar']]); + } + + + $model_admin->data($post_data); + + $model_admin->save(); + + return $this->success('保存成功','Admin/edit'); + } +} diff --git a/app/admin/controller/Common.php b/app/admin/controller/Common.php index eeb20b6..d88b893 100644 --- a/app/admin/controller/Common.php +++ b/app/admin/controller/Common.php @@ -5,6 +5,7 @@ use app\BaseController; use think\facade\Session; use app\model\Admin; use think\exception\HttpResponseException; +use think\facade\View; class Common extends BaseController{ @@ -30,5 +31,7 @@ class Common extends BaseController{ } } + View::assign('admin',$this->adminInfo); + } } \ No newline at end of file diff --git a/app/admin/controller/Login.php b/app/admin/controller/Login.php index 50799bd..7d55082 100644 --- a/app/admin/controller/Login.php +++ b/app/admin/controller/Login.php @@ -48,4 +48,11 @@ class Login extends Common return json_message(); } + + public function logout() + { + Session::clear(); + + $this->success('已经安全退出','Login/Index'); + } } diff --git a/app/common.php b/app/common.php index a19a7d8..cc9d351 100644 --- a/app/common.php +++ b/app/common.php @@ -33,15 +33,20 @@ function json_message($data = [],$code = 0,$msg = '') ]); } -function get_system_config($name,$default = '') +function get_system_config($name = '',$default = '') { + $list = Cache::get('system_config'); if(empty($list)){ $list = SystemConfig::column('value','name'); } + if($name === ''){ + return $list; + } + if(isset($list[$name])){ return $list[$name]; } diff --git a/app/model/Admin.php b/app/model/Admin.php index 3910a40..faadbac 100644 --- a/app/model/Admin.php +++ b/app/model/Admin.php @@ -10,4 +10,9 @@ use think\Model; class Admin extends Model { // + + public function getAvatarAttr($value) + { + return \get_source_link($value); + } } diff --git a/database/seeds/InitSystemConfig.php b/database/seeds/InitSystemConfig.php new file mode 100644 index 0000000..8eda86f --- /dev/null +++ b/database/seeds/InitSystemConfig.php @@ -0,0 +1,42 @@ +'奥宏后台管理小模板' + ]; + + $list = get_system_config(); + + foreach ($data as $key => $value) { + + if(isset($list[$key])){ + SystemConfig::where('name',$key)->update(['value'=>$value]); + }else{ + $model_sysconfig = new SystemConfig(); + $model_sysconfig->name = $key; + $model_sysconfig->value = $value; + $model_sysconfig->save(); + } + + $list[$key] = $value; + } + + Cache::set('system_config',$list); + } +} \ No newline at end of file diff --git a/view/admin/admin/edit.html b/view/admin/admin/edit.html new file mode 100644 index 0000000..bd0500b --- /dev/null +++ b/view/admin/admin/edit.html @@ -0,0 +1,100 @@ + + + + + + + 基本资料 + {include file="common/_require"} + + + +
+ {include file="common/_header"} + + {include file="common/left_admin"} + +
+ +
+
+ + 首页 + 基本资料 + +
+
+
+
+
+ 资料管理 +
+
+
+
登录账号
+
+ +
+
+
+
昵称
+
+ +
+
+
+
头像
+
+
+
上传
+
+
+ +
+ +
+
+
+ +
+
+
+
+
+
+
+
+
+ + + {include file="common/_footer"} + + +
+ + \ No newline at end of file diff --git a/view/admin/admin/password.html b/view/admin/admin/password.html new file mode 100644 index 0000000..63e4c52 --- /dev/null +++ b/view/admin/admin/password.html @@ -0,0 +1,68 @@ + + + + + + + 基本资料 + {include file="common/_require"} + + + +
+ {include file="common/_header"} + + {include file="common/left_admin"} + +
+ +
+
+ + 首页 + 密码管理 + +
+
+
+
+
+ 密码管理 +
+
+
+
原密码
+
+ +
+
+
+
新密码
+
+ +
+
+
+
确认密码
+
+ +
+
+
+ +
+
+
+
+
+
+
+
+
+ + + {include file="common/_footer"} + +
+ + \ No newline at end of file diff --git a/view/admin/common/_header.html b/view/admin/common/_header.html index ef41d79..0875f7c 100644 --- a/view/admin/common/_header.html +++ b/view/admin/common/_header.html @@ -9,15 +9,15 @@ \ No newline at end of file diff --git a/view/admin/common/left_admin.html b/view/admin/common/left_admin.html new file mode 100644 index 0000000..c65df59 --- /dev/null +++ b/view/admin/common/left_admin.html @@ -0,0 +1,13 @@ +
+
+ + +
+
\ No newline at end of file diff --git a/view/admin/login/index.html b/view/admin/login/index.html index f672cd1..2ab5562 100644 --- a/view/admin/login/index.html +++ b/view/admin/login/index.html @@ -31,7 +31,7 @@