正在显示
7 个修改的文件
包含
405 行增加
和
14 行删除
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :InitHtmlController.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2023/12/27 10:37 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Http\Controllers\Bside\Template; | ||
| 11 | + | ||
| 12 | +use App\Enums\Common\Code; | ||
| 13 | +use App\Http\Controllers\Bside\BaseController; | ||
| 14 | +use App\Http\Logic\Bside\BTemplate\BTemplateLogic; | ||
| 15 | +use App\Http\Logic\Bside\BTemplate\InitHtmlLogic; | ||
| 16 | +use App\Http\Logic\Bside\BTemplate\VisualizationLogic; | ||
| 17 | + | ||
| 18 | +/** | ||
| 19 | + * @remark :初始复合页代码块上传 | ||
| 20 | + * @name :InitHtmlController | ||
| 21 | + * @author :lyh | ||
| 22 | + * @method :post | ||
| 23 | + * @time :2023/12/27 10:37 | ||
| 24 | + */ | ||
| 25 | +class InitHtmlController extends BaseController | ||
| 26 | +{ | ||
| 27 | + /** | ||
| 28 | + * @remark :获取可视化详情页模板数据 | ||
| 29 | + * @name :getDetailInfo | ||
| 30 | + * @author :lyh | ||
| 31 | + * @method :post | ||
| 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 | ||
| 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 | + /** | ||
| 62 | + * @remark :获取当前定制代码块详情 | ||
| 63 | + * @name :info | ||
| 64 | + * @author :lyh | ||
| 65 | + * @method :post | ||
| 66 | + * @time :2023/11/15 10:26 | ||
| 67 | + */ | ||
| 68 | + public function getCustomizedHtml(InitHtmlLogic $logic){ | ||
| 69 | + $this->request->validate([ | ||
| 70 | + 'type'=>['required'], | ||
| 71 | + ],[ | ||
| 72 | + 'type.required' => '类型不能为空', | ||
| 73 | + ]); | ||
| 74 | + $info = $logic->getCustomizedHtml(); | ||
| 75 | + if($info === false){ | ||
| 76 | + $info = []; | ||
| 77 | + } | ||
| 78 | + $this->response('success',Code::SUCCESS,$info); | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + /** | ||
| 82 | + * @remark :保存定制项目html | ||
| 83 | + * @name :save | ||
| 84 | + * @author :lyh | ||
| 85 | + * @method :post | ||
| 86 | + * @time :2023/11/15 10:08 | ||
| 87 | + */ | ||
| 88 | + public function saveCustomizedHtml(InitHtmlLogic $logic){ | ||
| 89 | + $this->request->validate([ | ||
| 90 | + 'type'=>['required'], | ||
| 91 | + ],[ | ||
| 92 | + 'type.required' => '类型不能为空', | ||
| 93 | + ]); | ||
| 94 | + $logic->saveCustomizedHtml(); | ||
| 95 | + $this->response('success'); | ||
| 96 | + } | ||
| 97 | +} |
| @@ -30,6 +30,11 @@ class VisualizationController extends BaseController | @@ -30,6 +30,11 @@ class VisualizationController extends BaseController | ||
| 30 | * @time :2023/11/15 10:26 | 30 | * @time :2023/11/15 10:26 |
| 31 | */ | 31 | */ |
| 32 | public function info(VisualizationLogic $logic){ | 32 | public function info(VisualizationLogic $logic){ |
| 33 | + $this->request->validate([ | ||
| 34 | + 'type'=>['required'], | ||
| 35 | + ],[ | ||
| 36 | + 'type.required' => '类型不能为空', | ||
| 37 | + ]); | ||
| 33 | $info = $logic->getVisualizationInfo(); | 38 | $info = $logic->getVisualizationInfo(); |
| 34 | if($info === false){ | 39 | if($info === false){ |
| 35 | $info = []; | 40 | $info = []; |
| @@ -45,6 +50,11 @@ class VisualizationController extends BaseController | @@ -45,6 +50,11 @@ class VisualizationController extends BaseController | ||
| 45 | * @time :2023/11/15 10:08 | 50 | * @time :2023/11/15 10:08 |
| 46 | */ | 51 | */ |
| 47 | public function save(VisualizationLogic $logic){ | 52 | public function save(VisualizationLogic $logic){ |
| 53 | + $this->request->validate([ | ||
| 54 | + 'type'=>['required'], | ||
| 55 | + ],[ | ||
| 56 | + 'type.required' => '类型不能为空', | ||
| 57 | + ]); | ||
| 48 | $logic->saveVisualization(); | 58 | $logic->saveVisualization(); |
| 49 | $this->response('success'); | 59 | $this->response('success'); |
| 50 | } | 60 | } |
| @@ -98,10 +98,7 @@ class BTemplateLogic extends BaseLogic | @@ -98,10 +98,7 @@ class BTemplateLogic extends BaseLogic | ||
| 98 | $commonInfo['head_html'].$mainInfo['main_html'].$commonInfo['footer_html']; | 98 | $commonInfo['head_html'].$mainInfo['main_html'].$commonInfo['footer_html']; |
| 99 | $html = $this->getHeadFooter($html); | 99 | $html = $this->getHeadFooter($html); |
| 100 | $result = ['html'=>$html,'template_id'=>$template_id]; | 100 | $result = ['html'=>$html,'template_id'=>$template_id]; |
| 101 | - if($templateInfo !== false){ | ||
| 102 | - $result['id'] = $templateInfo['id']; | ||
| 103 | - $result['updated_at'] = $templateInfo['updated_at']; | ||
| 104 | - } | 101 | + if($templateInfo !== false){$result['id'] = $templateInfo['id'];$result['updated_at'] = $templateInfo['updated_at'];} |
| 105 | return $this->success($result); | 102 | return $this->success($result); |
| 106 | } | 103 | } |
| 107 | 104 |
| 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\Template\BTemplate; | ||
| 14 | +use App\Models\Template\BTemplateCommon; | ||
| 15 | +use App\Models\Template\BTemplateMain; | ||
| 16 | +use App\Models\Template\Setting; | ||
| 17 | +use App\Models\Template\TemplateTypeMain; | ||
| 18 | + | ||
| 19 | +class InitHtmlLogic extends BaseLogic | ||
| 20 | +{ | ||
| 21 | + public function __construct() | ||
| 22 | + { | ||
| 23 | + parent::__construct(); | ||
| 24 | + $this->param = $this->requestAll; | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + /** | ||
| 28 | + * @remark :获取非定制项目复合页数据 | ||
| 29 | + * @name :getDetailHtml | ||
| 30 | + * @author :lyh | ||
| 31 | + * @method :post | ||
| 32 | + * @time :2023/12/27 10:50 | ||
| 33 | + */ | ||
| 34 | + public function getDetailHtml(){ | ||
| 35 | + $template_id = $this->getTemplateId(); | ||
| 36 | + $is_custom = $this->param['is_custom'] ?? 0;//TODO::1:代表扩展模块 | ||
| 37 | + $is_list = $this->param['is_list'] ?? 0;//TODO::1:代表分类列表模块 | ||
| 38 | + //获取设置的默认中间部分 | ||
| 39 | + $bTemplateMainModel = new BTemplateMain(); | ||
| 40 | + $mainInfo = $bTemplateMainModel->read(['project_id'=>$this->user['project_id'],'type'=>$this->param['type'],'is_list'=>$is_list,'is_custom'=>$is_custom]); | ||
| 41 | + if($mainInfo === false){ | ||
| 42 | + $main_html = $this->getInitModule($this->param['type'],$is_list); | ||
| 43 | + $main_style = "<style id='globalsojs-styles'></style>"; | ||
| 44 | + }else{ | ||
| 45 | + $main_html = $mainInfo['main_html']; | ||
| 46 | + $main_style = $mainInfo['main_css']; | ||
| 47 | + } | ||
| 48 | + $commonInfo = $this->getTypeCommonHtml($template_id,$this->param['type'],$is_custom,$is_list); //获取头部 | ||
| 49 | + $html = $commonInfo['head_css'].$main_style.$commonInfo['footer_css'].$commonInfo['other'].$commonInfo['head_html'].$main_html.$commonInfo['footer_html']; | ||
| 50 | + $html = $this->getHeadFooter($html);//组装数据 | ||
| 51 | + return $this->success($html); | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + /** | ||
| 55 | + * @remark :保存复合页数据 | ||
| 56 | + * @name :saveDetailHtml | ||
| 57 | + * @author :lyh | ||
| 58 | + * @method :post | ||
| 59 | + * @time :2023/12/27 11:57 | ||
| 60 | + */ | ||
| 61 | + public function saveDetailHtml(){ | ||
| 62 | + $template_id = $this->getTemplateId(); | ||
| 63 | + $is_custom = $this->param['is_custom'] ?? 0;//TODO::1:代表扩展模块 | ||
| 64 | + $is_list = $this->param['is_list'] ?? 0;//TODO::1:代表分类列表模块 | ||
| 65 | + //保存中间部分 | ||
| 66 | + $bTemplateMainModel = new BTemplateMain(); | ||
| 67 | + $mainInfo = $bTemplateMainModel->read(['project_id'=>$this->user['project_id'],'type'=>$this->param['type'],'is_custom'=>$is_custom,'is_list'=>$is_list]); | ||
| 68 | + if($mainInfo === false){ | ||
| 69 | + $data = [ | ||
| 70 | + 'main_html'=>characterTruncation($this->param['html'],'/<main\b[^>]*>(.*?)<\/main>/s'), | ||
| 71 | + 'main_css'=>characterTruncation($this->param['html'],'/<style id="globalsojs-styles">(.*?)<\/style>/s'), | ||
| 72 | + 'section_list_id'=>$this->param['section_list_id'] ?? '', | ||
| 73 | + 'project_id'=>$this->user['project_id'], | ||
| 74 | + 'type'=>$this->param['type'], | ||
| 75 | + 'is_custom'=>$is_custom, | ||
| 76 | + 'is_list'=>$is_list | ||
| 77 | + ]; | ||
| 78 | + $bTemplateMainModel->add($data); | ||
| 79 | + }else{ | ||
| 80 | + $data = [ | ||
| 81 | + 'main_html'=>characterTruncation($this->param['html'],'/<main\b[^>]*>(.*?)<\/main>/s'), | ||
| 82 | + 'main_css'=>characterTruncation($this->param['html'],'/<style id="globalsojs-styles">(.*?)<\/style>/s'), | ||
| 83 | + 'section_list_id'=>$this->param['section_list_id'] ?? '', | ||
| 84 | + ]; | ||
| 85 | + $bTemplateMainModel->edit($data,['id'=>$mainInfo['id']]); | ||
| 86 | + } | ||
| 87 | + $this->saveDetailCommonHtml($this->param['html'],$this->param['type'],$template_id,$is_custom,$is_list); | ||
| 88 | + return $this->success(); | ||
| 89 | + } | ||
| 90 | + /** | ||
| 91 | + * @remark :保存详情页模版头部底部 | ||
| 92 | + * @name :saveDetailCommonHtml | ||
| 93 | + * @author :lyh | ||
| 94 | + * @method :post | ||
| 95 | + * @time :2023/12/15 18:12 | ||
| 96 | + */ | ||
| 97 | + public function saveDetailCommonHtml($html,$template_id,$is_custom,$is_list){ | ||
| 98 | + $publicData = $this->handleCommonParam($html); | ||
| 99 | + $templateCommonModel = new BTemplateCommon(); | ||
| 100 | + if($is_custom == BTemplate::SOURCE_CUSTOM){//扩展模块 | ||
| 101 | + //更新首页头部底部 | ||
| 102 | + $templateCommonModel->edit($publicData,['type'=>BTemplate::SOURCE_HOME,'project_id'=>$this->user['project_id'],'template_id'=>$template_id]); | ||
| 103 | + return $this->success(); | ||
| 104 | + } | ||
| 105 | + //查看当前模板是否有独立头部,有独立头部,更新独立头部,无独立头部,更新公共头部 | ||
| 106 | + if(isset($this->user['configuration']['is_head']) && ($this->user['configuration']['is_head'] != 0)) { | ||
| 107 | + $templateCommonInfo = $templateCommonModel->read(['type'=>$type,'project_id'=>$this->user['project_id'],'template_id'=>$template_id]); | ||
| 108 | + if($templateCommonInfo === false){ | ||
| 109 | + $publicData['type'] = $type; | ||
| 110 | + $publicData['project_id'] = $this->user['project_id']; | ||
| 111 | + $publicData['template_id'] = $template_id; | ||
| 112 | + $templateCommonModel->add($publicData); | ||
| 113 | + }else{ | ||
| 114 | + $templateCommonModel->edit($publicData,['id'=>$templateCommonInfo['id']]); | ||
| 115 | + } | ||
| 116 | + }else{ | ||
| 117 | + | ||
| 118 | + } | ||
| 119 | + return true; | ||
| 120 | + } | ||
| 121 | + | ||
| 122 | + /** | ||
| 123 | + * @remark :保存时字符串处理 | ||
| 124 | + * @name :handleCommonParam | ||
| 125 | + * @author :lyh | ||
| 126 | + * @method :post | ||
| 127 | + * @time :2023/6/29 15:35 | ||
| 128 | + */ | ||
| 129 | + public function handleCommonParam($html){ | ||
| 130 | + //字符串截取 | ||
| 131 | + $param['head_html'] = characterTruncation($html,'/<header\b[^>]*>(.*?)<\/header>/s'); | ||
| 132 | + $param['footer_html'] = characterTruncation($html,'/<footer\b[^>]*>(.*?)<\/footer>/s'); | ||
| 133 | + $param['head_css'] = characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s'); | ||
| 134 | + $param['footer_css'] = characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s'); | ||
| 135 | + $footer_other = str_replace('<header','',characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<header/s')); | ||
| 136 | + $param['other'] = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other); | ||
| 137 | + return $this->success($param); | ||
| 138 | + } | ||
| 139 | + | ||
| 140 | + /** | ||
| 141 | + * @remark :默认复合页数据 | ||
| 142 | + * @name :getProductModule | ||
| 143 | + * @author :lyh | ||
| 144 | + * @method :post | ||
| 145 | + * @time :2023/7/27 15:08 | ||
| 146 | + */ | ||
| 147 | + public function getInitModule($type,$is_custom,$is_list){ | ||
| 148 | + if($is_custom == BTemplate::SOURCE_CUSTOM) { | ||
| 149 | + $type = BTemplate::TYPE_CUSTOM; | ||
| 150 | + } | ||
| 151 | + $mainModel = new TemplateTypeMain(); | ||
| 152 | + $info = $mainModel->read(['type'=>$type,'is_list'=>$is_list]); | ||
| 153 | + return $info['main_html']; | ||
| 154 | + } | ||
| 155 | + | ||
| 156 | + /** | ||
| 157 | + * @remark :根据type获取头部html | ||
| 158 | + * @name :getHeaderFooter | ||
| 159 | + * @author :lyh | ||
| 160 | + * @method :post | ||
| 161 | + * @time :2023/12/15 18:06 | ||
| 162 | + */ | ||
| 163 | + public function getTypeCommonHtml($template_id,$type,$is_custom,$is_list){ | ||
| 164 | + //获取首页公共部分 | ||
| 165 | + $templateCommonModel = new BTemplateCommon(); | ||
| 166 | + $commonInfo = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>1]); | ||
| 167 | + if($is_custom == BTemplate::SOURCE_CUSTOM){ | ||
| 168 | + return $this->success($commonInfo); | ||
| 169 | + } | ||
| 170 | + //判断当前项目是否有设置独立头部的权限 | ||
| 171 | + if(isset($this->user['configuration']['is_head']) && ($this->user['configuration']['is_head'] != 0)) { | ||
| 172 | + //有独立头部,获取独立头部 | ||
| 173 | + $commonType = $this->getHeaderType($type,$is_list); | ||
| 174 | + $commonTypeInfo = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>$commonType['type']]); | ||
| 175 | + if($commonTypeInfo !== false){ | ||
| 176 | + $commonInfo = $commonTypeInfo; | ||
| 177 | + } | ||
| 178 | + } | ||
| 179 | + return $this->success($commonInfo); | ||
| 180 | + } | ||
| 181 | + | ||
| 182 | + /** | ||
| 183 | + * @remark :独立头部获取头部底部类型 | ||
| 184 | + * @name :getHeaderType | ||
| 185 | + * @author :lyh | ||
| 186 | + * @method :post | ||
| 187 | + * @time :2023/12/27 11:36 | ||
| 188 | + */ | ||
| 189 | + public function getHeaderType($type,$is_list){ | ||
| 190 | + $resultType = BTemplate::SOURCE_HOME; | ||
| 191 | + if($type == BTemplate::SOURCE_PRODUCT){ | ||
| 192 | + if($is_list == BTemplate::IS_LIST){ | ||
| 193 | + $resultType = BTemplate::TYPE_THREE; | ||
| 194 | + }else{ | ||
| 195 | + $resultType = BTemplate::TYPE_TWO; | ||
| 196 | + } | ||
| 197 | + } | ||
| 198 | + if($type == BTemplate::SOURCE_BLOG){ | ||
| 199 | + if($is_list == BTemplate::IS_LIST){ | ||
| 200 | + $resultType = BTemplate::TYPE_FIVE; | ||
| 201 | + }else{ | ||
| 202 | + $resultType = BTemplate::TYPE_FOUR; | ||
| 203 | + } | ||
| 204 | + } | ||
| 205 | + if($type == BTemplate::SOURCE_NEWS){ | ||
| 206 | + if($is_list == BTemplate::IS_LIST){ | ||
| 207 | + $resultType = BTemplate::TYPE_SEVEN; | ||
| 208 | + }else{ | ||
| 209 | + $resultType = BTemplate::TYPE_SIX; | ||
| 210 | + } | ||
| 211 | + } | ||
| 212 | + return $this->success(['type'=>$resultType]); | ||
| 213 | + } | ||
| 214 | + | ||
| 215 | + /** | ||
| 216 | + * @remark :获取模版id | ||
| 217 | + * @name :getTemplateId | ||
| 218 | + * @author :lyh | ||
| 219 | + * @method :post | ||
| 220 | + * @time :2023/12/27 10:51 | ||
| 221 | + */ | ||
| 222 | + public function getTemplateId(){ | ||
| 223 | + $bSettingModel = new Setting(); | ||
| 224 | + $bSettingInfo = $bSettingModel->read(['project_id'=>$this->user['project_id']],['id','template_id']); | ||
| 225 | + if($bSettingInfo === false){ | ||
| 226 | + $this->fail('请先设置模板'); | ||
| 227 | + } | ||
| 228 | + return $this->success($bSettingInfo['template_id']); | ||
| 229 | + } | ||
| 230 | + | ||
| 231 | + /** | ||
| 232 | + * @remark :获取代码块 | ||
| 233 | + * @name :getVisualizationInfo | ||
| 234 | + * @author :lyh | ||
| 235 | + * @method :post | ||
| 236 | + * @time :2023/11/17 14:44 | ||
| 237 | + */ | ||
| 238 | + public function getCustomizedHtml(){ | ||
| 239 | + $is_list = $this->param['is_list'] ?? 0; | ||
| 240 | + $bTemplateMainModel = new BTemplateMain(); | ||
| 241 | + $info = $bTemplateMainModel->read(['type'=>$this->param['type'],'is_list'=>$is_list]); | ||
| 242 | + if($info === false){ | ||
| 243 | + $html = ''; | ||
| 244 | + }else{ | ||
| 245 | + $html = $info['main_html']; | ||
| 246 | + } | ||
| 247 | + return $this->success(['html'=>$html]); | ||
| 248 | + } | ||
| 249 | + | ||
| 250 | + /** | ||
| 251 | + * @remark :保存定制html | ||
| 252 | + * @name :saveHtml | ||
| 253 | + * @author :lyh | ||
| 254 | + * @method :post | ||
| 255 | + * @time :2023/11/15 10:12 | ||
| 256 | + */ | ||
| 257 | + public function saveCustomizedHtml(){ | ||
| 258 | + try { | ||
| 259 | + $is_list = $this->param['is_list'] ?? 0; | ||
| 260 | + $bTemplateMainModel = new BTemplateMain(); | ||
| 261 | + $mainInfo = $bTemplateMainModel->read(['type'=>$this->param['type'],'is_list'=>$is_list]); | ||
| 262 | + if($mainInfo === false){ | ||
| 263 | + $mainData = [ | ||
| 264 | + 'project_id'=>$this->user['project_id'], | ||
| 265 | + 'type'=>$this->param['type'], | ||
| 266 | + 'is_list'=>$is_list, | ||
| 267 | + 'main_html'=>$this->param['html'] | ||
| 268 | + ]; | ||
| 269 | + $bTemplateMainModel->add($mainData); | ||
| 270 | + }else{ | ||
| 271 | + $bTemplateMainModel->edit(['main_html'=>$this->param['html']],['id'=>$mainInfo['id']]); | ||
| 272 | + } | ||
| 273 | + }catch (\Exception $exception){ | ||
| 274 | + $this->fail('保存失败,请联系开发人员'); | ||
| 275 | + } | ||
| 276 | + return $this->success(); | ||
| 277 | + } | ||
| 278 | +} |
| @@ -42,8 +42,9 @@ class VisualizationLogic extends BaseLogic | @@ -42,8 +42,9 @@ class VisualizationLogic extends BaseLogic | ||
| 42 | * @time :2023/11/17 14:44 | 42 | * @time :2023/11/17 14:44 |
| 43 | */ | 43 | */ |
| 44 | public function getVisualizationInfo(){ | 44 | public function getVisualizationInfo(){ |
| 45 | + $is_list = $this->param['is_list'] ?? 0; | ||
| 45 | $bTemplateMainModel = new BTemplateMain(); | 46 | $bTemplateMainModel = new BTemplateMain(); |
| 46 | - $info = $bTemplateMainModel->read(['type'=>$this->param['type']]); | 47 | + $info = $bTemplateMainModel->read(['type'=>$this->param['type'],'is_list'=>$is_list]); |
| 47 | if($info === false){ | 48 | if($info === false){ |
| 48 | $html = ''; | 49 | $html = ''; |
| 49 | }else{ | 50 | }else{ |
| @@ -61,21 +62,22 @@ class VisualizationLogic extends BaseLogic | @@ -61,21 +62,22 @@ class VisualizationLogic extends BaseLogic | ||
| 61 | */ | 62 | */ |
| 62 | public function saveVisualization(){ | 63 | public function saveVisualization(){ |
| 63 | try { | 64 | try { |
| 64 | - $type = $this->param['type']; | 65 | + $is_list = $this->param['is_list'] ?? 0; |
| 65 | $bTemplateMainModel = new BTemplateMain(); | 66 | $bTemplateMainModel = new BTemplateMain(); |
| 66 | - $mainInfo = $bTemplateMainModel->read(['type'=>$type]); | 67 | + $mainInfo = $bTemplateMainModel->read(['type'=>$this->param['type'],'is_list'=>$is_list]); |
| 67 | if($mainInfo === false){ | 68 | if($mainInfo === false){ |
| 68 | $mainData = [ | 69 | $mainData = [ |
| 69 | 'project_id'=>$this->user['project_id'], | 70 | 'project_id'=>$this->user['project_id'], |
| 70 | - 'type'=>$type, | 71 | + 'type'=>$this->param['type'], |
| 72 | + 'is_list'=>$is_list, | ||
| 71 | 'main_html'=>$this->param['html'] | 73 | 'main_html'=>$this->param['html'] |
| 72 | ]; | 74 | ]; |
| 73 | $bTemplateMainModel->add($mainData); | 75 | $bTemplateMainModel->add($mainData); |
| 74 | }else{ | 76 | }else{ |
| 75 | $bTemplateMainModel->edit(['main_html'=>$this->param['html']],['id'=>$mainInfo['id']]); | 77 | $bTemplateMainModel->edit(['main_html'=>$this->param['html']],['id'=>$mainInfo['id']]); |
| 76 | } | 78 | } |
| 77 | - }catch (\Exception $e){ | ||
| 78 | - $this->fail('系统错误,请联系管理员'); | 79 | + }catch (\Exception $exception){ |
| 80 | + $this->fail('保存失败,请联系开发人员'); | ||
| 79 | } | 81 | } |
| 80 | return $this->success(); | 82 | return $this->success(); |
| 81 | } | 83 | } |
| @@ -36,8 +36,8 @@ class BTemplate extends Base | @@ -36,8 +36,8 @@ 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 | 41 | ||
| 42 | protected $table = 'gl_web_template'; | 42 | protected $table = 'gl_web_template'; |
| 43 | //连接数据库 | 43 | //连接数据库 |
| @@ -345,8 +345,14 @@ Route::middleware(['bloginauth'])->group(function () { | @@ -345,8 +345,14 @@ Route::middleware(['bloginauth'])->group(function () { | ||
| 345 | Route::prefix('visualization')->group(function () { | 345 | Route::prefix('visualization')->group(function () { |
| 346 | Route::any('/info', [\App\Http\Controllers\Bside\Template\VisualizationController::class, 'info'])->name('visualization_info'); | 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'); | 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'); | 348 | + }); |
| 349 | + | ||
| 350 | + //初始代码块 | ||
| 351 | + Route::prefix('init_html')->group(function () { | ||
| 352 | + Route::any('/getCustomizedHtml', [\App\Http\Controllers\Bside\Template\InitHtmlController::class, 'getCustomizedHtml'])->name('init_getCustomizedHtml'); | ||
| 353 | + Route::any('/saveCustomizedHtml', [\App\Http\Controllers\Bside\Template\InitHtmlController::class, 'saveCustomizedHtml'])->name('init_saveCustomizedHtml'); | ||
| 354 | + Route::any('/getDetailHtml', [\App\Http\Controllers\Bside\Template\InitHtmlController::class, 'getDetailHtml'])->name('init_getDetailHtml'); | ||
| 355 | + Route::any('/saveDetailHtml', [\App\Http\Controllers\Bside\Template\InitHtmlController::class, 'saveDetailHtml'])->name('init_saveDetailHtml'); | ||
| 350 | }); | 356 | }); |
| 351 | 357 | ||
| 352 | // 自定义页面,专题页 | 358 | // 自定义页面,专题页 |
| @@ -434,6 +440,7 @@ Route::middleware(['bloginauth'])->group(function () { | @@ -434,6 +440,7 @@ Route::middleware(['bloginauth'])->group(function () { | ||
| 434 | //自定义模板 | 440 | //自定义模板 |
| 435 | Route::prefix('custom_module')->group(function () { | 441 | Route::prefix('custom_module')->group(function () { |
| 436 | Route::any('/', [\App\Http\Controllers\Bside\CustomModule\CustomModuleController::class, 'lists'])->name('custom_lists'); | 442 | Route::any('/', [\App\Http\Controllers\Bside\CustomModule\CustomModuleController::class, 'lists'])->name('custom_lists'); |
| 443 | + 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'); | 444 | 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'); | 445 | Route::any('/del', [\App\Http\Controllers\Bside\CustomModule\CustomModuleController::class, 'del'])->name('custom_del'); |
| 439 | 446 |
-
请 注册 或 登录 后发表评论