/** * date:2020/02/27 * author:Mr.Chung * version:2.0 * description:layuimini 菜单框架扩展 */ layui.define(["element","laytpl" ,"jquery"], function (exports) { var element = layui.element, $ = layui.$, laytpl = layui.laytpl, layer = layui.layer; var miniMenu = { /** * 菜单初始化 * @param options.menuList 菜单数据信息 * @param options.multiModule 是否开启多模块 * @param options.menuChildOpen 是否展开子菜单 */ render: function (options) { options.menuList = options.menuList || []; options.multiModule = options.multiModule || false; options.menuChildOpen = options.menuChildOpen || false; console.log(options.menuList) if (options.multiModule) { console.log(options.menuList) miniMenu.renderMultiModule(options.menuList, options.menuChildOpen); } else { miniMenu.renderSingleModule(options.menuList, options.menuChildOpen); } miniMenu.listen(); }, /** * 单模块 * @param menuList 菜单数据 * @param menuChildOpen 是否默认展开 */ renderSingleModule: function (menuList, menuChildOpen) { console.log(menuList) menuList = menuList || []; var leftMenuHtml = '', childOpenClass = '', leftMenuCheckDefault = 'layui-this'; var me = this ; if (menuChildOpen) childOpenClass = ' layui-nav-itemed'; leftMenuHtml = this.renderLeftMenu(menuList,{ childOpenClass:childOpenClass }) ; $('.layui-layout-body').addClass('layuimini-single-module'); //单模块标识 $('.layuimini-header-menu').remove(); $('.layuimini-menu-left').html(leftMenuHtml); element.init(); }, /** * 渲染一级菜单 */ compileMenu: function (menu, isSub) { var menuHtml = '