作者 张关杰

Merge branch 'develop' of http://47.244.231.31:8099/zhl/globalso-v6 into bate

@@ -80,13 +80,14 @@ class BTemplateLogic extends BaseLogic @@ -80,13 +80,14 @@ class BTemplateLogic extends BaseLogic
80 $mainInfo = $this->getMAinHtml($this->param['source'],$is_custom,$is_list);//获取中间部分代码 80 $mainInfo = $this->getMAinHtml($this->param['source'],$is_custom,$is_list);//获取中间部分代码
81 }else{ 81 }else{
82 if($templateInfo['type'] == BTemplate::ALL_HTML){//返回整个html代码 82 if($templateInfo['type'] == BTemplate::ALL_HTML){//返回整个html代码
83 - $commonInfo = $this->getCommonHtml($this->param['source'],$is_list,0);//获取定制头部 83 + $type = $this->getCustomizedType($this->param['source'],$is_list);
  84 + $commonInfo = $this->getCustomizedCommonHtml($type);//获取定制头部
84 $html = $this->handleAllHtml($commonInfo,$templateInfo['html']); 85 $html = $this->handleAllHtml($commonInfo,$templateInfo['html']);
85 return $this->success(['html'=>$html,'template_id'=>$template_id,'id'=>$templateInfo['id'],'updated_at'=>$templateInfo['updated_at']]); 86 return $this->success(['html'=>$html,'template_id'=>$template_id,'id'=>$templateInfo['id'],'updated_at'=>$templateInfo['updated_at']]);
86 } 87 }
87 $mainInfo = ['main_html'=>$templateInfo['main_html'], 'main_css'=>$templateInfo['main_css']]; 88 $mainInfo = ['main_html'=>$templateInfo['main_html'], 'main_css'=>$templateInfo['main_css']];
88 } 89 }
89 - $commonInfo = $this->getCommonHtml($this->param['source'],$is_list,$template_id);//获取定制头部 90 + $commonInfo = $this->getCommonHtml($this->param['source'],$is_list,$template_id,$is_custom);//获取定制头部
90 $html = $commonInfo['head_css'].$mainInfo['main_css'].$commonInfo['footer_css'].$commonInfo['other']. 91 $html = $commonInfo['head_css'].$mainInfo['main_css'].$commonInfo['footer_css'].$commonInfo['other'].
91 $commonInfo['head_html'].$mainInfo['main_html'].$commonInfo['footer_html']; 92 $commonInfo['head_html'].$mainInfo['main_html'].$commonInfo['footer_html'];
92 $html = $this->getHeadFooter($html); 93 $html = $this->getHeadFooter($html);
@@ -172,7 +173,7 @@ class BTemplateLogic extends BaseLogic @@ -172,7 +173,7 @@ class BTemplateLogic extends BaseLogic
172 if($customHtmlInfo === false){ 173 if($customHtmlInfo === false){
173 $this->fail('定制页面,请先上传代码块'); 174 $this->fail('定制页面,请先上传代码块');
174 } 175 }
175 - $commonInfo = $this->getCommonHtml($type,$is_list,0);//获取定制头部 176 + $commonInfo = $this->getCustomizedCommonHtml($type);//获取定制头部
176 if($commonInfo !== false){ 177 if($commonInfo !== false){
177 $customHtmlInfo['main_html'] = $this->handleAllHtml($commonInfo,$customHtmlInfo['main_html']); 178 $customHtmlInfo['main_html'] = $this->handleAllHtml($commonInfo,$customHtmlInfo['main_html']);
178 } 179 }
@@ -182,7 +183,24 @@ class BTemplateLogic extends BaseLogic @@ -182,7 +183,24 @@ class BTemplateLogic extends BaseLogic
182 } 183 }
183 184
184 /** 185 /**
185 - * @remark :根据source获取type类型 186 + * @remark :定制项目获取头部底部
  187 + * @name :getCustomizedCommonHtml
  188 + * @author :lyh
  189 + * @method :post
  190 + * @time :2023/12/29 13:13
  191 + */
  192 + public function getCustomizedCommonHtml($type){
  193 + $data = [
  194 + 'template_id' => 0,
  195 + 'project_id' => $this->user['project_id'],
  196 + 'type'=>$type
  197 + ];
  198 + $commonTemplateModel = new BTemplateCommon();
  199 + return $commonTemplateModel->read($data);
  200 + }
  201 +
  202 + /**
  203 + * @remark :定制页面头部类型---根据source获取type类型
186 * @name :getType 204 * @name :getType
187 * @author :lyh 205 * @author :lyh
188 * @method :post 206 * @method :post
@@ -247,8 +265,8 @@ class BTemplateLogic extends BaseLogic @@ -247,8 +265,8 @@ class BTemplateLogic extends BaseLogic
247 * @method :post 265 * @method :post
248 * @time :2023/10/21 16:55 266 * @time :2023/10/21 16:55
249 */ 267 */
250 - public function getCommonHtml($source,$is_list,$template_id){  
251 - $type = $this->getType($source,$is_list,$template_id); 268 + public function getCommonHtml($source,$is_list,$template_id,$is_custom = 0){
  269 + $type = $this->getType($source,$is_list,$is_custom);
252 $data = [ 270 $data = [
253 'template_id' => $template_id, 271 'template_id' => $template_id,
254 'project_id' => $this->user['project_id'], 272 'project_id' => $this->user['project_id'],
@@ -306,7 +324,7 @@ class BTemplateLogic extends BaseLogic @@ -306,7 +324,7 @@ class BTemplateLogic extends BaseLogic
306 $this->model->edit($data,$condition); 324 $this->model->edit($data,$condition);
307 } 325 }
308 //更新头部信息 326 //更新头部信息
309 - $this->saveCommonHtml($this->param['html'],$this->param['source'],$this->param['is_list'],$this->param['template_id']); 327 + $this->saveCommonHtml($this->param['html'],$this->param['source'],$this->param['is_list'],$this->param['template_id'],$this->param['is_custom']);
310 $this->setOperationRecords($this->param['html'],$this->param['source'],$this->param['source_id'],$this->param['template_id'],$this->param['is_custom']); 328 $this->setOperationRecords($this->param['html'],$this->param['source'],$this->param['source_id'],$this->param['template_id'],$this->param['is_custom']);
311 //通知更新 329 //通知更新
312 $this->homeOrProduct($this->param['source'],$this->param['source_id'],$this->param['is_custom'],$this->param['is_list']); 330 $this->homeOrProduct($this->param['source'],$this->param['source_id'],$this->param['is_custom'],$this->param['is_list']);
@@ -364,8 +382,11 @@ class BTemplateLogic extends BaseLogic @@ -364,8 +382,11 @@ class BTemplateLogic extends BaseLogic
364 * @method :post 382 * @method :post
365 * @time :2023/12/13 17:05 383 * @time :2023/12/13 17:05
366 */ 384 */
367 - public function saveCommonHtml($html,$source,$is_list,$template_id){  
368 - $type = $this->getType($source,$is_list,$template_id);//获取头部类型1-9(首页到自定义页面) 385 + public function saveCommonHtml($html,$source,$is_list,$template_id,$is_custom){
  386 + $type = $this->getType($source,$is_list,$is_custom);//获取头部类型1-9(首页到自定义页面)
  387 + if($template_id == 0){//定制页面默认为独立头部
  388 + $type = $this->getCustomizedType($source,$is_list);//定制默认独立头部
  389 + }
369 $templateCommonModel = new BTemplateCommon(); 390 $templateCommonModel = new BTemplateCommon();
370 $commonInfo = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>$type]);//查看当前头部是否存在 391 $commonInfo = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>$type]);//查看当前头部是否存在
371 $handleInfo = $this->handleCommonParam($html); 392 $handleInfo = $this->handleCommonParam($html);
@@ -440,11 +461,11 @@ class BTemplateLogic extends BaseLogic @@ -440,11 +461,11 @@ class BTemplateLogic extends BaseLogic
440 * @method :post 461 * @method :post
441 * @time :2023/10/21 17:29 462 * @time :2023/10/21 17:29
442 */ 463 */
443 - public function getType($source,$is_list,$template_id){ 464 + public function getType($source,$is_list,$is_custom = 0){
444 $type = BTemplate::SOURCE_HOME;//首页公共头部底部 465 $type = BTemplate::SOURCE_HOME;//首页公共头部底部
445 $is_head = $this->user['configuration']['is_head'] ?? BTemplate::IS_NO_HEADER; 466 $is_head = $this->user['configuration']['is_head'] ?? BTemplate::IS_NO_HEADER;
446 - if($template_id == 0){//保存上传的代码块时,默认为独立头部  
447 - $is_head == BTemplate::IS_HEADER; 467 + if($is_custom == BTemplate::IS_CUSTOM){//拓展模块为首页头部
  468 + return $this->success($type);
448 } 469 }
449 //查看页面是否设置自定义头部底部 470 //查看页面是否设置自定义头部底部
450 if($is_head != BTemplate::IS_NO_HEADER) { 471 if($is_head != BTemplate::IS_NO_HEADER) {
@@ -464,6 +485,7 @@ class BTemplateLogic extends BaseLogic @@ -464,6 +485,7 @@ class BTemplateLogic extends BaseLogic
464 return $this->success($type); 485 return $this->success($type);
465 } 486 }
466 487
  488 +
467 /** 489 /**
468 * @remark :生成记录 490 * @remark :生成记录
469 * @name :setTemplateLog 491 * @name :setTemplateLog
@@ -10,6 +10,7 @@ @@ -10,6 +10,7 @@
10 namespace App\Http\Logic\Bside\BTemplate; 10 namespace App\Http\Logic\Bside\BTemplate;
11 11
12 use App\Http\Logic\Bside\BaseLogic; 12 use App\Http\Logic\Bside\BaseLogic;
  13 +use App\Models\Project\PageSetting;
13 use App\Models\RouteMap\RouteMap; 14 use App\Models\RouteMap\RouteMap;
14 use App\Models\Service\Service as ServiceSettingModel; 15 use App\Models\Service\Service as ServiceSettingModel;
15 use App\Models\Template\BTemplate; 16 use App\Models\Template\BTemplate;
@@ -47,7 +48,7 @@ class InitHtmlLogic extends BaseLogic @@ -47,7 +48,7 @@ class InitHtmlLogic extends BaseLogic
47 $main_html = $mainInfo['main_html']; 48 $main_html = $mainInfo['main_html'];
48 $main_style = $mainInfo['main_css']; 49 $main_style = $mainInfo['main_css'];
49 } 50 }
50 - $commonInfo = $this->getTypeCommonHtml($template_id,$this->param['type'],$is_custom,$is_list); //获取头部 51 + $commonInfo = $this->getCommonHtml($this->param['type'],$is_list,$template_id,$is_custom); //获取头部
51 $html = $commonInfo['head_css'].$main_style.$commonInfo['footer_css'].$commonInfo['other'].$commonInfo['head_html'].$main_html.$commonInfo['footer_html']; 52 $html = $commonInfo['head_css'].$main_style.$commonInfo['footer_css'].$commonInfo['other'].$commonInfo['head_html'].$main_html.$commonInfo['footer_html'];
52 $html = $this->getHeadFooter($html);//组装数据 53 $html = $this->getHeadFooter($html);//组装数据
53 return $this->success($html); 54 return $this->success($html);
@@ -109,43 +110,94 @@ class InitHtmlLogic extends BaseLogic @@ -109,43 +110,94 @@ class InitHtmlLogic extends BaseLogic
109 ]; 110 ];
110 $bTemplateMainModel->edit($data,['id'=>$mainInfo['id']]); 111 $bTemplateMainModel->edit($data,['id'=>$mainInfo['id']]);
111 } 112 }
112 - $this->saveDetailCommonHtml($this->param['html'],$this->param['type'],$template_id,$is_custom,$is_list); 113 + $this->saveCommonHtml($this->param['html'],$this->param['type'],$is_list,$template_id,$is_custom);
113 $route = RouteMap::getRoute('all',0,$this->user['project_id']); 114 $route = RouteMap::getRoute('all',0,$this->user['project_id']);
114 $this->curlDelRoute(['route'=>$route,'new_route'=>$route]); 115 $this->curlDelRoute(['route'=>$route,'new_route'=>$route]);
115 return $this->success(); 116 return $this->success();
116 } 117 }
  118 +
117 /** 119 /**
118 - * @remark :保存详情页模版头部底部  
119 - * @name :saveDetailCommonHtml 120 + * @remark :保存公共头部底部
  121 + * @name :saveCommonHtml
120 * @author :lyh 122 * @author :lyh
121 * @method :post 123 * @method :post
122 - * @time :2023/12/15 18:12 124 + * @time :2023/12/13 17:05
123 */ 125 */
124 - public function saveDetailCommonHtml($html,$type,$template_id,$is_custom,$is_list){  
125 - $publicData = $this->handleCommonParam($html); 126 + public function saveCommonHtml($html,$source,$is_list,$template_id,$is_custom){
  127 + $type = $this->getType($source,$is_list,$is_custom);//获取头部类型1-9(首页到自定义页面)
126 $templateCommonModel = new BTemplateCommon(); 128 $templateCommonModel = new BTemplateCommon();
127 - //查看当前模板是否有独立头部,有独立头部,更新独立头部,无独立头部,更新公共头部  
128 - $is_head = $this->user['configuration']['is_head'] ?? 0;  
129 - if($is_custom == BTemplate::IS_CUSTOM){//todo::扩展模块无独立头部底部  
130 - $is_head = BTemplate::IS_NO_HEADER; 129 + $commonInfo = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>$type]);//查看当前头部是否存在
  130 + $handleInfo = $this->handleCommonParam($html);
  131 + if($commonInfo === false){
  132 + $data = [
  133 + 'head_html'=>$handleInfo['head_html'], 'head_css'=>$handleInfo['head_css'],'other'=>$handleInfo['other'],
  134 + 'footer_html'=>$handleInfo['footer_html'], 'footer_css'=>$handleInfo['footer_css'],
  135 + 'type'=>$type,'template_id'=>$template_id, 'project_id'=>$this->user['project_id'],
  136 + ];
  137 + $templateCommonModel->add($data);
  138 + }else{
  139 + $data = [
  140 + 'head_html'=>$handleInfo['head_html'], 'head_css'=>$handleInfo['head_css'],'other'=>$handleInfo['other'],
  141 + 'footer_html'=>$handleInfo['footer_html'], 'footer_css'=>$handleInfo['footer_css'],
  142 + ];
  143 + $templateCommonModel->edit($data,['id'=>$commonInfo['id']]);
131 } 144 }
132 - if($is_head == BTemplate::IS_HEADER) {  
133 - //有独立头部,更新独立头部  
134 - $commonType = $this->getHeaderType($type,$is_list);  
135 - $templateCommonInfo = $templateCommonModel->read(['project_id'=>$this->user['project_id'],'template_id'=>$template_id,'type'=>$commonType]);  
136 - if($templateCommonInfo === false){  
137 - $publicData['type'] = $type;  
138 - $publicData['project_id'] = $this->user['project_id'];  
139 - $publicData['template_id'] = $template_id;  
140 - $templateCommonModel->add($publicData);  
141 - }else{  
142 - $templateCommonModel->edit($publicData,['id'=>$templateCommonInfo['id']]); 145 + //更新所有界面的other
  146 + return $templateCommonModel->edit(['other'=>$handleInfo['other']],['project_id'=>$this->user['project_id'],'template_id'=>$template_id]);
  147 + }
  148 +
  149 + /**
  150 + * @remark :根据类型获取公共头和底
  151 + * @name :getCommonPage
  152 + * @author :lyh
  153 + * @method :post
  154 + * @time :2023/10/21 16:55
  155 + */
  156 + public function getCommonHtml($source,$is_list,$template_id,$is_custom){
  157 + $type = $this->getType($source,$is_list,$is_custom);
  158 + $data = [
  159 + 'template_id' => $template_id,
  160 + 'project_id' => $this->user['project_id'],
  161 + 'type'=>$type
  162 + ];
  163 + $commonTemplateModel = new BTemplateCommon();
  164 + $commonInfo = $commonTemplateModel->read($data);
  165 + if($commonInfo === false){
  166 + $data['type'] = BTemplate::SOURCE_HOME;
  167 + $commonInfo = $commonTemplateModel->read($data);
  168 + }
  169 + return $this->success($commonInfo);
  170 + }
  171 +
  172 + /**
  173 + * @remark :保存时获取获取设置的类型
  174 + * @name :getType
  175 + * @author :lyh
  176 + * @method :post
  177 + * @time :2023/10/21 17:29
  178 + */
  179 + public function getType($source,$is_list,$is_custom = 0){
  180 + $type = BTemplate::SOURCE_HOME;//首页公共头部底部
  181 + $is_head = $this->user['configuration']['is_head'] ?? BTemplate::IS_NO_HEADER;
  182 + if($is_custom == BTemplate::IS_CUSTOM){//拓展模块为首页头部
  183 + return $this->success($type);
  184 + }
  185 + //查看页面是否设置自定义头部底部
  186 + if($is_head != BTemplate::IS_NO_HEADER) {
  187 + $pageSettingModel = new PageSetting();
  188 + $pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id']]);
  189 + if ($pageInfo === false) {
  190 + return $this->success($type);
143 } 191 }
144 - }else{  
145 - //更新首页头部底部  
146 - $templateCommonModel->edit($publicData,['type'=>BTemplate::SOURCE_HOME,'project_id'=>$this->user['project_id'],'template_id'=>$template_id]); 192 + if ($source == BTemplate::SOURCE_PRODUCT) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['product_details'] != 0) {$type = BTemplate::TYPE_PRODUCT_DETAIL;}}
  193 + else {if ($pageInfo['product_list'] != 0) {$type = BTemplate::TYPE_PRODUCT_LIST;}}}
  194 + if ($source == BTemplate::SOURCE_BLOG) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['blog_details'] != 0) {$type = BTemplate::TYPE_BLOG_DETAIL;}}
  195 + else {if ($pageInfo['blog_list'] != 0) {$type = BTemplate::TYPE_BLOG_LIST;}}}
  196 + if ($source == BTemplate::SOURCE_NEWS) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['news_details'] != 0) {$type = BTemplate::TYPE_NEWS_DETAIL;}}
  197 + else {if ($pageInfo['news_list'] != 0) {$type = BTemplate::TYPE_NEWS_LIST;}}}
  198 + if ($source == BTemplate::SOURCE_KEYWORD) {if ($pageInfo['polymerization'] != 0) {$type = BTemplate::TYPE_CUSTOM_PAGE;}}
147 } 199 }
148 - return $this->success(); 200 + return $this->success($type);
149 } 201 }
150 202
151 /** 203 /**
@@ -183,67 +235,6 @@ class InitHtmlLogic extends BaseLogic @@ -183,67 +235,6 @@ class InitHtmlLogic extends BaseLogic
183 } 235 }
184 236
185 /** 237 /**
186 - * @remark :根据type获取头部html  
187 - * @name :getHeaderFooter  
188 - * @author :lyh  
189 - * @method :post  
190 - * @time :2023/12/15 18:06  
191 - */  
192 - public function getTypeCommonHtml($template_id,$type,$is_custom,$is_list){  
193 - //判断当前项目是否有设置独立头部的权限  
194 - $is_head = $this->user['configuration']['is_head'] ?? 0;  
195 - if($is_custom == BTemplate::IS_CUSTOM){//todo::拓展模块默认取首页  
196 - $is_head = BTemplate::IS_NO_HEADER;  
197 - }  
198 - //获取首页公共部分  
199 - $templateCommonModel = new BTemplateCommon();  
200 - if($is_head == BTemplate::IS_HEADER) {  
201 - //有独立头部,获取独立头部  
202 - $commonType = $this->getHeaderType($type,$is_list);  
203 - $commonInfo = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>$commonType]);  
204 - if($commonInfo !== false){  
205 - return $this->success($commonInfo);  
206 - }  
207 - }  
208 - //首页头底  
209 - $commonInfo = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>BTemplate::SOURCE_HOME]);  
210 - return $this->success($commonInfo);  
211 - }  
212 -  
213 - /**  
214 - * @remark :独立头部获取头部底部类型  
215 - * @name :getHeaderType  
216 - * @author :lyh  
217 - * @method :post  
218 - * @time :2023/12/27 11:36  
219 - */  
220 - public function getHeaderType($type,$is_list){  
221 - $resultType = BTemplate::SOURCE_HOME;  
222 - if($type == BTemplate::SOURCE_PRODUCT){  
223 - if($is_list == BTemplate::IS_LIST){  
224 - $resultType = BTemplate::TYPE_PRODUCT_LIST;  
225 - }else{  
226 - $resultType = BTemplate::TYPE_PRODUCT_DETAIL;  
227 - }  
228 - }  
229 - if($type == BTemplate::SOURCE_BLOG){  
230 - if($is_list == BTemplate::IS_LIST){  
231 - $resultType = BTemplate::TYPE_BLOG_LIST;  
232 - }else{  
233 - $resultType = BTemplate::TYPE_BLOG_DETAIL;  
234 - }  
235 - }  
236 - if($type == BTemplate::SOURCE_NEWS){  
237 - if($is_list == BTemplate::IS_LIST){  
238 - $resultType = BTemplate::TYPE_NEWS_LIST;  
239 - }else{  
240 - $resultType = BTemplate::TYPE_NEWS_DETAIL;  
241 - }  
242 - }  
243 - return $this->success($resultType);  
244 - }  
245 -  
246 - /**  
247 * @remark :获取模版id 238 * @remark :获取模版id
248 * @name :getTemplateId 239 * @name :getTemplateId
249 * @author :lyh 240 * @author :lyh