作者 lyh

gx

@@ -81,22 +81,55 @@ class Demo extends Command @@ -81,22 +81,55 @@ class Demo extends Command
81 $settingInfo = $settingModel->read(['project_id'=>$project_id]); 81 $settingInfo = $settingModel->read(['project_id'=>$project_id]);
82 if($settingInfo !== false){ 82 if($settingInfo !== false){
83 $templateCommonModel = new BTemplateCommon(); 83 $templateCommonModel = new BTemplateCommon();
84 - $commonList = $templateCommonModel->list(['template_id'=>$settingModel['template_id']]); 84 + $commonList = $templateCommonModel->list(['id'=>1,'template_id'=>$settingModel['template_id'],'is_custom'=>0]);
85 if(!empty($commonList)){ 85 if(!empty($commonList)){
86 foreach ($commonList as $v){ 86 foreach ($commonList as $v){
87 - if($v['type'] == 1){//首页头部底部  
88 - //保存一次公共头+底  
89 -  
90 - }  
91 - //保存一次公共头部+底部+other信息  
92 - $bComTemplateModel = new BTemplateCom();  
93 - $param = ['template_id'=>$settingModel['template_id'],'common_type'=>BTemplate::COMMON_HEAD,'source'=>BTemplate::SOURCE_COM];  
94 - if($headInfo === false){  
95 - $headData = ['html'=>$settingModel['template_id']['head_html'], 'html_style'=>$templateInfo['head_css'], 'project_id'=>$project_id];  
96 - $bComTemplateModel->add(array_merge($condition,$headData)); 87 + $typeArr = [BTemplate::COMMON_HEAD, BTemplate::COMMON_FOOTER, BTemplate::COMMON_OTHER];
  88 + foreach ($typeArr as $type){
  89 + if($type == BTemplate::COMMON_HEAD){
  90 + $headData = [
  91 + 'project_id'=>$v['project_id'],
  92 + 'source'=>$v['type'] == 1 ? 99 : $v['type'],
  93 + 'common_type'=>BTemplate::COMMON_HEAD,
  94 + 'template_id'=>$v['template_id'],
  95 + 'html'=>$v['head_html'],
  96 + 'html_style'=>$v['head_css'],
  97 + 'is_custom'=>$v['is_custom'],
  98 + 'is_list'=>$v['list']
  99 + ];
  100 + $templateComModel = new BTemplateCom();
  101 + $templateComModel->add($headData);
  102 + }elseif ($type == BTemplate::COMMON_FOOTER){
  103 + $footerData = [
  104 + 'project_id'=>$v['project_id'],
  105 + 'source'=>$v['type'] == 1 ? 99 : $v['type'],
  106 + 'common_type'=>BTemplate::COMMON_FOOTER,
  107 + 'template_id'=>$v['template_id'],
  108 + 'html'=>$v['footer_html'],
  109 + 'html_style'=>$v['footer_css'],
  110 + 'is_custom'=>$v['is_custom'],
  111 + 'is_list'=>$v['is_list']
  112 + ];
  113 + $templateComModel = new BTemplateCom();
  114 + $templateComModel->add($footerData);
  115 + }elseif ($type == BTemplate::COMMON_OTHER){
  116 + $otherData = [
  117 + 'project_id'=>$v['project_id'],
  118 + 'source'=>$v['type'] == 1 ? 99 : $v['type'],
  119 + 'common_type'=>BTemplate::COMMON_OTHER,
  120 + 'template_id'=>$v['template_id'],
  121 + 'html'=>$v['other'],
  122 + 'html_style'=>null,
  123 + 'is_custom'=>$v['is_custom'],
  124 + 'is_list'=>$v['is_list']
  125 + ];
  126 + $templateComModel = new BTemplateCom();
  127 + $templateComModel->add($otherData);
  128 + }
97 } 129 }
98 } 130 }
99 } 131 }
100 } 132 }
  133 + return true;
101 } 134 }
102 } 135 }