From f08ae0bc69e283e237ba65497176efd86731134c Mon Sep 17 00:00:00 2001 From: tensent Date: Thu, 9 Apr 2020 20:39:05 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3linux=E4=B8=8B=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=90=8D=E5=A4=A7=E5=B0=8F=E5=86=99=E7=9A=84bug?= =?UTF-8?q?=E3=80=81=E5=AE=8C=E5=96=84=E7=94=A8=E6=88=B7=E4=B8=AD=E5=BF=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/user/Base.php | 13 ++- app/controller/user/Content.php | 39 ++++++- app/controller/user/Form.php | 25 +++++ app/controller/user/Index.php | 56 +++++----- app/controller/user/{Login.php => User.php} | 63 ++++++----- public/static/admin/css/style.css | 2 +- public/static/common/css/main.css | 2 +- public/template/default/user/base.html | 26 +++-- .../template/default/user/content_index.html | 71 ++++++++++++ .../{index_avatar.html => form_index.html} | 0 public/template/default/user/user_avatar.html | 10 ++ .../{index_profile.html => user_profile.html} | 0 ...index_repasswd.html => user_repasswd.html} | 0 view/admin/content/index.html | 103 +++++++++--------- 14 files changed, 280 insertions(+), 130 deletions(-) create mode 100644 app/controller/user/Form.php rename app/controller/user/{Login.php => User.php} (53%) create mode 100644 public/template/default/user/content_index.html rename public/template/default/user/{index_avatar.html => form_index.html} (100%) create mode 100644 public/template/default/user/user_avatar.html rename public/template/default/user/{index_profile.html => user_profile.html} (100%) rename public/template/default/user/{index_repasswd.html => user_repasswd.html} (100%) diff --git a/app/controller/user/Base.php b/app/controller/user/Base.php index c2bc4216..736d8128 100644 --- a/app/controller/user/Base.php +++ b/app/controller/user/Base.php @@ -10,17 +10,24 @@ namespace app\controller\user; use think\facade\View; use think\facade\Cache; -use \app\controller\Base as BaseC; +use app\controller\Base as BaseC; +use app\model\Model; +use app\model\Form; class Base extends BaseC { protected function initialize() { $url = str_replace(".", "/", strtolower($this->request->controller())) . '/' . $this->request->action(); if (!is_login() and !in_array($url, array('admin/index/login', 'admin/index/logout', 'admin/index/verify'))) { - $this->redirect('/admin/index/login'); + $this->redirect('/user/index/login'); } - if (!in_array($url, array('admin/index/login', 'admin/index/logout', 'admin/index/verify'))) { + if (!in_array($url, array('user/index/login', 'user/index/logout', 'user/index/verify'))) { + $map = []; + $model = Model::where($map)->column('name, title, icon', 'name'); + View::assign('model', $model); + $form = Form::where($map)->column('id, name, title', 'name'); + View::assign('form', $form); View::assign('meta_title', isset($this->data['meta_title']) ? $this->data['meta_title'] : $this->getCurrentTitle()); } } diff --git a/app/controller/user/Content.php b/app/controller/user/Content.php index 1f2def81..44a048fb 100644 --- a/app/controller/user/Content.php +++ b/app/controller/user/Content.php @@ -8,17 +8,54 @@ // +---------------------------------------------------------------------- namespace app\controller\user; +use think\facade\Db; +use app\model\Model; +use app\model\Attribute; + /** * @title 内容模块 */ class Content extends Base { + public $modelInfo = []; + public $model = null; + + public function initialize() { + parent::initialize(); + $this->modelInfo = Model::where('name', $this->request->param('name'))->find()->append(['grid_list', 'attr_group'])->toArray(); + $this->model = Db::name($this->modelInfo['name']); + } + /** * @title 内容首页 * @return [type] [description] */ public function index() { - return $this->fetch(); + if ($this->modelInfo['list_grid'] == '') { + return $this->error("列表定义不正确!", url('/user/model/edit', array('id' => $this->modelInfo['id']))); + } + $order = "id desc"; + $map = []; + $map[] = ['uid', '=', session('userInfo.uid')]; + + $list = $this->model->where($map)->order($order)->paginate($this->modelInfo['list_row'], false, array( + 'query' => $this->request->param(), + )); + + $this->data = array( + 'grid' => $this->modelInfo['grid_list'], + 'list' => $list, + 'page' => $list->render(), + 'model_name' => $this->modelInfo['name'], + 'model_id' => $this->modelInfo['id'], + 'meta_title' => $this->modelInfo['title'].'列表' + ); + if ($this->modelInfo['template_list']) { + $template = 'user@content/' . $this->modelInfo['template_list']; + } else { + $template = 'user@content/index'; + } + return $this->fetch($template); } /** diff --git a/app/controller/user/Form.php b/app/controller/user/Form.php new file mode 100644 index 00000000..e8088f7d --- /dev/null +++ b/app/controller/user/Form.php @@ -0,0 +1,25 @@ + +// +---------------------------------------------------------------------- +namespace app\controller\user; + +use app\model\Member; + +/** + * @title 表单管理 + */ +class Form extends Base { + + /** + * @title 表单数据列表 + * @return [type] [description] + */ + public function index(){ + return $this->fetch(); + } +} \ No newline at end of file diff --git a/app/controller/user/Index.php b/app/controller/user/Index.php index b9c0b682..ed74391b 100644 --- a/app/controller/user/Index.php +++ b/app/controller/user/Index.php @@ -8,8 +8,6 @@ // +---------------------------------------------------------------------- namespace app\controller\user; -use app\model\Member; - /** * @title 用户中心 */ @@ -24,40 +22,42 @@ class Index extends Base { } /** - * @title 个人资料 + * @title 用户登录 * @return [type] [description] */ - public function profile() { - if ($this->request->isPost()) { - $reuslt = (new Member())->editUser($this->request, session('userInfo.uid')); - if (false !== $reuslt) { - return $this->success('修改成功!'); - } else { - return $this->error('修改失败'); - } - }else{ - $info = Member::find(session('userInfo.uid')); - $this->data = [ - 'info' => $info, - 'keyList' => Member::$useredit - ]; - return $this->fetch('user@/edit'); - } + public function login() { + return $this->fetch(); + } + + /** + * @title 用户退出 + * @return [type] [description] + */ + public function logout() { + return $this->fetch(); + } + + /** + * @title 用户注册 + * @return [type] [description] + */ + public function register() { + return $this->fetch(); + } + + /** + * @title 忘记密码 + * @return [type] [description] + */ + public function forget() { + return $this->fetch(); } /** * @title 重置密码 * @return [type] [description] */ - public function repasswd() { - return $this->fetch(); - } - - /** - * @title 上传头像 - * @return [type] [description] - */ - public function avatar() { + public function resetpasswd() { return $this->fetch(); } } \ No newline at end of file diff --git a/app/controller/user/Login.php b/app/controller/user/User.php similarity index 53% rename from app/controller/user/Login.php rename to app/controller/user/User.php index ce4af389..b8cb7609 100644 --- a/app/controller/user/Login.php +++ b/app/controller/user/User.php @@ -8,48 +8,47 @@ // +---------------------------------------------------------------------- namespace app\controller\user; +use app\model\Member; + /** - * @title 登录注册 + * @title 用户管理 */ -class Login extends Base { - +class User extends Base { /** - * @title 用户登录 + * @title 个人资料 * @return [type] [description] */ - public function index() { - return $this->fetch(); - } - - /** - * @title 用户退出 - * @return [type] [description] - */ - public function logout() { - return $this->fetch(); - } - - /** - * @title 用户注册 - * @return [type] [description] - */ - public function register() { - return $this->fetch(); - } - - /** - * @title 忘记密码 - * @return [type] [description] - */ - public function forget() { - return $this->fetch(); + public function profile() { + if ($this->request->isPost()) { + $reuslt = (new Member())->editUser($this->request, session('userInfo.uid')); + if (false !== $reuslt) { + return $this->success('修改成功!'); + } else { + return $this->error('修改失败'); + } + }else{ + $info = Member::find(session('userInfo.uid')); + $this->data = [ + 'info' => $info, + 'keyList' => Member::$useredit + ]; + return $this->fetch('user@/edit'); + } } /** * @title 重置密码 * @return [type] [description] */ - public function resetpasswd() { + public function repasswd() { return $this->fetch(); } -} + + /** + * @title 上传头像 + * @return [type] [description] + */ + public function avatar() { + return $this->fetch(); + } +} \ No newline at end of file diff --git a/public/static/admin/css/style.css b/public/static/admin/css/style.css index 0b023cf6..8919fc4b 100644 --- a/public/static/admin/css/style.css +++ b/public/static/admin/css/style.css @@ -1,6 +1,6 @@ @import url(../../common/css/font-awesome.min.css); @import url(../../plugins/bootstrap/css/bootstrap.min.css); -@import url(../../plugins/adminlte/css/adminlte.min.css); +@import url(../../plugins/adminlte/css/AdminLTE.min.css); @import url(../../plugins/adminlte/css/skins/_all-skins.min.css); .user-list tbody td>img { diff --git a/public/static/common/css/main.css b/public/static/common/css/main.css index e61b488d..1d199bad 100644 --- a/public/static/common/css/main.css +++ b/public/static/common/css/main.css @@ -1,4 +1,4 @@ @import url(font-awesome.min.css); @import url(../../plugins/bootstrap/css/bootstrap.min.css); -@import url(../../plugins/adminlte/css/adminlte.min.css); +@import url(../../plugins/adminlte/css/AdminLTE.min.css); @import url(../../plugins/adminlte/css/skins/_all-skins.min.css); \ No newline at end of file diff --git a/public/template/default/user/base.html b/public/template/default/user/base.html index 2a0f6fd7..7239631e 100644 --- a/public/template/default/user/base.html +++ b/public/template/default/user/base.html @@ -32,9 +32,9 @@ @@ -100,10 +100,10 @@ @@ -139,18 +139,22 @@ diff --git a/public/template/default/user/content_index.html b/public/template/default/user/content_index.html new file mode 100644 index 00000000..079b79c5 --- /dev/null +++ b/public/template/default/user/content_index.html @@ -0,0 +1,71 @@ +{extend name="base" /} +{block name="body"} +
+
+

{$meta_title}

+
+
+
+
+
+ +
+ {if isset($cate_list)} +
+ +
+ {/if} +
+ +
+
+
+
+ + + + + {volist name="grid" id="item"} + + {/volist} + + + + + {if condition="empty($list)"} + {php} + $cow = count($grid)+2; + {/php} + + + + {else/} + {volist name="list" id="item"} + + + {volist name="grid" id="vo"} + {if isset($vo['format'])} + + {else/} + + {/if} + {/volist} + + + {/volist} + {/if} + +
{$item['title']}操作
暂无数据!
{$item[$vo['field']]|$vo['format']}{$item[$vo['field']]} + 编辑 + 删除 +
+ {$page|raw} +
+
+
+{/block} \ No newline at end of file diff --git a/public/template/default/user/index_avatar.html b/public/template/default/user/form_index.html similarity index 100% rename from public/template/default/user/index_avatar.html rename to public/template/default/user/form_index.html diff --git a/public/template/default/user/user_avatar.html b/public/template/default/user/user_avatar.html new file mode 100644 index 00000000..2ab2e75f --- /dev/null +++ b/public/template/default/user/user_avatar.html @@ -0,0 +1,10 @@ +{extend name="base" /} +{block name="body"} +
+
+

{$meta_title}

+
+
+
+
+{/block} \ No newline at end of file diff --git a/public/template/default/user/index_profile.html b/public/template/default/user/user_profile.html similarity index 100% rename from public/template/default/user/index_profile.html rename to public/template/default/user/user_profile.html diff --git a/public/template/default/user/index_repasswd.html b/public/template/default/user/user_repasswd.html similarity index 100% rename from public/template/default/user/index_repasswd.html rename to public/template/default/user/user_repasswd.html diff --git a/view/admin/content/index.html b/view/admin/content/index.html index 54eb57d1..cbe2fe4b 100644 --- a/view/admin/content/index.html +++ b/view/admin/content/index.html @@ -30,61 +30,58 @@
- -
- - - - - {volist name="grid" id="item"} - - {/volist} - - - - - {if condition="empty($list)"} - {php} - $cow = count($grid)+2; - {/php} - - - - {else/} - {volist name="list" id="item"} - - - {volist name="grid" id="vo"} - {if isset($vo['format'])} - - {else/} - - {/if} - {/volist} - - +
{$item['title']}操作
暂无数据!
{$item[$vo['field']]|$vo['format']}{$item[$vo['field']]} - {if isset($item['is_top'])} - {if $item['is_top']} - 取消置顶 - {else/} - 置顶 - {/if} - {/if} - {if isset($item['status'])} - {if $item['status']} - 取消审核 - {else/} - 审核 - {/if} - {/if} - 编辑 - 删除 -
+ + + + {volist name="grid" id="item"} + {/volist} + + + + + {if condition="empty($list)"} + {php} + $cow = count($grid)+2; + {/php} + + + + {else/} + {volist name="list" id="item"} + + + {volist name="grid" id="vo"} + {if isset($vo['format'])} + + {else/} + {/if} - -
{$item['title']}操作
暂无数据!
{$item[$vo['field']]|$vo['format']}{$item[$vo['field']]}
-
+ {/volist} + + {if isset($item['is_top'])} + {if $item['is_top']} + 取消置顶 + {else/} + 置顶 + {/if} + {/if} + {if isset($item['status'])} + {if $item['status']} + 取消审核 + {else/} + 审核 + {/if} + {/if} + 编辑 + 删除 + + + {/volist} + {/if} + + {$page|raw}