作者 lyh

gx

@@ -7,6 +7,7 @@ use App\Models\Blog\BlogCategory; @@ -7,6 +7,7 @@ use App\Models\Blog\BlogCategory;
7 use App\Models\News\NewsCategory; 7 use App\Models\News\NewsCategory;
8 use App\Models\Product\Category; 8 use App\Models\Product\Category;
9 use App\Models\Product\Product; 9 use App\Models\Product\Product;
  10 +use App\Models\Project\PageSetting;
10 use App\Models\RouteMap\RouteMap; 11 use App\Models\RouteMap\RouteMap;
11 use App\Models\Service\Service as ServiceSettingModel; 12 use App\Models\Service\Service as ServiceSettingModel;
12 use App\Models\Template\BTemplateCommon; 13 use App\Models\Template\BTemplateCommon;
@@ -61,12 +62,10 @@ class BTemplateLogic extends BaseLogic @@ -61,12 +62,10 @@ class BTemplateLogic extends BaseLogic
61 if($info === false){ 62 if($info === false){
62 $this->fail('请先选择模版'); 63 $this->fail('请先选择模版');
63 } 64 }
64 - $TemplateInfo = [];  
65 if($this->param['source'] == $this->model::SOURCE_HOME){//首页 65 if($this->param['source'] == $this->model::SOURCE_HOME){//首页
66 $TemplateInfo = $this->homeHtml($info,$this->param['source'],$this->param['source_id']); 66 $TemplateInfo = $this->homeHtml($info,$this->param['source'],$this->param['source_id']);
67 - }  
68 - if($this->param['source'] == $this->model::SOURCE_PRODUCT){//产品页  
69 - $TemplateInfo = $this->productHtml($info,$this->param['source'],$this->param['source_id']); 67 + }else{
  68 + $TemplateInfo = $this->otherHtml($info,$this->param['source'],$this->param['source_id']);
70 } 69 }
71 return $this->success($TemplateInfo); 70 return $this->success($TemplateInfo);
72 } 71 }
@@ -105,7 +104,7 @@ class BTemplateLogic extends BaseLogic @@ -105,7 +104,7 @@ class BTemplateLogic extends BaseLogic
105 $TemplateInfo = $ATemplateModel->read(['id'=>$info['template_id']]); 104 $TemplateInfo = $ATemplateModel->read(['id'=>$info['template_id']]);
106 }else{ 105 }else{
107 $commonTemplateModel = new BTemplateCommon(); 106 $commonTemplateModel = new BTemplateCommon();
108 - $commonInfo = $commonTemplateModel->read(['template_id'=>$info['template_id'],'project_id'=>$this->user['project_id'],'type'=>$source]); 107 + $commonInfo = $commonTemplateModel->read(['template_id'=>$info['template_id'],'project_id'=>$this->user['project_id'],'type'=>1]);
109 if($commonInfo !== false){ 108 if($commonInfo !== false){
110 $TemplateInfo['html'] = $commonInfo['head_css'].$TemplateInfo['main_css'].$commonInfo['footer_css'].$commonInfo['other']. 109 $TemplateInfo['html'] = $commonInfo['head_css'].$TemplateInfo['main_css'].$commonInfo['footer_css'].$commonInfo['other'].
111 $commonInfo['head_html'].$TemplateInfo['main_html'].$commonInfo['footer_html']; 110 $commonInfo['head_html'].$TemplateInfo['main_html'].$commonInfo['footer_html'];
@@ -126,7 +125,7 @@ class BTemplateLogic extends BaseLogic @@ -126,7 +125,7 @@ class BTemplateLogic extends BaseLogic
126 * @method :post 125 * @method :post
127 * @time :2023/7/25 16:40 126 * @time :2023/7/25 16:40
128 */ 127 */
129 - public function productHtml($info,$source,$source_id){ 128 + public function otherHtml($info,$source,$source_id){
130 $homeTemplateInfo = $this->webTemplateInfo($info['template_id'],1,0); 129 $homeTemplateInfo = $this->webTemplateInfo($info['template_id'],1,0);
131 if($homeTemplateInfo === false){ 130 if($homeTemplateInfo === false){
132 $this->fail('请先装修首页'); 131 $this->fail('请先装修首页');
@@ -140,9 +139,7 @@ class BTemplateLogic extends BaseLogic @@ -140,9 +139,7 @@ class BTemplateLogic extends BaseLogic
140 $main_html = $TemplateInfo['main_html']; 139 $main_html = $TemplateInfo['main_html'];
141 $main_style = $TemplateInfo['main_css']; 140 $main_style = $TemplateInfo['main_css'];
142 } 141 }
143 - //兼容老数据  
144 - $commonTemplateModel = new BTemplateCommon();  
145 - $commonInfo = $commonTemplateModel->read(['template_id'=>$info['template_id'],'project_id'=>$this->user['project_id'],'type'=>$source]); 142 + $commonInfo = $this->getCommonPage($source,$source_id,$info['template_id']);
146 if($commonInfo !== false){ 143 if($commonInfo !== false){
147 $html = $commonInfo['head_css'].$main_style.$commonInfo['footer_css'].$commonInfo['other']. 144 $html = $commonInfo['head_css'].$main_style.$commonInfo['footer_css'].$commonInfo['other'].
148 $commonInfo['head_html'].$main_html.$commonInfo['footer_html']; 145 $commonInfo['head_html'].$main_html.$commonInfo['footer_html'];
@@ -155,6 +152,72 @@ class BTemplateLogic extends BaseLogic @@ -155,6 +152,72 @@ class BTemplateLogic extends BaseLogic
155 } 152 }
156 153
157 /** 154 /**
  155 + * @remark :根据类型获取公共头和底
  156 + * @name :getCommonPage
  157 + * @author :lyh
  158 + * @method :post
  159 + * @time :2023/10/21 16:55
  160 + */
  161 + public function getCommonPage($source,$source_id,$template_id){
  162 + //获取首页公共的头部和底部
  163 + $commonTemplateModel = new BTemplateCommon();
  164 + $commonInfo = $commonTemplateModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>1]);
  165 + //查看页面是否设置自定义头部底部
  166 + $pageSettingModel = new PageSetting();
  167 + $pageInfo = $pageSettingModel->read(['project_id'=>$this->user['project_id']]);
  168 + if($pageInfo != false){
  169 + $commonTemplateModel = new BTemplateCommon();
  170 + if($source == 2){//产品页
  171 + if($source_id != 0){//产品详情页
  172 + if($pageInfo['product_list'] != 0){
  173 + //使用独立头和底
  174 + $commonInfo = $commonTemplateModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>3]);
  175 + }
  176 + }else{//产品列表页
  177 + if($pageInfo['product_details'] != 0){
  178 + //使用独立头和底
  179 + $commonInfo = $commonTemplateModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>2]);
  180 + }
  181 + }
  182 + }
  183 + if($source == 3){//博客页
  184 + if($source_id != 0){//博客详情页
  185 + if($pageInfo['blog_lists'] != 0){
  186 + //使用独立头和底
  187 + $commonInfo = $commonTemplateModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>4]);
  188 + }
  189 + }else{//产品列表页
  190 + if($pageInfo['blog_details'] != 0){
  191 + //使用独立头和底
  192 + $commonInfo = $commonTemplateModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>5]);
  193 + }
  194 + }
  195 + }
  196 + if($source == 4){//新闻页
  197 + if($source_id != 0){//新闻详情页
  198 + if($pageInfo['news_lists'] != 0){
  199 + //使用独立头和底
  200 + $commonInfo = $commonTemplateModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>6]);
  201 + }
  202 + }else{//新闻列表页
  203 + if($pageInfo['news_details'] != 0){
  204 + //使用独立头和底
  205 + $commonInfo = $commonTemplateModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>7]);
  206 + }
  207 + }
  208 + }
  209 + if($source == 5){//聚合页
  210 + if($pageInfo['polymerization'] != 0){
  211 + //使用独立头和底
  212 + $commonInfo = $commonTemplateModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>8]);
  213 + }
  214 + }
  215 + }
  216 + return $commonInfo;
  217 + }
  218 +
  219 +
  220 + /**
158 * @remark :设置模板 221 * @remark :设置模板
159 * @name :setTemplate 222 * @name :setTemplate
160 * @author :lyh 223 * @author :lyh
@@ -197,6 +260,7 @@ class BTemplateLogic extends BaseLogic @@ -197,6 +260,7 @@ class BTemplateLogic extends BaseLogic
197 $info = $this->webTemplateInfo($this->param['template_id'],$this->param['source'],$this->param['source_id']); 260 $info = $this->webTemplateInfo($this->param['template_id'],$this->param['source'],$this->param['source_id']);
198 //字符串截取 261 //字符串截取
199 $this->param = $this->stringProcessing($this->param); 262 $this->param = $this->stringProcessing($this->param);
  263 + //保存头部信息
200 $this->saveCommonTemplate($this->param); 264 $this->saveCommonTemplate($this->param);
201 $this->param = $this->templateSaveParam($this->param);//组装数据 265 $this->param = $this->templateSaveParam($this->param);//组装数据
202 if($info === false){ 266 if($info === false){
@@ -224,8 +288,9 @@ class BTemplateLogic extends BaseLogic @@ -224,8 +288,9 @@ class BTemplateLogic extends BaseLogic
224 * @time :2023/10/13 14:27 288 * @time :2023/10/13 14:27
225 */ 289 */
226 public function saveCommonTemplate($param){ 290 public function saveCommonTemplate($param){
  291 + $type = $this->getType($param['source'],$param['source_id']);
227 $templateCommonModel = new BTemplateCommon(); 292 $templateCommonModel = new BTemplateCommon();
228 - $info = $templateCommonModel->read(['template_id'=>$param['template_id'],'project_id'=>$this->user['project_id'],'type'=>1]); 293 + $info = $templateCommonModel->read(['template_id'=>$param['template_id'],'project_id'=>$this->user['project_id'],'type'=>$type]);
229 $data = [ 294 $data = [
230 'head_html'=>$param['head_html'], 295 'head_html'=>$param['head_html'],
231 'head_css'=>$param['head_css'], 296 'head_css'=>$param['head_css'],
@@ -236,7 +301,7 @@ class BTemplateLogic extends BaseLogic @@ -236,7 +301,7 @@ class BTemplateLogic extends BaseLogic
236 if($info === false){ 301 if($info === false){
237 $data['template_id'] = $param['template_id']; 302 $data['template_id'] = $param['template_id'];
238 $data['project_id'] = $this->user['project_id']; 303 $data['project_id'] = $this->user['project_id'];
239 - $data['type'] = 1; 304 + $data['type'] = $type;
240 $templateCommonModel->add($data); 305 $templateCommonModel->add($data);
241 }else{ 306 }else{
242 $templateCommonModel->edit($data,['id'=>$info['id']]); 307 $templateCommonModel->edit($data,['id'=>$info['id']]);
@@ -245,6 +310,61 @@ class BTemplateLogic extends BaseLogic @@ -245,6 +310,61 @@ class BTemplateLogic extends BaseLogic
245 } 310 }
246 311
247 /** 312 /**
  313 + * @remark :获取设置的类型
  314 + * @name :getType
  315 + * @author :lyh
  316 + * @method :post
  317 + * @time :2023/10/21 17:29
  318 + */
  319 + public function getType($source,$source_id){
  320 + $type = 1;//首页公共头部底部
  321 + //查看页面是否设置自定义头部底部
  322 + $pageSettingModel = new PageSetting();
  323 + $pageInfo = $pageSettingModel->read(['project_id'=>$this->user['project_id']]);
  324 + if($pageInfo !== false){
  325 + if($source == 2){
  326 + if($source_id != 0){
  327 + if($pageInfo['product_list'] != 0){
  328 + $type = 3;
  329 + }
  330 + }else{
  331 + if($pageInfo['product_details'] != 0){
  332 + $type = 2;
  333 + }
  334 + }
  335 + }
  336 + if($source == 3){
  337 + if($source_id != 0){
  338 + if($pageInfo['blog_list'] != 0){
  339 + $type = 4;
  340 + }
  341 + }else{
  342 + if($pageInfo['blog_details'] != 0){
  343 + $type = 5;
  344 + }
  345 + }
  346 + }
  347 + if($source == 4){
  348 + if($source_id != 0){
  349 + if($pageInfo['news_list'] != 0){
  350 + $type = 6;
  351 + }
  352 + }else{
  353 + if($pageInfo['news_details'] != 0){
  354 + $type = 7;
  355 + }
  356 + }
  357 + }
  358 + if($source == 5){
  359 + if($pageInfo['polymerization'] != 0){
  360 + $type = 8;
  361 + }
  362 + }
  363 + }
  364 + return $type;
  365 + }
  366 +
  367 + /**
248 * @remark :生成记录 368 * @remark :生成记录
249 * @name :setTemplateLog 369 * @name :setTemplateLog
250 * @author :lyh 370 * @author :lyh