1.提交缺失的东西
This commit is contained in:
@ -39,7 +39,8 @@ class GoodsCategoryController extends BaseAdminController
|
|||||||
*/
|
*/
|
||||||
public function lists()
|
public function lists()
|
||||||
{
|
{
|
||||||
return $this->dataLists(new GoodsCategoryLists());
|
$category_tree = GoodsCategoryLogic::categoryThirdTree();
|
||||||
|
return $this->success('查询成功', $category_tree);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -17,6 +17,7 @@ namespace app\adminapi\logic;
|
|||||||
|
|
||||||
use app\common\model\GoodsCategory;
|
use app\common\model\GoodsCategory;
|
||||||
use app\common\logic\BaseLogic;
|
use app\common\logic\BaseLogic;
|
||||||
|
use app\common\service\UrlServer;
|
||||||
use think\facade\Db;
|
use think\facade\Db;
|
||||||
|
|
||||||
|
|
||||||
@ -69,7 +70,42 @@ class GoodsCategoryLogic extends BaseLogic
|
|||||||
->select()->toArray();
|
->select()->toArray();
|
||||||
return $lists;
|
return $lists;
|
||||||
}
|
}
|
||||||
|
public static function categoryThirdTree()
|
||||||
|
{
|
||||||
|
|
||||||
|
$lists = Db::name('goods_category')
|
||||||
|
->where(['del' => 0])
|
||||||
|
->order('id asc')
|
||||||
|
->column('id,name,pid,is_recommend,is_show,level,image,sort');
|
||||||
|
foreach ($lists as $k => $item){
|
||||||
|
$lists[$k]['image'] = UrlServer::getFileUrl($item['image']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$lists = linear_to_tree($lists);
|
||||||
|
|
||||||
|
foreach ($lists as $key => $list){
|
||||||
|
|
||||||
|
if(1 == $list['is_recommend']){
|
||||||
|
$sub = [];
|
||||||
|
foreach ($list['sub'] as $key1 => $sub1){
|
||||||
|
$sub1['is_recommend'] = 1;
|
||||||
|
|
||||||
|
|
||||||
|
foreach ($sub1['sub'] as $key2 => $sub2){
|
||||||
|
$sub1['sub'][$key2]['is_recommend'] = 1;
|
||||||
|
|
||||||
|
}
|
||||||
|
$sub[] = $sub1;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$lists[$key]['sub'] = $sub;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $lists;
|
||||||
|
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* @notes 编辑
|
* @notes 编辑
|
||||||
* @param array $params
|
* @param array $params
|
||||||
|
|||||||
Reference in New Issue
Block a user