作者 lyh

gx

@@ -80,13 +80,13 @@ class BTemplateLogic extends BaseLogic @@ -80,13 +80,13 @@ 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 + $commonInfo = $this->getCommonHtml($this->param['source'],$is_list,0,0);//获取定制头部
84 $html = $this->handleAllHtml($commonInfo,$templateInfo['html']); 84 $html = $this->handleAllHtml($commonInfo,$templateInfo['html']);
85 return $this->success(['html'=>$html,'template_id'=>$template_id,'id'=>$templateInfo['id'],'updated_at'=>$templateInfo['updated_at']]); 85 return $this->success(['html'=>$html,'template_id'=>$template_id,'id'=>$templateInfo['id'],'updated_at'=>$templateInfo['updated_at']]);
86 } 86 }
87 $mainInfo = ['main_html'=>$templateInfo['main_html'], 'main_css'=>$templateInfo['main_css']]; 87 $mainInfo = ['main_html'=>$templateInfo['main_html'], 'main_css'=>$templateInfo['main_css']];
88 } 88 }
89 - $commonInfo = $this->getCommonHtml($this->param['source'],$is_list,$template_id);//获取定制头部 89 + $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']. 90 $html = $commonInfo['head_css'].$mainInfo['main_css'].$commonInfo['footer_css'].$commonInfo['other'].
91 $commonInfo['head_html'].$mainInfo['main_html'].$commonInfo['footer_html']; 91 $commonInfo['head_html'].$mainInfo['main_html'].$commonInfo['footer_html'];
92 $html = $this->getHeadFooter($html); 92 $html = $this->getHeadFooter($html);
@@ -172,7 +172,7 @@ class BTemplateLogic extends BaseLogic @@ -172,7 +172,7 @@ class BTemplateLogic extends BaseLogic
172 if($customHtmlInfo === false){ 172 if($customHtmlInfo === false){
173 $this->fail('定制页面,请先上传代码块'); 173 $this->fail('定制页面,请先上传代码块');
174 } 174 }
175 - $commonInfo = $this->getCommonHtml($type,$is_list,0);//获取定制头部 175 + $commonInfo = $this->getCommonHtml($type,$is_list,0,0);//获取定制头部
176 if($commonInfo !== false){ 176 if($commonInfo !== false){
177 $customHtmlInfo['main_html'] = $this->handleAllHtml($commonInfo,$customHtmlInfo['main_html']); 177 $customHtmlInfo['main_html'] = $this->handleAllHtml($commonInfo,$customHtmlInfo['main_html']);
178 } 178 }
@@ -247,8 +247,8 @@ class BTemplateLogic extends BaseLogic @@ -247,8 +247,8 @@ class BTemplateLogic extends BaseLogic
247 * @method :post 247 * @method :post
248 * @time :2023/10/21 16:55 248 * @time :2023/10/21 16:55
249 */ 249 */
250 - public function getCommonHtml($source,$is_list,$template_id){  
251 - $type = $this->getType($source,$is_list,$template_id); 250 + public function getCommonHtml($source,$is_list,$template_id,$is_custom){
  251 + $type = $this->getType($source,$is_list,$template_id,$is_custom);
252 $data = [ 252 $data = [
253 'template_id' => $template_id, 253 'template_id' => $template_id,
254 'project_id' => $this->user['project_id'], 254 'project_id' => $this->user['project_id'],
@@ -306,7 +306,7 @@ class BTemplateLogic extends BaseLogic @@ -306,7 +306,7 @@ class BTemplateLogic extends BaseLogic
306 $this->model->edit($data,$condition); 306 $this->model->edit($data,$condition);
307 } 307 }
308 //更新头部信息 308 //更新头部信息
309 - $this->saveCommonHtml($this->param['html'],$this->param['source'],$this->param['is_list'],$this->param['template_id']); 309 + $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']); 310 $this->setOperationRecords($this->param['html'],$this->param['source'],$this->param['source_id'],$this->param['template_id'],$this->param['is_custom']);
311 //通知更新 311 //通知更新
312 $this->homeOrProduct($this->param['source'],$this->param['source_id'],$this->param['is_custom'],$this->param['is_list']); 312 $this->homeOrProduct($this->param['source'],$this->param['source_id'],$this->param['is_custom'],$this->param['is_list']);
@@ -364,8 +364,8 @@ class BTemplateLogic extends BaseLogic @@ -364,8 +364,8 @@ class BTemplateLogic extends BaseLogic
364 * @method :post 364 * @method :post
365 * @time :2023/12/13 17:05 365 * @time :2023/12/13 17:05
366 */ 366 */
367 - public function saveCommonHtml($html,$source,$is_list,$template_id){  
368 - $type = $this->getType($source,$is_list,$template_id);//获取头部类型1-9(首页到自定义页面) 367 + public function saveCommonHtml($html,$source,$is_list,$template_id,$is_custom){
  368 + $type = $this->getType($source,$is_list,$template_id,$is_custom);//获取头部类型1-9(首页到自定义页面)
369 $templateCommonModel = new BTemplateCommon(); 369 $templateCommonModel = new BTemplateCommon();
370 $commonInfo = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>$type]);//查看当前头部是否存在 370 $commonInfo = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>$type]);//查看当前头部是否存在
371 $handleInfo = $this->handleCommonParam($html); 371 $handleInfo = $this->handleCommonParam($html);
@@ -440,9 +440,12 @@ class BTemplateLogic extends BaseLogic @@ -440,9 +440,12 @@ class BTemplateLogic extends BaseLogic
440 * @method :post 440 * @method :post
441 * @time :2023/10/21 17:29 441 * @time :2023/10/21 17:29
442 */ 442 */
443 - public function getType($source,$is_list,$template_id){ 443 + public function getType($source,$is_list,$template_id,$is_custom){
444 $type = BTemplate::SOURCE_HOME;//首页公共头部底部 444 $type = BTemplate::SOURCE_HOME;//首页公共头部底部
445 $is_head = $this->user['configuration']['is_head'] ?? BTemplate::IS_NO_HEADER; 445 $is_head = $this->user['configuration']['is_head'] ?? BTemplate::IS_NO_HEADER;
  446 + if($is_custom == BTemplate::IS_CUSTOM){//拓展模块为首页头部
  447 + return $this->success($type);
  448 + }
446 if($template_id == 0){//保存上传的代码块时,默认为独立头部 449 if($template_id == 0){//保存上传的代码块时,默认为独立头部
447 $is_head == BTemplate::IS_HEADER; 450 $is_head == BTemplate::IS_HEADER;
448 } 451 }
@@ -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,97 @@ class InitHtmlLogic extends BaseLogic @@ -109,43 +110,97 @@ 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,$template_id,$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,$template_id,$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,$template_id,$is_custom){
  180 + $type = BTemplate::SOURCE_HOME;//首页公共头部底部
  181 + $is_head = $this->user['configuration']['is_head'] ?? BTemplate::IS_NO_HEADER;
  182 + if($template_id == 0){//保存上传的代码块时,默认为独立头部
  183 + $is_head == BTemplate::IS_HEADER;
  184 + }
  185 + if($is_custom == BTemplate::IS_CUSTOM){//拓展模块为首页头部
  186 + $is_head == BTemplate::IS_NO_HEADER;
  187 + }
  188 + //查看页面是否设置自定义头部底部
  189 + if($is_head != BTemplate::IS_NO_HEADER) {
  190 + $pageSettingModel = new PageSetting();
  191 + $pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id']]);
  192 + if ($pageInfo === false) {
  193 + return $this->success($type);
143 } 194 }
144 - }else{  
145 - //更新首页头部底部  
146 - $templateCommonModel->edit($publicData,['type'=>BTemplate::SOURCE_HOME,'project_id'=>$this->user['project_id'],'template_id'=>$template_id]); 195 + if ($source == BTemplate::SOURCE_PRODUCT) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['product_details'] != 0) {$type = BTemplate::TYPE_PRODUCT_DETAIL;}}
  196 + else {if ($pageInfo['product_list'] != 0) {$type = BTemplate::TYPE_PRODUCT_LIST;}}}
  197 + if ($source == BTemplate::SOURCE_BLOG) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['blog_details'] != 0) {$type = BTemplate::TYPE_BLOG_DETAIL;}}
  198 + else {if ($pageInfo['blog_list'] != 0) {$type = BTemplate::TYPE_BLOG_LIST;}}}
  199 + if ($source == BTemplate::SOURCE_NEWS) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['news_details'] != 0) {$type = BTemplate::TYPE_NEWS_DETAIL;}}
  200 + else {if ($pageInfo['news_list'] != 0) {$type = BTemplate::TYPE_NEWS_LIST;}}}
  201 + if ($source == BTemplate::SOURCE_KEYWORD) {if ($pageInfo['polymerization'] != 0) {$type = BTemplate::TYPE_CUSTOM_PAGE;}}
147 } 202 }
148 - return $this->success(); 203 + return $this->success($type);
149 } 204 }
150 205
151 /** 206 /**
@@ -183,67 +238,6 @@ class InitHtmlLogic extends BaseLogic @@ -183,67 +238,6 @@ class InitHtmlLogic extends BaseLogic
183 } 238 }
184 239
185 /** 240 /**
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 241 * @remark :获取模版id
248 * @name :getTemplateId 242 * @name :getTemplateId
249 * @author :lyh 243 * @author :lyh