1. // 递归:菜单分类显示
    2. public function levelList($table ='mvc_category', $id = 0,$data_list = [],$level=0){
    3. // 查询出来所有的一级
    4. $data = Db::table($table)->where([
    5. 'fid'=>$id
    6. ])->select();
    7. // 组装数据
    8. foreach($data as $k => $v){
    9. $data_list[$v['id']]['name'] = str_repeat('  ',$level).'|-'.$v['name'];
    10. $data_list[$v['id']]['id'] = $v['id'];
    11. $data_list[$v['id']]['fid'] = $v['fid'];
    12. if(isset($v['type'])){
    13. $data_list[$v['id']]['type'] = $v['type'];
    14. }
    15. if(isset($v['module'])){
    16. $data_list[$v['id']]['module'] = $v['module'];
    17. }
    18. $data_list[$v['id']]['level'] = $level;
    19. $data_list = $this->levelList($table,$v['id'],$data_list,$level+1);
    20. }
    21. return $data_list;
    22. }