作者 lyh

gx

@@ -7,10 +7,12 @@ @@ -7,10 +7,12 @@
7 */ 7 */
8 namespace App\Services\Html; 8 namespace App\Services\Html;
9 9
  10 +use App\Enums\Common\Code;
10 use App\Models\Product\Keyword; 11 use App\Models\Product\Keyword;
11 use App\Models\Project\Project; 12 use App\Models\Project\Project;
12 use App\Models\RouteMap\RouteMap; 13 use App\Models\RouteMap\RouteMap;
13 use App\Models\WebSetting\WebSettingSeo; 14 use App\Models\WebSetting\WebSettingSeo;
  15 +use App\Services\TdkService;
14 16
15 class CreateHtmlService 17 class CreateHtmlService
16 { 18 {
@@ -22,22 +24,38 @@ class CreateHtmlService @@ -22,22 +24,38 @@ class CreateHtmlService
22 */ 24 */
23 public function getHtml($project_id, $route, $lang = [], $page = 0) 25 public function getHtml($project_id, $route, $lang = [], $page = 0)
24 { 26 {
25 - //获取项目详情  
26 - $projectInfo = $this->getProjectInfo($project_id);  
27 - if($projectInfo === false){  
28 - return ['code'=>400,'message'=>'当前项目不存在或者已被删除'];  
29 - }  
30 - //获取页面信息  
31 - $pageInfo = $this->getInfoByRoute($route);  
32 - if(empty($pageInfo)){  
33 - return ['code'=>400,'message'=>'当前路由不存在或者已被删除'];  
34 - }  
35 - if($projectInfo['is_upgrade'] == 0){  
36 - $html = $this->getHtmlV6($project_id, $route); 27 + $projectModel = new Project();
  28 + $projectInfo = $projectModel->with(['payment', 'deploy_build'])->where(['id'=>$project_id])->first()->toArray();
  29 + $routeMapModel = new RouteMap();
  30 + $routeInfo = $routeMapModel->read(['route'=>$route]);
  31 + if($routeInfo === false){
  32 + if($route == 'top-search' || $route == 'products' || $route == 'news' || $route == 'blog'){
  33 + $html = '';
  34 + }else{
  35 + $html = '';
  36 + }
37 }else{ 37 }else{
38 - $html = $this->getHtmlV5(); 38 + //TODO::5.0,6.0获取html,自定义页面还需要单独处理
  39 + if(($routeInfo['source'] == RouteMap::SOURCE_PAGE) && ($route != 'index')){
  40 + $customTemplateService = new CustomTemplateService();
  41 + $data = $customTemplateService->getHtml($projectInfo,$routeInfo['source_id']);
  42 + if($data === false){
  43 + return false;
  44 + }
  45 + $html = $data['html'];
  46 + }else{
  47 + $generatePageService = new GeneratePageService();
  48 + $data = $generatePageService->generateHtml($projectInfo,$routeInfo);
  49 + if($data === false){
  50 + return false;
  51 + }
  52 + $html = $data['html'];
  53 + }
39 } 54 }
40 - return $html; 55 + //处理页面tdk
  56 + $tdkService = new TdkService();
  57 + $html = $tdkService->pageTdkHandle($projectInfo,$html,$routeInfo['source'],$routeInfo);
  58 + return ['html'=>$html];
41 } 59 }
42 60
43 /** 61 /**
@@ -54,16 +72,6 @@ class CreateHtmlService @@ -54,16 +72,6 @@ class CreateHtmlService
54 } 72 }
55 73
56 /** 74 /**
57 - * 返回5.0页面最终HTML  
58 - * @return string  
59 - */  
60 - public function getHtmlV5()  
61 - {  
62 - $html = '';  
63 - return $html;  
64 - }  
65 -  
66 - /**  
67 * 返回6.0页面最终HTML 75 * 返回6.0页面最终HTML
68 * @return mixed 76 * @return mixed
69 */ 77 */
@@ -104,10 +112,7 @@ class CreateHtmlService @@ -104,10 +112,7 @@ class CreateHtmlService
104 */ 112 */
105 public function originHtml($project_id,$route) 113 public function originHtml($project_id,$route)
106 { 114 {
107 - $generatePageService = new GeneratePageService();  
108 - $data = $generatePageService->generateHtml($project_id,$route);  
109 - $html = $data['html'] ?? '';  
110 - return $html; 115 +
111 } 116 }
112 117
113 /** 118 /**
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :CustomTemplateService.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/3/11 16:15
  8 + */
  9 +
  10 +namespace App\Services\Html;
  11 +
  12 +use App\Models\Project\PageSetting;
  13 +use App\Models\Service\Service as ServiceSettingModel;
  14 +use App\Models\Template\BTemplate;
  15 +use App\Models\Template\BTemplateCommon;
  16 +use App\Models\Template\Setting;
  17 +
  18 +class CustomTemplateService
  19 +{
  20 + /**
  21 + * @remark :获取当前自定义界面详情
  22 + * @name :customTemplateInfo
  23 + * @author :lyh
  24 + * @method :post
  25 + * @time :2023/6/29 16:23
  26 + */
  27 + public function getHtml($projectInfo,$custom_id){
  28 + $info = $this->model->read(['id'=>$custom_id]);
  29 + if($info === false){
  30 + return false;
  31 + }
  32 + if($info['is_visualization'] == 0 || $info['is_visualization'] == 1){
  33 + $html = $this->getBodyHeaderFooter($projectInfo,$info['html'],$info['html_style']);
  34 + $info['html'] = $this->getHeadFooter($html);
  35 + }
  36 + return ['html'=>$info['html']];
  37 + }
  38 +
  39 + /**
  40 + * @remark :获取body的详情
  41 + * @name :getBodyHeaderFooter
  42 + * @author :lyh
  43 + * @method :post
  44 + * @time :2023/7/21 18:08
  45 + */
  46 + public function getBodyHeaderFooter($projectInfo,$preg_html,$html_style){
  47 + if(empty($preg_html)){
  48 + $preg_html = "<main></main>";
  49 + $html_style = "<style id='globalsojs-styles'></style>";
  50 + }
  51 + //获取设置的默认模版
  52 + $bSettingModel = new Setting();
  53 + $info = $bSettingModel->read(['project_id'=>$projectInfo['id']]);
  54 + if($info === false){
  55 + return false;
  56 + }
  57 + //获取type类型
  58 + $commonInfo = $this->getCommonPage($projectInfo,$info['template_id']);
  59 + $html = $commonInfo['head_css'].$html_style.$commonInfo['footer_css'].$commonInfo['other'].
  60 + $commonInfo['head_html'].$preg_html.$commonInfo['footer_html'];
  61 + return ['html'=>$html];
  62 + }
  63 +
  64 + /**
  65 + * @remark :根据类型获取公共头和底
  66 + * @name :getCommonPage
  67 + * @author :lyh
  68 + * @method :post
  69 + */
  70 + public function getCommonPage($projectInfo,$template_id){
  71 + $is_head = $projectInfo['deploy_build']['configuration']['is_head'] ?? BTemplate::IS_NO_HEADER;
  72 + if(isset($is_head) && ($is_head != 0)) {
  73 + //查看页面是否设置自定义头部底部
  74 + $pageSettingModel = new PageSetting();
  75 + $pageInfo = $pageSettingModel->read(['project_id' => $projectInfo['id']]);
  76 + if ($pageInfo !== false) {
  77 + $commonTemplateModel = new BTemplateCommon();
  78 + if ($pageInfo['page_list'] != 0) {
  79 + //使用独立头和底
  80 + $commonInfo = $commonTemplateModel->read(['template_id' => $template_id, 'project_id' => $projectInfo['id'], 'type' => 9]);
  81 + }
  82 + }
  83 + }
  84 + if(!isset($commonInfo) || $commonInfo === false){
  85 + //获取首页公共的头部和底部
  86 + $commonTemplateModel = new BTemplateCommon();
  87 + $commonInfo = $commonTemplateModel->read(['template_id'=>$template_id,'project_id'=>$projectInfo['id'],'type'=>1]);
  88 + }
  89 + return $commonInfo;
  90 + }
  91 +
  92 + /**
  93 + * @remark :拼接获取公共头部底部
  94 + * @name :getHeadFooter
  95 + * @author :lyh
  96 + * @method :post
  97 + */
  98 + public function getHeadFooter($html = ''){
  99 + //获取公共主题头部底部
  100 + $serviceSettingModel = new ServiceSettingModel();
  101 + $list = $serviceSettingModel->list(['type'=>2],'created_at');
  102 + //拼接html
  103 + foreach ($list as $v){
  104 + if($v['key'] == 'head'){
  105 + $html = $v['values'].$html;
  106 + }
  107 + if($v['key'] == 'footer'){
  108 + $html = $html.$v['values'];
  109 + }
  110 + }
  111 + return $html;
  112 + }
  113 +}
@@ -12,6 +12,8 @@ namespace App\Services\Html; @@ -12,6 +12,8 @@ namespace App\Services\Html;
12 use App\Models\CustomModule\CustomModule; 12 use App\Models\CustomModule\CustomModule;
13 use App\Models\CustomModule\CustomModuleCategory; 13 use App\Models\CustomModule\CustomModuleCategory;
14 use App\Models\CustomModule\CustomModuleContent; 14 use App\Models\CustomModule\CustomModuleContent;
  15 +use App\Models\Project\PageSetting;
  16 +use App\Models\Project\Project;
15 use App\Models\RouteMap\RouteMap; 17 use App\Models\RouteMap\RouteMap;
16 use App\Models\Template\BTemplate; 18 use App\Models\Template\BTemplate;
17 use App\Models\Template\BTemplateCommon; 19 use App\Models\Template\BTemplateCommon;
@@ -36,20 +38,14 @@ class GeneratePageService @@ -36,20 +38,14 @@ class GeneratePageService
36 * @method :post 38 * @method :post
37 * @time :2024/2/19 16:57 39 * @time :2024/2/19 16:57
38 */ 40 */
39 - public function generateHtml($project_id,$route){  
40 - $this->project_id = $project_id;  
41 - $this->route = $route; 41 + public function generateHtml($projectInfo,$routeInfo){
  42 + $this->project_id = $projectInfo['id'];
  43 + $this->route = $routeInfo['route'];
42 ProjectServer::useProject($this->project_id); 44 ProjectServer::useProject($this->project_id);
43 - $routeMapModel = new RouteMap();  
44 - $routeInfo = $routeMapModel->read(['route'=>$this->param['route']]);  
45 - if($this->param['route'] != RouteMap::SOURCE_INDEX && $routeInfo['source'] == RouteMap::SOURCE_PAGE){  
46 - //页面管理单独处理  
47 - }else{  
48 - $this->handleParam($routeInfo);  
49 - return $this->getTemplateHtml();  
50 - } 45 + $this->handleParam($routeInfo);
  46 + $result = $this->getTemplateHtml($projectInfo);
51 DB::disconnect('custom_mysql'); 47 DB::disconnect('custom_mysql');
52 - return true; 48 + return $this->success($result);
53 } 49 }
54 50
55 /** 51 /**
@@ -125,14 +121,17 @@ class GeneratePageService @@ -125,14 +121,17 @@ class GeneratePageService
125 * @author :lyh 121 * @author :lyh
126 * @method :post 122 * @method :post
127 */ 123 */
128 - public function getTemplateHtml(){ 124 + public function getTemplateHtml($projectInfo){
129 $is_custom = $this->param['is_custom'] ?? 0;//是否为扩展模块 125 $is_custom = $this->param['is_custom'] ?? 0;//是否为扩展模块
130 $is_list = $this->param['is_list'] ?? 0;//是否为列表页 126 $is_list = $this->param['is_list'] ?? 0;//是否为列表页
131 - $template_id = $this->getSettingTemplate($this->param['source'],$is_list,$is_custom);//设置的模版id 127 + $template_id = $this->getSettingTemplate($projectInfo,$this->param['source'],$is_list,$is_custom);//设置的模版id
  128 + if($template_id === false){
  129 + return false;
  130 + }
132 $templateInfo = $this->webTemplateInfo($this->param['source'],$this->param['source_id'],$template_id,$is_custom,$is_list); 131 $templateInfo = $this->webTemplateInfo($this->param['source'],$this->param['source_id'],$template_id,$is_custom,$is_list);
133 if($templateInfo === false){ 132 if($templateInfo === false){
134 - if($this->user['is_customized'] == BTemplate::IS_VISUALIZATION){//处理定制页面初始数据  
135 - $html = $this->customizedReturnHtml($this->param['source'],$template_id,$is_custom,$is_list); 133 + if($projectInfo['is_customized'] == BTemplate::IS_VISUALIZATION){//处理定制页面初始数据
  134 + $html = $this->customizedReturnHtml($projectInfo,$this->param['source'],$template_id,$is_custom,$is_list);
136 if($html !== false){ 135 if($html !== false){
137 return $this->success($html); 136 return $this->success($html);
138 } 137 }
@@ -145,10 +144,10 @@ class GeneratePageService @@ -145,10 +144,10 @@ class GeneratePageService
145 } 144 }
146 $mainInfo = ['main_html'=>$templateInfo['main_html'], 'main_css'=>$templateInfo['main_css']]; 145 $mainInfo = ['main_html'=>$templateInfo['main_html'], 'main_css'=>$templateInfo['main_css']];
147 } 146 }
148 - $commonInfo = $this->getCommonHtml($this->param['source'],$is_list,$template_id,$is_custom);//获取非定制头部 147 + $commonInfo = $this->getCommonHtml($projectInfo,$this->param['source'],$is_list,$template_id,$is_custom);//获取非定制头部
149 $html = $commonInfo['head_css'].$mainInfo['main_css'].$commonInfo['footer_css'].$commonInfo['other']. $commonInfo['head_html'].$mainInfo['main_html'].$commonInfo['footer_html']; 148 $html = $commonInfo['head_css'].$mainInfo['main_css'].$commonInfo['footer_css'].$commonInfo['other']. $commonInfo['head_html'].$mainInfo['main_html'].$commonInfo['footer_html'];
150 $html = $this->getHeadFooter($html); 149 $html = $this->getHeadFooter($html);
151 - $result = ['html'=>$html,'template_id'=>$template_id]; 150 + $result = ['html'=>$html];
152 return $this->success($result); 151 return $this->success($result);
153 } 152 }
154 153
@@ -181,7 +180,7 @@ class GeneratePageService @@ -181,7 +180,7 @@ class GeneratePageService
181 public function webTemplateInfo($source,$source_id,$template_id,$is_custom,$is_list){ 180 public function webTemplateInfo($source,$source_id,$template_id,$is_custom,$is_list){
182 $templateInfo = $this->model->read([ 181 $templateInfo = $this->model->read([
183 'template_id'=>$template_id, 'source'=>$source, 182 'template_id'=>$template_id, 'source'=>$source,
184 - 'project_id'=>$this->user['project_id'], 'source_id'=>$source_id, 183 + 'project_id'=>$this->project_id, 'source_id'=>$source_id,
185 'is_custom'=>$is_custom, 'is_list'=>$is_list 184 'is_custom'=>$is_custom, 'is_list'=>$is_list
186 ]); 185 ]);
187 return $this->success($templateInfo); 186 return $this->success($templateInfo);
@@ -194,29 +193,35 @@ class GeneratePageService @@ -194,29 +193,35 @@ class GeneratePageService
194 * @method :post 193 * @method :post
195 * @time :2024/1/10 13:46 194 * @time :2024/1/10 13:46
196 */ 195 */
197 - public function customizedReturnHtml($source,$template_id,$is_custom,$is_list){ 196 + public function customizedReturnHtml($projectInfo,$source,$template_id,$is_custom,$is_list){
198 //TODO::扩展模块定制单独处理 197 //TODO::扩展模块定制单独处理
199 if($is_custom == BTemplate::IS_CUSTOM){ 198 if($is_custom == BTemplate::IS_CUSTOM){
200 $customModuleModel = new CustomModule(); 199 $customModuleModel = new CustomModule();
201 $info = $customModuleModel->read(['id'=>$source]); 200 $info = $customModuleModel->read(['id'=>$source]);
202 if($info === false){ 201 if($info === false){
203 - $this->fail('当前扩展模块不存在或已被删除'); 202 + return false;
204 } 203 }
205 //扩展模块定制 204 //扩展模块定制
206 if($is_list == BTemplate::IS_LIST && $info['list_customized'] == BTemplate::IS_VISUALIZATION){ 205 if($is_list == BTemplate::IS_LIST && $info['list_customized'] == BTemplate::IS_VISUALIZATION){
207 $html = $this->customModuleCustomizeHtml($source,$is_list,$is_custom); 206 $html = $this->customModuleCustomizeHtml($source,$is_list,$is_custom);
208 - return $this->success(['html'=>$html,'template_id'=>$template_id]); 207 + if($html === false){
  208 + return false;
  209 + }
  210 + return $this->success(['html'=>$html]);
209 } 211 }
210 if($is_list == BTemplate::IS_DETAIL && $info['detail_customized'] == BTemplate::IS_VISUALIZATION){ 212 if($is_list == BTemplate::IS_DETAIL && $info['detail_customized'] == BTemplate::IS_VISUALIZATION){
211 $html = $this->customModuleCustomizeHtml($source,$is_list,$is_custom); 213 $html = $this->customModuleCustomizeHtml($source,$is_list,$is_custom);
212 - return $this->success(['html'=>$html,'template_id'=>$template_id]); 214 + if($html === false){
  215 + return false;
  216 + }
  217 + return $this->success(['html'=>$html]);
213 } 218 }
214 return false; 219 return false;
215 } 220 }
216 //TODO::默认模块定制 221 //TODO::默认模块定制
217 - $html = $this->isCustomizedPage($source,$is_list,$is_custom);//获取定制页面的html  
218 - if(!empty($html)){  
219 - return $this->success(['html'=>$html,'template_id'=>$template_id]); 222 + $html = $this->isCustomizedPage($projectInfo,$source,$is_list,$is_custom);//获取定制页面的html
  223 + if($html !== false){
  224 + return $this->success(['html'=>$html]);
220 } 225 }
221 return false; 226 return false;
222 } 227 }
@@ -233,7 +238,7 @@ class GeneratePageService @@ -233,7 +238,7 @@ class GeneratePageService
233 //TODO::获取初始代码 238 //TODO::获取初始代码
234 $customHtmlInfo = $bTemplateMainModel->read(['type'=>$source,'is_list'=>$is_list,'is_custom'=>$is_custom]); 239 $customHtmlInfo = $bTemplateMainModel->read(['type'=>$source,'is_list'=>$is_list,'is_custom'=>$is_custom]);
235 if($customHtmlInfo === false){ 240 if($customHtmlInfo === false){
236 - $this->fail('定制页面,请先上传代码块'); 241 + return false;
237 } 242 }
238 $commonInfo = $this->getCustomizedCommonHtml($source,$is_custom,$is_list);//获取定制头部 243 $commonInfo = $this->getCustomizedCommonHtml($source,$is_custom,$is_list);//获取定制头部
239 if($commonInfo !== false){ 244 if($commonInfo !== false){
@@ -303,17 +308,17 @@ class GeneratePageService @@ -303,17 +308,17 @@ class GeneratePageService
303 * @method :post 308 * @method :post
304 * @time :2023/12/13 10:55 309 * @time :2023/12/13 10:55
305 */ 310 */
306 - public function isCustomizedPage($source,$is_list,$is_custom) 311 + public function isCustomizedPage($projectInfo,$source,$is_list,$is_custom)
307 { 312 {
308 $type = $this->getCustomizedType($source, $is_list);//获取定制界面类型 313 $type = $this->getCustomizedType($source, $is_list);//获取定制界面类型
309 //查看当前页面是否定制,是否开启可视化 314 //查看当前页面是否定制,是否开启可视化
310 - $page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面 315 + $page_array = (array)$projectInfo['is_visualization']->page_array;//获取所有定制界面
311 if (in_array($type, $page_array)) {//是定制界面 316 if (in_array($type, $page_array)) {//是定制界面
312 //TODO::获取初始代码 317 //TODO::获取初始代码
313 $bTemplateMainModel = new BTemplateMain(); 318 $bTemplateMainModel = new BTemplateMain();
314 $customHtmlInfo = $bTemplateMainModel->read(['type'=>$source,'is_custom'=>$is_custom,'is_list'=>$is_list]); 319 $customHtmlInfo = $bTemplateMainModel->read(['type'=>$source,'is_custom'=>$is_custom,'is_list'=>$is_list]);
315 if($customHtmlInfo === false){ 320 if($customHtmlInfo === false){
316 - $this->fail('定制页面,请先上传代码块'); 321 + return false;
317 } 322 }
318 $commonInfo = $this->getCustomizedCommonHtml($type,$is_custom,$is_list);//获取定制头部 323 $commonInfo = $this->getCustomizedCommonHtml($type,$is_custom,$is_list);//获取定制头部
319 if($commonInfo !== false){ 324 if($commonInfo !== false){
@@ -334,7 +339,7 @@ class GeneratePageService @@ -334,7 +339,7 @@ class GeneratePageService
334 public function getCustomizedCommonHtml($type,$is_custom = 0,$is_list = 0){ 339 public function getCustomizedCommonHtml($type,$is_custom = 0,$is_list = 0){
335 $data = [ 340 $data = [
336 'template_id' => 0, 341 'template_id' => 0,
337 - 'project_id' => $this->user['project_id'], 342 + 'project_id' => $this->project_id,
338 'type'=>$type, 343 'type'=>$type,
339 'is_custom'=>$is_custom, 344 'is_custom'=>$is_custom,
340 'is_list'=>$is_list 345 'is_list'=>$is_list
@@ -383,9 +388,9 @@ class GeneratePageService @@ -383,9 +388,9 @@ class GeneratePageService
383 * @method :post 388 * @method :post
384 * @time :2023/12/13 10:48 389 * @time :2023/12/13 10:48
385 */ 390 */
386 - public function getSettingTemplate($source,$is_list,$is_custom){ 391 + public function getSettingTemplate($projectInfo,$source,$is_list,$is_custom){
387 $template_id = 0; 392 $template_id = 0;
388 - if($this->user['is_customized'] == BTemplate::IS_VISUALIZATION) {//定制项目 393 + if($projectInfo['is_customized'] == BTemplate::IS_VISUALIZATION) {//定制项目
389 if($is_custom == BTemplate::IS_CUSTOM){ 394 if($is_custom == BTemplate::IS_CUSTOM){
390 $customModuleModel = new CustomModule(); 395 $customModuleModel = new CustomModule();
391 $info = $customModuleModel->read(['id'=>$source]); 396 $info = $customModuleModel->read(['id'=>$source]);
@@ -401,16 +406,16 @@ class GeneratePageService @@ -401,16 +406,16 @@ class GeneratePageService
401 }else{ 406 }else{
402 $type = $this->getCustomizedType($source, $is_list);//获取定制界面类型 407 $type = $this->getCustomizedType($source, $is_list);//获取定制界面类型
403 //查看当前页面是否定制,是否开启可视化 408 //查看当前页面是否定制,是否开启可视化
404 - $page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面 409 + $page_array = (array)$projectInfo['is_visualization']->page_array;//获取所有定制界面
405 if (in_array($type, $page_array)) {//是定制界面 410 if (in_array($type, $page_array)) {//是定制界面
406 return $this->success($template_id); 411 return $this->success($template_id);
407 } 412 }
408 } 413 }
409 } 414 }
410 $bSettingModel = new Setting(); 415 $bSettingModel = new Setting();
411 - $info = $bSettingModel->read(['project_id'=>$this->user['project_id']]); 416 + $info = $bSettingModel->read(['project_id'=>$this->project_id]);
412 if($info === false){ 417 if($info === false){
413 - $this->fail('请先选择模版'); 418 + return false;
414 } 419 }
415 $template_id = $info['template_id']; 420 $template_id = $info['template_id'];
416 return $this->success($template_id); 421 return $this->success($template_id);
@@ -423,11 +428,11 @@ class GeneratePageService @@ -423,11 +428,11 @@ class GeneratePageService
423 * @method :post 428 * @method :post
424 * @time :2023/10/21 16:55 429 * @time :2023/10/21 16:55
425 */ 430 */
426 - public function getCommonHtml($source,$is_list,$template_id,$is_custom = 0){  
427 - $type = $this->getType($source,$is_list,$is_custom); 431 + public function getCommonHtml($ProjectInfo,$source,$is_list,$template_id,$is_custom = 0,){
  432 + $type = $this->getType($ProjectInfo,$source,$is_list,$is_custom);
428 $data = [ 433 $data = [
429 'template_id' => $template_id, 434 'template_id' => $template_id,
430 - 'project_id' => $this->user['project_id'], 435 + 'project_id' => $this->project_id,
431 'type'=>$type, 436 'type'=>$type,
432 'is_custom'=>0, 437 'is_custom'=>0,
433 ]; 438 ];
@@ -440,4 +445,36 @@ class GeneratePageService @@ -440,4 +445,36 @@ class GeneratePageService
440 return $this->success($commonInfo); 445 return $this->success($commonInfo);
441 } 446 }
442 447
  448 + /**
  449 + * @remark :(非定制)保存时获取获取设置的类型
  450 + * @name :getType
  451 + * @author :lyh
  452 + * @method :post
  453 + * @time :2023/10/21 17:29
  454 + */
  455 + public function getType($projectInfo,$source,$is_list,$is_custom = 0){
  456 + $type = BTemplate::SOURCE_HOME;//首页公共头部底部
  457 + $is_head = $projectInfo['deploy_build']['configuration']['is_head'] ?? BTemplate::IS_NO_HEADER;
  458 + if($is_custom == BTemplate::IS_CUSTOM){//拓展模块为首页头部
  459 + return $this->success($type);
  460 + }
  461 + //查看页面是否设置自定义头部底部
  462 + if($is_head != BTemplate::IS_NO_HEADER) {
  463 + $pageSettingModel = new PageSetting();
  464 + $pageInfo = $pageSettingModel->read(['project_id' => $projectInfo['id']]);
  465 + if ($pageInfo === false) {
  466 + return $this->success($type);
  467 + }
  468 + if ($source == BTemplate::SOURCE_PRODUCT) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['product_details'] != 0) {$type = BTemplate::TYPE_PRODUCT_DETAIL;}}
  469 + else {if ($pageInfo['product_list'] != 0) {$type = BTemplate::TYPE_PRODUCT_LIST;}}}
  470 + if ($source == BTemplate::SOURCE_BLOG) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['blog_details'] != 0) {$type = BTemplate::TYPE_BLOG_DETAIL;}}
  471 + else {if ($pageInfo['blog_list'] != 0) {$type = BTemplate::TYPE_BLOG_LIST;}}}
  472 + if ($source == BTemplate::SOURCE_NEWS) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['news_details'] != 0) {$type = BTemplate::TYPE_NEWS_DETAIL;}}
  473 + else {if ($pageInfo['news_list'] != 0) {$type = BTemplate::TYPE_NEWS_LIST;}}}
  474 + if ($source == BTemplate::SOURCE_KEYWORD) {if ($pageInfo['polymerization'] != 0) {$type = BTemplate::TYPE_CUSTOM_PAGE;}}
  475 + }
  476 + return $this->success($type);
  477 + }
  478 +
  479 +
443 } 480 }