|
...
|
...
|
@@ -42,51 +42,17 @@ class VisualizationLogic extends BaseLogic |
|
|
|
* @time :2023/11/17 14:44
|
|
|
|
*/
|
|
|
|
public function getVisualizationInfo(){
|
|
|
|
$data = $this->getSource($this->param['type']);
|
|
|
|
$source = $data['source'];
|
|
|
|
$source_id = $data['source_id'];
|
|
|
|
$type = $this->getType($source,$source_id);
|
|
|
|
$typeArray = [BTemplate::TYPE_ONE,BTemplate::TYPE_THREE,BTemplate::TYPE_FIVE,BTemplate::TYPE_SEVEN];//单页数据
|
|
|
|
if(in_array($type,$typeArray)){
|
|
|
|
$bTemplateModel = new BTemplate();
|
|
|
|
$info = $bTemplateModel->read(['source'=>$source,'source_id'=>$source_id,'template_id'=>0]);
|
|
|
|
if($info === false){
|
|
|
|
$html = '';
|
|
|
|
}else{
|
|
|
|
$html = $info['html'];
|
|
|
|
}
|
|
|
|
}else{//模块数据
|
|
|
|
$bTemplateMainModel = new BTemplateMain();
|
|
|
|
$info = $bTemplateMainModel->read(['type'=>$type]);
|
|
|
|
if($info === false){
|
|
|
|
$html = '';
|
|
|
|
}else{
|
|
|
|
$html = $info['main_html'];
|
|
|
|
}
|
|
|
|
$bTemplateMainModel = new BTemplateMain();
|
|
|
|
$info = $bTemplateMainModel->read(['type'=>$this->param['type']]);
|
|
|
|
if($info === false){
|
|
|
|
$html = '';
|
|
|
|
}else{
|
|
|
|
$html = $info['main_html'];
|
|
|
|
}
|
|
|
|
return $this->success(['html'=>$html]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :根据type获取source类型
|
|
|
|
* @name :getSource
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/12/6 11:25
|
|
|
|
*/
|
|
|
|
public function getSource($type){
|
|
|
|
$source_id = 0;
|
|
|
|
if ($type == BTemplate::TYPE_TWO){$source = BTemplate::SOURCE_PRODUCT;$source_id = 1;
|
|
|
|
}elseif ($type == BTemplate::TYPE_THREE){$source = BTemplate::SOURCE_PRODUCT;
|
|
|
|
}elseif ($type == BTemplate::TYPE_FOUR){$source = BTemplate::SOURCE_BLOG;$source_id = 1;
|
|
|
|
}elseif ($type == BTemplate::TYPE_FIVE){$source = BTemplate::SOURCE_BLOG;
|
|
|
|
}elseif ($type == BTemplate::TYPE_SIX){$source = BTemplate::SOURCE_NEWS;$source_id = 1;
|
|
|
|
}elseif ($type == BTemplate::TYPE_SEVEN){$source = BTemplate::SOURCE_NEWS;
|
|
|
|
}else{$source = BTemplate::SOURCE_HOME;}
|
|
|
|
return ['source'=>$source,'source_id'=>$source_id];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :保存定制html
|
|
|
|
* @name :saveHtml
|
|
|
|
* @author :lyh
|
|
...
|
...
|
@@ -95,36 +61,18 @@ class VisualizationLogic extends BaseLogic |
|
|
|
*/
|
|
|
|
public function saveVisualization(){
|
|
|
|
try {
|
|
|
|
$sourceData = $this->getSource($this->param['type']);
|
|
|
|
$source = $sourceData['source'];
|
|
|
|
$source_id = $sourceData['source_id'];
|
|
|
|
$type = $this->param['type'];
|
|
|
|
$typeArray = [BTemplate::TYPE_ONE,BTemplate::TYPE_THREE,BTemplate::TYPE_FIVE,BTemplate::TYPE_SEVEN];//所有列表页+首页
|
|
|
|
if(in_array($type,$typeArray)){
|
|
|
|
$bTemplateModel = new BTemplate();
|
|
|
|
$templateInfo = $bTemplateModel->read(['source'=>$source,'source_id'=>$source_id,'template_id'=>0]);
|
|
|
|
if($templateInfo === false){
|
|
|
|
$data = [
|
|
|
|
'html'=>$this->param['html'], 'project_id'=>$this->user['project_id'],
|
|
|
|
'source'=>$source, 'source_id'=>$source_id,
|
|
|
|
];
|
|
|
|
$bTemplateModel->add($data);
|
|
|
|
}else{
|
|
|
|
$bTemplateModel->edit(['html'=>$this->param['html']],['id'=>$templateInfo['id']]);
|
|
|
|
}
|
|
|
|
}else{//模块数据
|
|
|
|
$bTemplateMainModel = new BTemplateMain();
|
|
|
|
$mainInfo = $bTemplateMainModel->read(['type'=>$type]);
|
|
|
|
if($mainInfo === false){
|
|
|
|
$mainData = [
|
|
|
|
'project_id'=>$this->user['project_id'],
|
|
|
|
'type'=>$type,
|
|
|
|
'main_html'=>$this->param['html']
|
|
|
|
];
|
|
|
|
$bTemplateMainModel->add($mainData);
|
|
|
|
}else{
|
|
|
|
$bTemplateMainModel->edit(['main_html'=>$this->param['html']],['id'=>$mainInfo['id']]);
|
|
|
|
}
|
|
|
|
$bTemplateMainModel = new BTemplateMain();
|
|
|
|
$mainInfo = $bTemplateMainModel->read(['type'=>$type]);
|
|
|
|
if($mainInfo === false){
|
|
|
|
$mainData = [
|
|
|
|
'project_id'=>$this->user['project_id'],
|
|
|
|
'type'=>$type,
|
|
|
|
'main_html'=>$this->param['html']
|
|
|
|
];
|
|
|
|
$bTemplateMainModel->add($mainData);
|
|
|
|
}else{
|
|
|
|
$bTemplateMainModel->edit(['main_html'=>$this->param['html']],['id'=>$mainInfo['id']]);
|
|
|
|
}
|
|
|
|
}catch (\Exception $e){
|
|
|
|
$this->fail('系统错误,请联系管理员');
|
...
|
...
|
|