From 580934360359cc7838781adf53527ee44b2ad23f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=99=AF=E7=AB=8B?= Date: Sat, 16 Apr 2022 22:22:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=8A=A8=E6=80=81=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E6=9C=89=E8=BD=AE=E6=92=AD=E5=9B=BE=E7=89=87=E7=AE=A1?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/data/controller/base/Pager.php | 87 +++++++++++++++++ app/data/controller/base/Slider.php | 94 ++++++++++++++++++ app/data/view/base/pager/form.html | 35 +++++++ app/data/view/base/pager/index.html | 30 ++++++ app/data/view/base/slider/form.html | 141 +++++++++++++++++++++++++++ app/data/view/base/slider/index.html | 30 ++++++ 6 files changed, 417 insertions(+) create mode 100644 app/data/controller/base/Pager.php create mode 100644 app/data/controller/base/Slider.php create mode 100644 app/data/view/base/pager/form.html create mode 100644 app/data/view/base/pager/index.html create mode 100644 app/data/view/base/slider/form.html create mode 100644 app/data/view/base/slider/index.html diff --git a/app/data/controller/base/Pager.php b/app/data/controller/base/Pager.php new file mode 100644 index 000000000..799c9c67e --- /dev/null +++ b/app/data/controller/base/Pager.php @@ -0,0 +1,87 @@ +types = SystemBase::mk()->items($this->type); + } + + /** + * 内容页面管理 + * @auth true + * @menu true + */ + public function index() + { + $this->title = '内容页面管理'; + $this->fetch(); + } + + /** + * 内容页面编辑 + * @auth true + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ + public function edit() + { + $this->skey = input('get.type', ''); + $this->base = $this->types[$this->skey] ?? []; + if (empty($this->base)) $this->error('未配置基础数据!'); + $this->title = "编辑{$this->base['name']}"; + $this->sysdata(); + } + + /** + * 显示并保存数据 + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ + private function sysdata() + { + if ($this->request->isGet()) { + $this->data = sysdata($this->skey); + $this->fetch('form'); + } elseif ($this->request->isPost()) { + if (is_string(input('data'))) { + $data = json_decode(input('data'), true) ?: []; + } else { + $data = $this->request->post(); + } + if (sysdata($this->skey, $data) !== false) { + $this->success('内容保存成功!', 'javascript:history.back()'); + } else { + $this->error('内容保存失败,请稍候再试!'); + } + } + } +} \ No newline at end of file diff --git a/app/data/controller/base/Slider.php b/app/data/controller/base/Slider.php new file mode 100644 index 000000000..d502986ff --- /dev/null +++ b/app/data/controller/base/Slider.php @@ -0,0 +1,94 @@ + '不跳转', + 'LK' => '自定义链接', + 'NL' => '新闻资讯列表', + 'NS' => '新闻资讯详情', + ]; + + /** + * 数据类型 + * @var string + */ + protected $type = '轮播图片'; + + /** + * 页面类型 + * @var array + */ + protected $types = []; + + /** + * 控制器初始化 + * @return void + */ + protected function initialize() + { + $this->types = SystemBase::mk()->items($this->type); + } + + /** + * 轮播图片管理 + * @auth true + * @menu true + */ + public function index() + { + $this->title = '轮播图片管理'; + $this->fetch(); + } + + /** + * 编辑轮播图片 + * @auth true + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ + public function edit() + { + $this->skey = input('get.type', ''); + $this->base = $this->types[$this->skey] ?? []; + if (empty($this->base)) $this->error('未配置基础数据!'); + $this->number = 10; + $this->sysdata(); + } + + /** + * 保存轮播图片 + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ + private function sysdata() + { + if ($this->request->isGet()) { + $this->data = sysdata($this->skey); + $this->title = "{$this->base['name']}管理"; + $this->fetch('form'); + } else { + if (sysdata($this->skey, json_decode(input('data'), true))) { + $this->success("{$this->base['name']}保存成功!"); + } else { + $this->error("{$this->base['name']}保存失败,请稍候再试!"); + } + } + } +} \ No newline at end of file diff --git a/app/data/view/base/pager/form.html b/app/data/view/base/pager/form.html new file mode 100644 index 000000000..716e77bee --- /dev/null +++ b/app/data/view/base/pager/form.html @@ -0,0 +1,35 @@ +{extend name="../../admin/view/main"} + +{block name='content'} +
+
+ + + +
+ 页面内容Page Content + +
+ +
+ + +
+ + +
+ +
+
+ + +{/block} \ No newline at end of file diff --git a/app/data/view/base/pager/index.html b/app/data/view/base/pager/index.html new file mode 100644 index 000000000..659079af3 --- /dev/null +++ b/app/data/view/base/pager/index.html @@ -0,0 +1,30 @@ +{extend name="../../admin/view/main"} + +{block name='content'} +
温馨提示:如需添加新内容,需要在系统管理的基础数据添加类似为 “{$type|default=''}” 的基础数据。
+
+
+ {foreach $types as $key=>$type} +
+ +
+
+
编辑页面
+
{$type.name|default=''}
+
+ +
+ +
+
+
编辑页面
+
{$type.name|default=''}
+
+ +
+ +
+ {/foreach} +
+
+{/block} \ No newline at end of file diff --git a/app/data/view/base/slider/form.html b/app/data/view/base/slider/form.html new file mode 100644 index 000000000..881bc6fc7 --- /dev/null +++ b/app/data/view/base/slider/form.html @@ -0,0 +1,141 @@ +{extend name="../../admin/view/main"} + +{block name="content"} + + +
+
+
+ {$title|default='轮播图片管理'} +
{$base.content|default='图片尺寸:1080px * 1882px'}
+ + {$skey} + +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ +
+ + + +
+
+
+ +
+ +
+
若要跳转页面,请选择对应的数据或填写跳转的 URL 地址,不跳转请填写 “#” 号占位。
+
+
+
+ + + + +{/block} \ No newline at end of file diff --git a/app/data/view/base/slider/index.html b/app/data/view/base/slider/index.html new file mode 100644 index 000000000..659079af3 --- /dev/null +++ b/app/data/view/base/slider/index.html @@ -0,0 +1,30 @@ +{extend name="../../admin/view/main"} + +{block name='content'} +
温馨提示:如需添加新内容,需要在系统管理的基础数据添加类似为 “{$type|default=''}” 的基础数据。
+
+
+ {foreach $types as $key=>$type} +
+ +
+
+
编辑页面
+
{$type.name|default=''}
+
+ +
+ +
+
+
编辑页面
+
{$type.name|default=''}
+
+ +
+ +
+ {/foreach} +
+
+{/block} \ No newline at end of file