|
...
|
...
|
@@ -66,11 +66,16 @@ class BTemplateLogic extends BaseLogic |
|
|
|
if($info === false){
|
|
|
|
$this->fail('请先选择模版');
|
|
|
|
}
|
|
|
|
//自定义模块单独处理
|
|
|
|
if(isset($this->param['is_custom']) && $this->param['is_custom'] == 1){
|
|
|
|
$TemplateInfo = $this->customHtml($info,$this->param['source'],$this->param['source_id'],$this->param['is_custom']);
|
|
|
|
}else{//系统页面
|
|
|
|
if($this->param['source'] == $this->model::SOURCE_HOME){//首页
|
|
|
|
$TemplateInfo = $this->homeHtml($info,$this->param['source'],$this->param['source_id']);
|
|
|
|
}else{
|
|
|
|
$TemplateInfo = $this->otherHtml($info,$this->param['source'],$this->param['source_id']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $this->success($TemplateInfo);
|
|
|
|
}
|
|
|
|
|
|
...
|
...
|
@@ -81,13 +86,14 @@ class BTemplateLogic extends BaseLogic |
|
|
|
* @method :post
|
|
|
|
* @time :2023/7/25 16:41
|
|
|
|
*/
|
|
|
|
public function webTemplateInfo($template_id,$source,$source_id){
|
|
|
|
public function webTemplateInfo($template_id,$source,$source_id,$is_custom = 0){
|
|
|
|
//查看当前模板是否已编辑保存web_template
|
|
|
|
$TemplateInfo = $this->model->read([
|
|
|
|
'template_id'=>$template_id,
|
|
|
|
'source'=>$source,
|
|
|
|
'project_id'=>$this->user['project_id'],
|
|
|
|
'source_id'=>$source_id,
|
|
|
|
'is_custom'=>$is_custom
|
|
|
|
]);
|
|
|
|
return $this->success($TemplateInfo);
|
|
|
|
}
|
|
...
|
...
|
@@ -109,10 +115,8 @@ class BTemplateLogic extends BaseLogic |
|
|
|
}else{
|
|
|
|
$commonTemplateModel = new BTemplateCommon();
|
|
|
|
$commonInfo = $commonTemplateModel->read(['template_id'=>$info['template_id'],'project_id'=>$this->user['project_id'],'type'=>1]);
|
|
|
|
if($commonInfo !== false){
|
|
|
|
$TemplateInfo['html'] = $commonInfo['head_css'].$TemplateInfo['main_css'].$commonInfo['footer_css'].$commonInfo['other'].
|
|
|
|
$commonInfo['head_html'].$TemplateInfo['main_html'].$commonInfo['footer_html'];
|
|
|
|
}
|
|
|
|
$ATemplateModel = new Template();
|
|
|
|
$ATemplateInfo = $ATemplateModel->read(['id'=>$info['template_id']],['name','image']);
|
|
|
|
$TemplateInfo['name'] = $ATemplateInfo['name'];
|
|
...
|
...
|
@@ -158,6 +162,35 @@ class BTemplateLogic extends BaseLogic |
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :获取自定义模块的html
|
|
|
|
* @name :customHtml
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/12/12 9:39
|
|
|
|
*/
|
|
|
|
public function customHtml($info,$source,$source_id,$is_custom){
|
|
|
|
$templateInfo = $this->webTemplateInfo($info['template_id'],$source,$source_id,$is_custom);
|
|
|
|
if($templateInfo === false){
|
|
|
|
//TODO::取新闻的默认页,后期如果更新,修改此处
|
|
|
|
$news_source = 3;
|
|
|
|
$mainInfo = $this->getCommonMain($news_source,$source_id);
|
|
|
|
$main_html = $mainInfo['main_html'];
|
|
|
|
$main_style = $mainInfo['main_css'];
|
|
|
|
$templateInfo['template_id'] = $info['template_id'];
|
|
|
|
}else{
|
|
|
|
$main_html = $templateInfo['main_html'];
|
|
|
|
$main_style = $templateInfo['main_css'];
|
|
|
|
}
|
|
|
|
//TODO::无独立头部时,取首页的头部和底部
|
|
|
|
$commonTemplateModel = new BTemplateCommon();
|
|
|
|
$commonInfo = $commonTemplateModel->read(['template_id'=>$info['template_id'],'project_id'=>$this->user['project_id'],'type'=>1]);
|
|
|
|
$html = $commonInfo['head_css'].$main_style.$commonInfo['footer_css'].$commonInfo['other'].
|
|
|
|
$commonInfo['head_html'].$main_html.$commonInfo['footer_html'];
|
|
|
|
$templateInfo['html'] = $this->getHeadFooter($html);//组装数据
|
|
|
|
return $this->success($templateInfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :获取中间公共部分
|
|
|
|
* @name :getCommonMain
|
|
|
|
* @author :lyh
|
|
...
|
...
|
@@ -237,19 +270,16 @@ class BTemplateLogic extends BaseLogic |
|
|
|
//查询当前模版是否已保存
|
|
|
|
DB::beginTransaction();
|
|
|
|
try {
|
|
|
|
$info = $this->webTemplateInfo($this->param['template_id'],$this->param['source'],$this->param['source_id']);
|
|
|
|
//字符串截取
|
|
|
|
$this->param = $this->stringProcessing($this->param);
|
|
|
|
//保存头部信息
|
|
|
|
$this->saveCommonTemplate($this->param);
|
|
|
|
$param = $this->templateSaveParam($this->param);//组装数据
|
|
|
|
if($info === false){
|
|
|
|
$this->model->add($param);
|
|
|
|
//自定义模块单独处理
|
|
|
|
if(isset($this->param['is_custom']) && ($this->param['is_custom'] == 1)){
|
|
|
|
|
|
|
|
}else{
|
|
|
|
$this->model->edit($param,['id'=>$info['id']]);
|
|
|
|
}
|
|
|
|
$this->saveTemplateHtml($this->param);
|
|
|
|
//写入操作模版记录
|
|
|
|
$this->setTemplateLog($this->param);
|
|
|
|
}
|
|
|
|
DB::commit();
|
|
|
|
}catch (\Exception $e){
|
|
|
|
DB::rollBack();
|
|
...
|
...
|
@@ -261,6 +291,27 @@ class BTemplateLogic extends BaseLogic |
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :保存可视化数据
|
|
|
|
* @name :saveTemplateHtml
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/12/12 10:23
|
|
|
|
*/
|
|
|
|
public function saveTemplateHtml($param){
|
|
|
|
$info = $this->webTemplateInfo($this->param['template_id'],$param['source'],$param['source_id']);
|
|
|
|
//保存头部信息
|
|
|
|
$this->saveCommonTemplate($param);
|
|
|
|
$param['project_id'] = $this->user['project_id'];
|
|
|
|
unset($param['head_html'],$param['head_css'],$param['footer_html'],$param['footer_css']);
|
|
|
|
if($info === false){
|
|
|
|
$this->model->add($param);
|
|
|
|
}else{
|
|
|
|
$this->model->edit($param,['id'=>$info['id']]);
|
|
|
|
}
|
|
|
|
return true;//组装数据
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :保存头部公共数据
|
|
|
|
* @name :saveCommonTemplate
|
|
|
|
* @author :lyh
|
|
...
|
...
|
@@ -383,19 +434,6 @@ class BTemplateLogic extends BaseLogic |
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :处理保存模版数据
|
|
|
|
* @name :templateParam
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/7/21 16:30
|
|
|
|
*/
|
|
|
|
public function templateSaveParam($param){
|
|
|
|
$param['project_id'] = $this->user['project_id'];
|
|
|
|
unset($param['head_html'],$param['head_css'],$param['footer_html'],$param['footer_css']);
|
|
|
|
return $this->success($param);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :拼接获取公共头部底部
|
|
|
|
* @name :getHeadFooter
|
|
|
|
* @author :lyh
|
...
|
...
|
|