正在显示
3 个修改的文件
包含
37 行增加
和
22 行删除
| @@ -12,6 +12,7 @@ namespace App\Http\Logic\Bside\BTemplate; | @@ -12,6 +12,7 @@ namespace App\Http\Logic\Bside\BTemplate; | ||
| 12 | use App\Http\Logic\Bside\BaseLogic; | 12 | use App\Http\Logic\Bside\BaseLogic; |
| 13 | use App\Models\Service\Service as ServiceSettingModel; | 13 | use App\Models\Service\Service as ServiceSettingModel; |
| 14 | use App\Models\Template\BTemplate; | 14 | use App\Models\Template\BTemplate; |
| 15 | +use App\Models\Template\BTemplateCommon; | ||
| 15 | use App\Models\Template\BTemplateLog; | 16 | use App\Models\Template\BTemplateLog; |
| 16 | 17 | ||
| 17 | class BTemplateLogLogic extends BaseLogic | 18 | class BTemplateLogLogic extends BaseLogic |
| @@ -41,12 +42,17 @@ class BTemplateLogLogic extends BaseLogic | @@ -41,12 +42,17 @@ class BTemplateLogLogic extends BaseLogic | ||
| 41 | if(($this->user['project_id'] == 1) && (!in_array($this->user['mobile'],$bTemplateModel->mobile)) && ($info['source'] == 1)){ | 42 | if(($this->user['project_id'] == 1) && (!in_array($this->user['mobile'],$bTemplateModel->mobile)) && ($info['source'] == 1)){ |
| 42 | $this->fail('演示项目仅支持演示功能,无法更改首页'); | 43 | $this->fail('演示项目仅支持演示功能,无法更改首页'); |
| 43 | } | 44 | } |
| 44 | - $data = $this->setParam($info); | ||
| 45 | - $BTemplateModel = new BTemplate(); | ||
| 46 | - $rs = $BTemplateModel->edit($data,['template_id'=>$info['template_id'],'source'=>$info['source'],'source_id'=>$info['source_id']]); | ||
| 47 | - if($rs === false){ | ||
| 48 | - $this->fail('error'); | 45 | + try { |
| 46 | + $data = $this->setParam($info); | ||
| 47 | + $BTemplateModel = new BTemplate(); | ||
| 48 | + $BTemplateModel->edit($data,['template_id'=>$info['template_id'],'source'=>$info['source'],'source_id'=>$info['source_id']]); | ||
| 49 | + $commonData = $this->setCommonParam($info); | ||
| 50 | + $commonTemplateModel = new BTemplateCommon(); | ||
| 51 | + $commonTemplateModel->edit($commonData,['template_id'=>$info['template_id'],'project_id'=>$this->user['project_id']]); | ||
| 52 | + }catch (\Exception $e){ | ||
| 53 | + $this->fail('系统错误,请联系管理员'); | ||
| 49 | } | 54 | } |
| 55 | + //同步更新公共头和底 | ||
| 50 | return $this->success(); | 56 | return $this->success(); |
| 51 | } | 57 | } |
| 52 | 58 | ||
| @@ -71,6 +77,23 @@ class BTemplateLogLogic extends BaseLogic | @@ -71,6 +77,23 @@ class BTemplateLogLogic extends BaseLogic | ||
| 71 | } | 77 | } |
| 72 | 78 | ||
| 73 | /** | 79 | /** |
| 80 | + * @remark :设置回滚公共参数参数 | ||
| 81 | + * @name :setParam | ||
| 82 | + * @author :lyh | ||
| 83 | + * @method :post | ||
| 84 | + * @time :2023/8/23 14:18 | ||
| 85 | + */ | ||
| 86 | + public function setCommonParam($info){ | ||
| 87 | + $data = [ | ||
| 88 | + 'head_html'=>$info['head_html'], | ||
| 89 | + 'head_css'=>$info['head_css'], | ||
| 90 | + 'footer_html'=>$info['footer_html'], | ||
| 91 | + 'footer_css'=>$info['footer_css'], | ||
| 92 | + ]; | ||
| 93 | + return $this->success($data); | ||
| 94 | + } | ||
| 95 | + | ||
| 96 | + /** | ||
| 74 | * @remark :获取数据详情 | 97 | * @remark :获取数据详情 |
| 75 | * @name :templateLogInfo | 98 | * @name :templateLogInfo |
| 76 | * @author :lyh | 99 | * @author :lyh |
| @@ -212,6 +212,7 @@ class BTemplateLogic extends BaseLogic | @@ -212,6 +212,7 @@ class BTemplateLogic extends BaseLogic | ||
| 212 | }else{ | 212 | }else{ |
| 213 | $this->model->edit($this->param,['id'=>$info['id']]); | 213 | $this->model->edit($this->param,['id'=>$info['id']]); |
| 214 | } | 214 | } |
| 215 | + //写入操作模版记录 | ||
| 215 | $this->setTemplateLog($this->param); | 216 | $this->setTemplateLog($this->param); |
| 216 | DB::commit(); | 217 | DB::commit(); |
| 217 | }catch (\Exception $e){ | 218 | }catch (\Exception $e){ |
| @@ -6,6 +6,7 @@ use App\Http\Logic\Bside\BaseLogic; | @@ -6,6 +6,7 @@ use App\Http\Logic\Bside\BaseLogic; | ||
| 6 | use App\Models\RouteMap\RouteMap; | 6 | use App\Models\RouteMap\RouteMap; |
| 7 | use App\Models\Service\Service as ServiceSettingModel; | 7 | use App\Models\Service\Service as ServiceSettingModel; |
| 8 | use App\Models\Template\BCustomTemplate; | 8 | use App\Models\Template\BCustomTemplate; |
| 9 | +use App\Models\Template\BTemplateCommon; | ||
| 9 | use App\Models\Template\Setting; | 10 | use App\Models\Template\Setting; |
| 10 | use App\Models\Template\BTemplate; | 11 | use App\Models\Template\BTemplate; |
| 11 | 12 | ||
| @@ -169,27 +170,17 @@ class CustomTemplateLogic extends BaseLogic | @@ -169,27 +170,17 @@ class CustomTemplateLogic extends BaseLogic | ||
| 169 | * @method :post | 170 | * @method :post |
| 170 | * @time :2023/7/21 18:08 | 171 | * @time :2023/7/21 18:08 |
| 171 | */ | 172 | */ |
| 172 | - public function getBodyHeaderFooter($preg_html,$html_style){ | 173 | + public function getBodyHeaderFooter($preg_html = "<main></main>",$html_style = "<style id='globalsojs-styles'></style>"){ |
| 173 | //获取设置的默认模版 | 174 | //获取设置的默认模版 |
| 174 | $bSettingModel = new Setting(); | 175 | $bSettingModel = new Setting(); |
| 175 | $info = $bSettingModel->read(['project_id'=>$this->user['project_id']]); | 176 | $info = $bSettingModel->read(['project_id'=>$this->user['project_id']]); |
| 176 | - //获取模板详情 | ||
| 177 | - $bTemplateModel = new BTemplate(); | ||
| 178 | - $TemplateInfo = $bTemplateModel->read([ | ||
| 179 | - 'template_id'=>$info['template_id'], | ||
| 180 | - 'project_id'=>$this->user['project_id'], | ||
| 181 | - 'source'=>1//首页 | ||
| 182 | - ]); | 177 | + //兼容老数据 |
| 178 | + $commonTemplateModel = new BTemplateCommon(); | ||
| 179 | + $commonInfo = $commonTemplateModel->read(['template_id'=>$info['template_id'],'project_id'=>$this->user['project_id']]); | ||
| 183 | $html = ''; | 180 | $html = ''; |
| 184 | - if($TemplateInfo !== false){ | ||
| 185 | - if(empty($preg_html)){ | ||
| 186 | - $preg_html = "<main></main>"; | ||
| 187 | - $html = preg_replace('/<style id="globalsojs-styles">(.*?)<\/style>/s', "<style id='globalsojs-styles'></style>", $TemplateInfo['html']); | ||
| 188 | - }else{ | ||
| 189 | - $html = preg_replace('/<style id="globalsojs-styles">(.*?)<\/style>/s',$html_style , $TemplateInfo['html']); | ||
| 190 | - } | ||
| 191 | - //内容 | ||
| 192 | - $html = preg_replace('/<main\b[^>]*>(.*?)<\/main>/s', $preg_html, $html); | 181 | + if($commonInfo !== false){ |
| 182 | + $html = $commonInfo['head_css'].$html_style.$commonInfo['footer_css'].$commonInfo['other']. | ||
| 183 | + $commonInfo['head_html'].$preg_html.$commonInfo['footer_html']; | ||
| 193 | } | 184 | } |
| 194 | return $html; | 185 | return $html; |
| 195 | } | 186 | } |
-
请 注册 或 登录 后发表评论