mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-04-06 03:58:04 +08:00
增加配置模板
This commit is contained in:
parent
fba4c6be5a
commit
9ab2fc8f0b
@ -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('配置保存成功!');
|
||||
|
20
app/data/view/config/content.html
Normal file
20
app/data/view/config/content.html
Normal file
@ -0,0 +1,20 @@
|
||||
{extend name="../../admin/view/main"}
|
||||
|
||||
{block name="content"}
|
||||
<div class="think-box-shadow">
|
||||
<form onsubmit="return false;" data-auto="true" action="{$request->url()}" method="post" class='layui-form layui-card' autocomplete="off">
|
||||
<div class="layui-card-body padding-30">
|
||||
<textarea class="layui-hide" name="content">{$data.content|default=''}</textarea>
|
||||
<div class="hr-line-dashed margin-bottom-20"></div>
|
||||
</div>
|
||||
<div class="layui-form-item text-center">
|
||||
<button class="layui-btn" type="submit">保存配置</button>
|
||||
</div>
|
||||
</form>
|
||||
<script>
|
||||
require(['ckeditor'], function () {
|
||||
createEditor('[name="content"]', {height: 500});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
{/block}
|
Loading…
x
Reference in New Issue
Block a user