You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
277 lines
12 KiB
277 lines
12 KiB
<?php
|
|
// +----------------------------------------------------------------------
|
|
// | 天诚科技 [ 刘海东 17600099397赋能开发者,助力企业发展 ]
|
|
// +----------------------------------------------------------------------
|
|
// | Copyright (c) 2016~2020 https://www.tczxkj.com All rights reserved.
|
|
// +----------------------------------------------------------------------
|
|
// | Licensed 该系统并不是自由软件,未经许可不能去掉相关版权
|
|
// +----------------------------------------------------------------------
|
|
// | Author:甘肃天诚志信电子商务有限公司 刘海东 联系电话维系17600099397
|
|
// +----------------------------------------------------------------------
|
|
|
|
namespace app\institution\controller\official;
|
|
|
|
use think\Url;
|
|
use service\FormBuilder as Form;
|
|
use think\Request;
|
|
use service\JsonService as Json;
|
|
use service\UploadService as Upload;
|
|
use app\institution\controller\AuthController;
|
|
use app\admin\model\system\SystemConfig as ConfigModel;
|
|
use think\Db;
|
|
|
|
/**
|
|
* 配置列表控制器
|
|
* Class SystemConfig
|
|
* @package app\admin\controller\setting
|
|
*/
|
|
class Information extends AuthController
|
|
{
|
|
/**
|
|
* 基础配置
|
|
* */
|
|
public function index()
|
|
{
|
|
list($type, $pid, $tab_id, $children_tab_id) = parent::getMore([
|
|
['type', $this->request->param('type', 1)],//配置类型
|
|
['paid', 0],//父级分类ID
|
|
['tab_id', $this->request->param('tab_id', 0)],//当前分类ID
|
|
['children_tab_id', null],//当前子集分类ID
|
|
], null, true);
|
|
|
|
$config_tab = null;//顶级分类
|
|
$children_config_tab = null;//二级分类
|
|
|
|
if ($type == 3) {//其它分类
|
|
$config_tab = null;
|
|
} else {
|
|
$config_tab = ConfigModel::getConfigTabAll($type);
|
|
}
|
|
if ($pid) {
|
|
$children_config_tab = ConfigModel::getConfigChildrenTabAll($pid);
|
|
foreach ($children_config_tab as $kk => $vv) {
|
|
$arr = ConfigModel::getAll($vv['id'])->toArray();
|
|
if (empty($arr)) {
|
|
unset($children_config_tab[$kk]);
|
|
}
|
|
}
|
|
$tab_id = $pid;
|
|
//表单字段
|
|
$list = ConfigModel::getAll($children_tab_id);
|
|
} else {
|
|
$children_config_tab = ConfigModel::getConfigChildrenTabAll($tab_id);
|
|
foreach ($children_config_tab as $kk => $vv) {
|
|
$arr = ConfigModel::getAll($vv['id'])->toArray();
|
|
if (empty($arr)) {
|
|
unset($children_config_tab[$kk]);
|
|
}
|
|
}
|
|
if (!$children_tab_id && $children_config_tab) $children_tab_id = $children_config_tab[0]['id'];
|
|
//表单字段
|
|
$list = ConfigModel::getAll($tab_id);
|
|
}
|
|
$this->assign('pid', $pid);
|
|
$this->assign('children_tab_id', $children_tab_id);
|
|
$this->assign('tab_id', $tab_id);
|
|
$this->assign('config_tab', $config_tab);
|
|
$this->assign('children_config_tab', $children_config_tab);
|
|
$mer_list = Db::name('cache_merchant')->where(array('mer_id'=>$this->merchantId,'type'=>1))->find();
|
|
|
|
$formbuider = [];
|
|
if($tab_id == 2){
|
|
$formbuider[] = Form::input('wechat_appid', 'AppID',$mer_list['wechat_appid'])->info("AppID")->placeholder("AppID")->col(13);
|
|
$formbuider[] = Form::input('wechat_appsecret', 'AppSecret',$mer_list['wechat_appsecret'])->info("AppSecret")->placeholder("AppSecret")->col(13);
|
|
$formbuider[] = Form::input('wechat_token', '微信验证TOKEN',$mer_list['wechat_token'])->info("微信验证TOKEN")->placeholder("微信验证TOKEN")->col(13);
|
|
$options = [
|
|
['label'=> '明文模式','value'=>0],
|
|
['label'=> '兼容模式','value'=>1],
|
|
['label'=> '安全模式','value'=>2]
|
|
];
|
|
$formbuider[] = Form::radio('wechat_encode', '消息加解密方式',$mer_list['wechat_encode'])->options($options)->info('如需使用安全模式请在管理中心修改,仅限服务号和认证订阅号')->col(13);
|
|
$formbuider[] = Form::input('wechat_encodingaeskey', 'EncodingAESKey',$mer_list['wechat_encodingaeskey'])->info("公众号消息加解密Key,在使用安全模式情况下要填写该值,请先在管理中心修改,然后填写该值,仅限服务号和认证订阅号")->placeholder("公众号消息加解密Key,在使用安全模式情况下要填写该值,请先在管理中心修改,然后填写该值,仅限服务号和认证订阅号")->col(13);
|
|
$formbuider[] = Form::frameImageOne('wechat_qrcode', '公众号二维码', Url::build('admin/widget.images/index', array('fodder' => 'wechat_qrcode')), $mer_list['wechat_qrcode'])->icon('image')->width('70%')->height('500px')->info('您的公众号二维码')->col(13);
|
|
$formbuider[] = Form::input('api', '接口地址',$mer_list['api'])->info("微信接口例如:http://www.abc.com/wap/wechat/serve
|
|
")->placeholder("微信接口例如:http://www.abc.com/wap/wechat/serve
|
|
")->col(13);
|
|
|
|
}else{
|
|
$formbuider[] = Form::frameImageOne('wechat_share_img', '微信分享图片', Url::build('admin/widget.images/index', array('fodder' => 'wechat_share_img')), $mer_list['wechat_share_img'])->icon('image')->width('70%')->height('500px')->info('若填写此图片地址,则分享网页出去时会分享此图片。可有效防止分享图片变形')->col(13);
|
|
$formbuider[] = Form::input('wechat_share_title', '微信分享标题',$mer_list['wechat_share_title'])->info("微信分享标题")->placeholder("微信分享标题")->col(13);
|
|
$formbuider[] = Form::textarea('wechat_share_synopsis', '微信分享简介', $mer_list['wechat_share_synopsis'])->placeholder('微信分享简介')->info('微信分享简介')->rows(6)->col(13);
|
|
|
|
}
|
|
$form = Form::make_post_form('编辑配置', $formbuider, Url::build('save_basics'), 2);
|
|
$this->assign(compact('form'));
|
|
$this->assign('list', $list);
|
|
return $this->fetch();
|
|
}
|
|
|
|
/**
|
|
* @param Request $request
|
|
* @param $id
|
|
* @return \think\response\Json
|
|
*/
|
|
public function update_config(Request $request, $id)
|
|
{
|
|
$data = parent::postMore(['status', 'info', 'desc', 'sort', 'config_tab_id', 'required', 'parameter', 'value', 'upload_type'], $request);
|
|
if (!ConfigModel::get($id)) return Json::fail('编辑的记录不存在!');
|
|
// $data['value'] = rtrim($data['value'], '"');
|
|
// $data['value'] = ltrim($data['value'], '"');
|
|
ConfigModel::edit($data, $id);
|
|
return Json::successful('修改成功!');
|
|
}
|
|
|
|
/**
|
|
* 修改是否显示子子段
|
|
* @param $id
|
|
* @return mixed
|
|
*/
|
|
public function edit_cinfig($id)
|
|
{
|
|
$menu = ConfigModel::get($id)->getData();
|
|
if (!$menu) return Json::fail('数据不存在!');
|
|
$formbuider = array();
|
|
$formbuider[] = Form::input('menu_name', '字段变量', $menu['menu_name'])->disabled(1);
|
|
$formbuider[] = Form::select('config_tab_id', '分类', (string)$menu['config_tab_id'])->setOptions(ConfigModel::getConfigTabAll(-1));
|
|
$formbuider[] = Form::input('info', '配置名称', $menu['info'])->autofocus(1);
|
|
$formbuider[] = Form::input('desc', '配置简介', $menu['desc']);
|
|
//输入框验证规则
|
|
if (!empty($menu['required'])) {
|
|
$formbuider[] = Form::input('value', '默认值', $menu['value']);
|
|
$formbuider[] = Form::number('width', '文本框宽(%)', $menu['width']);
|
|
$formbuider[] = Form::input('required', '验证规则', $menu['required'])->placeholder('多个请用,隔开例如:required:true,url:true');
|
|
}
|
|
//多行文本
|
|
if (!empty($menu['high'])) {
|
|
$formbuider[] = Form::textarea('value', '默认值', $menu['value'])->rows(5);
|
|
$formbuider[] = Form::number('width', '文本框宽(%)', $menu['width']);
|
|
$formbuider[] = Form::number('high', '多行文本框高(%)', $menu['high']);
|
|
} else {
|
|
$formbuider[] = Form::input('value', '默认值', $menu['value']);
|
|
}
|
|
//单选和多选参数配置
|
|
if (!empty($menu['parameter'])) {
|
|
$formbuider[] = Form::textarea('parameter', '配置参数', $menu['parameter'])->placeholder("参数方式例如:\n1=白色\n2=红色\n3=黑色");
|
|
}
|
|
//上传类型选择
|
|
if (!empty($menu['upload_type'])) {
|
|
$formbuider[] = Form::radio('upload_type', '上传类型', $menu['upload_type'])->options([['value' => 1, 'label' => '单图'], ['value' => 2, 'label' => '多图'], ['value' => 3, 'label' => '文件']]);
|
|
}
|
|
$formbuider[] = Form::number('sort', '排序', $menu['sort']);
|
|
$formbuider[] = Form::radio('status', '状态', $menu['status'])->options([['value' => 1, 'label' => '显示'], ['value' => 2, 'label' => '隐藏']]);
|
|
|
|
$form = Form::make_post_form('编辑字段', $formbuider, Url::build('update_config', array('id' => $id)), 2);
|
|
$this->assign(compact('form'));
|
|
return $this->fetch('public/form-builder');
|
|
}
|
|
|
|
/**
|
|
* 删除子字段
|
|
* @return \think\response\Json
|
|
*/
|
|
public function delete_cinfig()
|
|
{
|
|
$id = input('id');
|
|
if (!ConfigModel::del($id))
|
|
return Json::fail(ConfigModel::getErrorInfo('删除失败,请稍候再试!'));
|
|
else
|
|
return Json::successful('删除成功!');
|
|
}
|
|
|
|
/**
|
|
* 保存数据 true
|
|
* */
|
|
public function save_basics()
|
|
{
|
|
$request = Request::instance();
|
|
if ($request->isPost()) {
|
|
$post = $request->post();
|
|
$menus = Db::name('cache_merchant')->where(array('mer_id'=>$this->merchantId,'type'=>1))->find();
|
|
if($menus){
|
|
Db::name('cache_merchant')->where('mer_id',$this->merchantId)->update($post);
|
|
}else{
|
|
$post['type'] = 1;
|
|
$post['mer_id'] = $this->merchantId;
|
|
Db::name('cache_merchant')->insert($post);
|
|
}
|
|
return Json::successful('修改成功');
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 模板表单提交
|
|
* */
|
|
public function view_upload()
|
|
{
|
|
if ($_POST['type'] == 3) {
|
|
$res = Upload::file($_POST['file'], 'config/file');
|
|
} else {
|
|
$res = Upload::Image($_POST['file'], 'config/image');
|
|
}
|
|
if (!$res->status) return Json::fail($res->error);
|
|
return Json::successful('上传成功!', ['url' => $res->filePath]);
|
|
}
|
|
|
|
/**
|
|
* 基础配置 单个
|
|
* @return mixed|void
|
|
*/
|
|
public function index_alone()
|
|
{
|
|
$tab_id = input('tab_id');
|
|
if (!$tab_id) return $this->failed('参数错误,请重新打开');
|
|
$this->assign('tab_id', $tab_id);
|
|
$list = ConfigModel::getAll($tab_id);
|
|
$config_tab = ConfigModel::getConfigTabAll();
|
|
foreach ($config_tab as $kk => $vv) {
|
|
$arr = ConfigModel::getAll($vv['value'])->toArray();
|
|
if (empty($arr)) {
|
|
unset($config_tab[$kk]);
|
|
}
|
|
}
|
|
$this->assign('config_tab', $config_tab);
|
|
$this->assign('list', $list);
|
|
return $this->fetch();
|
|
}
|
|
|
|
/**
|
|
* 保存数据 单个
|
|
* @return mixed
|
|
*/
|
|
public function save_basics_alone()
|
|
{
|
|
$request = Request::instance();
|
|
if ($request->isPost()) {
|
|
$post = $request->post();
|
|
$tab_id = $post['tab_id'];
|
|
unset($post['tab_id']);
|
|
foreach ($post as $k => $v) {
|
|
ConfigModel::edit(['value' => json_encode($v)], $k, 'menu_name');
|
|
}
|
|
return $this->successfulNotice('修改成功');
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 获取文件名
|
|
* */
|
|
public function getImageName()
|
|
{
|
|
$request = Request::instance();
|
|
$post = $request->post();
|
|
$src = $post['src'];
|
|
$data['name'] = basename($src);
|
|
exit(json_encode($data));
|
|
}
|
|
|
|
/**
|
|
* 上传文件
|
|
* @return string
|
|
*/
|
|
public function file_upload()
|
|
{
|
|
$res = Upload::file('file', 'config/file');
|
|
if (!$res->status) return Json::fail($res->error);
|
|
return Json::successful('上传成功!', ['filePath' => $res->filePath]);
|
|
}
|
|
}
|
|
|