作者 lyh

gx

@@ -89,22 +89,48 @@ class BTemplateLogic extends BaseLogic @@ -89,22 +89,48 @@ class BTemplateLogic extends BaseLogic
89 */ 89 */
90 public function getTemplateHtml(){ 90 public function getTemplateHtml(){
91 $settingTemplateInfo = $this->getSettingTemplate();//模版详情 91 $settingTemplateInfo = $this->getSettingTemplate();//模版详情
92 - 92 + $is_customized = $this->watchProjectIsCustomized();//查看是否为定制项目
93 93
94 } 94 }
95 95
96 /** 96 /**
97 - * @remark :查看项目是否定制 97 + * @remark :处理定制项目
98 * @name :watchProjectIsCustomized 98 * @name :watchProjectIsCustomized
99 * @author :lyh 99 * @author :lyh
100 * @method :post 100 * @method :post
101 * @time :2023/12/13 10:55 101 * @time :2023/12/13 10:55
102 */ 102 */
103 - public function watchProjectIsCustomized(){  
104 - if($this->user['is_customized'] == Project::){ 103 + public function watchProjectIsCustomized($source,$source_id){
  104 + //定制项目
  105 + if($this->user['is_customized'] == Project::CUSTOMIZED_ONE){
  106 + $type = $this->getCustomizedType($source,$source_id);//获取定制界面类型
  107 + //查看当前页面是否定制,是否开启可视化
  108 + $page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面
  109 + if(in_array($type,$page_array)){//是定制界面
  110 + return $this->getVisualizationHtml($type);
  111 + }
  112 + }
  113 + }
105 114
  115 + /**
  116 + * @remark :定制界面根据source+source_id获取type类型
  117 + * @name :getType
  118 + * @author :lyh
  119 + * @method :post
  120 + * @time :2023/11/16 11:20
  121 + */
  122 + public function getCustomizedType($source,$source_id){
  123 + $type = BTemplate::TYPE_ONE;
  124 + if($source == BTemplate::SOURCE_PRODUCT){
  125 + if($source_id == 0){$type = BTemplate::TYPE_THREE;}else{$type = BTemplate::TYPE_TWO;}
106 } 126 }
107 - $this->user['is_customized'] 127 + if($source == BTemplate::SOURCE_BLOG){
  128 + if($source_id == 0){$type = BTemplate::TYPE_FIVE;}else{$type = BTemplate::TYPE_FOUR;}
  129 + }
  130 + if($source == BTemplate::SOURCE_NEWS){
  131 + if($source_id == 0){$type = BTemplate::TYPE_SEVEN;}else{$type = BTemplate::TYPE_SIX;}
  132 + }
  133 + return $type;
108 } 134 }
109 135
110 /** 136 /**
@@ -42,51 +42,17 @@ class VisualizationLogic extends BaseLogic @@ -42,51 +42,17 @@ class VisualizationLogic extends BaseLogic
42 * @time :2023/11/17 14:44 42 * @time :2023/11/17 14:44
43 */ 43 */
44 public function getVisualizationInfo(){ 44 public function getVisualizationInfo(){
45 - $data = $this->getSource($this->param['type']);  
46 - $source = $data['source'];  
47 - $source_id = $data['source_id'];  
48 - $type = $this->getType($source,$source_id);  
49 - $typeArray = [BTemplate::TYPE_ONE,BTemplate::TYPE_THREE,BTemplate::TYPE_FIVE,BTemplate::TYPE_SEVEN];//单页数据  
50 - if(in_array($type,$typeArray)){  
51 - $bTemplateModel = new BTemplate();  
52 - $info = $bTemplateModel->read(['source'=>$source,'source_id'=>$source_id,'template_id'=>0]);  
53 - if($info === false){  
54 - $html = '';  
55 - }else{  
56 - $html = $info['html'];  
57 - }  
58 - }else{//模块数据  
59 - $bTemplateMainModel = new BTemplateMain();  
60 - $info = $bTemplateMainModel->read(['type'=>$type]);  
61 - if($info === false){  
62 - $html = '';  
63 - }else{  
64 - $html = $info['main_html'];  
65 - } 45 + $bTemplateMainModel = new BTemplateMain();
  46 + $info = $bTemplateMainModel->read(['type'=>$this->param['type']]);
  47 + if($info === false){
  48 + $html = '';
  49 + }else{
  50 + $html = $info['main_html'];
66 } 51 }
67 return $this->success(['html'=>$html]); 52 return $this->success(['html'=>$html]);
68 } 53 }
69 54
70 /** 55 /**
71 - * @remark :根据type获取source类型  
72 - * @name :getSource  
73 - * @author :lyh  
74 - * @method :post  
75 - * @time :2023/12/6 11:25  
76 - */  
77 - public function getSource($type){  
78 - $source_id = 0;  
79 - if ($type == BTemplate::TYPE_TWO){$source = BTemplate::SOURCE_PRODUCT;$source_id = 1;  
80 - }elseif ($type == BTemplate::TYPE_THREE){$source = BTemplate::SOURCE_PRODUCT;  
81 - }elseif ($type == BTemplate::TYPE_FOUR){$source = BTemplate::SOURCE_BLOG;$source_id = 1;  
82 - }elseif ($type == BTemplate::TYPE_FIVE){$source = BTemplate::SOURCE_BLOG;  
83 - }elseif ($type == BTemplate::TYPE_SIX){$source = BTemplate::SOURCE_NEWS;$source_id = 1;  
84 - }elseif ($type == BTemplate::TYPE_SEVEN){$source = BTemplate::SOURCE_NEWS;  
85 - }else{$source = BTemplate::SOURCE_HOME;}  
86 - return ['source'=>$source,'source_id'=>$source_id];  
87 - }  
88 -  
89 - /**  
90 * @remark :保存定制html 56 * @remark :保存定制html
91 * @name :saveHtml 57 * @name :saveHtml
92 * @author :lyh 58 * @author :lyh
@@ -95,36 +61,18 @@ class VisualizationLogic extends BaseLogic @@ -95,36 +61,18 @@ class VisualizationLogic extends BaseLogic
95 */ 61 */
96 public function saveVisualization(){ 62 public function saveVisualization(){
97 try { 63 try {
98 - $sourceData = $this->getSource($this->param['type']);  
99 - $source = $sourceData['source'];  
100 - $source_id = $sourceData['source_id'];  
101 $type = $this->param['type']; 64 $type = $this->param['type'];
102 - $typeArray = [BTemplate::TYPE_ONE,BTemplate::TYPE_THREE,BTemplate::TYPE_FIVE,BTemplate::TYPE_SEVEN];//所有列表页+首页  
103 - if(in_array($type,$typeArray)){  
104 - $bTemplateModel = new BTemplate();  
105 - $templateInfo = $bTemplateModel->read(['source'=>$source,'source_id'=>$source_id,'template_id'=>0]);  
106 - if($templateInfo === false){  
107 - $data = [  
108 - 'html'=>$this->param['html'], 'project_id'=>$this->user['project_id'],  
109 - 'source'=>$source, 'source_id'=>$source_id,  
110 - ];  
111 - $bTemplateModel->add($data);  
112 - }else{  
113 - $bTemplateModel->edit(['html'=>$this->param['html']],['id'=>$templateInfo['id']]);  
114 - }  
115 - }else{//模块数据  
116 - $bTemplateMainModel = new BTemplateMain();  
117 - $mainInfo = $bTemplateMainModel->read(['type'=>$type]);  
118 - if($mainInfo === false){  
119 - $mainData = [  
120 - 'project_id'=>$this->user['project_id'],  
121 - 'type'=>$type,  
122 - 'main_html'=>$this->param['html']  
123 - ];  
124 - $bTemplateMainModel->add($mainData);  
125 - }else{  
126 - $bTemplateMainModel->edit(['main_html'=>$this->param['html']],['id'=>$mainInfo['id']]);  
127 - } 65 + $bTemplateMainModel = new BTemplateMain();
  66 + $mainInfo = $bTemplateMainModel->read(['type'=>$type]);
  67 + if($mainInfo === false){
  68 + $mainData = [
  69 + 'project_id'=>$this->user['project_id'],
  70 + 'type'=>$type,
  71 + 'main_html'=>$this->param['html']
  72 + ];
  73 + $bTemplateMainModel->add($mainData);
  74 + }else{
  75 + $bTemplateMainModel->edit(['main_html'=>$this->param['html']],['id'=>$mainInfo['id']]);
128 } 76 }
129 }catch (\Exception $e){ 77 }catch (\Exception $e){
130 $this->fail('系统错误,请联系管理员'); 78 $this->fail('系统错误,请联系管理员');