|
...
|
...
|
@@ -11,6 +11,7 @@ use App\Models\Project\PageSetting; |
|
|
|
use App\Models\RouteMap\RouteMap;
|
|
|
|
use App\Models\Service\Service as ServiceSettingModel;
|
|
|
|
use App\Models\Template\BTemplateCommon;
|
|
|
|
use App\Models\Template\BTemplateMain;
|
|
|
|
use App\Models\Template\Setting;
|
|
|
|
use App\Models\Template\BTemplate;
|
|
|
|
use App\Models\Template\BTemplateLog;
|
|
...
|
...
|
@@ -165,51 +166,22 @@ class BTemplateLogic extends BaseLogic |
|
|
|
$pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id']]);
|
|
|
|
if ($pageInfo != false) {
|
|
|
|
$commonTemplateModel = new BTemplateCommon();
|
|
|
|
$data = [
|
|
|
|
'template_id' => $template_id,
|
|
|
|
'project_id' => $this->user['project_id']
|
|
|
|
];
|
|
|
|
if ($source == 2) {//产品页
|
|
|
|
if ($source_id != 0) {//产品详情页
|
|
|
|
if ($pageInfo['product_list'] != 0) {
|
|
|
|
//使用独立头和底
|
|
|
|
$commonInfo = $commonTemplateModel->read(['template_id' => $template_id, 'project_id' => $this->user['project_id'], 'type' => 3]);
|
|
|
|
}
|
|
|
|
} else {//产品列表页
|
|
|
|
if ($pageInfo['product_details'] != 0) {
|
|
|
|
//使用独立头和底
|
|
|
|
$commonInfo = $commonTemplateModel->read(['template_id' => $template_id, 'project_id' => $this->user['project_id'], 'type' => 2]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if($source_id != 0){$data['type'] = 2;if ($pageInfo['product_details'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}
|
|
|
|
else {$data['type'] = 3;if ($pageInfo['product_list'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}}
|
|
|
|
if ($source == 3) {//博客页
|
|
|
|
if ($source_id != 0) {//博客详情页
|
|
|
|
if ($pageInfo['blog_lists'] != 0) {
|
|
|
|
//使用独立头和底
|
|
|
|
$commonInfo = $commonTemplateModel->read(['template_id' => $template_id, 'project_id' => $this->user['project_id'], 'type' => 4]);
|
|
|
|
}
|
|
|
|
} else {//产品列表页
|
|
|
|
if ($pageInfo['blog_details'] != 0) {
|
|
|
|
//使用独立头和底
|
|
|
|
$commonInfo = $commonTemplateModel->read(['template_id' => $template_id, 'project_id' => $this->user['project_id'], 'type' => 5]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($source_id != 0) {$data['type'] = 4;if ($pageInfo['blog_details'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}
|
|
|
|
else {$data['type'] = 5;if ($pageInfo['blog_lists'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}}
|
|
|
|
if ($source == 4) {//新闻页
|
|
|
|
if ($source_id != 0) {//新闻详情页
|
|
|
|
if ($pageInfo['news_lists'] != 0) {
|
|
|
|
//使用独立头和底
|
|
|
|
$commonInfo = $commonTemplateModel->read(['template_id' => $template_id, 'project_id' => $this->user['project_id'], 'type' => 6]);
|
|
|
|
}
|
|
|
|
} else {//新闻列表页
|
|
|
|
if ($pageInfo['news_details'] != 0) {
|
|
|
|
//使用独立头和底
|
|
|
|
$commonInfo = $commonTemplateModel->read(['template_id' => $template_id, 'project_id' => $this->user['project_id'], 'type' => 7]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($source_id != 0) {$data['type'] = 6;if ($pageInfo['news_details'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}
|
|
|
|
else {$data['type'] = 7;if ($pageInfo['news_lists'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}}
|
|
|
|
if ($source == 5) {//聚合页
|
|
|
|
if ($pageInfo['polymerization'] != 0) {
|
|
|
|
//使用独立头和底
|
|
|
|
$commonInfo = $commonTemplateModel->read(['template_id' => $template_id, 'project_id' => $this->user['project_id'], 'type' => 8]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$data['type'] = 8;
|
|
|
|
if ($pageInfo['polymerization'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//获取首页公共的头部和底部
|
|
...
|
...
|
@@ -327,44 +299,10 @@ class BTemplateLogic extends BaseLogic |
|
|
|
$pageSettingModel = new PageSetting();
|
|
|
|
$pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id']]);
|
|
|
|
if ($pageInfo !== false) {
|
|
|
|
if ($source == 2) {
|
|
|
|
if ($source_id != 0) {
|
|
|
|
if ($pageInfo['product_list'] != 0) {
|
|
|
|
$type = 3;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if ($pageInfo['product_details'] != 0) {
|
|
|
|
$type = 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($source == 3) {
|
|
|
|
if ($source_id != 0) {
|
|
|
|
if ($pageInfo['blog_list'] != 0) {
|
|
|
|
$type = 4;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if ($pageInfo['blog_details'] != 0) {
|
|
|
|
$type = 5;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($source == 4) {
|
|
|
|
if ($source_id != 0) {
|
|
|
|
if ($pageInfo['news_list'] != 0) {
|
|
|
|
$type = 6;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if ($pageInfo['news_details'] != 0) {
|
|
|
|
$type = 7;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($source == 5) {
|
|
|
|
if ($pageInfo['polymerization'] != 0) {
|
|
|
|
$type = 8;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($source == 2) {if ($source_id != 0) {if ($pageInfo['product_details'] != 0) {$type = 2;}} else {if ($pageInfo['product_list'] != 0) {$type = 3;}}}
|
|
|
|
if ($source == 3) {if ($source_id != 0) {if ($pageInfo['blog_details'] != 0) {$type = 4;}} else {if ($pageInfo['blog_list'] != 0) {$type = 5;}}}
|
|
|
|
if ($source == 4) {if ($source_id != 0) {if ($pageInfo['news_details'] != 0) {$type = 6;}} else {if ($pageInfo['news_list'] != 0) {$type = 7;}}}
|
|
|
|
if ($source == 5) {if ($pageInfo['polymerization'] != 0) {$type = 8;}}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $type;
|
|
...
|
...
|
@@ -545,19 +483,13 @@ class BTemplateLogic extends BaseLogic |
|
|
|
$newCategory = NewsCategory::where($map)->get();
|
|
|
|
$blogCategory = BlogCategory::where($map)->get();
|
|
|
|
if (!empty($productCategory)){
|
|
|
|
foreach ($productCategory as $item){
|
|
|
|
$data["products"]["category"][] =$item;
|
|
|
|
}
|
|
|
|
foreach ($productCategory as $item){$data["products"]["category"][] =$item;}
|
|
|
|
}
|
|
|
|
if (!empty($newCategory)){
|
|
|
|
foreach ($newCategory as $item){
|
|
|
|
$data["news"]["category"][] =$item;
|
|
|
|
}
|
|
|
|
foreach ($newCategory as $item){$data["news"]["category"][] =$item;}
|
|
|
|
}
|
|
|
|
if (!empty($blogCategory)){
|
|
|
|
foreach ($blogCategory as $item){
|
|
|
|
$data["blogs"]["category"][] =$item;
|
|
|
|
}
|
|
|
|
foreach ($blogCategory as $item){$data["blogs"]["category"][] =$item;}
|
|
|
|
}
|
|
|
|
//返回
|
|
|
|
return $this->success($data);
|
|
...
|
...
|
@@ -581,4 +513,99 @@ class BTemplateLogic extends BaseLogic |
|
|
|
}
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :获取详情模板详情
|
|
|
|
* @name :getDetail
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/10/24 11:29
|
|
|
|
*/
|
|
|
|
public function getDetail(){
|
|
|
|
$bSettingModel = new Setting();
|
|
|
|
$bSettingInfo = $bSettingModel->read(['project_id'=>$this->user['project_id']]);
|
|
|
|
if($bSettingInfo === false){
|
|
|
|
$this->fail('请先设置模板');
|
|
|
|
}
|
|
|
|
//获取首页公共部分
|
|
|
|
$templateCommonModel = new BTemplateCommon();
|
|
|
|
$commonInfo = $templateCommonModel->read(['template_id'=>$bSettingInfo['template_id'],'project_id'=>$this->user['project_id'],'type'=>1]);
|
|
|
|
if($commonInfo === false){
|
|
|
|
$this->fail('已装修的项目使用当前功能时,可视化保存首页数据一次,未装修首页请先装修首页');
|
|
|
|
}
|
|
|
|
//判断当前项目是否有设置独立头部的权限是
|
|
|
|
if(isset($this->user['configuration']['is_head']) && ($this->user['configuration']['is_head'] != 0)) {
|
|
|
|
//有权限时,获取独立头部
|
|
|
|
$commonTypeInfo = $templateCommonModel->read(['template_id'=>$bSettingInfo['template_id'],'project_id'=>$this->user['project_id'],'type'=>$this->param['type']]);
|
|
|
|
if($commonTypeInfo !== false){
|
|
|
|
$commonInfo = $commonTypeInfo;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//获取设置的默认中间部分
|
|
|
|
$bTemplateMainModel = new BTemplateMain();
|
|
|
|
$mainInfo = $bTemplateMainModel->read(['project_id'=>$this->user['project_id'],'type'=>$this->param['type']]);
|
|
|
|
if($mainInfo === false){
|
|
|
|
$main_html = "<main>{$this->getProductModule()}</main>";
|
|
|
|
$main_style = "<style id='globalsojs-styles'></style>";
|
|
|
|
}else{
|
|
|
|
$main_html = $mainInfo['main_html'];
|
|
|
|
$main_style = $mainInfo['main_style'];
|
|
|
|
}
|
|
|
|
$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);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :保存详情模板数据
|
|
|
|
* @name :saveDetail
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/10/24 11:53
|
|
|
|
*/
|
|
|
|
public function saveDetail(){
|
|
|
|
$bSettingModel = new Setting();
|
|
|
|
$bSettingInfo = $bSettingModel->read(['project_id'=>$this->user['project_id']]);
|
|
|
|
if($bSettingInfo === false){
|
|
|
|
$this->fail('请先设置模板');
|
|
|
|
}
|
|
|
|
$data = [
|
|
|
|
'main_html'=>characterTruncation($this->param['html'],'/<main\b[^>]*>(.*?)<\/main>/s'),
|
|
|
|
'main_css'=>characterTruncation($this->param['html'],'/<style id="globalsojs-styles">(.*?)<\/style>/s'),
|
|
|
|
];
|
|
|
|
//保存中间部分
|
|
|
|
$bTemplateMainModel = new BTemplateMain();
|
|
|
|
$mainInfo = $bTemplateMainModel->read(['project_id'=>$this->user['project_id'],'type'=>$this->param['type']]);
|
|
|
|
if($mainInfo === false){
|
|
|
|
$data['project_id'] = $this->user['project_id'];
|
|
|
|
$data['type'] = $this->param['type'];
|
|
|
|
$bTemplateMainModel->add($data);
|
|
|
|
}else{
|
|
|
|
$bTemplateMainModel->edit($data,['id'=>$mainInfo['id']]);
|
|
|
|
}
|
|
|
|
$publicData = [
|
|
|
|
'head_html' => characterTruncation($this->param['html'],'/<header\b[^>]*>(.*?)<\/header>/s'),
|
|
|
|
'head_css' => characterTruncation($this->param['html'],'/<style id="globalsojs-header">(.*?)<\/style>/s'),
|
|
|
|
'footer_html' => characterTruncation($this->param['html'],'/<footer\b[^>]*>(.*?)<\/footer>/s'),
|
|
|
|
'footer_css' => characterTruncation($this->param['html'],'/<style id="globalsojs-footer">(.*?)<\/style>/s'),
|
|
|
|
];
|
|
|
|
//查看当前模板是否有独立头部,有独立头部,更新独立头部,无独立头部,更新公共头部
|
|
|
|
$templateCommonModel = new BTemplateCommon();
|
|
|
|
if(isset($this->user['configuration']['is_head']) && ($this->user['configuration']['is_head'] != 0)) {
|
|
|
|
$templateCommonInfo = $templateCommonModel->read(['type'=>$this->param['type'],'project_id'=>$this->user['project_id'],'template_id'=>$bSettingInfo['template_id']]);
|
|
|
|
if($templateCommonInfo === false){
|
|
|
|
$publicData['type'] = $this->param['type'];
|
|
|
|
$publicData['project_id'] = $this->user['project_id'];
|
|
|
|
$publicData['template_id'] = $bSettingInfo['template_id'];
|
|
|
|
$templateCommonModel->add($publicData);
|
|
|
|
}else{
|
|
|
|
$templateCommonModel->edit($publicData,['id'=>$templateCommonInfo['id']]);
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
//更新首页头部底部
|
|
|
|
$templateCommonModel->edit($publicData,['type'=>1,'project_id'=>$this->user['project_id'],'template_id'=>$bSettingInfo['template_id']]);
|
|
|
|
}
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|