diff --git a/app/data/controller/Config.php b/app/data/controller/Config.php index d5b99f336..939e14da9 100644 --- a/app/data/controller/Config.php +++ b/app/data/controller/Config.php @@ -3,7 +3,6 @@ namespace app\data\controller; use think\admin\Controller; -use think\admin\storage\LocalStorage; /** * 应用参数配置 @@ -12,6 +11,21 @@ use think\admin\storage\LocalStorage; */ class Config extends Controller { + /** + * 关于我们描述 + * @auth true + * @menu true + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ + public function about() + { + $this->skey = 'about'; + $this->title = '关于我们描述'; + $this->__sysdata('content'); + } + /** * 微信小程序配置 * @auth true @@ -22,16 +36,12 @@ class Config extends Controller */ public function wxapp() { - if ($this->request->isGet()) { - $this->title = '微信小程序配置'; - $this->fetch(); - } else { - $this->__save(); - } + $this->title = '微信小程序配置'; + $this->__sysconf('wxapp'); } /** - * 首页轮播图片 + * 应用轮播图片 * @menu true * @auth true * @throws \think\db\exception\DataNotFoundException @@ -41,28 +51,63 @@ class Config extends Controller public function slider() { $this->skey = 'slider'; + $this->title = '应用轮播图片'; + $this->__sysdata($this->skey); + } + + /** + * 会员服务协议 + * @auth true + * @menu true + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ + public function agreement() + { + $this->skey = 'agreement'; + $this->title = '会员服务协议'; + $this->__sysdata('content'); + } + + /** + * 显示并保存数据 + * @param string $template 模板文件 + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ + private function __sysdata($template = 'content') + { if ($this->request->isGet()) { - $this->title = '轮播图片管理'; $this->data = sysdata($this->skey); - $this->fetch(); - } else { - if (sysdata($this->skey, json_decode(input('data'), true))) { - $this->success('轮播图保存成功!', ''); + $this->fetch($template); + } elseif ($this->request->isPost()) { + if (is_string(input('data'))) { + $data = json_decode(input('data'), true); } else { - $this->error('轮播图保存失败,请稍候再试!'); + $data = $this->request->post(); + } + if (sysdata($this->skey, $data) !== false) { + $this->success('内容保存成功!', ''); + } else { + $this->error('内容保存失败,请稍候再试!'); } } } /** - * 保存配置参数 + * 显示并保存配置 + * @param string $template 模板文件名称 * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ - private function __save() + private function __sysconf($template = 'wxapp') { - if ($this->request->isPost()) { + if ($this->request->isGet()) { + $this->fetch($template); + } elseif ($this->request->isPost()) { $data = $this->request->post(); foreach ($data as $k => $v) sysconf($k, $v); $this->success('配置保存成功!'); diff --git a/app/data/view/config/content.html b/app/data/view/config/content.html new file mode 100644 index 000000000..7ce4fd4d7 --- /dev/null +++ b/app/data/view/config/content.html @@ -0,0 +1,20 @@ +{extend name="../../admin/view/main"} + +{block name="content"} +
+
+
+ +
+
+
+ +
+
+ +
+{/block} \ No newline at end of file