mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-04-06 03:58:04 +08:00
115 lines
3.1 KiB
PHP
115 lines
3.1 KiB
PHP
<?php
|
|
|
|
namespace app\data\controller;
|
|
|
|
use think\admin\Controller;
|
|
|
|
/**
|
|
* 应用参数配置
|
|
* Class Config
|
|
* @package app\data\controller
|
|
*/
|
|
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 wxapp()
|
|
{
|
|
$this->title = '微信小程序配置';
|
|
$this->__sysconf('wxapp');
|
|
}
|
|
|
|
/**
|
|
* 内容页面管理
|
|
* @auth true
|
|
* @menu true
|
|
*/
|
|
public function pageHome()
|
|
{
|
|
$this->title = '内容页面管理';
|
|
$this->types = ['关于我们', '用户协议'];
|
|
$this->fetch('page_home');
|
|
}
|
|
|
|
/**
|
|
* 内容页面编辑
|
|
* @auth true
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
* @throws \think\db\exception\DbException
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
*/
|
|
public function pageEdit()
|
|
{
|
|
$this->skey = input('type');
|
|
$this->title = '编辑' . $this->skey;
|
|
$this->__sysdata('page_form', 'javascript:history.back()');
|
|
}
|
|
|
|
/**
|
|
* 首页轮播图片
|
|
* @menu true
|
|
* @auth true
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
* @throws \think\db\exception\DbException
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
*/
|
|
public function sliderHome()
|
|
{
|
|
$this->skey = 'SliderHome';
|
|
$this->title = '首页轮播图片';
|
|
$this->__sysdata('slider');
|
|
}
|
|
|
|
/**
|
|
* 显示并保存配置
|
|
* @param string $template 模板文件名称
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
* @throws \think\db\exception\DbException
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
*/
|
|
private function __sysconf(string $template)
|
|
{
|
|
if ($this->request->isGet()) {
|
|
$this->fetch($template);
|
|
}
|
|
if ($this->request->isPost()) {
|
|
$data = $this->request->post();
|
|
foreach ($data as $k => $v) sysconf($k, $v);
|
|
$this->success('配置保存成功!');
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 显示并保存数据
|
|
* @param string $template 模板文件
|
|
* @param string $history 跳转处理
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
* @throws \think\db\exception\DbException
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
*/
|
|
private function __sysdata(string $template, $history = '')
|
|
{
|
|
if ($this->request->isGet()) {
|
|
$this->data = sysdata($this->skey);
|
|
$this->fetch($template);
|
|
}
|
|
if ($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('内容保存成功!', $history);
|
|
} else {
|
|
$this->error('内容保存失败,请稍候再试!');
|
|
}
|
|
}
|
|
}
|
|
} |