|
...
|
...
|
@@ -104,9 +104,14 @@ class BTemplateLogic extends BaseLogic |
|
|
|
$ATemplateModel = new Template();
|
|
|
|
$TemplateInfo = $ATemplateModel->read(['id'=>$info['template_id']]);
|
|
|
|
}else{
|
|
|
|
//渲染首页数据
|
|
|
|
$commonTemplateModel = new BTemplateCommon();
|
|
|
|
$commonInfo = $commonTemplateModel->read(['template_id'=>$info['template_id'],'project_id'=>$this->user['project_id']]);
|
|
|
|
if($commonInfo !== false){
|
|
|
|
$TemplateInfo['html'] = $commonInfo['head_css'].$TemplateInfo['main_css'].$commonInfo['footer_css'].$commonInfo['other'].
|
|
|
|
$commonInfo['head_html'].$TemplateInfo['main_html'].$commonInfo['footer_html'];
|
|
|
|
}
|
|
|
|
$ATemplateModel = new Template();
|
|
|
|
$ATemplateInfo = $ATemplateModel->read(['id'=>$info['template_id']]);
|
|
|
|
$ATemplateInfo = $ATemplateModel->read(['id'=>$info['template_id']],['name','image']);
|
|
|
|
$TemplateInfo['name'] = $ATemplateInfo['name'];
|
|
|
|
$TemplateInfo['image_link'] = getImageUrl($ATemplateInfo['image']);
|
|
|
|
}
|
|
...
|
...
|
@@ -122,24 +127,35 @@ class BTemplateLogic extends BaseLogic |
|
|
|
* @time :2023/7/25 16:40
|
|
|
|
*/
|
|
|
|
public function productHtml($info,$source,$source_id){
|
|
|
|
//查看当前模板是否已编辑保存web_template
|
|
|
|
$TemplateInfo = $this->webTemplateInfo($info['template_id'],$source,$source_id);
|
|
|
|
if($TemplateInfo === false){
|
|
|
|
//获取首页数据
|
|
|
|
$homeTemplateInfo = $this->webTemplateInfo($info['template_id'],1,0);
|
|
|
|
if($homeTemplateInfo === false){
|
|
|
|
$this->fail('请先装修首页');
|
|
|
|
}
|
|
|
|
//查看当前模板是否已编辑保存web_template
|
|
|
|
$TemplateInfo = $this->webTemplateInfo($info['template_id'],$source,$source_id);
|
|
|
|
if($TemplateInfo === false){
|
|
|
|
//兼容老数据
|
|
|
|
$commonTemplateModel = new BTemplateCommon();
|
|
|
|
$commonInfo = $commonTemplateModel->read(['template_id'=>$info['template_id'],'project_id'=>$this->user['project_id']]);
|
|
|
|
if($commonInfo !== false){
|
|
|
|
$html = $commonInfo['head_css']."<style id='globalsojs-styles'></style>".$commonInfo['footer_css'].$commonInfo['other'].
|
|
|
|
$commonInfo['head_html']."<main>{$this->getProductModule()}</main>".$commonInfo['footer_html'];
|
|
|
|
}else{
|
|
|
|
$html = preg_replace('/<style id="globalsojs-styles">(.*?)<\/style>/s', "<style id='globalsojs-styles'></style>", $homeTemplateInfo['html']);
|
|
|
|
$html = preg_replace('/<main\b[^>]*>(.*?)<\/main>/s', "<main>{$this->getProductModule()}</main>", $html);
|
|
|
|
}else{
|
|
|
|
$homeTemplateInfo = $this->webTemplateInfo($info['template_id'],1,0);
|
|
|
|
if($homeTemplateInfo === false){
|
|
|
|
$this->fail('请先装修首页');
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
//兼容老数据
|
|
|
|
$commonTemplateModel = new BTemplateCommon();
|
|
|
|
$commonInfo = $commonTemplateModel->read(['template_id'=>$info['template_id'],'project_id'=>$this->user['project_id']]);
|
|
|
|
if($commonInfo !== false){
|
|
|
|
$html = $commonInfo['head_css'].$TemplateInfo['main_css'].$commonInfo['footer_css'].$commonInfo['other'].
|
|
|
|
$commonInfo['head_html'].$TemplateInfo['main_html'].$commonInfo['footer_html'];
|
|
|
|
}else{
|
|
|
|
$html = preg_replace('/<style id="globalsojs-styles">(.*?)<\/style>/s', $TemplateInfo['main_css'], $homeTemplateInfo['html']);
|
|
|
|
$html = preg_replace('/<main\b[^>]*>(.*?)<\/main>/s',$TemplateInfo['main_html'] , $html);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$TemplateInfo['html'] = $this->getHeadFooter($html);//组装数据
|
|
|
|
return $this->success($TemplateInfo);
|
|
|
|
}
|
|
...
|
...
|
@@ -187,17 +203,19 @@ class BTemplateLogic extends BaseLogic |
|
|
|
$info = $this->webTemplateInfo($this->param['template_id'],$this->param['source'],$this->param['source_id']);
|
|
|
|
//字符串截取
|
|
|
|
$this->param = $this->stringProcessing($this->param);
|
|
|
|
$this->param = $this->templateSaveParam($this->param);
|
|
|
|
$this->saveCommonTemplate($this->param);
|
|
|
|
$this->param = $this->templateSaveParam($this->param);//组装数据
|
|
|
|
if($info === false){
|
|
|
|
$this->model->add($this->param);
|
|
|
|
}else{
|
|
|
|
$this->model->edit($this->param,['id'=>$info['id']]);
|
|
|
|
}
|
|
|
|
//写入操作模版记录
|
|
|
|
$this->setTemplateLog($this->param);
|
|
|
|
DB::commit();
|
|
|
|
}catch (\Exception $e){
|
|
|
|
DB::rollBack();
|
|
|
|
$this->fail('error');
|
|
|
|
$this->fail('系统错误,请联系管理员');
|
|
|
|
}
|
|
|
|
//通知更新
|
|
|
|
$this->homeOrProduct($this->param['source'],$this->param['source_id']);
|
|
...
|
...
|
@@ -205,6 +223,34 @@ class BTemplateLogic extends BaseLogic |
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :保存头部公共数据
|
|
|
|
* @name :saveCommonTemplate
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/10/13 14:27
|
|
|
|
*/
|
|
|
|
public function saveCommonTemplate($param){
|
|
|
|
$templateCommonModel = new BTemplateCommon();
|
|
|
|
$info = $templateCommonModel->read(['template_id'=>$param['template_id'],'project_id'=>$this->user['project_id']]);
|
|
|
|
// @file_put_contents(storage_path('logs/lyh_error.log'), var_export($param['html'], true) . PHP_EOL, FILE_APPEND);
|
|
|
|
$data = [
|
|
|
|
'head_html'=>$param['head_html'],
|
|
|
|
'head_css'=>$param['head_css'],
|
|
|
|
'footer_html'=>$param['footer_html'],
|
|
|
|
'footer_css'=>$param['footer_css'],
|
|
|
|
'other'=>str_replace('<header','',characterTruncation($param['html'],"/<link id=\"google-fonts-link\"(.*?)<header/s")),
|
|
|
|
];
|
|
|
|
if($info === false){
|
|
|
|
$data['template_id'] = $param['template_id'];
|
|
|
|
$data['project_id'] = $this->user['project_id'];
|
|
|
|
$templateCommonModel->add($data);
|
|
|
|
}else{
|
|
|
|
$templateCommonModel->edit($data,['id'=>$info['id']]);
|
|
|
|
}
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :生成记录
|
|
|
|
* @name :setTemplateLog
|
|
|
|
* @author :lyh
|
...
|
...
|
|