application/core/manage/logic/MenuLogic.php
public function getMenuTree()
    {
        $menu = [
            'main_menu' => [],
            'sub_menu' => [],
            'sub_sub_menu' => []
        ];
        
        // 一级菜单
        $map = [
            'menu_pid' => 0
        ];
        $list = $this->model->where($map)
            ->order('menu_sort asc')
            ->select();
        
        $main_pids = [];
        foreach ($list as $vo) {
            $main_pids[] = $vo['id'];
            $menu['main_menu'][$vo['id']] = [
                'menu_id' => $vo['id'],
                'menu_name' => $vo['menu_name']
            ];
            $menu['sub_menu'][$vo['id']] = [];
        }
        
        // 二级菜单
        $map = [
            'menu_pid' => [
                'in',
                $main_pids
            ]
        ];
        $list = $this->model->where($map)
            ->order('menu_sort asc')
            ->select();
        
        $sub_pids = [];
        foreach ($list as $vo) {
            $sub_pids[] = $vo['id'];
            $menu['sub_menu'][$vo['menu_pid']][$vo['id']] = [
                'menu_id' => $vo['id'],
                'menu_name' => $vo['menu_name']
            ];
            $menu['sub_sub_menu'][$vo['id']] = [];
        }
        
        // 三级菜单
        $map = [
            'menu_pid' => [
                'in',
                $sub_pids
            ]
        ];
        $list = $this->model->where($map)
            ->order('menu_sort asc')
            ->select();
        
        $sub_pids = [];
        foreach ($list as $vo) {
            $sub_pids[] = $vo['id'];
            $menu['sub_sub_menu'][$vo['menu_pid']][$vo['id']] = [
                'menu_id' => $vo['id'],
                'menu_name' => $vo['menu_name']
            ];
        }
        
        return $menu;
    }
public function getMenuTree()
    {
        $menu = [
            'main_menu' => [],
            'sub_menu' => [],
            'sub_sub_menu' => []
        ];
        
        // 一级菜单
        $map = [
            'menu_pid' => 0
        ];
        $list = $this->model->where($map)
            ->order('menu_sort asc')
            ->select();
        
        $main_pids = [];
        foreach ($list as $vo) {
            $main_pids[] = $vo['id'];
            $menu['main_menu'][$vo['id']] = [
                'menu_id' => $vo['id'],
                'menu_name' => $vo['menu_name']
            ];
            $menu['sub_menu'][$vo['id']] = [];
        }
        
        // 二级菜单
        $map = [
            'menu_pid' => [
                'in',
                $main_pids
            ]
        ];
        $list = $this->model->where($map)
            ->order('menu_sort asc')
            ->select();
        
        $sub_pids = [];
        foreach ($list as $vo) {
            $sub_pids[] = $vo['id'];
            $menu['sub_menu'][$vo['menu_pid']][$vo['id']] = [
                'menu_id' => $vo['id'],
                'menu_name' => $vo['menu_name']
            ];
            $menu['sub_sub_menu'][$vo['id']] = [];
        }
        
        // 三级菜单
        $map = [
            'menu_pid' => [
                'in',
                $sub_pids
            ]
        ];
        $list = $this->model->where($map)
            ->order('menu_sort asc')
            ->select();
        
        $sub_pids = [];
        foreach ($list as $vo) {
            $sub_pids[] = $vo['id'];
            $menu['sub_sub_menu'][$vo['menu_pid']][$vo['id']] = [
                'menu_id' => $vo['id'],
                'menu_name' => $vo['menu_name']
            ];
        }
        
        return $menu;
    }
public function getMenuTree ( ) { $ menu = [ 'main_menu' => [ ] , 'sub_menu' => [ ] , 'sub_sub_menu' => [ ] ] ; // 一级菜单 $ map = [ 'menu_pid' => 0 ] ; $ list = $ this -> model -> where ( $ map ) -> order ( 'menu_sort asc' ) -> select ( ) ; $ main_pids = [ ] ; foreach ( $ list as $ vo ) { $ main_pids [ ] = $ vo [ 'id' ] ; $ menu [ 'main_menu' ] [ $ vo [ 'id' ] ] = [ 'menu_id' => $ vo [ 'id' ] , 'menu_name' => $ vo [ 'menu_name' ] ] ; $ menu [ 'sub_menu' ] [ $ vo [ 'id' ] ] = [ ] ; } // 二级菜单 $ map = [ 'menu_pid' => [ 'in' , $ main_pids ] ] ; $ list = $ this -> model -> where ( $ map ) -> order ( 'menu_sort asc' ) -> select ( ) ; $ sub_pids = [ ] ; foreach ( $ list as $ vo ) { $ sub_pids [ ] = $ vo [ 'id' ] ; $ menu [ 'sub_menu' ] [ $ vo [ 'menu_pid' ] ] [ $ vo [ 'id' ] ] = [ 'menu_id' => $ vo [ 'id' ] , 'menu_name' => $ vo [ 'menu_name' ] ] ; $ menu [ 'sub_sub_menu' ] [ $ vo [ 'id' ] ] = [ ] ; } // 三级菜单 $ map = [ 'menu_pid' => [ 'in' , $ sub_pids ] ] ; $ list = $ this -> model -> where ( $ map ) -> order ( 'menu_sort asc' ) -> select ( ) ; $ sub_pids = [ ] ; foreach ( $ list as $ vo ) { $ sub_pids [ ] = $ vo [ 'id' ] ; $ menu [ 'sub_sub_menu' ] [ $ vo [ 'menu_pid' ] ] [ $ vo [ 'id' ] ] = [ 'menu_id' => $ vo [ 'id' ] , 'menu_name' => $ vo [ 'menu_name' ] ] ; } return $ menu ; }
菜单树

@return array
菜单树