作者 lyh

gx

... ... @@ -697,18 +697,61 @@ class BTemplateLogic extends BaseLogic
public function getModuleTypes(){
$data['module'] = ['默认','产品','新闻','博客','产品分类'];
$data = [
['id'=>'0',"name"=>'默认','category'=>[["id"=>"all", "title"=>"全部"], ["id"=>"hot", "title"=>"热销产品",], ["id"=>"recommend", "title"=>"推荐产品",]]],
['id'=>'1',"name"=>'产品','category'=>[]],
['id'=>'2',"name"=>'新闻','category'=>[]],
['id'=>'3',"name"=>'博客','category'=>[]],
['id'=>'0',"name"=>'默认','category'=>[]],
['id'=>'1',"name"=>'产品','category'=>[["id"=>"all", "title"=>"全部"], ["id"=>"hot", "title"=>"热销产品",], ["id"=>"recommend", "title"=>"推荐产品"]]],
['id'=>'2',"name"=>'新闻','category'=>[["id"=>"all", "name"=>"全部",], ["id"=>"new", "name"=>"最新"]]],
['id'=>'3',"name"=>'博客','category'=>[["id"=>"all", "name"=>"全部",], ["id"=>"new", "name"=>"最新"]]],
['id'=>'4','name'=>'产品分类','category'=>[]],
];
$data = $this->handleCategory($data);
//获取当前项目的扩展模块
$moduleModel = new CustomModule();
$moduleList = $moduleModel->list(['status'=>0]);
foreach ($moduleList as $v){
$data[] = ['id'=>'custom-'.$v['id'],'name'=>$v['name'],'category'=>[]];
$data[] = ['id'=>'custom-'.$v['id'],'name'=>$v['name'],'category'=>[["id"=>"all", "name"=>"全部",], ["id"=>"new", "name"=>"最新"]]];
}
}
/**
* @remark :处理默认分类
* @name :handleCategory
* @author :lyh
* @method :post
* @time :2023/12/21 18:31
*/
public function handleCategory($data){
foreach ($data as $key => $values){
switch ($values['name']){
case '产品':
$productCategory = $this->getCategoryList((new Category()),1);
if(!empty($productCategory)){
foreach ($productCategory as $item){
$values['category'][] = $item;
}
}
break;
case '新闻':
$newCategory = $this->getCategoryList((new NewsCategory()));
if(!empty($newCategory)){
foreach ($newCategory as $item){
$values['category'][] = $item;
}
}
break;
case '博客':
$blogCategory = $this->getCategoryList((new BlogCategory()));
if(!empty($blogCategory)){
foreach ($blogCategory as $item){
$values['category'][] = $item;
}
}
break;
default:
break;
}
}
return $this->success($data);
}
/**
... ...