|
...
|
...
|
@@ -55,54 +55,80 @@ class BTemplateLogic extends BaseLogic |
|
|
|
$info = $bSettingModel->read(['project_id'=>$this->user['project_id']]);
|
|
|
|
$TemplateInfo = [];
|
|
|
|
if($info !== false){
|
|
|
|
if($this->param['source'] == 1){//首页
|
|
|
|
//查看当前模板是否已编辑保存web_template
|
|
|
|
$TemplateInfo = $this->model->read([
|
|
|
|
'template_id'=>$info['template_id'],
|
|
|
|
'source'=>!isset($this->param['source']) ? 1 : $this->param['source'],
|
|
|
|
'project_id'=>$this->user['project_id'],
|
|
|
|
'source_id'=>!isset($this->param['source_id']) ? 0 : $this->param['source_id'],
|
|
|
|
]);
|
|
|
|
if($TemplateInfo === false){
|
|
|
|
//获取模板详情
|
|
|
|
$ATemplateModel = new Template();
|
|
|
|
$TemplateInfo = $ATemplateModel->read(['id'=>$info['template_id']]);
|
|
|
|
}
|
|
|
|
$TemplateInfo['html'] = $this->getHeadFooter($TemplateInfo['html']);
|
|
|
|
}else{
|
|
|
|
//查看当前模板是否已编辑保存web_template
|
|
|
|
$TemplateInfo = $this->model->read([
|
|
|
|
'template_id'=>$info['template_id'],
|
|
|
|
'source'=>$this->param['source'],
|
|
|
|
'project_id'=>$this->user['project_id'],
|
|
|
|
'source_id'=>$this->param['source_id'],
|
|
|
|
]);
|
|
|
|
if($TemplateInfo === false){
|
|
|
|
//查看当前模板是否已编辑保存web_template
|
|
|
|
$TemplateInfo = $this->model->read([
|
|
|
|
'template_id'=>$info['template_id'],
|
|
|
|
'source'=>1,
|
|
|
|
'project_id'=>$this->user['project_id'],
|
|
|
|
]);
|
|
|
|
if($TemplateInfo === false){
|
|
|
|
$this->fail('请先装修首页');
|
|
|
|
}
|
|
|
|
$TemplateInfo['html'] = preg_replace('/<style id="vvvebjs-styles">(.*?)<\/style>/s', "<style id='vvvebjs-styles'></style>", $TemplateInfo['html']);
|
|
|
|
$TemplateInfo['html'] = preg_replace('/<main\b[^>]*>(.*?)<\/main>/s', "<main></main>", $TemplateInfo['html']);
|
|
|
|
$TemplateInfo['html'] = $this->getHeadFooter($TemplateInfo['html']);
|
|
|
|
}else{
|
|
|
|
//查看当前模板是否已编辑保存web_template
|
|
|
|
$TemplateInfo = $this->model->read([
|
|
|
|
'template_id'=>$info['template_id'],
|
|
|
|
'source'=>1,
|
|
|
|
'project_id'=>$this->user['project_id'],
|
|
|
|
]);
|
|
|
|
$TemplateInfo['html'] = preg_replace('/<style id="vvvebjs-styles">(.*?)<\/style>/s', $TemplateInfo['main_css'], $TemplateInfo['html']);
|
|
|
|
$TemplateInfo['html'] = preg_replace('/<main\b[^>]*>(.*?)<\/main>/s',$TemplateInfo['main_html'] , $TemplateInfo['html']);
|
|
|
|
$TemplateInfo['html'] = $this->getHeadFooter($TemplateInfo['html']);
|
|
|
|
}
|
|
|
|
if($this->param['source'] == $this->model::SOURCE_HOME){//首页
|
|
|
|
$TemplateInfo = $this->homeHtml($info,$this->param['source'],$this->param['source_id']);
|
|
|
|
}
|
|
|
|
if($this->param['source'] == $this->model::SOURCE_PRODUCT){//产品页
|
|
|
|
$TemplateInfo = $this->productHtml($info,$this->param['source'],$this->param['source_id']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $this->success($TemplateInfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :根据参数获取数据详情
|
|
|
|
* @name :webTemplateInfo
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/7/25 16:41
|
|
|
|
*/
|
|
|
|
public function webTemplateInfo($template_id,$source,$source_id){
|
|
|
|
//查看当前模板是否已编辑保存web_template
|
|
|
|
$TemplateInfo = $this->model->read([
|
|
|
|
'template_id'=>$template_id,
|
|
|
|
'source'=>$source,
|
|
|
|
'project_id'=>$this->user['project_id'],
|
|
|
|
'source_id'=>$source_id,
|
|
|
|
]);
|
|
|
|
return $this->success($TemplateInfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :处理首页数据
|
|
|
|
* @name :homeHtml
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/7/25 16:36
|
|
|
|
*/
|
|
|
|
public function homeHtml($info,$source,$source_id){
|
|
|
|
//查看当前模板是否已编辑保存web_template
|
|
|
|
$TemplateInfo = $this->webTemplateInfo($info['template_id'],$source,$source_id);
|
|
|
|
if($TemplateInfo === false){
|
|
|
|
//获取模板详情
|
|
|
|
$ATemplateModel = new Template();
|
|
|
|
$TemplateInfo = $ATemplateModel->read(['id'=>$info['template_id']]);
|
|
|
|
}
|
|
|
|
$TemplateInfo['html'] = $this->getHeadFooter($TemplateInfo['html']);
|
|
|
|
return $this->success($TemplateInfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :处理产品页数据
|
|
|
|
* @name :ProductHtml
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @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('请先装修首页');
|
|
|
|
}
|
|
|
|
$html = preg_replace('/<style id="vvvebjs-styles">(.*?)<\/style>/s', "<style id='vvvebjs-styles'></style>", $homeTemplateInfo['html']);
|
|
|
|
$html = preg_replace('/<main\b[^>]*>(.*?)<\/main>/s', "<main></main>", $html);
|
|
|
|
}else{
|
|
|
|
$homeTemplateInfo = $this->webTemplateInfo($info['template_id'],1,0);
|
|
|
|
if($homeTemplateInfo === false){
|
|
|
|
$this->fail('请先装修首页');
|
|
|
|
}
|
|
|
|
$html = preg_replace('/<style id="vvvebjs-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);
|
|
|
|
}
|
|
|
|
|
|
...
|
...
|
@@ -140,14 +166,7 @@ class BTemplateLogic extends BaseLogic |
|
|
|
*/
|
|
|
|
public function templateSave(){
|
|
|
|
//查询当前模版是否已保存
|
|
|
|
$info = $this->model->read(
|
|
|
|
[
|
|
|
|
'project_id'=>$this->user['project_id'],
|
|
|
|
'source'=>$this->param['source'] ?? 1,
|
|
|
|
'source_id'=>$this->param['source_id'] ?? 0,
|
|
|
|
'template_id'=>$this->param['template_id'],
|
|
|
|
]
|
|
|
|
);
|
|
|
|
$info = $this->webTemplateInfo($this->param['template_id'],$this->param['source'],$this->param['source_id']);
|
|
|
|
if($info === false){
|
|
|
|
//字符串截取
|
|
|
|
$this->StringProcessing();
|
|
...
|
...
|
@@ -179,12 +198,11 @@ class BTemplateLogic extends BaseLogic |
|
|
|
//同步数据
|
|
|
|
$this->param['name'] = $TemplateInfo['name'];
|
|
|
|
$this->param['image'] = $TemplateInfo['image'];
|
|
|
|
if($this->param['source'] == 1){
|
|
|
|
if($this->param['source'] == 1){//首页
|
|
|
|
$this->param['html'] = characterTruncation($this->param['html'],'/<style id="vvvebjs-header">(.*?)<\/footer>/s');
|
|
|
|
}else{
|
|
|
|
$this->param['html'] = $this->param['main_html'];
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
...
|
...
|
|