作者 lyh

gx

@@ -671,11 +671,9 @@ class BTemplateLogic extends BaseLogic @@ -671,11 +671,9 @@ class BTemplateLogic extends BaseLogic
671 { 671 {
672 //定义数据结构 672 //定义数据结构
673 $data = $this->model->product_type; 673 $data = $this->model->product_type;
674 - //产品,新闻,博客,一级分类数据  
675 - $map = ['pid'=>0, 'project_id'=>$this->user['project_id']];  
676 - $productCategory = Category::where($map)->get();  
677 - $newCategory = NewsCategory::where($map)->get();  
678 - $blogCategory = BlogCategory::where($map)->get(); 674 + $productCategory = $this->getCategoryList((new Category()));
  675 + $newCategory = $this->getCategoryList((new NewsCategory()));
  676 + $blogCategory = $this->getCategoryList((new BlogCategory()));
679 if (!empty($productCategory)){ 677 if (!empty($productCategory)){
680 foreach ($productCategory as $item){$data["products"]["category"][] =$item;} 678 foreach ($productCategory as $item){$data["products"]["category"][] =$item;}
681 } 679 }
@@ -690,6 +688,26 @@ class BTemplateLogic extends BaseLogic @@ -690,6 +688,26 @@ class BTemplateLogic extends BaseLogic
690 } 688 }
691 689
692 /** 690 /**
  691 + * @remark :获取1级+2级
  692 + * @name :getCategoryList
  693 + * @author :lyh
  694 + * @method :post
  695 + * @time :2023/12/20 10:26
  696 + */
  697 + public function getCategoryList($categoryModel){
  698 + $data = array();
  699 + $list = $categoryModel->list(['pid'=>0,'status'=>1]);
  700 + foreach ($list as $v){
  701 + $data[] = $v;
  702 + $son_list = $categoryModel->list(['pid'=>$v['id'],'status'=>1]);
  703 + foreach ($son_list as $v1){
  704 + $data[] = $v1;
  705 + }
  706 + }
  707 + return $this->success($data);
  708 + }
  709 +
  710 + /**
693 * @remark :保存html 711 * @remark :保存html
694 * @name :savePublicTemplateHtml 712 * @name :savePublicTemplateHtml
695 * @author :lyh 713 * @author :lyh