<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="X-UA-Compatible" content="IE=Edge">
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>商家管理后台</title>
	<link type="image/x-icon" href="{webroot:favicon.ico}" rel="icon">
	{js:jquery}
	{js:dialog}
	{js:form}
	{js:artTemplate}
	{js:validate}
	{js:cookie}
	<script type='text/javascript' src="{theme:javascript/html5.js}"></script>
	<!--[if lt IE 9]>
	<link rel="stylesheet" href="{skin:css/ie.css}" type="text/css" media="screen" />
	<![endif]-->
	<link rel="stylesheet" href="{skin:css/admin.css}" type="text/css" media="screen" />
	<script type='text/javascript' src="{webroot:public/javascript/public.js}"></script>
	{set:$seller_id = $this->seller['seller_id'];$seller_name = $this->seller['seller_name'];}
</head>

<body>
	<!--头部 开始-->
	<header id="header">
		<nav class="navbar">
			<div class="container-fluid">
				<div class="navbar-holder d-flex align-items-center justify-content-between">
					<div class="navbar-header">
						<h1 class="site_title">
						    <a href="{url:/seller/index}">{$this->_siteConfig->name}商家管理</a>
						</h1>
					</div>

					<ul class="nav-menu list-unstyled d-flex flex-md-row align-items-md-center">
						<li class="nav-item"><a class="nav-link" href="{url:}" target="_blank">网站首页</a></li>
						<li class="nav-item"><a class="nav-link" href="{url:/site/home/id/$seller_id}" target="_blank">商家主页</a></li>
						<li class="nav-item"><a class="nav-link" href="{url:/systemseller/logout}">退出登录</a></li>
					</ul>
				</div>
			</div>
		</nav>
	</header>
	<!--头部 结束-->

	<div class="page-content d-flex align-items-stretch">
		<!--侧边栏菜单 开始-->
		<nav id="sidebar" class="side-navbar">
			<ul class="list-unstyled">
				{foreach:items=menuSeller::init()}
				<li>
				    <a href="#{$key}" aria-expanded="false" data-toggle="collapse" name="menuItems" title="{$key}">
				        <i class=""></i> {$key}
				    </a>

					<ul id="{$key}" name="leftMenu" class="collapse list-unstyled" data-parent="#sidebar">
						{foreach:items=$item key=$moreKey item=$moreValue}
						<li><a href="{url:$moreKey}">{$moreValue}</a></li>
						{/foreach}
					</ul>
				</li>
				{/foreach}
			</ul>
		</nav>
		<!--侧边栏菜单 结束-->

		<!--主体内容 开始-->
		<section class="content-inner">
			{viewcontent}
		</section>
		<!--主题内容 结束-->
	</div>

	<script src="{webroot:public/javascript/twitter-bootstrap/4.1.3/js/bootstrap.bundle.min.js}"></script>
	<script src="{webroot:public/javascript/twitter-bootstrap/4.1.3/js/bootstrap.min.js}"></script>

	<script type="text/javascript">
	//菜单图片ICO配置
	function menuIco(val)
	{
		var icoConfig = {
			"统计结算模块" : "fa fa-bar-chart-o",
			"商品模块" : "fa fa-inbox",
			"订单模块" : "fa fa-file-text",
			"营销模块" : "fa fa-bullhorn",
			"配置模块" : "fa fa-gears"
		};
		return icoConfig[val] ? icoConfig[val] : "fa fa-list";
	}

	$("[name='menuItems']").each(function()
	{
		$(this).find("i").addClass(menuIco($(this).attr('title')));
	});

    //兼容IE系列
    $("[name='leftMenu'] [href^='javascript:']").each(function(i)
    {
    	var fun = $(this).attr('href').replace("javascript:","");
    	$(this).attr('href','javascript:void(0)');
    	$(this).on("click",function(){eval(fun)});
    });

    //重置容器高度
    function resizeContentHeight()
    {
        var winHeight     = $(window).height();
        var contentHeight = $('.page-content').outerHeight();
        var finnalHeight  = winHeight >= contentHeight ? winHeight : contentHeight;
        $('.page-content').css('height',finnalHeight);
        $('#sidebar').css('height',winHeight - 75);
    }

    //窗口大小调整触发
    window.onresize = resizeContentHeight;
    jQuery(function()
    {
        resizeContentHeight();
    });

    //获取左侧菜单项
    function matchLeftMenu(leftItem)
    {
        var matchObject = $('[name="leftMenu"]>li a[href="'+leftItem+'"]');
        if(matchObject.length > 0)
        {
            $.cookie('lastUrl', leftItem);
            return matchObject;
        }

        var lastUrl = $.cookie('lastUrl');
        if(lastUrl)
        {
            return $('[name="leftMenu"]>li a[href="'+lastUrl+'"]');
        }
        return null;
    }

    //左边栏菜单高亮
    var leftItem   = "{echo:IUrl::getUri()}";
    var matchObject = matchLeftMenu(leftItem);
    if(matchObject)
    {
        matchObject.parent().addClass('active').parent().collapse("show");
    }
	</script>
</body>
</html>