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'} +
+ + +{/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'} +