|
...
|
...
|
@@ -10,6 +10,7 @@ |
|
|
|
namespace App\Http\Logic\Bside\BTemplate;
|
|
|
|
|
|
|
|
use App\Http\Logic\Bside\BaseLogic;
|
|
|
|
use App\Models\Project\PageSetting;
|
|
|
|
use App\Models\RouteMap\RouteMap;
|
|
|
|
use App\Models\Service\Service as ServiceSettingModel;
|
|
|
|
use App\Models\Template\BTemplate;
|
|
...
|
...
|
@@ -47,7 +48,7 @@ class InitHtmlLogic extends BaseLogic |
|
|
|
$main_html = $mainInfo['main_html'];
|
|
|
|
$main_style = $mainInfo['main_css'];
|
|
|
|
}
|
|
|
|
$commonInfo = $this->getTypeCommonHtml($template_id,$this->param['type'],$is_custom,$is_list); //获取头部
|
|
|
|
$commonInfo = $this->getCommonHtml($this->param['type'],$is_list,$template_id,$is_custom); //获取头部
|
|
|
|
$html = $commonInfo['head_css'].$main_style.$commonInfo['footer_css'].$commonInfo['other'].$commonInfo['head_html'].$main_html.$commonInfo['footer_html'];
|
|
|
|
$html = $this->getHeadFooter($html);//组装数据
|
|
|
|
return $this->success($html);
|
|
...
|
...
|
@@ -109,43 +110,97 @@ class InitHtmlLogic extends BaseLogic |
|
|
|
];
|
|
|
|
$bTemplateMainModel->edit($data,['id'=>$mainInfo['id']]);
|
|
|
|
}
|
|
|
|
$this->saveDetailCommonHtml($this->param['html'],$this->param['type'],$template_id,$is_custom,$is_list);
|
|
|
|
$this->saveCommonHtml($this->param['html'],$this->param['type'],$is_list,$template_id,$is_custom);
|
|
|
|
$route = RouteMap::getRoute('all',0,$this->user['project_id']);
|
|
|
|
$this->curlDelRoute(['route'=>$route,'new_route'=>$route]);
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :保存详情页模版头部底部
|
|
|
|
* @name :saveDetailCommonHtml
|
|
|
|
* @remark :保存公共头部底部
|
|
|
|
* @name :saveCommonHtml
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/12/15 18:12
|
|
|
|
* @time :2023/12/13 17:05
|
|
|
|
*/
|
|
|
|
public function saveDetailCommonHtml($html,$type,$template_id,$is_custom,$is_list){
|
|
|
|
$publicData = $this->handleCommonParam($html);
|
|
|
|
public function saveCommonHtml($html,$source,$is_list,$template_id,$is_custom){
|
|
|
|
$type = $this->getType($source,$is_list,$template_id,$is_custom);//获取头部类型1-9(首页到自定义页面)
|
|
|
|
$templateCommonModel = new BTemplateCommon();
|
|
|
|
//查看当前模板是否有独立头部,有独立头部,更新独立头部,无独立头部,更新公共头部
|
|
|
|
$is_head = $this->user['configuration']['is_head'] ?? 0;
|
|
|
|
if($is_custom == BTemplate::IS_CUSTOM){//todo::扩展模块无独立头部底部
|
|
|
|
$is_head = BTemplate::IS_NO_HEADER;
|
|
|
|
$commonInfo = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>$type]);//查看当前头部是否存在
|
|
|
|
$handleInfo = $this->handleCommonParam($html);
|
|
|
|
if($commonInfo === false){
|
|
|
|
$data = [
|
|
|
|
'head_html'=>$handleInfo['head_html'], 'head_css'=>$handleInfo['head_css'],'other'=>$handleInfo['other'],
|
|
|
|
'footer_html'=>$handleInfo['footer_html'], 'footer_css'=>$handleInfo['footer_css'],
|
|
|
|
'type'=>$type,'template_id'=>$template_id, 'project_id'=>$this->user['project_id'],
|
|
|
|
];
|
|
|
|
$templateCommonModel->add($data);
|
|
|
|
}else{
|
|
|
|
$data = [
|
|
|
|
'head_html'=>$handleInfo['head_html'], 'head_css'=>$handleInfo['head_css'],'other'=>$handleInfo['other'],
|
|
|
|
'footer_html'=>$handleInfo['footer_html'], 'footer_css'=>$handleInfo['footer_css'],
|
|
|
|
];
|
|
|
|
$templateCommonModel->edit($data,['id'=>$commonInfo['id']]);
|
|
|
|
}
|
|
|
|
if($is_head == BTemplate::IS_HEADER) {
|
|
|
|
//有独立头部,更新独立头部
|
|
|
|
$commonType = $this->getHeaderType($type,$is_list);
|
|
|
|
$templateCommonInfo = $templateCommonModel->read(['project_id'=>$this->user['project_id'],'template_id'=>$template_id,'type'=>$commonType]);
|
|
|
|
if($templateCommonInfo === false){
|
|
|
|
$publicData['type'] = $type;
|
|
|
|
$publicData['project_id'] = $this->user['project_id'];
|
|
|
|
$publicData['template_id'] = $template_id;
|
|
|
|
$templateCommonModel->add($publicData);
|
|
|
|
}else{
|
|
|
|
$templateCommonModel->edit($publicData,['id'=>$templateCommonInfo['id']]);
|
|
|
|
//更新所有界面的other
|
|
|
|
return $templateCommonModel->edit(['other'=>$handleInfo['other']],['project_id'=>$this->user['project_id'],'template_id'=>$template_id]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :根据类型获取公共头和底
|
|
|
|
* @name :getCommonPage
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/10/21 16:55
|
|
|
|
*/
|
|
|
|
public function getCommonHtml($source,$is_list,$template_id,$is_custom){
|
|
|
|
$type = $this->getType($source,$is_list,$template_id,$is_custom);
|
|
|
|
$data = [
|
|
|
|
'template_id' => $template_id,
|
|
|
|
'project_id' => $this->user['project_id'],
|
|
|
|
'type'=>$type
|
|
|
|
];
|
|
|
|
$commonTemplateModel = new BTemplateCommon();
|
|
|
|
$commonInfo = $commonTemplateModel->read($data);
|
|
|
|
if($commonInfo === false){
|
|
|
|
$data['type'] = BTemplate::SOURCE_HOME;
|
|
|
|
$commonInfo = $commonTemplateModel->read($data);
|
|
|
|
}
|
|
|
|
return $this->success($commonInfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :保存时获取获取设置的类型
|
|
|
|
* @name :getType
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/10/21 17:29
|
|
|
|
*/
|
|
|
|
public function getType($source,$is_list,$template_id,$is_custom){
|
|
|
|
$type = BTemplate::SOURCE_HOME;//首页公共头部底部
|
|
|
|
$is_head = $this->user['configuration']['is_head'] ?? BTemplate::IS_NO_HEADER;
|
|
|
|
if($template_id == 0){//保存上传的代码块时,默认为独立头部
|
|
|
|
$is_head == BTemplate::IS_HEADER;
|
|
|
|
}
|
|
|
|
if($is_custom == BTemplate::IS_CUSTOM){//拓展模块为首页头部
|
|
|
|
$is_head == BTemplate::IS_NO_HEADER;
|
|
|
|
}
|
|
|
|
//查看页面是否设置自定义头部底部
|
|
|
|
if($is_head != BTemplate::IS_NO_HEADER) {
|
|
|
|
$pageSettingModel = new PageSetting();
|
|
|
|
$pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id']]);
|
|
|
|
if ($pageInfo === false) {
|
|
|
|
return $this->success($type);
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
//更新首页头部底部
|
|
|
|
$templateCommonModel->edit($publicData,['type'=>BTemplate::SOURCE_HOME,'project_id'=>$this->user['project_id'],'template_id'=>$template_id]);
|
|
|
|
if ($source == BTemplate::SOURCE_PRODUCT) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['product_details'] != 0) {$type = BTemplate::TYPE_PRODUCT_DETAIL;}}
|
|
|
|
else {if ($pageInfo['product_list'] != 0) {$type = BTemplate::TYPE_PRODUCT_LIST;}}}
|
|
|
|
if ($source == BTemplate::SOURCE_BLOG) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['blog_details'] != 0) {$type = BTemplate::TYPE_BLOG_DETAIL;}}
|
|
|
|
else {if ($pageInfo['blog_list'] != 0) {$type = BTemplate::TYPE_BLOG_LIST;}}}
|
|
|
|
if ($source == BTemplate::SOURCE_NEWS) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['news_details'] != 0) {$type = BTemplate::TYPE_NEWS_DETAIL;}}
|
|
|
|
else {if ($pageInfo['news_list'] != 0) {$type = BTemplate::TYPE_NEWS_LIST;}}}
|
|
|
|
if ($source == BTemplate::SOURCE_KEYWORD) {if ($pageInfo['polymerization'] != 0) {$type = BTemplate::TYPE_CUSTOM_PAGE;}}
|
|
|
|
}
|
|
|
|
return $this->success();
|
|
|
|
return $this->success($type);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
...
|
...
|
@@ -183,67 +238,6 @@ class InitHtmlLogic extends BaseLogic |
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :根据type获取头部html
|
|
|
|
* @name :getHeaderFooter
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/12/15 18:06
|
|
|
|
*/
|
|
|
|
public function getTypeCommonHtml($template_id,$type,$is_custom,$is_list){
|
|
|
|
//判断当前项目是否有设置独立头部的权限
|
|
|
|
$is_head = $this->user['configuration']['is_head'] ?? 0;
|
|
|
|
if($is_custom == BTemplate::IS_CUSTOM){//todo::拓展模块默认取首页
|
|
|
|
$is_head = BTemplate::IS_NO_HEADER;
|
|
|
|
}
|
|
|
|
//获取首页公共部分
|
|
|
|
$templateCommonModel = new BTemplateCommon();
|
|
|
|
if($is_head == BTemplate::IS_HEADER) {
|
|
|
|
//有独立头部,获取独立头部
|
|
|
|
$commonType = $this->getHeaderType($type,$is_list);
|
|
|
|
$commonInfo = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>$commonType]);
|
|
|
|
if($commonInfo !== false){
|
|
|
|
return $this->success($commonInfo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//首页头底
|
|
|
|
$commonInfo = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>BTemplate::SOURCE_HOME]);
|
|
|
|
return $this->success($commonInfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :独立头部获取头部底部类型
|
|
|
|
* @name :getHeaderType
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/12/27 11:36
|
|
|
|
*/
|
|
|
|
public function getHeaderType($type,$is_list){
|
|
|
|
$resultType = BTemplate::SOURCE_HOME;
|
|
|
|
if($type == BTemplate::SOURCE_PRODUCT){
|
|
|
|
if($is_list == BTemplate::IS_LIST){
|
|
|
|
$resultType = BTemplate::TYPE_PRODUCT_LIST;
|
|
|
|
}else{
|
|
|
|
$resultType = BTemplate::TYPE_PRODUCT_DETAIL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if($type == BTemplate::SOURCE_BLOG){
|
|
|
|
if($is_list == BTemplate::IS_LIST){
|
|
|
|
$resultType = BTemplate::TYPE_BLOG_LIST;
|
|
|
|
}else{
|
|
|
|
$resultType = BTemplate::TYPE_BLOG_DETAIL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if($type == BTemplate::SOURCE_NEWS){
|
|
|
|
if($is_list == BTemplate::IS_LIST){
|
|
|
|
$resultType = BTemplate::TYPE_NEWS_LIST;
|
|
|
|
}else{
|
|
|
|
$resultType = BTemplate::TYPE_NEWS_DETAIL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $this->success($resultType);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :获取模版id
|
|
|
|
* @name :getTemplateId
|
|
|
|
* @author :lyh
|
...
|
...
|
|