修改页面管理

This commit is contained in:
邹景立 2022-04-16 22:28:23 +08:00
parent 5809343603
commit c379d6224e
5 changed files with 6 additions and 272 deletions

View File

@ -11,14 +11,6 @@ use think\admin\Controller;
*/
class Config extends Controller
{
/**
* 页面类型
* @var array
*/
protected $pageTypes = [
'关于我们' => '关于我们',
'用户协议' => '用户协议',
];
/**
* 微信小程序配置
@ -30,8 +22,9 @@ class Config extends Controller
*/
public function wxapp()
{
$this->skey = 'wxapp';
$this->title = '微信小程序配置';
$this->__sysconf('wxapp');
$this->__sysdata('wxapp');
}
/**
@ -44,85 +37,11 @@ class Config extends Controller
*/
public function cropper()
{
$this->title = '邀请二维码设置';
$this->skey = 'cropper';
$this->title = '邀请二维码设置';
$this->__sysdata('cropper');
}
/**
* 内容页面管理
* @auth true
* @menu true
*/
public function pageHome()
{
$this->title = '内容页面管理';
$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->pageTypes[0];
$this->title = '编辑' . $this->pageTypes[$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 iconHome()
{
$this->skey = 'IconHome';
$this->title = '首页推荐位管理';
$this->__sysdata('slider');
}
/**
* 首页轮播图片
* @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 模板文件

View File

@ -1,36 +0,0 @@
{extend name="../../admin/view/main"}
{block name='content'}
<form action="{:sysuri()}" autocomplete="off" class="layui-form layui-card" data-auto="true" method="post">
<div class="layui-card-body">
<label class="layui-form-item relative block">
<span class="color-green font-w7">页面名称</span>
<span class="color-desc margin-left-5">Page Name</span>
<input class="layui-input" name="name" placeholder="请输入页面名称" required value='{$data.name|default=""}'>
</label>
<div class="layui-form-item relative block">
<span class="color-green font-w7 label-required-prev">页面内容</span>
<span class="color-desc margin-left-5">Page Content</span>
<label class="relative block">
<textarea class="layui-hide" name="content">{$data.content|default=''}</textarea>
</label>
</div>
<div class="hr-line-dashed"></div>
<div class="layui-form-item text-center">
<button class="layui-btn" type="submit">保存数据</button>
<button class="layui-btn layui-btn-danger" data-confirm="确定要取消编辑吗?" data-history-back type='button'>取消编辑</button>
</div>
</div>
</form>
<script>
require(['ckeditor'], function () {
window.createEditor('[name=content]', {height: 535});
});
</script>
{/block}

View File

@ -1,25 +0,0 @@
{extend name="../../admin/view/main"}
{block name='content'}
<div class="layui-row layui-col-space20 portal-block-container notselect">
{foreach $pageTypes as $key=>$type}
<div class="layui-col-sm4 layui-col-md4 layui-col-lg3">
<!--{if auth('pageEdit')}-->
<div class="pointer" data-open="{:url('pageEdit')}?type={$key}">
<div class="portal-block-item nowrap think-bg-violet">
<div>编辑页面内容</div>
<div style="font-size:26px">{$type|default=''}</div>
</div>
<i class="portal-block-icon layui-icon layui-icon-read"></i>
</div>
<!--{else}-->
<div class="portal-block-item nowrap think-bg-violet">
<div>编辑页面内容</div>
<div style="font-size:26px">{$type|default=''}</div>
</div>
<i class="portal-block-icon layui-icon layui-icon-read"></i>
<!--{/if}-->
</div>
{/foreach}
</div>
{/block}

View File

@ -1,124 +0,0 @@
{extend name="../../admin/view/main"}
{block name="content"}
<div class="think-box-shadow">
<form autocomplete="off" class='layui-form layui-card' id="DataForm" onsubmit="return false;" style="width:850px">
<div class="layui-card-header text-center margin-20 font-w7 color-text layui-bg-gray border-radius-5">
{$title|default='图片数据管理'}<span class="color-desc font-s12"> ( 建议上传图片尺寸为 690px 250px )</span>
</div>
<div class="layui-card-body margin-top-20 padding-bottom-0">
<div class="padding-left-20" data-rule-list>
<div class="layui-form-item text-center">
<a class="layui-btn layui-btn-primary" data-item-add>添加图片</a>
</div>
</div>
<div class="hr-line-dashed margin-top-30"></div>
<div class="layui-form-item text-center padding-left-20">
<button class="layui-btn" data-submit>保存数据</button>
</div>
</div>
</form>
</div>
<div class="layui-hide" data-item-tpl>
<div class="layui-form-item" data-rule-item>
<div class="layui-input-inline nowrap relative" style="width:180px">
<input data-upload-image name="img[]" type="hidden">
</div>
<label class="layui-input-inline nowrap relative margin-bottom-5" style="width:300px">
<b class="notselect color-green margin-right-5">图片名称</b>
<input class="layui-input inline-block" name="name[]" placeholder="请输入图片名称" required style="width:240px" value="#">
<a class="layui-btn layui-btn-primary" data-item-up><i class="layui-icon layui-icon-up margin-0"></i></a>
<a class="layui-btn layui-btn-primary" data-item-dn><i class="layui-icon layui-icon-down margin-0"></i></a>
<a class="layui-btn layui-btn-primary" data-item-rm><i class="layui-icon layui-icon-close margin-0"></i></a>
</label>
<label class="layui-input-inline nowrap relative margin-bottom-5" style="width:300px">
<b class="notselect color-green margin-right-5">跳转规则</b>
<input class="layui-input inline-block" name="rule[]" placeholder="请输入跳转规则" required style="width:240px" value="#">
<a class="layui-btn layui-btn-primary" data-prefix="NEWS" data-rule-page="{:url('data/news.item/select')}">选择文章</a>
<a class="layui-btn layui-btn-primary" data-prefix="GOODS" data-rule-page="{:url('data/shop.goods/select')}">选择商品</a>
<span class="help-block block notselect">若要跳转页面,请选择对应的数据或填写跳转的 URL 地址,不跳转请填写 #” 号占位。</span>
</label>
</div>
</div>
<label class="layui-hide">
<textarea id="DefaultData">{$data|default=[]|json_encode}</textarea>
</label>
<style>
[data-rule-page] {
margin-top: -3px;
margin-left: 5px;
}
[data-rule-item] {
padding-left: 40px;
margin-bottom: 20px;
}
[data-rule-item] .uploadimage {
width: 135px;
height: 100px;
}
[data-item-dn], [data-item-up], [data-item-rm] {
margin-top: -4px;
margin-left: 5px;
}
</style>
<script>
(function (data) {
/*! 默认数据渲染 */
if (data.length < 1) addItem();
else data.forEach(function (item) {
addItem(item)
});
/*! 初始化上传插件 */
(function initUpload() {
$('[data-rule-list] input[data-upload-image]').map(function () {
if (!$(this).attr('inited')) $(this).attr('inited', true).uploadOneImage();
});
setTimeout(initUpload, 100);
})();
/*! 数据选项操作 */
$('[data-rule-list]').on('click', '[data-rule-page]', function ($that) {
$that = $(this), top.setItemValue = function (value) {
$that.prevAll('input').val(($that.data('prefix') + '#{v}').replace('{v}', value));
};
$.form.iframe($(this).data('rule-page'), $that.data('title') || $that.text(), ['930px', '600px']);
}).on('click', '[data-item-add]', function () {
addItem();
}).on('click', '[data-item-rm]', function () {
$(this).parents('[data-rule-item]').remove();
}).on('click', '[data-item-up]', function () {
var item = $(this).parents('[data-rule-item]');
var prev = item.prev('[data-rule-item]');
if (item.index() > 0) item.insertBefore(prev);
}).on('click', '[data-item-dn]', function () {
var item = $(this).parents('[data-rule-item]');
var next = item.next('[data-rule-item]');
if (next) item.insertAfter(next);
});
/*! 表单提交处理 */
$('form#DataForm').vali(function (ret) {
var idx, data = [];
for (idx in ret.img) {
if (!ret.img[idx]) return $.msg.tips('请上传展示图片哦!');
data.push({img: ret.img[idx], rule: ret.rule[idx], name: ret.name[idx]});
}
$.form.load('{$request->url()}', {data: JSON.stringify(data)}, 'post');
});
})(JSON.parse($('#DefaultData').val() || '[]') || []);
/*! 添加数据选项 */
function addItem(data) {
this.$html = $($('[data-item-tpl]').html());
if (data) for (this.index in data) this.$html.find('[name^="' + this.index + '"]').val(data[this.index]);
$('[data-item-add]').parent().before(this.$html), setTimeout(function () {
$.form.reInit();
}, 100);
}
</script>
{/block}

View File

@ -2,7 +2,7 @@
{block name="content"}
<div class="think-box-shadow">
<form action="{:sysuri()}" autocomplete="off" class="layui-form layui-card" data-auto="true" method="post" style="width:850px">
<form action="{:sysuri()}" class="layui-form layui-card" data-auto="true" method="post" style="width:850px">
<div class="layui-card-header text-center margin-20 font-w7 color-text layui-bg-gray border-radius-5">
{$title|default='小程序接口配置'}<span class="color-desc font-s12"> ( 微信公众号平台配置获取 )</span>
</div>
@ -10,13 +10,13 @@
<label class="layui-form-item margin-bottom-20 block relative">
<span class="color-green font-s14 font-w7 margin-right-10">小程序 AppId</span>
<input class="layui-input" maxlength="18" name="data.wxapp_appid" pattern="^wx[0-9a-z]{16}$" placeholder="请输入18位小程序 AppID" required value="{:sysconf('data.wxapp_appid')}">
<input class="layui-input" maxlength="18" name="appid" pattern="^wx[0-9a-z]{16}$" placeholder="请输入18位小程序 AppID" required value="{$data.appid|default=''}">
<span class="help-block"><b>必选</b>,微信小程序 AppID 需要微信公众号平台获取!</span>
</label>
<label class="layui-form-item margin-bottom-20 block relative">
<span class="color-green font-s14 font-w7 margin-right-10">小程序密钥 AppSecret</span>
<input class="layui-input" maxlength="32" name="data.wxapp_appkey" pattern="^[0-9a-z]{32}$" placeholder="请输入32位小程序 AppSecret" required value="{:sysconf('data.wxapp_appkey')}">
<input class="layui-input" maxlength="32" name="appkey" pattern="^[0-9a-z]{32}$" placeholder="请输入32位小程序 AppSecret" required value="{$data.appkey|default=''}">
<span class="help-block"><b>必选</b>,微信小程序 AppSecret 需要微信公众号平台获取!</span>
</label>