作者 lyh

gx

@@ -28,6 +28,10 @@ use App\Models\Project\MinorLanguages; @@ -28,6 +28,10 @@ use App\Models\Project\MinorLanguages;
28 use App\Models\Project\Project; 28 use App\Models\Project\Project;
29 use App\Models\RouteMap\RouteMap; 29 use App\Models\RouteMap\RouteMap;
30 use App\Models\Template\BCustomTemplate; 30 use App\Models\Template\BCustomTemplate;
  31 +use App\Models\Template\BTemplate;
  32 +use App\Models\Template\BTemplateCom;
  33 +use App\Models\Template\BTemplateCommon;
  34 +use App\Models\Template\Setting;
31 use App\Models\WebSetting\WebSettingService; 35 use App\Models\WebSetting\WebSettingService;
32 use App\Services\AmazonS3Service; 36 use App\Services\AmazonS3Service;
33 use App\Services\ProjectServer; 37 use App\Services\ProjectServer;
@@ -52,84 +56,47 @@ class Demo extends Command @@ -52,84 +56,47 @@ class Demo extends Command
52 * @var string 56 * @var string
53 */ 57 */
54 protected $description = 'demo'; 58 protected $description = 'demo';
55 -  
56 - public function s(){ 59 + /**
  60 + * Execute the job.
  61 + *
  62 + * @return void
  63 + */
  64 + public function handle()
  65 + {
57 $projectModel = new Project(); 66 $projectModel = new Project();
58 - $list = $projectModel->list(['id'=>181]); 67 + $list = $projectModel->list(['delete_status'=>0]);
  68 + $data = [];
59 foreach ($list as $v){ 69 foreach ($list as $v){
60 echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL; 70 echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
61 ProjectServer::useProject($v['id']); 71 ProjectServer::useProject($v['id']);
62 - $this->initSearch($v['id']); 72 + $this->saveTemplateCom();
63 DB::disconnect('custom_mysql'); 73 DB::disconnect('custom_mysql');
64 } 74 }
65 echo date('Y-m-d H:i:s') . 'end' . PHP_EOL; 75 echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
66 } 76 }
67 77
68 - /**  
69 - * @remark :创建search页面  
70 - * @name :initSearch  
71 - * @author :lyh  
72 - * @method :post  
73 - * @time :2024/4/25 11:35  
74 - */  
75 - public function initSearch($project_id){  
76 - $bCustomTemplateModel = new BCustomTemplate();  
77 - $info = $bCustomTemplateModel->read(['url'=>'search']);  
78 - if($info === false){  
79 - $time = date('Y-m-d H:i:s');  
80 - $info = DB::connection('custom_mysql')->table('gl_web_custom_template')->first();  
81 - if(empty($info)) {  
82 - $data = [  
83 - 'project_id' => $project_id,  
84 - 'name' => 'search',  
85 - 'status' => 1,  
86 - 'url' => 'search',  
87 - 'html' => '',  
88 - 'html_style' =>'search',  
89 - 'title' => 'search',  
90 - 'description' => 'Sorry. The page has either moved or cannot be found.',  
91 - 'created_at' => $time, 'updated_at' => $time];  
92 - $id = DB::connection('custom_mysql')->table('gl_web_custom_template')->insertGetId($data);  
93 - //路由  
94 - $info = DB::connection('custom_mysql')->table('gl_route_map')->first();  
95 - if(empty($info)) {  
96 - $data = ['project_id' => $project_id, 'source' => RouteMap::SOURCE_PAGE, 'source_id' => $id, 'route' => 'search', 'created_at' => $time, 'updated_at' => $time];  
97 - DB::connection('custom_mysql')->table('gl_route_map')->insert($data);  
98 - }  
99 - }  
100 - }  
101 - return true;  
102 - }  
103 -  
104 - /**  
105 - * Execute the job.  
106 - *  
107 - * @return void  
108 - */  
109 - public function handle()  
110 - {  
111 - $this->param['project_id'] = 181;  
112 - $imageModel = new ImageModel();  
113 - //获取当前项目的所有图片  
114 - $imageList = $imageModel->list(['project_id'=>$this->param['project_id'],'is_cos'=>1],'id',['id','path','is_cos','size']);  
115 - if(!empty($imageList)){  
116 - $amazonS3Service = new AmazonS3Service();  
117 - foreach ($imageList as $k => $v){  
118 - $amazonS3Service->syncImageFiles(getImageUrl($v['path']));  
119 - $imageModel->edit(['is_cos'=>0],['id'=>$v['id']]);  
120 - }  
121 - } 78 + public function saveTemplateCom($project_id){
  79 + //获取当前项目选择的模版
  80 + $settingModel = new Setting();
  81 + $settingInfo = $settingModel->read(['project_id'=>$project_id]);
  82 + if($settingInfo !== false){
  83 + $templateCommonModel = new BTemplateCommon();
  84 + $commonList = $templateCommonModel->list(['template_id'=>$settingModel['template_id']]);
  85 + if(!empty($commonList)){
  86 + foreach ($commonList as $v){
  87 + if($v['type'] == 1){//首页头部底部
  88 + //保存一次公共头+底
122 89
123 - $fileModel = new FileModel();  
124 - $fileList = $fileModel->list(['project_id'=>$this->param['project_id'],'is_cos'=>1],'id',['id','path','is_cos','name']);  
125 - if(!empty($fileList)){  
126 - $amazonS3Service = new AmazonS3Service();  
127 - foreach ($fileList as $k => $v){  
128 - echo date('Y-m-d H:i:s') . '执行的数据id:' . $v['id'] . '名称:'.$v['name'] . PHP_EOL;  
129 - $amazonS3Service->syncImageFiles(getFileUrl($v['path']));  
130 - $fileModel->edit(['is_cos'=>0],['id'=>$v['id']]); 90 + }
  91 + //保存一次公共头部+底部+other信息
  92 + $bComTemplateModel = new BTemplateCom();
  93 + $param = ['template_id'=>$settingModel['template_id'],'common_type'=>BTemplate::COMMON_HEAD,'source'=>BTemplate::SOURCE_COM];
  94 + if($headInfo === false){
  95 + $headData = ['html'=>$settingModel['template_id']['head_html'], 'html_style'=>$templateInfo['head_css'], 'project_id'=>$project_id];
  96 + $bComTemplateModel->add(array_merge($condition,$headData));
  97 + }
  98 + }
131 } 99 }
132 } 100 }
133 - return true;  
134 } 101 }
135 } 102 }
@@ -451,7 +451,7 @@ class ImageController extends Controller @@ -451,7 +451,7 @@ class ImageController extends Controller
451 foreach ($files as $file){ 451 foreach ($files as $file){
452 if(isset($this->cache['image_max']) && ($this->cache['image_max'] != 0)){ 452 if(isset($this->cache['image_max']) && ($this->cache['image_max'] != 0)){
453 if ($file->getSize() > $this->cache['image_max'] * 1024) { 453 if ($file->getSize() > $this->cache['image_max'] * 1024) {
454 - $this->response('图片最大为1024K',Code::SYSTEM_ERROR); 454 + $this->response('图片最大为'.$this->cache['image_max'],Code::SYSTEM_ERROR);
455 } 455 }
456 }else{ 456 }else{
457 if ($file->getSize() > $max) { 457 if ($file->getSize() > $max) {
@@ -462,7 +462,7 @@ class ImageController extends Controller @@ -462,7 +462,7 @@ class ImageController extends Controller
462 }else{ 462 }else{
463 if(isset($this->cache['image_max']) && ($this->cache['image_max'] != 0)){ 463 if(isset($this->cache['image_max']) && ($this->cache['image_max'] != 0)){
464 if ($files->getSize() > $this->cache['image_max'] * 1024) { 464 if ($files->getSize() > $this->cache['image_max'] * 1024) {
465 - $this->response('图片最大为1024K',Code::SYSTEM_ERROR); 465 + $this->response('图片最大为'.$this->cache['image_max'],Code::SYSTEM_ERROR);
466 } 466 }
467 }else{ 467 }else{
468 if ($files->getSize() > $max) { 468 if ($files->getSize() > $max) {
@@ -13,6 +13,7 @@ use App\Http\Logic\Bside\BaseLogic; @@ -13,6 +13,7 @@ use App\Http\Logic\Bside\BaseLogic;
13 use App\Models\Project\PageSetting; 13 use App\Models\Project\PageSetting;
14 use App\Models\Service\Service as ServiceSettingModel; 14 use App\Models\Service\Service as ServiceSettingModel;
15 use App\Models\Template\BTemplate; 15 use App\Models\Template\BTemplate;
  16 +use App\Models\Template\BTemplateCom;
16 use App\Models\Template\BTemplateCommon; 17 use App\Models\Template\BTemplateCommon;
17 use App\Models\Template\BTemplateLog; 18 use App\Models\Template\BTemplateLog;
18 use App\Models\Template\Setting; 19 use App\Models\Template\Setting;
@@ -64,13 +65,14 @@ class BTemplateLogLogic extends BaseLogic @@ -64,13 +65,14 @@ class BTemplateLogLogic extends BaseLogic
64 'is_list'=>$info['is_list'],'is_custom'=>$info['is_custom']]; 65 'is_list'=>$info['is_list'],'is_custom'=>$info['is_custom']];
65 //TODO::还原头部+底部 66 //TODO::还原头部+底部
66 $bTemplateModel->edit(['html'=>$info['text']],$condition); 67 $bTemplateModel->edit(['html'=>$info['text']],$condition);
67 - $commonData = [  
68 - 'head_html'=>$info['head_html'], 'head_css'=>$info['head_css'],  
69 - 'footer_html'=>$info['footer_html'], 'footer_css'=>$info['footer_css']  
70 - ];  
71 - $type = $this->getCustomizedType($info['source'],$info['is_list']);  
72 $commonTemplateModel = new BTemplateCommon(); 68 $commonTemplateModel = new BTemplateCommon();
73 - $commonTemplateModel->edit($commonData,['template_id'=>$info['template_id'],'type'=>$type,'project_id'=>$this->user['project_id']]); 69 + //还原头部
  70 + $condition = ['template_id'=>$info['template_id'],'source'=>$info['source'],
  71 + 'is_list'=>$info['is_list'],'is_custom'=>$info['is_custom'],'project_id'=>$this->user['project_id']];
  72 + $condition['common_type'] = BTemplate::COMMON_HEAD;
  73 + $commonTemplateModel->edit(['head'=>$info['head_html'], 'head_style'=>$info['head_css']],$condition);
  74 + $condition['common_type'] = BTemplate::COMMON_FOOTER;
  75 + $commonTemplateModel->edit(['footer_html'=>$info['footer_html'], 'footer_css'=>$info['footer_css']],$condition);
74 return $this->success(); 76 return $this->success();
75 } 77 }
76 78
@@ -99,18 +101,9 @@ class BTemplateLogLogic extends BaseLogic @@ -99,18 +101,9 @@ class BTemplateLogLogic extends BaseLogic
99 $bTemplateModel->edit($data,$condition); 101 $bTemplateModel->edit($data,$condition);
100 //还原头部+底部 102 //还原头部+底部
101 $commonData = [ 103 $commonData = [
102 - 'head_html'=>$info['head_html'], 'head_css'=>$info['head_css'], 'footer_html'=>$info['footer_html'], 'footer_css'=>$info['footer_css'] 104 + 'head_html'=>$info['head_html'], 'head_style'=>$info['head_css'], 'footer_html'=>$info['footer_html'], 'footer_css'=>$info['footer_style'],'other'=>$info['other']
103 ]; 105 ];
104 - $commonTemplateModel = new BTemplateCommon();  
105 - $type = $this->getType($info['source'],$info['is_list'],$info['is_custom']);  
106 - $commonTemplateModel->edit($commonData,['template_id'=>$info['template_id'],'type'=>$type,'project_id'=>$this->user['project_id']]);  
107 - if(!empty($info['other'])){  
108 - $commonTemplateModel->edit(['other'=>$info['other']],['project_id'=>$this->user['project_id'],'template_id'=>$info['template_id'],'type'=>$info['type']]);  
109 - }else{  
110 - $footer_other = str_replace('<header','',characterTruncation($info['text'],'/<style id="globalsojs-footer">(.*?)<header/s'));  
111 - $other = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other);  
112 - $commonTemplateModel->edit(['other'=>$other],['project_id'=>$this->user['project_id'],'template_id'=>$info['template_id'],'type'=>$type]);  
113 - } 106 + $this->saveTemplateCom($commonData,$info['template_id'],$info['source'],$info['is_list'],$info['is_custom']);
114 }catch (\Exception $e){ 107 }catch (\Exception $e){
115 $this->fail('系统错误,请联系管理员'); 108 $this->fail('系统错误,请联系管理员');
116 } 109 }
@@ -118,36 +111,40 @@ class BTemplateLogLogic extends BaseLogic @@ -118,36 +111,40 @@ class BTemplateLogLogic extends BaseLogic
118 } 111 }
119 112
120 /** 113 /**
121 - * @remark :定制页面头部类型---根据source获取type类型  
122 - * @name :getType 114 + * @remark :保存公共部分(头部。底部。连接部分)
  115 + * @name :saveTemplateCom
123 * @author :lyh 116 * @author :lyh
124 * @method :post 117 * @method :post
125 - * @time :2023/11/16 11:20 118 + * @time :2024/4/29 10:32
126 */ 119 */
127 - public function getCustomizedType($source,$is_list){  
128 - $type = BTemplate::TYPE_HOME;  
129 - if($source == BTemplate::SOURCE_PRODUCT){  
130 - if($is_list == BTemplate::IS_LIST){  
131 - $type = BTemplate::TYPE_PRODUCT_LIST;  
132 - }else{  
133 - $type = BTemplate::TYPE_PRODUCT_DETAIL;  
134 - }  
135 - }  
136 - if($source == BTemplate::SOURCE_BLOG){  
137 - if($is_list == BTemplate::IS_LIST){  
138 - $type = BTemplate::TYPE_BLOG_LIST; 120 + public function saveTemplateCom($handleInfo,$template_id,$source,$is_list,$is_custom){
  121 + $typeArr = [BTemplate::COMMON_HEAD, BTemplate::COMMON_FOOTER, BTemplate::COMMON_OTHER];
  122 + $templateComModel = new BTemplateCom();
  123 + foreach ($typeArr as $type){
  124 + if($type == BTemplate::COMMON_HEAD){
  125 + $param['html'] = $handleInfo['head_html'];
  126 + $param['html_style'] = $handleInfo['head_style'];
  127 + $typeSource = $this->getType($source,$is_list,$is_custom,$type);//头部是否为独立头部
  128 + }elseif ($type == BTemplate::COMMON_FOOTER){
  129 + $param['html'] = $handleInfo['footer_html'];
  130 + $param['html_style'] = $handleInfo['footer_style'];
  131 + $typeSource = $this->getType($source,$is_list,$is_custom,$type);
139 }else{ 132 }else{
140 - $type = BTemplate::TYPE_BLOG_DETAIL; 133 + $param['html'] = $handleInfo['other'];
  134 + $param['html_style'] = null;
  135 + $typeSource = $this->getType($source,$is_list,$is_custom);
141 } 136 }
142 - }  
143 - if($source == BTemplate::SOURCE_NEWS){  
144 - if($is_list == BTemplate::IS_LIST){  
145 - $type = BTemplate::TYPE_NEWS_LIST; 137 + //查看当前数据是否还存在
  138 + $condition = ['project_id'=>$this->user['project_id'],'template_id'=>$template_id,'is_list'=>$is_list,'is_custom'=>$is_custom,'source'=>$typeSource,'common_type'=>$type];
  139 + $info = $templateComModel->read($condition);
  140 + if($info === false){
  141 + $data = array_merge($param,$condition);
  142 + $templateComModel->add($data);
146 }else{ 143 }else{
147 - $type = BTemplate::TYPE_NEWS_DETAIL; 144 + $templateComModel->edit($param,$condition);
148 } 145 }
149 } 146 }
150 - return $type; 147 + return $this->success();
151 } 148 }
152 149
153 /** 150 /**
@@ -157,27 +154,26 @@ class BTemplateLogLogic extends BaseLogic @@ -157,27 +154,26 @@ class BTemplateLogLogic extends BaseLogic
157 * @method :post 154 * @method :post
158 * @time :2023/10/21 17:29 155 * @time :2023/10/21 17:29
159 */ 156 */
160 - public function getType($source,$is_list,$is_custom = 0){  
161 - $type = BTemplate::SOURCE_HOME;//首页公共头部底部 157 + public function getType($source,$is_list,$is_custom = BTemplate::IS_NO_CUSTOM,$CommonType = BTemplate::COMMON_HEAD){
  158 + $type = BTemplate::SOURCE_COM;//公共头部底部
162 $is_head = $this->user['configuration']['is_head'] ?? BTemplate::IS_NO_HEADER; 159 $is_head = $this->user['configuration']['is_head'] ?? BTemplate::IS_NO_HEADER;
163 - if($is_custom == BTemplate::IS_CUSTOM){//拓展模块为首页头部 160 + if($is_custom == BTemplate::IS_CUSTOM || $is_head == BTemplate::IS_NO_HEADER){//拓展模块为首页头部
164 return $this->success($type); 161 return $this->success($type);
165 } 162 }
166 //查看页面是否设置自定义头部底部 163 //查看页面是否设置自定义头部底部
167 - if($is_head != BTemplate::IS_NO_HEADER) {  
168 - $pageSettingModel = new PageSetting();  
169 - $pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id']]);  
170 - if ($pageInfo === false) {  
171 - return $this->success($type);  
172 - }  
173 - if ($source == BTemplate::SOURCE_PRODUCT) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['product_details'] != 0) {$type = BTemplate::TYPE_PRODUCT_DETAIL;}}  
174 - else {if ($pageInfo['product_list'] != 0) {$type = BTemplate::TYPE_PRODUCT_LIST;}}}  
175 - if ($source == BTemplate::SOURCE_BLOG) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['blog_details'] != 0) {$type = BTemplate::TYPE_BLOG_DETAIL;}}  
176 - else {if ($pageInfo['blog_list'] != 0) {$type = BTemplate::TYPE_BLOG_LIST;}}}  
177 - if ($source == BTemplate::SOURCE_NEWS) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['news_details'] != 0) {$type = BTemplate::TYPE_NEWS_DETAIL;}}  
178 - else {if ($pageInfo['news_list'] != 0) {$type = BTemplate::TYPE_NEWS_LIST;}}}  
179 - if ($source == BTemplate::SOURCE_KEYWORD) {if ($pageInfo['polymerization'] != 0) {$type = BTemplate::TYPE_CUSTOM_PAGE;}} 164 + $pageSettingModel = new PageSetting();
  165 + $pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id'],'type'=>$CommonType]);
  166 + if ($pageInfo === false) {
  167 + return $this->success($type);
180 } 168 }
  169 + if($source == BTemplate::SOURCE_HOME){if ($pageInfo['home'] != 0){$type = BTemplate::SOURCE_HOME;}}
  170 + if ($source == BTemplate::SOURCE_PRODUCT) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['product_details'] != 0) {$type = BTemplate::SOURCE_PRODUCT;}}
  171 + else {if ($pageInfo['product_list'] != 0) {$type = BTemplate::SOURCE_PRODUCT;}}}
  172 + if ($source == BTemplate::SOURCE_BLOG) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['blog_details'] != 0) {$type = BTemplate::SOURCE_BLOG;}}
  173 + else {if ($pageInfo['blog_list'] != 0) {$type = BTemplate::SOURCE_BLOG;}}}
  174 + if ($source == BTemplate::SOURCE_NEWS) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['news_details'] != 0) {$type = BTemplate::SOURCE_NEWS;}}
  175 + else {if ($pageInfo['news_list'] != 0) {$type = BTemplate::SOURCE_NEWS;}}}
  176 + if ($source == BTemplate::SOURCE_KEYWORD) {if ($pageInfo['polymerization'] != 0) {$type = BTemplate::TYPE_CUSTOM_PAGE;}}
181 return $this->success($type); 177 return $this->success($type);
182 } 178 }
183 179
@@ -7,6 +7,7 @@ use App\Models\Project\PageSetting; @@ -7,6 +7,7 @@ use App\Models\Project\PageSetting;
7 use App\Models\RouteMap\RouteMap; 7 use App\Models\RouteMap\RouteMap;
8 use App\Models\Service\Service as ServiceSettingModel; 8 use App\Models\Service\Service as ServiceSettingModel;
9 use App\Models\Template\BCustomTemplate; 9 use App\Models\Template\BCustomTemplate;
  10 +use App\Models\Template\BTemplateCom;
10 use App\Models\Template\BTemplateCommon; 11 use App\Models\Template\BTemplateCommon;
11 use App\Models\Template\BTemplateLog; 12 use App\Models\Template\BTemplateLog;
12 use App\Models\Template\Setting; 13 use App\Models\Template\Setting;
@@ -164,9 +165,9 @@ class CustomTemplateLogic extends BaseLogic @@ -164,9 +165,9 @@ class CustomTemplateLogic extends BaseLogic
164 $info = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>$type]); 165 $info = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>$type]);
165 $data = [ 166 $data = [
166 'head_html'=>characterTruncation($html,'/<header\b[^>]*>(.*?)<\/header>/s'), 167 'head_html'=>characterTruncation($html,'/<header\b[^>]*>(.*?)<\/header>/s'),
167 - 'head_css'=>characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s'), 168 + 'head_style'=>characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s'),
168 'footer_html'=>characterTruncation($html,'/<footer\b[^>]*>(.*?)<\/footer>/s'), 169 'footer_html'=>characterTruncation($html,'/<footer\b[^>]*>(.*?)<\/footer>/s'),
169 - 'footer_css'=>characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s'), 170 + 'footer_style'=>characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s'),
170 ]; 171 ];
171 $footer_other = str_replace('<header','',characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<header/s')); 172 $footer_other = str_replace('<header','',characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<header/s'));
172 $other = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other); 173 $other = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other);
@@ -184,25 +185,66 @@ class CustomTemplateLogic extends BaseLogic @@ -184,25 +185,66 @@ class CustomTemplateLogic extends BaseLogic
184 } 185 }
185 186
186 /** 187 /**
187 - * @remark :获取设置的类型 188 + * @remark :保存公共部分(头部。底部。连接部分)
  189 + * @name :saveTemplateCom
  190 + * @author :lyh
  191 + * @method :post
  192 + * @time :2024/4/29 10:32
  193 + */
  194 + public function saveTemplateCom($html,$template_id,$source,$is_list,$is_custom){
  195 + $typeArr = [BTemplate::COMMON_HEAD, BTemplate::COMMON_FOOTER, BTemplate::COMMON_OTHER];
  196 + $handleInfo = $this->handleCommonParam($html);
  197 + @file_put_contents(storage_path('logs/lyh_error.log'), var_export($handleInfo, true) . PHP_EOL, FILE_APPEND);
  198 + $templateComModel = new BTemplateCom();
  199 + foreach ($typeArr as $type){
  200 + if($type == BTemplate::COMMON_HEAD){
  201 + $param['html'] = $handleInfo['head_html'];
  202 + $param['html_style'] = $handleInfo['head_style'];
  203 + $typeSource = $this->getType($type);//头部是否为独立头部
  204 + }elseif ($type == BTemplate::COMMON_FOOTER){
  205 + $param['html'] = $handleInfo['footer_html'];
  206 + $param['html_style'] = $handleInfo['footer_style'];
  207 + $typeSource = $this->getType($type);
  208 + }else{
  209 + $param['html'] = $handleInfo['other'];
  210 + $param['html_style'] = null;
  211 + $typeSource = $this->getType();
  212 + }
  213 + //查看当前数据是否还存在
  214 + $condition = ['project_id'=>$this->user['project_id'],'template_id'=>$template_id,'is_list'=>$is_list,'is_custom'=>$is_custom,'source'=>$typeSource,'common_type'=>$type];
  215 + $info = $templateComModel->read($condition);
  216 + if($info === false){
  217 + $data = array_merge($param,$condition);
  218 + $templateComModel->add($data);
  219 + }else{
  220 + $templateComModel->edit($param,$condition);
  221 + }
  222 + }
  223 + return $this->success();
  224 + }
  225 +
  226 + /**
  227 + * @remark :(非定制)保存时获取获取设置的类型
188 * @name :getType 228 * @name :getType
189 * @author :lyh 229 * @author :lyh
190 * @method :post 230 * @method :post
191 * @time :2023/10/21 17:29 231 * @time :2023/10/21 17:29
192 */ 232 */
193 - public function getType(){  
194 - $type = 1;//首页公共头部底部 233 + public function getType($CommonType = BTemplate::COMMON_HEAD){
  234 + $type = BTemplate::SOURCE_COM;//公共头部底部
  235 + $is_head = $this->user['configuration']['is_head'] ?? BTemplate::IS_NO_HEADER;
  236 + if($is_head == BTemplate::IS_NO_HEADER){//拓展模块为首页头部
  237 + return $this->success($type);
  238 + }
195 //查看页面是否设置自定义头部底部 239 //查看页面是否设置自定义头部底部
196 - if(isset($this->user['configuration']['is_head']) && ($this->user['configuration']['is_head'] != 0)) {  
197 - $pageSettingModel = new PageSetting();  
198 - $pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id']]);  
199 - if ($pageInfo !== false) {  
200 - if ($pageInfo['page_list'] != 0) {  
201 - $type = 9;  
202 - } 240 + $pageSettingModel = new PageSetting();
  241 + $pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id'],'type'=>$CommonType]);
  242 + if ($pageInfo !== false) {
  243 + if ($pageInfo['page_list'] != 0) {
  244 + $type = 9;
203 } 245 }
204 } 246 }
205 - return $type; 247 + return $this->success($type);
206 } 248 }
207 249
208 /** 250 /**