diff --git a/app/home/controller/Conf.php b/app/home/controller/Conf.php index f92f6cf..352e39d 100644 --- a/app/home/controller/Conf.php +++ b/app/home/controller/Conf.php @@ -33,23 +33,11 @@ class Conf extends BaseController } } - //添加 + //添加/编辑配置项 public function add() { - $id = empty(get_params('id')) ? 0 : get_params('id'); - if ($id > 0) { - $config = Db::name('Config')->where(['id' => $id])->find(); - View::assign('config', $config); - } - View::assign('id', $id); - return view(); - } - - //提交添加 - public function post_submit() - { + $param = get_params(); if (request()->isAjax()) { - $param = get_params(); try { validate(ConfCheck::class)->check($param); } catch (ValidateException $e) { @@ -62,7 +50,6 @@ class Conf extends BaseController if ($res) { add_log('edit', $param['id'], $param); } - return to_assign(); } else { $param['create_time'] = time(); @@ -70,12 +57,20 @@ class Conf extends BaseController if ($insertId) { add_log('add', $insertId, $param); } - return to_assign(); } + } else { + $id = empty($param['id']) ? 0 : $param['id']; + if ($id > 0) { + $config = Db::name('Config')->where(['id' => $id])->find(); + View::assign('config', $config); + } + View::assign('id', $id); + return view(); } } - //删除 + + //删除配置项 public function delete() { $id = get_params("id"); @@ -90,22 +85,11 @@ class Conf extends BaseController } } - //编辑配置 + //编辑配置信息 public function edit() { - $id = empty(get_params('id')) ? 0 : get_params('id'); - $conf = Db::name('Config')->where('id', $id)->find(); - $config = []; - if ($conf['content']) { - $config = unserialize($conf['content']); - } - return view($conf['name'], ['id' => $id, 'config' => $config]); - } - //提交添加 - public function conf_submit() - { + $param = get_params(); if (request()->isAjax()) { - $param = get_params(); $data['content'] = serialize($param); $data['update_time'] = time(); $data['id'] = $param['id']; @@ -116,6 +100,16 @@ class Conf extends BaseController add_log('edit', $param['id'], $param); } return to_assign(); + } else { + $id = empty($param['id']) ? 0 : $param['id']; + $conf = Db::name('Config')->where('id', $id)->find(); + $config = []; + if ($conf['content']) { + $config = unserialize($conf['content']); + } + View::assign('id', $id); + View::assign('config', $config); + return view($conf['name']); } } } diff --git a/app/home/view/conf/add.html b/app/home/view/conf/add.html index 80df6d9..ede337f 100644 --- a/app/home/view/conf/add.html +++ b/app/home/view/conf/add.html @@ -8,9 +8,7 @@ - + 状态* {if condition="$id eq 0"} @@ -29,7 +27,7 @@ 配置标识* - + (注意:新增配置项以后,需要对应新增模板文件,模板文件名称需与标识名称一致,建议复制现有的配置模板文件,然后根据需求修改对应的表单即可) @@ -52,14 +50,13 @@ //监听提交 form.on('submit(webform)', function (data) { $.ajax({ - url: "{:url('home/conf/conf_submit')}", + url: "{:url('home/conf/add')}", type: 'post', data: data.field, success: function (e) { if (e.code == 0) { layer.confirm('保存成功,返回列表页吗?', { icon: 3, title: '提示' }, function (index) { - history.back(-1); - layer.close(index); + window.location.href="{:url('home/conf/index')}"; }); } else { layer.msg(e.msg); diff --git a/app/home/view/conf/email.html b/app/home/view/conf/email.html index 3dcc513..13f9a41 100644 --- a/app/home/view/conf/email.html +++ b/app/home/view/conf/email.html @@ -9,8 +9,7 @@ - + 如:QQ邮箱的SMTP服务器地址是smtp.qq.com,163邮箱的SMTP服务器地址是smtp.163.com @@ -18,8 +17,7 @@ 协议端口号* - + 如:QQ邮箱的ssl协议方式端口号是465/587,163邮箱的ssl协议方式端口号是465/994 @@ -27,8 +25,7 @@ 邮箱账户* - + 如:gougucms@qq.com @@ -47,7 +44,7 @@ 发送人* - 用于展示给发送方,如:勾股CMS系统管理员 @@ -56,7 +53,7 @@ 显示的邮箱* - 可以不同于上面的账户,用于展示给发送方的邮箱,如:admin@gougucms.com @@ -86,7 +83,7 @@ //监听提交 form.on('submit(webform)', function (data) { $.ajax({ - url: "{:url('home/conf/conf_submit')}", + url: "{:url('home/conf/edit')}", type: 'post', data: data.field, success: function (e) { diff --git a/app/home/view/conf/index.html b/app/home/view/conf/index.html index f06c7a3..a255c78 100644 --- a/app/home/view/conf/index.html +++ b/app/home/view/conf/index.html @@ -38,6 +38,7 @@ align: 'center' },{ field: 'title', + width: 200, title: '配置名称' }, { field: 'name', diff --git a/app/home/view/conf/other.html b/app/home/view/conf/other.html index 51ff47d..e35af69 100644 --- a/app/home/view/conf/other.html +++ b/app/home/view/conf/other.html @@ -8,14 +8,12 @@ 开发者 - + 开发版本号 - + @@ -39,7 +37,7 @@ //监听提交 form.on('submit(webform)', function (data) { $.ajax({ - url: "{:url('home/conf/conf_submit')}", + url: "{:url('home/conf/edit')}", type: 'post', data: data.field, success: function (e) { diff --git a/app/home/view/conf/token.html b/app/home/view/conf/token.html index 0eb1e52..3ee6d24 100644 --- a/app/home/view/conf/token.html +++ b/app/home/view/conf/token.html @@ -8,27 +8,23 @@ Token签发组织 - + Token签发作者 - + Token Secrect - + Token过期时间 - + @@ -60,7 +56,7 @@ //监听提交 form.on('submit(webform)', function (data) { $.ajax({ - url: "{:url('home/conf/conf_submit')}", + url: "{:url('home/conf/edit')}", type: 'post', data: data.field, success: function (e) { diff --git a/app/home/view/conf/web.html b/app/home/view/conf/web.html index 4493f8d..5b81eab 100644 --- a/app/home/view/conf/web.html +++ b/app/home/view/conf/web.html @@ -9,14 +9,12 @@ - + 网站名称* - + 系统LOGO @@ -34,34 +32,29 @@ 网站域名* - + ICP备案号 - + SEO关键词* - + 公安备案号 - + SEO描述* - + @@ -73,14 +66,12 @@ 版权信息 - + 代码版本号* - + @@ -122,7 +113,7 @@ //监听提交 form.on('submit(webform)', function (data) { $.ajax({ - url: "{:url('home/conf/conf_submit')}", + url: "{:url('home/conf/edit')}", type: 'post', data: data.field, success: function (e) { diff --git a/app/home/view/conf/wechat.html b/app/home/view/conf/wechat.html deleted file mode 100644 index 2b1baa5..0000000 --- a/app/home/view/conf/wechat.html +++ /dev/null @@ -1,108 +0,0 @@ -{extend name="common/base"/} - -{block name="body"} -
-

微信配置

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
token* - - - 登录回调地址* - -
公众号appid* - - 公众号appsecret* - -
支付商户号 - - 支付API密钥 - -
支付证书路径 - - 支付回调地址 - -
小程序appid* - - 小程序appsecret* - -
-
- - - -
-
-{/block} - - - -{block name="script"} - -{include file="common/layui" base="base" extend="[]" callback="init" /} -{/block} -