作者 lyh

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

  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :UpdateRoute.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2023/11/20 15:07
  8 + */
  9 +
  10 +namespace App\Console\Commands;
  11 +
  12 +use App\Models\Blog\Blog;
  13 +use App\Models\Blog\BlogCategory;
  14 +use App\Models\News\News;
  15 +use App\Models\News\NewsCategory;
  16 +use App\Models\Product\Category;
  17 +use App\Models\Product\Keyword;
  18 +use App\Models\Product\Product;
  19 +use App\Models\Project\Project;
  20 +use App\Models\RouteMap\RouteMap;
  21 +use App\Services\ProjectServer;
  22 +use Illuminate\Console\Command;
  23 +use Illuminate\Support\Facades\DB;
  24 +
  25 +/**
  26 + * @remark :更新所有项目的路由
  27 + * @name :UpdateRoute
  28 + * @author :lyh
  29 + * @method :post
  30 + * @time :2023/11/20 15:08
  31 + */
  32 +class UpdateMainHtml extends Command
  33 +{
  34 + /**
  35 + * The name and signature of the console command.
  36 + *
  37 + * @var string
  38 + */
  39 + protected $signature = 'update_main';
  40 +
  41 + /**
  42 + * The console command description.
  43 + *
  44 + * @var string
  45 + */
  46 + protected $description = '洗数据';
  47 +
  48 + /**
  49 + * @remark :统一更新路由
  50 + * @name :handle
  51 + * @author :lyh
  52 + * @method :post
  53 + * @time :2023/11/20 15:13
  54 + */
  55 + public function handle(){
  56 + $projectModel = new Project();
  57 + $list = $projectModel->list(['is_upgrade'=>0]);
  58 + foreach ($list as $v){
  59 + echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
  60 + ProjectServer::useProject($v['id']);
  61 + DB::disconnect('custom_mysql');
  62 + }
  63 + echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
  64 + }
  65 +
  66 + /**
  67 + * @remark :洗数据
  68 + * @name :getMainHtml
  69 + * @author :lyh
  70 + * @method :post
  71 + * @time :2023/12/27 18:03
  72 + */
  73 + public function editMainHtml(){
  74 +
  75 + }
  76 +}
@@ -45,7 +45,7 @@ class BTemplateController extends BaseController @@ -45,7 +45,7 @@ class BTemplateController extends BaseController
45 'source.required' => 'source不能为空', 45 'source.required' => 'source不能为空',
46 'source_id.required' => 'source_id不能为空', 46 'source_id.required' => 'source_id不能为空',
47 ]); 47 ]);
48 - $info = $BTemplateLogic->getTemplate(); 48 + $info = $BTemplateLogic->getTemplateHtml();
49 $this->response('success',Code::SUCCESS,$info); 49 $this->response('success',Code::SUCCESS,$info);
50 } 50 }
51 51
@@ -138,28 +138,4 @@ class BTemplateController extends BaseController @@ -138,28 +138,4 @@ class BTemplateController extends BaseController
138 $this->response('模板保存成功'); 138 $this->response('模板保存成功');
139 } 139 }
140 140
141 - /**  
142 - * @remark :获取可视化详情页模板数据  
143 - * @name :getDetailInfo  
144 - * @author :lyh  
145 - * @method :post  
146 - * @time :2023/10/24 11:27  
147 - */  
148 - public function getDetailInfo(BTemplateLogic $BTemplateLogic){  
149 - $html = $BTemplateLogic->getDetail();  
150 - $this->response('success',Code::SUCCESS,['html'=>$html]);  
151 - }  
152 -  
153 - /**  
154 - * @remark :保存详情页模板数据  
155 - * @name :saveDetail  
156 - * @author :lyh  
157 - * @method :post  
158 - * @time :2023/10/24 14:47  
159 - */  
160 - public function saveDetail(BTemplateLogic $BTemplateLogic){  
161 - $BTemplateLogic->saveDetail();  
162 - $this->response('success');  
163 - }  
164 -  
165 } 141 }
1 <?php 1 <?php
2 /** 2 /**
3 * @remark : 3 * @remark :
4 - * @name :VisualizationController.php 4 + * @name :InitHtmlController.php
5 * @author :lyh 5 * @author :lyh
6 * @method :post 6 * @method :post
7 - * @time :2023/11/15 9:55 7 + * @time :2023/12/27 10:37
8 */ 8 */
9 9
10 namespace App\Http\Controllers\Bside\Template; 10 namespace App\Http\Controllers\Bside\Template;
11 11
12 use App\Enums\Common\Code; 12 use App\Enums\Common\Code;
13 use App\Http\Controllers\Bside\BaseController; 13 use App\Http\Controllers\Bside\BaseController;
  14 +use App\Http\Logic\Bside\BTemplate\BTemplateLogic;
  15 +use App\Http\Logic\Bside\BTemplate\InitHtmlLogic;
14 use App\Http\Logic\Bside\BTemplate\VisualizationLogic; 16 use App\Http\Logic\Bside\BTemplate\VisualizationLogic;
15 17
16 /** 18 /**
17 - * @remark :定制项目处理  
18 - * @name :VisualizationController 19 + * @remark :初始复合页代码块上传
  20 + * @name :InitHtmlController
19 * @author :lyh 21 * @author :lyh
20 * @method :post 22 * @method :post
21 - * @time :2023/11/15 9:55 23 + * @time :2023/12/27 10:37
22 */ 24 */
23 -class VisualizationController extends BaseController 25 +class InitHtmlController extends BaseController
24 { 26 {
25 /** 27 /**
  28 + * @remark :获取可视化详情页模板数据
  29 + * @name :getDetailInfo
  30 + * @author :lyh
  31 + * @method :post $param (type:类型,2产品 3博客 4新闻 对应扩展模块的id)
  32 + * @time :2023/10/24 11:27
  33 + */
  34 + public function getDetailHtml(InitHtmlLogic $logic){
  35 + $this->request->validate([
  36 + 'type'=>['required'],
  37 + ],[
  38 + 'type.required' => '类型不能为空',
  39 + ]);
  40 + $html = $logic->getDetailHtml();
  41 + $this->response('success',Code::SUCCESS,['html'=>$html]);
  42 + }
  43 +
  44 + /**
  45 + * @remark :保存详情页模板数据
  46 + * @name :saveDetail
  47 + * @author :lyh
  48 + * @method :post $param (type:类型,2产品 3博客 4新闻 对应扩展模块的id)
  49 + * @time :2023/10/24 14:47
  50 + */
  51 + public function saveDetailHtml(InitHtmlLogic $logic){
  52 + $this->request->validate([
  53 + 'type'=>['required'],
  54 + ],[
  55 + 'type.required' => '类型不能为空',
  56 + ]);
  57 + $logic->saveDetailHtml();
  58 + $this->response('success');
  59 + }
  60 +
  61 + /**
26 * @remark :获取当前定制代码块详情 62 * @remark :获取当前定制代码块详情
27 * @name :info 63 * @name :info
28 * @author :lyh 64 * @author :lyh
29 * @method :post 65 * @method :post
30 * @time :2023/11/15 10:26 66 * @time :2023/11/15 10:26
31 */ 67 */
32 - public function info(VisualizationLogic $logic){  
33 - $info = $logic->getVisualizationInfo(); 68 + public function getCustomizedHtml(InitHtmlLogic $logic){
  69 + $this->request->validate([
  70 + 'type'=>['required'],
  71 + ],[
  72 + 'type.required' => '类型不能为空',
  73 + ]);
  74 + $info = $logic->getCustomizedHtml();
34 if($info === false){ 75 if($info === false){
35 $info = []; 76 $info = [];
36 } 77 }
@@ -44,8 +85,13 @@ class VisualizationController extends BaseController @@ -44,8 +85,13 @@ class VisualizationController extends BaseController
44 * @method :post 85 * @method :post
45 * @time :2023/11/15 10:08 86 * @time :2023/11/15 10:08
46 */ 87 */
47 - public function save(VisualizationLogic $logic){  
48 - $logic->saveVisualization(); 88 + public function saveCustomizedHtml(InitHtmlLogic $logic){
  89 + $this->request->validate([
  90 + 'type'=>['required'],
  91 + ],[
  92 + 'type.required' => '类型不能为空',
  93 + ]);
  94 + $logic->saveCustomizedHtml();
49 $this->response('success'); 95 $this->response('success');
50 } 96 }
51 } 97 }
@@ -57,48 +57,44 @@ class BTemplateLogic extends BaseLogic @@ -57,48 +57,44 @@ class BTemplateLogic extends BaseLogic
57 } 57 }
58 58
59 /** 59 /**
60 - * @remark :获取当前选择使用的模板  
61 - * @name :getModuleTemplate  
62 - * @author :lyh  
63 - * @method :post  
64 - * @time :2023/6/29 9:44  
65 - */  
66 - public function getTemplate(){  
67 - $template_id = $this->getSettingTemplate($this->param['source'],$this->param['source_id']);//设置的模版id  
68 - $data = $this->getHtml($template_id,$this->param['source'],$this->param['source_id'],$this->param['is_custom'] ?? 0);  
69 - return $this->success($data);  
70 - }  
71 -  
72 - /**  
73 - * @remark :获取可视化装修的html 60 + * @remark :获取可视化html
74 * @name :getTemplateHtml 61 * @name :getTemplateHtml
75 * @author :lyh 62 * @author :lyh
76 * @method :post 63 * @method :post
77 - * @time :2023/12/13 10:47 64 + * @time :2023/12/27 14:48
78 */ 65 */
79 - public function getHtml($template_id,$source,$source_id,$is_custom){  
80 - $templateInfo = $this->webTemplateInfo($template_id,$source,$source_id,$is_custom); 66 + public function getTemplateHtml(){
  67 + $is_custom = $this->param['is_custom'] ?? 0;//是否为扩展模块
  68 + $is_list = $this->param['is_list'] ?? 0;//是否为列表页
  69 + $template_id = $this->getSettingTemplate($this->param['source'],$is_list);//设置的模版id
  70 + $templateInfo = $this->model->read([
  71 + 'template_id'=>$template_id, 'source'=>$this->param['source'],
  72 + 'project_id'=>$this->user['project_id'], 'source_id'=>$this->param['source_id'],
  73 + 'is_custom'=>$is_custom, 'is_list'=>$is_list
  74 + ]);
81 if($templateInfo === false){ 75 if($templateInfo === false){
82 if($this->user['is_customized'] == BTemplate::SOURCE_VISUALIZATION){//处理定制页面初始数据 76 if($this->user['is_customized'] == BTemplate::SOURCE_VISUALIZATION){//处理定制页面初始数据
83 - $html = $this->isCustomizedPage($source,$source_id);//查看当前页面是否定制 77 + $html = $this->isCustomizedPage($this->param['source'],$is_list);//获取定制页面的html
84 return $this->success(['html'=>$html,'template_id'=>$template_id]); 78 return $this->success(['html'=>$html,'template_id'=>$template_id]);
85 } 79 }
86 - $mainInfo = $this->getCommonMain($source,$source_id,$is_custom);//获取中间部分代码 80 + $mainInfo = $this->getMAinHtml($this->param['source'],$is_custom,$is_list);//获取中间部分代码
87 }else{ 81 }else{
88 if($templateInfo['type'] == BTemplate::ALL_HTML){//返回整个html代码 82 if($templateInfo['type'] == BTemplate::ALL_HTML){//返回整个html代码
89 - $type = $this->getCustomizedType($source, $source_id);//定制获取头部底部类型  
90 - $commonInfo = $this->getCommonPage($type,$this->user['project_id'],0);//获取定制头部 83 + $type = $this->getCustomizedType($this->param['source'], $is_list);//获取头部底部类型
  84 + $commonInfo = $this->getCommonHtml($type,$is_list,0);//获取定制头部
91 $html = $this->handleAllHtml($commonInfo,$templateInfo['html']); 85 $html = $this->handleAllHtml($commonInfo,$templateInfo['html']);
92 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']]);
93 } 87 }
94 $mainInfo = ['main_html'=>$templateInfo['main_html'], 'main_css'=>$templateInfo['main_css']]; 88 $mainInfo = ['main_html'=>$templateInfo['main_html'], 'main_css'=>$templateInfo['main_css']];
95 } 89 }
96 - $commonInfo = $this->getCommonPage($source,$source_id,$template_id);//获取头部 90 + $type = $this->getCustomizedType($this->param['source'], $is_list);//获取头部底部类型
  91 + $commonInfo = $this->getCommonHtml($type,$is_list,$template_id);//获取定制头部
97 $html = $commonInfo['head_css'].$mainInfo['main_css'].$commonInfo['footer_css'].$commonInfo['other']. 92 $html = $commonInfo['head_css'].$mainInfo['main_css'].$commonInfo['footer_css'].$commonInfo['other'].
98 $commonInfo['head_html'].$mainInfo['main_html'].$commonInfo['footer_html']; 93 $commonInfo['head_html'].$mainInfo['main_html'].$commonInfo['footer_html'];
99 $html = $this->getHeadFooter($html); 94 $html = $this->getHeadFooter($html);
100 $result = ['html'=>$html,'template_id'=>$template_id]; 95 $result = ['html'=>$html,'template_id'=>$template_id];
101 - if($templateInfo !== false){ 96 + if($templateInfo !== false)
  97 + {
102 $result['id'] = $templateInfo['id']; 98 $result['id'] = $templateInfo['id'];
103 $result['updated_at'] = $templateInfo['updated_at']; 99 $result['updated_at'] = $templateInfo['updated_at'];
104 } 100 }
@@ -106,6 +102,43 @@ class BTemplateLogic extends BaseLogic @@ -106,6 +102,43 @@ class BTemplateLogic extends BaseLogic
106 } 102 }
107 103
108 /** 104 /**
  105 + * @remark :获取中间部分的html
  106 + * @name :getMAinHtml
  107 + * @author :lyh
  108 + * @method :post
  109 + * @time :2023/12/27 15:00
  110 + */
  111 + public function getMAinHtml($type,$is_custom,$is_list){
  112 + //获取设置的默认中间部分
  113 + $bTemplateMainModel = new BTemplateMain();
  114 + $mainInfo = $bTemplateMainModel->read(['type'=>$type,'is_list'=>$is_list,'is_custom'=>$is_custom]);
  115 + if($mainInfo === false){
  116 + $main_html = $this->getInitModule($type,$is_custom,$is_list);
  117 + $main_css = "<style id='globalsojs-styles'></style>";
  118 + }else{
  119 + $main_html = $mainInfo['main_html'];
  120 + $main_css = $mainInfo['main_css'];
  121 + }
  122 + return ['main_html'=>$main_html,'main_css'=>$main_css];
  123 + }
  124 +
  125 + /**
  126 + * @remark :默认复合页数据
  127 + * @name :getProductModule
  128 + * @author :lyh
  129 + * @method :post
  130 + * @time :2023/7/27 15:08
  131 + */
  132 + public function getInitModule($type,$is_custom,$is_list){
  133 + if($is_custom == BTemplate::SOURCE_CUSTOM) {
  134 + $type = BTemplate::TYPE_CUSTOM;
  135 + }
  136 + $mainModel = new TemplateTypeMain();
  137 + $info = $mainModel->read(['type'=>$type,'is_list'=>$is_list]);
  138 + return $info['main_html'];
  139 + }
  140 +
  141 + /**
109 * @remark :返回整个html截取代码 142 * @remark :返回整个html截取代码
110 * @name :handleAllHtml 143 * @name :handleAllHtml
111 * @author :lyh 144 * @author :lyh
@@ -129,19 +162,19 @@ class BTemplateLogic extends BaseLogic @@ -129,19 +162,19 @@ class BTemplateLogic extends BaseLogic
129 * @method :post 162 * @method :post
130 * @time :2023/12/13 10:55 163 * @time :2023/12/13 10:55
131 */ 164 */
132 - public function isCustomizedPage($source,$source_id) 165 + public function isCustomizedPage($source,$is_list)
133 { 166 {
134 - $type = $this->getCustomizedType($source, $source_id);//获取定制界面类型 167 + $type = $this->getCustomizedType($source, $is_list);//获取定制界面类型
135 //查看当前页面是否定制,是否开启可视化 168 //查看当前页面是否定制,是否开启可视化
136 $page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面 169 $page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面
137 if (in_array($type, $page_array)) {//是定制界面 170 if (in_array($type, $page_array)) {//是定制界面
138 //TODO::获取初始代码 171 //TODO::获取初始代码
139 $bTemplateMainModel = new BTemplateMain(); 172 $bTemplateMainModel = new BTemplateMain();
140 - $customHtmlInfo = $bTemplateMainModel->read(['type'=>$type]); 173 + $customHtmlInfo = $bTemplateMainModel->read(['type'=>$source,'is_list'=>$is_list]);
141 if($customHtmlInfo === false){ 174 if($customHtmlInfo === false){
142 $this->fail('定制页面,请先上传代码块'); 175 $this->fail('定制页面,请先上传代码块');
143 } 176 }
144 - $commonInfo = $this->getCommonPage($type,$this->user['project_id'],0);//获取定制头部 177 + $commonInfo = $this->getCommonHtml($type,$is_list,0);//获取定制头部
145 if($commonInfo !== false){ 178 if($commonInfo !== false){
146 $customHtmlInfo['main_html'] = $this->handleAllHtml($commonInfo,$customHtmlInfo['main_html']); 179 $customHtmlInfo['main_html'] = $this->handleAllHtml($commonInfo,$customHtmlInfo['main_html']);
147 } 180 }
@@ -151,22 +184,34 @@ class BTemplateLogic extends BaseLogic @@ -151,22 +184,34 @@ class BTemplateLogic extends BaseLogic
151 } 184 }
152 185
153 /** 186 /**
154 - * @remark :定制界面根据source+source_id获取type类型 187 + * @remark :根据source获取type类型
155 * @name :getType 188 * @name :getType
156 * @author :lyh 189 * @author :lyh
157 * @method :post 190 * @method :post
158 * @time :2023/11/16 11:20 191 * @time :2023/11/16 11:20
159 */ 192 */
160 - public function getCustomizedType($source,$source_id){ 193 + public function getCustomizedType($source,$is_list){
161 $type = BTemplate::TYPE_ONE; 194 $type = BTemplate::TYPE_ONE;
162 if($source == BTemplate::SOURCE_PRODUCT){ 195 if($source == BTemplate::SOURCE_PRODUCT){
163 - if($source_id == 0){$type = BTemplate::TYPE_THREE;}else{$type = BTemplate::TYPE_TWO;} 196 + if($is_list == BTemplate::IS_LIST){
  197 + $type = BTemplate::TYPE_THREE;
  198 + }else{
  199 + $type = BTemplate::TYPE_TWO;
  200 + }
164 } 201 }
165 if($source == BTemplate::SOURCE_BLOG){ 202 if($source == BTemplate::SOURCE_BLOG){
166 - if($source_id == 0){$type = BTemplate::TYPE_FIVE;}else{$type = BTemplate::TYPE_FOUR;} 203 + if($is_list == BTemplate::IS_LIST){
  204 + $type = BTemplate::TYPE_FIVE;
  205 + }else{
  206 + $type = BTemplate::TYPE_FOUR;
  207 + }
167 } 208 }
168 if($source == BTemplate::SOURCE_NEWS){ 209 if($source == BTemplate::SOURCE_NEWS){
169 - if($source_id == 0){$type = BTemplate::TYPE_SEVEN;}else{$type = BTemplate::TYPE_SIX;} 210 + if($is_list == BTemplate::IS_LIST){
  211 + $type = BTemplate::TYPE_SEVEN;
  212 + }else{
  213 + $type = BTemplate::TYPE_SIX;
  214 + }
170 } 215 }
171 return $type; 216 return $type;
172 } 217 }
@@ -178,13 +223,14 @@ class BTemplateLogic extends BaseLogic @@ -178,13 +223,14 @@ class BTemplateLogic extends BaseLogic
178 * @method :post 223 * @method :post
179 * @time :2023/12/13 10:48 224 * @time :2023/12/13 10:48
180 */ 225 */
181 - public function getSettingTemplate($source,$source_id){ 226 + public function getSettingTemplate($source,$is_list){
  227 + $template_id = 0;
182 if($this->user['is_customized'] == BTemplate::SOURCE_VISUALIZATION) {//定制项目 228 if($this->user['is_customized'] == BTemplate::SOURCE_VISUALIZATION) {//定制项目
183 - $type = $this->getCustomizedType($source, $source_id);//获取定制界面类型 229 + $type = $this->getCustomizedType($source, $is_list);//获取定制界面类型
184 //查看当前页面是否定制,是否开启可视化 230 //查看当前页面是否定制,是否开启可视化
185 $page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面 231 $page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面
186 if (in_array($type, $page_array)) {//是定制界面 232 if (in_array($type, $page_array)) {//是定制界面
187 - return 0; 233 + return $this->success($template_id);
188 } 234 }
189 } 235 }
190 $bSettingModel = new Setting(); 236 $bSettingModel = new Setting();
@@ -192,95 +238,172 @@ class BTemplateLogic extends BaseLogic @@ -192,95 +238,172 @@ class BTemplateLogic extends BaseLogic
192 if($info === false){ 238 if($info === false){
193 $this->fail('请先选择模版'); 239 $this->fail('请先选择模版');
194 } 240 }
195 - return $info['template_id']; 241 + $template_id = $info['template_id'];
  242 + return $this->success($template_id);
196 } 243 }
197 244
198 /** 245 /**
199 - * @remark :根据参数获取数据详情  
200 - * @name :webTemplateInfo 246 + * @remark :根据类型获取公共头和底
  247 + * @name :getCommonPage
201 * @author :lyh 248 * @author :lyh
202 * @method :post 249 * @method :post
203 - * @time :2023/7/25 16:41 250 + * @time :2023/10/21 16:55
204 */ 251 */
205 - public function webTemplateInfo($template_id,$source,$source_id,$is_custom = 0){  
206 - //查看当前模板是否已编辑保存web_template  
207 - $TemplateInfo = $this->model->read([  
208 - 'template_id'=>$template_id,  
209 - 'source'=>$source,  
210 - 'project_id'=>$this->user['project_id'],  
211 - 'source_id'=>$source_id,  
212 - 'is_custom'=>$is_custom  
213 - ]);  
214 - return $this->success($TemplateInfo); 252 + public function getCommonHtml($source,$is_list,$template_id){
  253 + $is_head = $this->user['configuration']['is_head'] ?? 0;
  254 + $data = [
  255 + 'template_id' => $template_id,
  256 + 'project_id' => $this->user['project_id']
  257 + ];
  258 + if($is_head != BTemplate::IS_NO_HEADER) {
  259 + //查看页面是否设置自定义头部底部
  260 + $pageSettingModel = new PageSetting();
  261 + $pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id']]);
  262 + if($pageInfo !== false){
  263 + $commonInfo = [];
  264 + if ($source == BTemplate::SOURCE_BLOG) {//产品页
  265 + $commonInfo = $this->getProductCommonHtml($data,$is_list,$pageInfo);
  266 + }
  267 + if ($source == BTemplate::SOURCE_BLOG) {//博客页
  268 + $commonInfo = $this->getBlogCommonHtml($data,$is_list,$pageInfo);
  269 + }
  270 + if ($source == BTemplate::SOURCE_NEWS) {//新闻页
  271 + $commonInfo = $this->getNewsCommonHtml($data,$is_list,$pageInfo);
  272 + }
  273 + if ($source == BTemplate::SOURCE_KEYWORD) {//聚合页
  274 + $commonInfo = $this->getKeywordCommonHtml($data,$pageInfo);
  275 + }
  276 + if(!empty($commonInfo)){
  277 + return $this->success($commonInfo);
  278 + }
  279 + }
  280 + }
  281 + //获取首页公共的头部和底部
  282 + $commonInfo = $this->getHomeCommonHtml($data);
  283 + return $commonInfo;
215 } 284 }
216 285
217 /** 286 /**
218 - * @remark :获取中间公共部分  
219 - * @name :getCommonMain 287 + * @remark :获取首页头部底部
  288 + * @name :getHomeCommonHtml
220 * @author :lyh 289 * @author :lyh
221 * @method :post 290 * @method :post
222 - * @time :2023/10/24 15:58 291 + * @time :2023/12/27 16:11
223 */ 292 */
224 - public function getCommonMain($source,$source_id,$is_custom){  
225 - $data = [];  
226 - if($is_custom == BTemplate::SOURCE_CUSTOM){  
227 - if($source_id != 0){$type = BTemplate::TYPE_CUSTOM_DETAIL;}else{$type = BTemplate::TYPE_CUSTOM_LIST;}  
228 - }else{  
229 - if ($source == BTemplate::SOURCE_PRODUCT) {if ($source_id != 0) {$type = BTemplate::TYPE_TWO;} else {$type = BTemplate::TYPE_THREE;}}  
230 - if ($source == BTemplate::SOURCE_BLOG) {if ($source_id != 0) {$type = BTemplate::TYPE_FOUR;} else {$type = BTemplate::TYPE_FIVE;}}  
231 - if ($source == BTemplate::SOURCE_NEWS) {if ($source_id != 0) {$type = BTemplate::TYPE_SIX;} else {$type = BTemplate::TYPE_SEVEN;}}  
232 - if ($source == BTemplate::SOURCE_KEYWORD) {$type = BTemplate::TYPE_EIGHT;} 293 + public function getHomeCommonHtml($data){
  294 + $data['type'] = BTemplate::SOURCE_HOME;
  295 + $commonTemplateModel = new BTemplateCommon();
  296 + return $commonTemplateModel->read($data);
  297 + }
  298 +
  299 + /**
  300 + * @remark :聚合页
  301 + * @name :getKeywordCommonHtml
  302 + * @author :lyh
  303 + * @method :post
  304 + * @time :2023/12/27 16:09
  305 + */
  306 + public function getKeywordCommonHtml($data,$pageInfo){
  307 + $commonInfo = [];
  308 + $commonTemplateModel = new BTemplateCommon();
  309 + $data['type'] = BTemplate::TYPE_EIGHT;
  310 + if ($pageInfo['polymerization'] != 0) {
  311 + $commonInfo = $commonTemplateModel->read($data);
  312 + if($commonInfo === false){
  313 + $commonInfo = [];
  314 + }
233 } 315 }
234 - //查询有没有公共详情模板  
235 - $bTemplateMainModel = new BTemplateMain();  
236 - $mainInfo = $bTemplateMainModel->read(['project_id'=>$this->user['project_id'],'type'=>$type]);  
237 - if($mainInfo === false){  
238 - $data['main_html'] = $this->getModule($type);  
239 - $data['main_css'] = "<style id='globalsojs-styles'></style>";  
240 - }else{  
241 - $data['main_html'] = $mainInfo['main_html'];  
242 - $data['main_css'] = $mainInfo['main_css']; 316 + return $this->success($commonInfo);
  317 + }
  318 +
  319 + /**
  320 + * @remark :产品头部底部
  321 + * @name :getProductCommonHtml
  322 + * @author :lyh
  323 + * @method :post
  324 + * @time :2023/12/27 16:01
  325 + */
  326 + public function getProductCommonHtml($data,$is_list,$pageInfo){
  327 + $commonInfo = [];
  328 + $commonTemplateModel = new BTemplateCommon();
  329 + if($is_list == BTemplate::IS_LIST){
  330 + $data['type'] = BTemplate::TYPE_THREE;
  331 + if ($pageInfo['product_list'] != 0) {
  332 + $commonInfo = $commonTemplateModel->read($data);
  333 + if($commonInfo === false){
  334 + $commonInfo = [];
  335 + }
  336 + }
  337 + } else {
  338 + $data['type'] = BTemplate::TYPE_TWO;
  339 + if ($pageInfo['product_details'] != 0) {
  340 + $commonInfo = $commonTemplateModel->read($data);
  341 + if($commonInfo === false){
  342 + $commonInfo = [];
  343 + }
  344 + }
243 } 345 }
244 - return $data; 346 + return $this->success($commonInfo);
245 } 347 }
246 348
247 /** 349 /**
248 - * @remark :根据类型获取公共头和底  
249 - * @name :getCommonPage 350 + * @remark :博客头部
  351 + * @name :getBlogCommonHtml
250 * @author :lyh 352 * @author :lyh
251 * @method :post 353 * @method :post
252 - * @time :2023/10/21 16:55 354 + * @time :2023/12/27 16:05
253 */ 355 */
254 - public function getCommonPage($source,$source_id,$template_id){  
255 - if(isset($this->user['configuration']['is_head']) && ($this->user['configuration']['is_head'] != 0)) {  
256 - //查看页面是否设置自定义头部底部  
257 - $pageSettingModel = new PageSetting();  
258 - $pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id']]);  
259 - if ($pageInfo != false) {  
260 - $commonTemplateModel = new BTemplateCommon();  
261 - $data = [  
262 - 'template_id' => $template_id,  
263 - 'project_id' => $this->user['project_id']  
264 - ];  
265 - if ($source == BTemplate::SOURCE_PRODUCT) {//产品页  
266 - if($source_id != 0){$data['type'] = BTemplate::TYPE_TWO;if ($pageInfo['product_details'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}  
267 - else {$data['type'] = BTemplate::TYPE_THREE;if ($pageInfo['product_list'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}}  
268 - if ($source == BTemplate::SOURCE_BLOG) {//博客页  
269 - if ($source_id != 0) {$data['type'] = BTemplate::TYPE_FOUR;if ($pageInfo['blog_details'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}  
270 - else {$data['type'] = BTemplate::TYPE_FIVE;if ($pageInfo['blog_list'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}}  
271 - if ($source == BTemplate::SOURCE_NEWS) {//新闻页  
272 - if ($source_id != 0) {$data['type'] = BTemplate::TYPE_SIX;if ($pageInfo['news_details'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}  
273 - else {$data['type'] = BTemplate::TYPE_SEVEN;if ($pageInfo['news_list'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}}  
274 - if ($source == BTemplate::SOURCE_KEYWORD) {//聚合页  
275 - $data['type'] = BTemplate::TYPE_EIGHT;if ($pageInfo['polymerization'] != 0) {$commonInfo = $commonTemplateModel->read($data);}} 356 + public function getBlogCommonHtml($data,$is_list,$pageInfo){
  357 + $commonInfo = [];
  358 + $commonTemplateModel = new BTemplateCommon();
  359 + if ($is_list == BTemplate::IS_LIST) {
  360 + $data['type'] = BTemplate::TYPE_SEVEN;
  361 + if ($pageInfo['blog_list'] != 0) {
  362 + $commonInfo = $commonTemplateModel->read($data);
  363 + if($commonInfo === false){
  364 + $commonInfo = [];
  365 + }
  366 + }
  367 + } else {
  368 + $data['type'] = BTemplate::TYPE_SIX;
  369 + if ($pageInfo['blog_details'] != 0) {
  370 + $commonInfo = $commonTemplateModel->read($data);
  371 + if($commonInfo === false){
  372 + $commonInfo = [];
  373 + }
276 } 374 }
277 } 375 }
278 - //获取首页公共的头部和底部  
279 - if(!isset($commonInfo) || $commonInfo === false){  
280 - $commonTemplateModel = new BTemplateCommon();  
281 - $commonInfo = $commonTemplateModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>BTemplate::TYPE_ONE]); 376 + return $this->success($commonInfo);
  377 + }
  378 +
  379 + /**
  380 + * @remark :新闻头部
  381 + * @name :getNewsCommonHtml
  382 + * @author :lyh
  383 + * @method :post
  384 + * @time :2023/12/27 16:07
  385 + */
  386 + public function getNewsCommonHtml($data,$is_list,$pageInfo){
  387 + $commonInfo = [];
  388 + $commonTemplateModel = new BTemplateCommon();
  389 + if ($is_list == BTemplate::IS_LIST) {
  390 + $data['type'] = BTemplate::TYPE_SEVEN;
  391 + if ($pageInfo['news_list'] != 0) {
  392 + $commonInfo = $commonTemplateModel->read($data);
  393 + if($commonInfo === false){
  394 + $commonInfo = [];
  395 + }
  396 + }
  397 + } else {
  398 + $data['type'] = BTemplate::TYPE_SIX;
  399 + if ($pageInfo['news_details'] != 0) {
  400 + $commonInfo = $commonTemplateModel->read($data);
  401 + if($commonInfo === false){
  402 + $commonInfo = [];
  403 + }
  404 + }
282 } 405 }
283 - return $commonInfo; 406 + return $this->success($commonInfo);
284 } 407 }
285 408
286 /** 409 /**
@@ -293,28 +416,40 @@ class BTemplateLogic extends BaseLogic @@ -293,28 +416,40 @@ class BTemplateLogic extends BaseLogic
293 public function templateSave(){ 416 public function templateSave(){
294 //演示项目不允许修改 417 //演示项目不允许修改
295 $this->showProjectNoEdit($this->param['source']); 418 $this->showProjectNoEdit($this->param['source']);
296 - DB::beginTransaction();  
297 - try {  
298 - $this->param = $this->handleDefaultString($this->param);//设置默认字符  
299 - $templateInfo = $this->webTemplateInfo($this->param['template_id'],$this->param['source'],  
300 - $this->param['source_id'],$this->param['is_custom']);  
301 - if($templateInfo === false){//执行新增  
302 - $this->templateAddHtml($this->param['html'], $this->param['source'], $this->param['source_id'],  
303 - $this->param['template_id'], $this->param['section_list_id'], $this->param['is_custom']);  
304 - }else{//执行编辑  
305 - $this->templateEditHtml($this->param['html'],$this->param['source'],$this->param['source_id'],  
306 - $this->param['template_id'],$this->param['section_list_id'], $this->param['is_custom']);  
307 - }  
308 - //更新头部信息  
309 - $this->saveCommonHtml($this->param['html'],$this->param['source'],$this->param['source_id'],$this->param['template_id']);  
310 - $this->setOperationRecords($this->param['html'],$this->param['source'],$this->param['source_id'],$this->param['template_id'],$this->param['is_custom']);  
311 - DB::commit();  
312 - }catch (\Exception $e){  
313 - DB::rollBack();  
314 - $this->fail('系统错误,请联系管理员'); 419 + $this->param = $this->handleDefaultString($this->param);//设置默认数据
  420 + $templateInfo = $this->model->read([
  421 + 'template_id'=>$this->param['template_id'],
  422 + 'source'=>$this->param['source'],
  423 + 'source_id'=>$this->param['source_id'],
  424 + 'is_custom'=>$this->param['is_custom'],
  425 + 'is_list'=>$this->param['is_list']
  426 + ]);
  427 + if($templateInfo === false){//执行新增
  428 + $data = [
  429 + 'source'=>$this->param['source'], 'source_id'=>$this->param['source_id'],'type'=>BTemplate::PAGE_HTML,
  430 + 'template_id'=>$this->param['template_id'], 'project_id'=>$this->user['project_id'],
  431 + 'section_list_id'=>$this->param['section_list_id'],'is_custom'=>$this->param['is_custom'],
  432 + 'is_list'=>$this->param['is_list']
  433 + ];
  434 + $data = $this->handleVisualizationParam($this->param['html'],$this->param['source'],$this->param['is_list'],$data);
  435 + $this->model->add($data);
  436 + }else{//执行编辑
  437 + $condition = [
  438 + 'source'=>$this->param['source'], 'source_id'=>$this->param['source'],
  439 + 'is_custom'=>$this->param['is_custom'], 'template_id'=>$this->param['template_id'],
  440 + 'is_list'=>$this->param['is_list']
  441 + ];
  442 + $data = [
  443 + 'section_list_id'=>$this->param['section_list_id']
  444 + ];
  445 + $data = $this->handleVisualizationParam($this->param['html'],$this->param['source'],$this->param['is_list'],$data);
  446 + $this->model->edit($data,$condition);
315 } 447 }
  448 + //更新头部信息
  449 + $this->saveCommonHtml($this->param['html'],$this->param['source'],$this->param['is_list'],$this->param['template_id']);
  450 + $this->setOperationRecords($this->param['html'],$this->param['source'],$this->param['source_id'],$this->param['template_id'],$this->param['is_custom']);
316 //通知更新 451 //通知更新
317 - $this->homeOrProduct($this->param['source'],$this->param['source_id'],$this->param['is_custom']); 452 + $this->homeOrProduct($this->param['source'],$this->param['source_id'],$this->param['is_custom'],$this->param['is_list']);
318 return $this->success(); 453 return $this->success();
319 } 454 }
320 455
@@ -326,66 +461,23 @@ class BTemplateLogic extends BaseLogic @@ -326,66 +461,23 @@ class BTemplateLogic extends BaseLogic
326 * @time :2023/12/15 10:30 461 * @time :2023/12/15 10:30
327 */ 462 */
328 public function handleDefaultString($param){ 463 public function handleDefaultString($param){
329 - if(!isset($param['template_id'])){  
330 - $param['template_id'] = 0;  
331 - }  
332 - if(!isset($param['is_custom'])){  
333 - $param['is_custom'] = 0;  
334 - }  
335 - if(!isset($param['section_list_id'])){  
336 - $param['section_list_id'] = '';  
337 - } 464 + $param['template_id'] = $param['template_id'] ?? 0;
  465 + $param['is_custom'] = $param['is_custom'] = 0;
  466 + $param['section_list_id'] = $param['section_list_id'] ?? '';
  467 + $param['is_list'] = $param['is_list'] ?? 0;
338 return $this->success($param); 468 return $this->success($param);
339 } 469 }
340 470
341 /** 471 /**
342 - * @remark :可视化添加数据  
343 - * @name :templateAddHtml  
344 - * @author :lyh  
345 - * @method :post  
346 - * @time :2023/12/15 10:15  
347 - */  
348 - public function templateAddHtml($html,$source,$source_id,$template,$section_list_id,$is_custom){  
349 - $data = [  
350 - 'source'=>$source, 'source_id'=>$source_id,'type'=>BTemplate::PAGE_HTML,  
351 - 'template_id'=>$template, 'project_id'=>$this->user['project_id'],  
352 - 'section_list_id'=>$section_list_id,'is_custom'=>$is_custom,  
353 - ];  
354 - $data = $this->handleVisualizationParam($html,$source,$source_id,$data);  
355 - $this->model->add($data);  
356 - return true;  
357 - }  
358 -  
359 - /**  
360 - * @remark :可视化更新html  
361 - * @name :templateEditHtml  
362 - * @author :lyh  
363 - * @method :post  
364 - * @time :2023/12/15 10:26  
365 - */  
366 - public function templateEditHtml($html,$source,$source_id,$template,$section_list_id,$is_custom){  
367 - $condition = [  
368 - 'source'=>$source, 'source_id'=>$source_id,  
369 - 'is_custom'=>$is_custom, 'template_id'=>$template  
370 - ];  
371 - $data = [  
372 - 'section_list_id'=>$section_list_id  
373 - ];  
374 - $data = $this->handleVisualizationParam($html,$source,$source_id,$data);  
375 - $this->model->edit($data,$condition);  
376 - return true;  
377 - }  
378 -  
379 - /**  
380 * @remark :处理可视化数据 472 * @remark :处理可视化数据
381 * @name :handleProjectParam 473 * @name :handleProjectParam
382 * @author :lyh 474 * @author :lyh
383 * @method :post 475 * @method :post
384 * @time :2023/12/15 10:59 476 * @time :2023/12/15 10:59
385 */ 477 */
386 - public function handleVisualizationParam($html,$source, $source_id,$data){ 478 + public function handleVisualizationParam($html,$source, $is_list,$data){
387 if($this->user['is_customized'] == BTemplate::SOURCE_VISUALIZATION){//定制项目 479 if($this->user['is_customized'] == BTemplate::SOURCE_VISUALIZATION){//定制项目
388 - $type = $this->getCustomizedType($source, $source_id);//获取定制界面类型 480 + $type = $this->getCustomizedType($source, $is_list);//获取定制界面类型
389 //查看当前页面是否定制,是否开启可视化 481 //查看当前页面是否定制,是否开启可视化
390 $page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面 482 $page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面
391 if (in_array($type, $page_array)) {//当前页面是定制界面 483 if (in_array($type, $page_array)) {//当前页面是定制界面
@@ -412,8 +504,8 @@ class BTemplateLogic extends BaseLogic @@ -412,8 +504,8 @@ class BTemplateLogic extends BaseLogic
412 * @method :post 504 * @method :post
413 * @time :2023/12/13 17:05 505 * @time :2023/12/13 17:05
414 */ 506 */
415 - public function saveCommonHtml($html,$source,$source_id,$template_id){  
416 - $type = $this->getType($source,$source_id,$template_id);//获取头部类型1-9(首页到自定义页面) 507 + public function saveCommonHtml($html,$source,$is_list,$template_id){
  508 + $type = $this->getType($source,$is_list,$template_id);//获取头部类型1-9(首页到自定义页面)
417 $templateCommonModel = new BTemplateCommon(); 509 $templateCommonModel = new BTemplateCommon();
418 $commonInfo = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>$type]);//查看当前头部是否存在 510 $commonInfo = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>$type]);//查看当前头部是否存在
419 $handleInfo = $this->handleCommonParam($html); 511 $handleInfo = $this->handleCommonParam($html);
@@ -482,32 +574,70 @@ class BTemplateLogic extends BaseLogic @@ -482,32 +574,70 @@ class BTemplateLogic extends BaseLogic
482 return $this->success($param); 574 return $this->success($param);
483 } 575 }
484 /** 576 /**
485 - * @remark :获取设置的类型 577 + * @remark :保存时获取获取设置的类型
486 * @name :getType 578 * @name :getType
487 * @author :lyh 579 * @author :lyh
488 * @method :post 580 * @method :post
489 * @time :2023/10/21 17:29 581 * @time :2023/10/21 17:29
490 */ 582 */
491 - public function getType($source,$source_id,$template_id){  
492 - $type = 1;//首页公共头部底部 583 + public function getType($source,$is_list,$template_id){
  584 + $type = BTemplate::SOURCE_HOME;//首页公共头部底部
  585 + $is_head = $this->user['configuration']['is_head'] ?? BTemplate::IS_NO_HEADER;
493 if($template_id == 0){//保存上传的代码块时,默认为独立头部 586 if($template_id == 0){//保存上传的代码块时,默认为独立头部
494 - $this->user['configuration']['is_head'] == 1; 587 + $is_head == BTemplate::IS_HEADER;
495 } 588 }
496 //查看页面是否设置自定义头部底部 589 //查看页面是否设置自定义头部底部
497 - if(isset($this->user['configuration']['is_head']) && ($this->user['configuration']['is_head'] != 0)) { 590 + if($is_head != BTemplate::IS_NO_HEADER) {
498 $pageSettingModel = new PageSetting(); 591 $pageSettingModel = new PageSetting();
499 $pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id']]); 592 $pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id']]);
500 - if ($pageInfo !== false) {  
501 - if ($source == BTemplate::SOURCE_PRODUCT) {if ($source_id != 0) {if ($pageInfo['product_details'] != 0) {$type = BTemplate::TYPE_TWO;}}  
502 - else {if ($pageInfo['product_list'] != 0) {$type = BTemplate::TYPE_THREE;}}}  
503 - if ($source == BTemplate::SOURCE_BLOG) {if ($source_id != 0) {if ($pageInfo['blog_details'] != 0) {$type = BTemplate::TYPE_FOUR;}}  
504 - else {if ($pageInfo['blog_list'] != 0) {$type = BTemplate::TYPE_FIVE;}}}  
505 - if ($source == BTemplate::SOURCE_NEWS) {if ($source_id != 0) {if ($pageInfo['news_details'] != 0) {$type = BTemplate::TYPE_SIX;}}  
506 - else {if ($pageInfo['news_list'] != 0) {$type = BTemplate::TYPE_SEVEN;}}}  
507 - if ($source == BTemplate::SOURCE_KEYWORD) {if ($pageInfo['polymerization'] != 0) {$type = BTemplate::TYPE_EIGHT;}} 593 + if ($pageInfo === false) {
  594 + return $this->success($type);
508 } 595 }
  596 + switch ($source){
  597 + case BTemplate::SOURCE_PRODUCT:
  598 + if ($is_list != BTemplate::IS_LIST) {
  599 + if ($pageInfo['product_details'] != 0) {
  600 + $type = BTemplate::TYPE_TWO;
  601 + }
  602 + } else {
  603 + if ($pageInfo['product_list'] != 0) {
  604 + $type = BTemplate::TYPE_THREE;
  605 + }
  606 + }
  607 + break;
  608 + case BTemplate::SOURCE_BLOG:
  609 + if ($is_list != BTemplate::IS_LIST) {
  610 + if ($pageInfo['blog_details'] != 0) {
  611 + $type = BTemplate::TYPE_FOUR;
  612 + }
  613 + } else {
  614 + if ($pageInfo['blog_details'] != 0) {
  615 + $type = BTemplate::TYPE_FIVE;
  616 + }
  617 + }
  618 + break;
  619 + case BTemplate::SOURCE_BLOG:
  620 + if ($is_list != BTemplate::IS_LIST) {
  621 + if ($pageInfo['news_details'] != 0) {
  622 + $type = BTemplate::TYPE_SIX;
  623 + }
  624 + } else {
  625 + if ($pageInfo['news_list'] != 0) {
  626 + $type = BTemplate::TYPE_SEVEN;
  627 + }
  628 + }
  629 + break;
  630 + case BTemplate::SOURCE_KEYWORD:
  631 + if ($pageInfo['polymerization'] != 0) {
  632 + $type = BTemplate::TYPE_EIGHT;
  633 + }
  634 + break;
  635 + default:
  636 + $type = BTemplate::SOURCE_HOME;//首页公共头部底部
  637 + break;
  638 + }
  639 + return $this->success($type);
509 } 640 }
510 - return $type;  
511 } 641 }
512 642
513 /** 643 /**
@@ -518,6 +648,9 @@ class BTemplateLogic extends BaseLogic @@ -518,6 +648,9 @@ class BTemplateLogic extends BaseLogic
518 * @time :2023/8/23 11:16 648 * @time :2023/8/23 11:16
519 */ 649 */
520 public function setOperationRecords($html,$source,$source_id,$template_id,$is_custom,$type = 0){ 650 public function setOperationRecords($html,$source,$source_id,$template_id,$is_custom,$type = 0){
  651 + if($source != BTemplate::SOURCE_HOME){
  652 + return true;
  653 + }
521 $data = [ 654 $data = [
522 'template_id'=>$template_id, 655 'template_id'=>$template_id,
523 'project_id'=>$this->user['project_id'], 656 'project_id'=>$this->user['project_id'],
@@ -547,22 +680,38 @@ class BTemplateLogic extends BaseLogic @@ -547,22 +680,38 @@ class BTemplateLogic extends BaseLogic
547 * @method :post 680 * @method :post
548 * @time :2023/7/31 16:05 681 * @time :2023/7/31 16:05
549 */ 682 */
550 - public function homeOrProduct($source,$source_id = 0,$is_custom = 0){ 683 + public function homeOrProduct($source,$source_id = 0,$is_custom = 0,$is_list = 0){
551 if($is_custom == 0){ 684 if($is_custom == 0){
552 if($source == BTemplate::SOURCE_HOME){ 685 if($source == BTemplate::SOURCE_HOME){
553 RouteMap::setRoute('index', RouteMap::SOURCE_PAGE, 0, $this->user['project_id']); 686 RouteMap::setRoute('index', RouteMap::SOURCE_PAGE, 0, $this->user['project_id']);
554 $type = RouteMap::SOURCE_PAGE; 687 $type = RouteMap::SOURCE_PAGE;
555 }elseif($source == BTemplate::SOURCE_PRODUCT){ 688 }elseif($source == BTemplate::SOURCE_PRODUCT){
556 - $type = RouteMap::SOURCE_PRODUCT; 689 + if($is_list == BTemplate::IS_LIST){
  690 + $type = RouteMap::SOURCE_PRODUCT_CATE;
  691 + }else{
  692 + $type = RouteMap::SOURCE_PRODUCT;
  693 + }
557 }elseif($source == BTemplate::SOURCE_BLOG){ 694 }elseif($source == BTemplate::SOURCE_BLOG){
558 - $type = RouteMap::SOURCE_BLOG; 695 + if($is_list == BTemplate::IS_LIST){
  696 + $type = RouteMap::SOURCE_BLOG_CATE;
  697 + }else{
  698 + $type = RouteMap::SOURCE_BLOG;
  699 + }
559 }elseif($source == BTemplate::SOURCE_NEWS){ 700 }elseif($source == BTemplate::SOURCE_NEWS){
560 - $type = RouteMap::SOURCE_NEWS; 701 + if($is_list == BTemplate::IS_LIST){
  702 + $type = RouteMap::SOURCE_NEWS_CATE;
  703 + }else{
  704 + $type = RouteMap::SOURCE_NEWS;
  705 + }
561 }else{ 706 }else{
562 $type = 'all'; 707 $type = 'all';
563 } 708 }
564 }else{ 709 }else{
565 - $type = RouteMap::SOURCE_MODULE; 710 + if($is_list == BTemplate::IS_LIST){
  711 + $type = RouteMap::SOURCE_MODULE_CATE;
  712 + }else{
  713 + $type = RouteMap::SOURCE_MODULE;
  714 + }
566 } 715 }
567 $route = RouteMap::getRoute($type,$source_id,$this->user['project_id']); 716 $route = RouteMap::getRoute($type,$source_id,$this->user['project_id']);
568 $this->addUpdateNotify($type,$route); 717 $this->addUpdateNotify($type,$route);
@@ -615,19 +764,6 @@ class BTemplateLogic extends BaseLogic @@ -615,19 +764,6 @@ class BTemplateLogic extends BaseLogic
615 } 764 }
616 765
617 /** 766 /**
618 - * @remark :默认产品模块  
619 - * @name :getProductModule  
620 - * @author :lyh  
621 - * @method :post  
622 - * @time :2023/7/27 15:08  
623 - */  
624 - public function getModule($type){  
625 - $mainModel = new TemplateTypeMain();  
626 - $info = $mainModel->read(['type'=>$type]);  
627 - return $info['main_html'];  
628 - }  
629 -  
630 - /**  
631 * @remark :设置主题公共head 767 * @remark :设置主题公共head
632 * @name :setHeadInfo 768 * @name :setHeadInfo
633 * @author :lyh 769 * @author :lyh
@@ -823,134 +959,4 @@ class BTemplateLogic extends BaseLogic @@ -823,134 +959,4 @@ class BTemplateLogic extends BaseLogic
823 } 959 }
824 return $this->success(); 960 return $this->success();
825 } 961 }
826 -  
827 - /**  
828 - * @remark :获取详情模板详情  
829 - * @name :getDetail  
830 - * @author :lyh  
831 - * @method :post  
832 - * @time :2023/10/24 11:29  
833 - */  
834 - public function getDetail(){  
835 - $bSettingModel = new Setting();  
836 - $bSettingInfo = $bSettingModel->read(['project_id'=>$this->user['project_id']]);  
837 - if($bSettingInfo === false){  
838 - $this->fail('请先设置模板');  
839 - }  
840 - $is_custom = $this->param['is_custom'] ?? 0;//扩展模块详情模版  
841 - $commonInfo = $this->getTypeCommonHtml($bSettingInfo['template_id'],$this->param['type'],$is_custom);  
842 - //获取设置的默认中间部分  
843 - $bTemplateMainModel = new BTemplateMain();  
844 - $mainInfo = $bTemplateMainModel->read(['project_id'=>$this->user['project_id'],'type'=>$this->param['type'],'is_custom'=>$is_custom]);  
845 - if($mainInfo === false){  
846 - if($is_custom == BTemplate::SOURCE_CUSTOM) {  
847 - $this->param['type'] = BTemplate::TYPE_CUSTOM_DETAIL;  
848 - }  
849 - $main_html = $this->getModule($this->param['type']);  
850 - $main_style = "<style id='globalsojs-styles'></style>";  
851 - }else{  
852 - $main_html = $mainInfo['main_html'];  
853 - $main_style = $mainInfo['main_css'];  
854 - }  
855 - $html = $commonInfo['head_css'].$main_style.$commonInfo['footer_css'].$commonInfo['other'].  
856 - $commonInfo['head_html'].$main_html.$commonInfo['footer_html'];  
857 - $html = $this->getHeadFooter($html);//组装数据  
858 - return $this->success($html);  
859 - }  
860 -  
861 - /**  
862 - * @remark :根据type获取html  
863 - * @name :getHeaderFooter  
864 - * @author :lyh  
865 - * @method :post  
866 - * @time :2023/12/15 18:06  
867 - */  
868 - public function getTypeCommonHtml($template_id,$type,$is_custom){  
869 - //获取首页公共部分  
870 - $templateCommonModel = new BTemplateCommon();  
871 - $commonInfo = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>1]);  
872 - if($is_custom == BTemplate::SOURCE_CUSTOM){  
873 - return $this->success($commonInfo);  
874 - }  
875 - //判断当前项目是否有设置独立头部的权限  
876 - if(isset($this->user['configuration']['is_head']) && ($this->user['configuration']['is_head'] != 0)) {  
877 - //有权限时,获取独立头部  
878 - $commonTypeInfo = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>$type]);  
879 - if($commonTypeInfo !== false){  
880 - $commonInfo = $commonTypeInfo;  
881 - }  
882 - }  
883 - return $this->success($commonInfo);  
884 - }  
885 -  
886 - /**  
887 - * @remark :保存详情模板数据  
888 - * @name :saveDetail  
889 - * @author :lyh  
890 - * @method :post  
891 - * @time :2023/10/24 11:53  
892 - */  
893 - public function saveDetail(){  
894 - $bSettingModel = new Setting();  
895 - $bSettingInfo = $bSettingModel->read(['project_id'=>$this->user['project_id']]);  
896 - if($bSettingInfo === false){  
897 - $this->fail('请先设置模板');  
898 - }  
899 - $is_custom = $this->param['is_custom'] ?? 0;//扩展模块详情模版  
900 - $data = [  
901 - 'main_html'=>characterTruncation($this->param['html'],'/<main\b[^>]*>(.*?)<\/main>/s'),  
902 - 'main_css'=>characterTruncation($this->param['html'],'/<style id="globalsojs-styles">(.*?)<\/style>/s'),  
903 - ];  
904 - $data['section_list_id'] = $this->param['section_list_id'];  
905 - //保存中间部分  
906 - $bTemplateMainModel = new BTemplateMain();  
907 - $mainInfo = $bTemplateMainModel->read(['project_id'=>$this->user['project_id'],'type'=>$this->param['type'],'is_custom'=>$is_custom]);  
908 - if($mainInfo === false){  
909 - $data['project_id'] = $this->user['project_id'];  
910 - $data['type'] = $this->param['type'];  
911 - $data['is_custom'] = $is_custom;  
912 - $bTemplateMainModel->add($data);  
913 - }else{  
914 - $bTemplateMainModel->edit($data,['id'=>$mainInfo['id']]);  
915 - }  
916 - $this->saveDetailCommonHtml($is_custom,$this->param['type'],$bSettingInfo['template_id'],$this->param['html']);  
917 - return $this->success();  
918 - }  
919 -  
920 - /**  
921 - * @remark :保存详情页模版头部底部  
922 - * @name :saveDetailCommonHtml  
923 - * @author :lyh  
924 - * @method :post  
925 - * @time :2023/12/15 18:12  
926 - */  
927 - public function saveDetailCommonHtml($is_custom,$type,$template_id,$html){  
928 - $publicData = [  
929 - 'head_html' => characterTruncation($html,'/<header\b[^>]*>(.*?)<\/header>/s'),  
930 - 'head_css' => characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s'),  
931 - 'footer_html' => characterTruncation($html,'/<footer\b[^>]*>(.*?)<\/footer>/s'),  
932 - 'footer_css' => characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s'),  
933 - 'other'=>str_replace('<header','',characterTruncation($html,"/<link id=\"google-fonts-link\"(.*?)<header/s")),  
934 - ];  
935 - //查看当前模板是否有独立头部,有独立头部,更新独立头部,无独立头部,更新公共头部  
936 - if($is_custom == BTemplate::SOURCE_CUSTOM){//扩展模块  
937 - $this->user['configuration']['is_head'] = BTemplate::SOURCE_NO_CUSTOM;  
938 - }  
939 - $templateCommonModel = new BTemplateCommon();  
940 - if(isset($this->user['configuration']['is_head']) && ($this->user['configuration']['is_head'] != 0)) {  
941 - $templateCommonInfo = $templateCommonModel->read(['type'=>$type,'project_id'=>$this->user['project_id'],'template_id'=>$template_id]);  
942 - if($templateCommonInfo === false){  
943 - $publicData['type'] = $type;  
944 - $publicData['project_id'] = $this->user['project_id'];  
945 - $publicData['template_id'] = $template_id;  
946 - $templateCommonModel->add($publicData);  
947 - }else{  
948 - $templateCommonModel->edit($publicData,['id'=>$templateCommonInfo['id']]);  
949 - }  
950 - }else{  
951 - //更新首页头部底部  
952 - $templateCommonModel->edit($publicData,['type'=>1,'project_id'=>$this->user['project_id'],'template_id'=>$template_id]);  
953 - }  
954 - return true;  
955 - }  
956 } 962 }
@@ -29,7 +29,7 @@ class CustomTemplateLogic extends BaseLogic @@ -29,7 +29,7 @@ class CustomTemplateLogic extends BaseLogic
29 * @time :2023/6/29 15:46 29 * @time :2023/6/29 15:46
30 */ 30 */
31 public function customTemplateLists($map,$page,$row,$order = 'created_at'){ 31 public function customTemplateLists($map,$page,$row,$order = 'created_at'){
32 - $filed = ['id','name','status','url','title','keywords','description','project_id','created_at','updated_at']; 32 + $filed = ['id','name','status','url','title','keywords','description','project_id','is_upgrade','six_read','created_at','updated_at'];
33 $map['deleted_status'] = 0; 33 $map['deleted_status'] = 0;
34 $map['project_id'] = $this->user['project_id']; 34 $map['project_id'] = $this->user['project_id'];
35 $lists = $this->model->lists($map,$page,$row,$order,$filed); 35 $lists = $this->model->lists($map,$page,$row,$order,$filed);
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :InitHtmlLogic.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2023/12/27 10:39
  8 + */
  9 +
  10 +namespace App\Http\Logic\Bside\BTemplate;
  11 +
  12 +use App\Http\Logic\Bside\BaseLogic;
  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\BTemplateMain;
  17 +use App\Models\Template\Setting;
  18 +use App\Models\Template\TemplateTypeMain;
  19 +
  20 +class InitHtmlLogic extends BaseLogic
  21 +{
  22 + public function __construct()
  23 + {
  24 + parent::__construct();
  25 + $this->param = $this->requestAll;
  26 + }
  27 +
  28 + /**
  29 + * @remark :获取非定制项目复合页数据
  30 + * @name :getDetailHtml
  31 + * @author :lyh
  32 + * @method :post $param (type:类型,2产品 3博客 4新闻 对应扩展模块的id)
  33 + * @time :2023/12/27 10:50
  34 + */
  35 + public function getDetailHtml(){
  36 + $template_id = $this->getTemplateId();
  37 + $is_custom = $this->param['is_custom'] ?? 0;//TODO::1:代表扩展模块
  38 + $is_list = $this->param['is_list'] ?? 0;//TODO::1:代表分类列表模块
  39 + //获取设置的默认中间部分
  40 + $bTemplateMainModel = new BTemplateMain();
  41 + $mainInfo = $bTemplateMainModel->read(['project_id'=>$this->user['project_id'],'type'=>$this->param['type'],'is_list'=>$is_list,'is_custom'=>$is_custom]);
  42 + if($mainInfo === false){
  43 + $main_html = $this->getInitModule($this->param['type'],$is_custom,$is_list);
  44 + $main_style = "<style id='globalsojs-styles'></style>";
  45 + }else{
  46 + $main_html = $mainInfo['main_html'];
  47 + $main_style = $mainInfo['main_css'];
  48 + }
  49 + $commonInfo = $this->getTypeCommonHtml($template_id,$this->param['type'],$is_custom,$is_list); //获取头部
  50 + $html = $commonInfo['head_css'].$main_style.$commonInfo['footer_css'].$commonInfo['other'].$commonInfo['head_html'].$main_html.$commonInfo['footer_html'];
  51 + $html = $this->getHeadFooter($html);//组装数据
  52 + return $this->success($html);
  53 + }
  54 +
  55 + /**
  56 + * @remark :拼接获取公共头部底部
  57 + * @name :getHeadFooter
  58 + * @author :lyh
  59 + * @method :post
  60 + * @time :2023/7/21 17:22
  61 + */
  62 + public function getHeadFooter($html){
  63 + //获取公共主题头部底部
  64 + $serviceSettingModel = new ServiceSettingModel();
  65 + $list = $serviceSettingModel->list(['type'=>2],'created_at');
  66 + //拼接html
  67 + foreach ($list as $v){
  68 + if($v['key'] == 'head'){
  69 + $html = $v['values'].$html;
  70 + }
  71 + if($v['key'] == 'footer'){
  72 + $html = $html.$v['values'];
  73 + }
  74 + }
  75 + return $html;
  76 + }
  77 +
  78 + /**
  79 + * @remark :保存复合页数据
  80 + * @name :saveDetailHtml
  81 + * @author :lyh
  82 + * @method :post
  83 + * @time :2023/12/27 11:57
  84 + */
  85 + public function saveDetailHtml(){
  86 + $template_id = $this->getTemplateId();
  87 + $is_custom = $this->param['is_custom'] ?? 0;//TODO::1:代表扩展模块
  88 + $is_list = $this->param['is_list'] ?? 0;//TODO::1:代表分类列表模块
  89 + //保存中间部分
  90 + $bTemplateMainModel = new BTemplateMain();
  91 + $mainInfo = $bTemplateMainModel->read(['project_id'=>$this->user['project_id'],'type'=>$this->param['type'],'is_custom'=>$is_custom,'is_list'=>$is_list]);
  92 + if($mainInfo === false){
  93 + $data = [
  94 + 'main_html'=>characterTruncation($this->param['html'],'/<main\b[^>]*>(.*?)<\/main>/s'),
  95 + 'main_css'=>characterTruncation($this->param['html'],'/<style id="globalsojs-styles">(.*?)<\/style>/s'),
  96 + 'section_list_id'=>$this->param['section_list_id'] ?? '',
  97 + 'project_id'=>$this->user['project_id'],
  98 + 'type'=>$this->param['type'],
  99 + 'is_custom'=>$is_custom,
  100 + 'is_list'=>$is_list
  101 + ];
  102 + $bTemplateMainModel->add($data);
  103 + }else{
  104 + $data = [
  105 + 'main_html'=>characterTruncation($this->param['html'],'/<main\b[^>]*>(.*?)<\/main>/s'),
  106 + 'main_css'=>characterTruncation($this->param['html'],'/<style id="globalsojs-styles">(.*?)<\/style>/s'),
  107 + 'section_list_id'=>$this->param['section_list_id'] ?? '',
  108 + ];
  109 + $bTemplateMainModel->edit($data,['id'=>$mainInfo['id']]);
  110 + }
  111 + $this->saveDetailCommonHtml($this->param['html'],$this->param['type'],$template_id,$is_custom,$is_list);
  112 + return $this->success();
  113 + }
  114 + /**
  115 + * @remark :保存详情页模版头部底部
  116 + * @name :saveDetailCommonHtml
  117 + * @author :lyh
  118 + * @method :post
  119 + * @time :2023/12/15 18:12
  120 + */
  121 + public function saveDetailCommonHtml($html,$type,$template_id,$is_custom,$is_list){
  122 + $publicData = $this->handleCommonParam($html);
  123 + $templateCommonModel = new BTemplateCommon();
  124 + //查看当前模板是否有独立头部,有独立头部,更新独立头部,无独立头部,更新公共头部
  125 + $is_head = $this->user['configuration']['is_head'] ?? 0;
  126 + if($is_custom == BTemplate::SOURCE_CUSTOM){//todo::扩展模块无独立头部底部
  127 + $is_head = BTemplate::IS_NO_HEADER;
  128 + }
  129 + if($is_head == BTemplate::IS_HEADER) {
  130 + //有独立头部,更新独立头部
  131 + $commonType = $this->getHeaderType($type,$is_list);
  132 + $templateCommonInfo = $templateCommonModel->read(['project_id'=>$this->user['project_id'],'template_id'=>$template_id,'type'=>$commonType]);
  133 + if($templateCommonInfo === false){
  134 + $publicData['type'] = $type;
  135 + $publicData['project_id'] = $this->user['project_id'];
  136 + $publicData['template_id'] = $template_id;
  137 + $templateCommonModel->add($publicData);
  138 + }else{
  139 + $templateCommonModel->edit($publicData,['id'=>$templateCommonInfo['id']]);
  140 + }
  141 + }else{
  142 + //更新首页头部底部
  143 + $templateCommonModel->edit($publicData,['type'=>BTemplate::SOURCE_HOME,'project_id'=>$this->user['project_id'],'template_id'=>$template_id]);
  144 + }
  145 + return $this->success();
  146 + }
  147 +
  148 + /**
  149 + * @remark :保存时字符串处理
  150 + * @name :handleCommonParam
  151 + * @author :lyh
  152 + * @method :post
  153 + * @time :2023/6/29 15:35
  154 + */
  155 + public function handleCommonParam($html){
  156 + //字符串截取
  157 + $param['head_html'] = characterTruncation($html,'/<header\b[^>]*>(.*?)<\/header>/s');
  158 + $param['footer_html'] = characterTruncation($html,'/<footer\b[^>]*>(.*?)<\/footer>/s');
  159 + $param['head_css'] = characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s');
  160 + $param['footer_css'] = characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s');
  161 + $footer_other = str_replace('<header','',characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<header/s'));
  162 + $param['other'] = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other);
  163 + return $this->success($param);
  164 + }
  165 +
  166 + /**
  167 + * @remark :默认复合页数据
  168 + * @name :getProductModule
  169 + * @author :lyh
  170 + * @method :post
  171 + * @time :2023/7/27 15:08
  172 + */
  173 + public function getInitModule($type,$is_custom,$is_list){
  174 + if($is_custom == BTemplate::SOURCE_CUSTOM) {
  175 + $type = BTemplate::TYPE_CUSTOM;
  176 + }
  177 + $mainModel = new TemplateTypeMain();
  178 + $info = $mainModel->read(['type'=>$type,'is_list'=>$is_list]);
  179 + return $info['main_html'];
  180 + }
  181 +
  182 + /**
  183 + * @remark :根据type获取头部html
  184 + * @name :getHeaderFooter
  185 + * @author :lyh
  186 + * @method :post
  187 + * @time :2023/12/15 18:06
  188 + */
  189 + public function getTypeCommonHtml($template_id,$type,$is_custom,$is_list){
  190 + //判断当前项目是否有设置独立头部的权限
  191 + $is_head = $this->user['configuration']['is_head'] ?? 0;
  192 + if($is_custom == BTemplate::SOURCE_CUSTOM){//todo::拓展模块默认取首页
  193 + $is_head = BTemplate::IS_NO_HEADER;
  194 + }
  195 + //获取首页公共部分
  196 + $templateCommonModel = new BTemplateCommon();
  197 + if($is_head == BTemplate::IS_HEADER) {
  198 + //有独立头部,获取独立头部
  199 + $commonType = $this->getHeaderType($type,$is_list);
  200 + $commonInfo = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>$commonType]);
  201 + if($commonInfo !== false){
  202 + return $this->success($commonInfo);
  203 + }
  204 + }
  205 + //首页头底
  206 + $commonInfo = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>BTemplate::SOURCE_HOME]);
  207 + return $this->success($commonInfo);
  208 + }
  209 +
  210 + /**
  211 + * @remark :独立头部获取头部底部类型
  212 + * @name :getHeaderType
  213 + * @author :lyh
  214 + * @method :post
  215 + * @time :2023/12/27 11:36
  216 + */
  217 + public function getHeaderType($type,$is_list){
  218 + $resultType = BTemplate::SOURCE_HOME;
  219 + if($type == BTemplate::SOURCE_PRODUCT){
  220 + if($is_list == BTemplate::IS_LIST){
  221 + $resultType = BTemplate::TYPE_THREE;
  222 + }else{
  223 + $resultType = BTemplate::TYPE_TWO;
  224 + }
  225 + }
  226 + if($type == BTemplate::SOURCE_BLOG){
  227 + if($is_list == BTemplate::IS_LIST){
  228 + $resultType = BTemplate::TYPE_FIVE;
  229 + }else{
  230 + $resultType = BTemplate::TYPE_FOUR;
  231 + }
  232 + }
  233 + if($type == BTemplate::SOURCE_NEWS){
  234 + if($is_list == BTemplate::IS_LIST){
  235 + $resultType = BTemplate::TYPE_SEVEN;
  236 + }else{
  237 + $resultType = BTemplate::TYPE_SIX;
  238 + }
  239 + }
  240 + return $this->success($resultType);
  241 + }
  242 +
  243 + /**
  244 + * @remark :获取模版id
  245 + * @name :getTemplateId
  246 + * @author :lyh
  247 + * @method :post
  248 + * @time :2023/12/27 10:51
  249 + */
  250 + public function getTemplateId(){
  251 + $bSettingModel = new Setting();
  252 + $bSettingInfo = $bSettingModel->read(['project_id'=>$this->user['project_id']],['id','template_id']);
  253 + if($bSettingInfo === false){
  254 + $this->fail('请先设置模板');
  255 + }
  256 + return $this->success($bSettingInfo['template_id']);
  257 + }
  258 +
  259 + /**
  260 + * @remark :获取代码块
  261 + * @name :getVisualizationInfo
  262 + * @author :lyh
  263 + * @method :post
  264 + * @time :2023/11/17 14:44
  265 + */
  266 + public function getCustomizedHtml(){
  267 + $is_list = $this->param['is_list'] ?? 0;
  268 + $bTemplateMainModel = new BTemplateMain();
  269 + $info = $bTemplateMainModel->read(['type'=>$this->param['type'],'is_list'=>$is_list]);
  270 + if($info === false){
  271 + $html = '';
  272 + }else{
  273 + $html = $info['main_html'];
  274 + }
  275 + return $this->success(['html'=>$html]);
  276 + }
  277 +
  278 + /**
  279 + * @remark :保存定制html
  280 + * @name :saveHtml
  281 + * @author :lyh
  282 + * @method :post
  283 + * @time :2023/11/15 10:12
  284 + */
  285 + public function saveCustomizedHtml(){
  286 + try {
  287 + $is_list = $this->param['is_list'] ?? 0;
  288 + $bTemplateMainModel = new BTemplateMain();
  289 + $mainInfo = $bTemplateMainModel->read(['type'=>$this->param['type'],'is_list'=>$is_list]);
  290 + if($mainInfo === false){
  291 + $mainData = [
  292 + 'project_id'=>$this->user['project_id'],
  293 + 'type'=>$this->param['type'],
  294 + 'is_list'=>$is_list,
  295 + 'main_html'=>$this->param['html']
  296 + ];
  297 + $bTemplateMainModel->add($mainData);
  298 + }else{
  299 + $bTemplateMainModel->edit(['main_html'=>$this->param['html']],['id'=>$mainInfo['id']]);
  300 + }
  301 + }catch (\Exception $exception){
  302 + $this->fail('保存失败,请联系开发人员');
  303 + }
  304 + return $this->success();
  305 + }
  306 +}
1 -<?php  
2 -/**  
3 - * @remark :  
4 - * @name :VisualizationLogic.php  
5 - * @author :lyh  
6 - * @method :post  
7 - * @time :2023/11/15 10:09  
8 - */  
9 -  
10 -namespace App\Http\Logic\Bside\BTemplate;  
11 -  
12 -use App\Http\Logic\Bside\BaseLogic;  
13 -use App\Models\Blog\Blog;  
14 -use App\Models\News\News;  
15 -use App\Models\Product\Product;  
16 -use App\Models\Project\PageSetting;  
17 -use App\Models\RouteMap\RouteMap;  
18 -use App\Models\Service\Service as ServiceSettingModel;  
19 -use App\Models\Template\BTemplate;  
20 -use App\Models\Template\BTemplateCommon;  
21 -use App\Models\Template\BTemplateLog;  
22 -use App\Models\Template\BTemplateMain;  
23 -use App\Models\Template\Setting;  
24 -use App\Models\Template\Template;  
25 -use App\Models\Template\TemplateTypeMain;  
26 -use App\Models\Visualization\Visualization;  
27 -  
28 -class VisualizationLogic extends BaseLogic  
29 -{  
30 - public function __construct()  
31 - {  
32 - parent::__construct();  
33 - $this->model = new BTemplateMain();  
34 - $this->param = $this->requestAll;  
35 - }  
36 -  
37 - /**  
38 - * @remark :获取代码块  
39 - * @name :getVisualizationInfo  
40 - * @author :lyh  
41 - * @method :post  
42 - * @time :2023/11/17 14:44  
43 - */  
44 - public function getVisualizationInfo(){  
45 - $bTemplateMainModel = new BTemplateMain();  
46 - $info = $bTemplateMainModel->read(['type'=>$this->param['type']]);  
47 - if($info === false){  
48 - $html = '';  
49 - }else{  
50 - $html = $info['main_html'];  
51 - }  
52 - return $this->success(['html'=>$html]);  
53 - }  
54 -  
55 - /**  
56 - * @remark :保存定制html  
57 - * @name :saveHtml  
58 - * @author :lyh  
59 - * @method :post  
60 - * @time :2023/11/15 10:12  
61 - */  
62 - public function saveVisualization(){  
63 - try {  
64 - $type = $this->param['type'];  
65 - $bTemplateMainModel = new BTemplateMain();  
66 - $mainInfo = $bTemplateMainModel->read(['type'=>$type]);  
67 - if($mainInfo === false){  
68 - $mainData = [  
69 - 'project_id'=>$this->user['project_id'],  
70 - 'type'=>$type,  
71 - 'main_html'=>$this->param['html']  
72 - ];  
73 - $bTemplateMainModel->add($mainData);  
74 - }else{  
75 - $bTemplateMainModel->edit(['main_html'=>$this->param['html']],['id'=>$mainInfo['id']]);  
76 - }  
77 - }catch (\Exception $e){  
78 - $this->fail('系统错误,请联系管理员');  
79 - }  
80 - return $this->success();  
81 - }  
82 -}  
@@ -36,8 +36,10 @@ class BTemplate extends Base @@ -36,8 +36,10 @@ class BTemplate extends Base
36 const TYPE_SEVEN = 7;//新闻列表 36 const TYPE_SEVEN = 7;//新闻列表
37 const TYPE_EIGHT = 8;//自定义页面 37 const TYPE_EIGHT = 8;//自定义页面
38 38
39 - const TYPE_CUSTOM_DETAIL = 11;//扩展详情  
40 - const TYPE_CUSTOM_LIST = 12;//扩展列表 39 + const TYPE_CUSTOM = 7;//扩展详情
  40 + const IS_LIST = 1;//列表页
  41 + const IS_HEADER = 1;//独立头部底部
  42 + const IS_NO_HEADER = 0;//非独立头部底部
41 43
42 protected $table = 'gl_web_template'; 44 protected $table = 'gl_web_template';
43 //连接数据库 45 //连接数据库
@@ -341,12 +341,12 @@ Route::middleware(['bloginauth'])->group(function () { @@ -341,12 +341,12 @@ Route::middleware(['bloginauth'])->group(function () {
341 }); 341 });
342 }); 342 });
343 343
344 - //定制项目上传代码块  
345 - Route::prefix('visualization')->group(function () {  
346 - Route::any('/info', [\App\Http\Controllers\Bside\Template\VisualizationController::class, 'info'])->name('visualization_info');  
347 - Route::any('/save', [\App\Http\Controllers\Bside\Template\VisualizationController::class, 'save'])->name('visualization_save');  
348 - Route::any('/getHtml', [\App\Http\Controllers\Bside\Template\VisualizationController::class, 'getHtml'])->name('visualization_getHtml');  
349 - Route::any('/saveHtml', [\App\Http\Controllers\Bside\Template\VisualizationController::class, 'saveHtml'])->name('visualization_saveHtml'); 344 + //初始代码块
  345 + Route::prefix('init_html')->group(function () {
  346 + Route::any('/getCustomizedHtml', [\App\Http\Controllers\Bside\Template\InitHtmlController::class, 'getCustomizedHtml'])->name('init_getCustomizedHtml');
  347 + Route::any('/saveCustomizedHtml', [\App\Http\Controllers\Bside\Template\InitHtmlController::class, 'saveCustomizedHtml'])->name('init_saveCustomizedHtml');
  348 + Route::any('/getDetailHtml', [\App\Http\Controllers\Bside\Template\InitHtmlController::class, 'getDetailHtml'])->name('init_getDetailHtml');
  349 + Route::any('/saveDetailHtml', [\App\Http\Controllers\Bside\Template\InitHtmlController::class, 'saveDetailHtml'])->name('init_saveDetailHtml');
350 }); 350 });
351 351
352 // 自定义页面,专题页 352 // 自定义页面,专题页
@@ -434,6 +434,7 @@ Route::middleware(['bloginauth'])->group(function () { @@ -434,6 +434,7 @@ Route::middleware(['bloginauth'])->group(function () {
434 //自定义模板 434 //自定义模板
435 Route::prefix('custom_module')->group(function () { 435 Route::prefix('custom_module')->group(function () {
436 Route::any('/', [\App\Http\Controllers\Bside\CustomModule\CustomModuleController::class, 'lists'])->name('custom_lists'); 436 Route::any('/', [\App\Http\Controllers\Bside\CustomModule\CustomModuleController::class, 'lists'])->name('custom_lists');
  437 + Route::any('/info', [\App\Http\Controllers\Bside\CustomModule\CustomModuleController::class, 'info'])->name('custom_info');
437 Route::any('/save', [\App\Http\Controllers\Bside\CustomModule\CustomModuleController::class, 'save'])->name('custom_save'); 438 Route::any('/save', [\App\Http\Controllers\Bside\CustomModule\CustomModuleController::class, 'save'])->name('custom_save');
438 Route::any('/del', [\App\Http\Controllers\Bside\CustomModule\CustomModuleController::class, 'del'])->name('custom_del'); 439 Route::any('/del', [\App\Http\Controllers\Bside\CustomModule\CustomModuleController::class, 'del'])->name('custom_del');
439 440