作者 lyh

gx

... ... @@ -89,22 +89,48 @@ class BTemplateLogic extends BaseLogic
*/
public function getTemplateHtml(){
$settingTemplateInfo = $this->getSettingTemplate();//模版详情
$is_customized = $this->watchProjectIsCustomized();//查看是否为定制项目
}
/**
* @remark :查看项目是否定制
* @remark :处理定制项目
* @name :watchProjectIsCustomized
* @author :lyh
* @method :post
* @time :2023/12/13 10:55
*/
public function watchProjectIsCustomized(){
if($this->user['is_customized'] == Project::){
public function watchProjectIsCustomized($source,$source_id){
//定制项目
if($this->user['is_customized'] == Project::CUSTOMIZED_ONE){
$type = $this->getCustomizedType($source,$source_id);//获取定制界面类型
//查看当前页面是否定制,是否开启可视化
$page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面
if(in_array($type,$page_array)){//是定制界面
return $this->getVisualizationHtml($type);
}
}
}
/**
* @remark :定制界面根据source+source_id获取type类型
* @name :getType
* @author :lyh
* @method :post
* @time :2023/11/16 11:20
*/
public function getCustomizedType($source,$source_id){
$type = BTemplate::TYPE_ONE;
if($source == BTemplate::SOURCE_PRODUCT){
if($source_id == 0){$type = BTemplate::TYPE_THREE;}else{$type = BTemplate::TYPE_TWO;}
}
$this->user['is_customized']
if($source == BTemplate::SOURCE_BLOG){
if($source_id == 0){$type = BTemplate::TYPE_FIVE;}else{$type = BTemplate::TYPE_FOUR;}
}
if($source == BTemplate::SOURCE_NEWS){
if($source_id == 0){$type = BTemplate::TYPE_SEVEN;}else{$type = BTemplate::TYPE_SIX;}
}
return $type;
}
/**
... ...
... ... @@ -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('系统错误,请联系管理员');
... ...