{% load staticfiles %}
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>后台管理</title>
    <link rel="stylesheet" href="{% static '/lib/layui/css/layui.css' %}">
    <link rel="stylesheet" href="{% static '/lib/css/reset.css' %}">
    <link rel="stylesheet" href="{% static '/lib/font/fontIcon/iconfont.css' %}">
    <!-- <link rel="stylesheet" href="{% static '/lib/font-awesome/4.5.0/css/font-awesome.css' %}"> -->
    <link rel="stylesheet" href="{% static '/css/home.css' %}">
    <style>
        @charset "utf-8";
        /* 以下实际使用若已初始化可删除 .nav height父级需逐级设置为100%*/

        body,
        html {
            height: 100%;
            background: #fff;
        }

        body,
        ul {
            margin: 0;
            padding: 0
        }

        body {
            font: 14px "微软雅黑", "宋体", "Arial Narrow", HELVETICA;
            -webkit-text-size-adjust: 100%;
        }

        li {
            list-style: none
        }

        a {
            text-decoration: none;
        }

        /* 以上实际使用若已初始化可删除 */

        /* nav */

        .leftNav {
            position: absolute;
            top: 62px;
            bottom: 0px;
            background: #fff;
            transition: all .3s;
            box-shadow: 0px 6px 6px 1px #aaa;
            width: 220px;
        }

        .nav {
            width: 240px;
            height: 102%;
            background: #fff;
            transition: all .3s;
            float: left;
            padding-top: 5px;
        }

        .nav a {
            display: block;
            overflow: hidden;
            padding-left: 20px;
            line-height: 46px;
            height: 46px;
            max-height: 46px;
            color: #393939;
            transition: all .3s;
            font-weight: 700;
        }

        .nav-item>a>i:nth-child(1) {
            vertical-align: middle;
            font-size: 18px;
        }

        .nav a span {
            margin-left: 12px;
            vertical-align: middle;
        }

        .nav-item {
            position: relative;
        }

        .nav-item.nav-show {
            border-bottom: none;
        }

        .nav-item.nav-show.active {
            background: #2189be;
        }

        .nav-item ul {
            display: none;
            background: rgba(0, 0, 0, .1);
        }

        .nav-item.nav-show ul .active {
            background: #2189be;
        }

        .nav-item.nav-show ul .active>a {
            color: #fff;
        }

        .nav-item>a:before {
            content: "";
            position: absolute;
            left: 0px;
            width: 2px;
            height: 46px;
            background: #34A0CE;
            opacity: 0;
            transition: all .3s;
        }

        .nav .nav-icon {
            font-size: 20px;
            position: absolute;
            margin-left: -1px;
        }

        /*---------------------*/

        .nav-more {
            /* float: right; */
            position: absolute;
            left: 193px;
            font-size: 12px;
            transition: transform .3s;
        }

        /* 此处为导航右侧箭头 如果自定义iconfont 也需要替换*/

        /*---------------------*/

        .nav-show .nav-more {
            transform: rotate(90deg);
        }

        .nav-show {
            color: #ffffff;
            background: rgb(57, 172, 240);
        }

        .nav-item.nav-show>a,
        .nav-item.nav-show>a:hover {
            color: #fff;
        }

        .nav-mini .nav-item.nav-show>a {
            color: #393939;
        }

        .nav-item>a:hover {
            color: #23a3ee;
            background: rgba(127, 196, 236, 0.2);
        }

        .nav-show>a:before,
        .nav-item>a:hover:before {
            opacity: 1;
        }

        .nav-item li:hover a {
            color: #fff;
            background: rgba(127, 196, 236, 0.2);
        }

        .nav-mini .nav-item li:hover a {
            color: #23a3ee;
            background: rgba(127, 196, 236, 0.2);
        }

        .nav-mini .nav-item li.active:hover a {
            color: #fff;
        }

        /* nav-mini */

        .minLeftNav {
            width: 60px;
        }

        .nav-mini.nav {
            width: 80px;
        }

        .nav-mini.nav .nav-icon {
            /* margin-left:-2px; */
        }

        .nav-mini.nav .nav-item>a span {
            display: none;
        }

        .nav-mini.nav .nav-more {
            margin-right: -20px;
        }

        .nav-mini.nav .nav-item ul {
            position: absolute;
            top: 0px;
            left: 60px;
            width: 180px;
            z-index: 99;
            background: #fff;
            overflow: hidden;
        }

        .nav-mini.nav .nav-item:hover {
            background: rgba(127, 196, 236, 0.2);
        }

        .nav-mini.nav .nav-item.nav-show:hover {
            color: #ffffff;
            background: rgb(35, 163, 238);
        }

        .nav-mini.nav .nav-item:hover .nav-item a {
            color: #FFF;
        }

        .nav-mini.nav .nav-item:hover a:before {
            opacity: 1;
        }

        .nav-mini.nav .nav-item:hover ul {
            display: block;
        }

        /* beirong */

        .main-content {
            margin-left: 225px;
            transition: all .3s;
        }

        .main-content.content-mini {
            margin-left: 65px;
        }

        /*  */

        .leftNav {
            overflow: hidden;
        }

        .nav {
            overflow-x: scroll;
        }
    </style>
</head>

<body>
    <!-- 头部 -->
    <div class="header" id="navbar">
        <div class="logo">
            <img id="mini" src="{% static 'imgs/mini.png'%}" width="30"> 休闲农业旅游网
        </div>
        <div class="navigation">
            <ul class="layui-nav layui-bg-blue">
                <li class="layui-nav-item">
                    <a href="">控制台
                        <!-- <span class="layui-badge">9</span> -->
                    </a>
                </li>
                <li class="layui-nav-item">
                    <a href="">个人中心
                        <!-- <span class="layui-badge-dot"></span> -->
                    </a>
                </li>
                <li class="layui-nav-item" lay-unselect="">
                    <a href="javascript:;">
                        <img src="{{current_user.user_picture}}" class="layui-nav-img">
                        <span class="currUser" id="">{{current_user.username}}</span>
                    </a>
                    <dl class="layui-nav-child">
                        <dd>
                            <a href="modify_head" target="BoardRight">个人信息</a>
                        </dd>
                        <dd>
                            <a href="user_change_pwd" target="BoardRight">修改密码</a>
                        </dd>
                        <dd>
                            <a href="javascript:;">退了</a>
                        </dd>
                    </dl>
                </li>
            </ul>
        </div>
    </div>
    <!-- 下半部 -->
    <div class="main-container" id="main-container">
        <!-- 菜单栏 -->
        <div class="leftNav">
            <div class="nav">
                <div class="nav-top">
                    <!-- <div id="mini" style="border-bottom:1px solid rgba(255,255,255,.1)">
                        <img src="{% static 'imgs/dev/icon_110.png'%}">
                         <span>分类</span> 
                    </div> -->
                </div>

                <ul id="menu">

                </ul>
            </div>
        </div>
        <!-- 主题部分 -->
        <div class="main-content">
            <!-- 内容 -->
            <div class="iframeDiv">
                <iframe name="BoardRight" id="iframe-main" src="" width="100%" height="800px" frameborder="1"></iframe>
            </div>
        </div>
        <!-- banquan -->
        <!-- <div class="copyrightBox">
            <div>
                <p>
                    <a class="copyright" rel="nofollow" href="">版权信息</a>
                </p>
            </div>

        </div> -->
    </div>
    <!-- <a href="javascript:;" onclick="goUp()" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse display">
        <i class="ace-icon fa fa-angle-double-up icon-only bigger-110"></i>
    </a> -->

    <script src="{% static '/lib/js/jquery-2.1.4.min.js'%}"></script>
    <script src="{% static '/lib/layui/layui.js'%}"></script>
    <script src="{% static '/js/backstageNet/common.js'%}"></script>
    <!-- <script src="{% static '/js/backstageNet/home.js'%}"></script> -->
    <script>

            $.ajax({
                url: 'back_manage',
                type: 'post',
                data: {},
                // dataType: 'json',
                success: function (data) {
                    var navList = eval('('+data+')');
                    var navData = '';
                    for (var i = 0; i < navList.length; i++) {
                        if (navList[i].children && navList[i].children.length) {
                            navData += "<li class='nav-item'>";
                            navData += "<a href='javascript:;'><i class='iconfont'>" + navList[i].icon + "</i><span>" + navList[i].title + "</span>";
                            navData += "<i class='iconfont nav-more'>&#xe608;</i></a><ul>";
                            for (var w = 0; w < navList[i].children.length; w++) {
                                navData += "<li><a href='" + navList[i].children[w].url + " ' target=\"BoardRight\" ><span>" + navList[i].children[w].title + "</span></a></li>";
                                if (w == navList[i].children.length - 1) {
                                    navData += "</ul>"
                                }
                            }
                        } else {
                            if (i == 0) {
                                navData += "<li class='nav-item nav-show'>";
                            } else {
                                navData += "<li class='nav-item'>";
                            }
                            navData += "<a href='" + navList[i].url + "' target=\"BoardRight\" ><i class='iconfont'>" + navList[i].icon + "</i><span>" + navList[i].title + "</span>";
                            navData += "</a>";
                        }

                        navData += "</li>";
                    }
                    $('#menu').html(navData);
                    if (navList[0].children && navList[0].children.length) {
                        $('#iframe-main').attr('src',navList[0].children[0].url)                        
                    }else{
                        $('#iframe-main').attr('src',navList[0].url)                        
                    }

                    // nav收缩展开
                    $('#menu').on('click', '.nav-item>a', function () {
                        $('.layui-nav-child dd').removeClass('layui-this')
                        if (!$('.nav').hasClass('nav-mini')) { //不是小图标
                            if ($(this).next().length == 0) { //没有子元素
                                $('.nav-item').removeClass('nav-show');
                                $('.nav-item').children('ul').slideUp(300, function () {
                                    $(this).removeAttr("style");
                                });
                                $(this).parent('li').addClass('nav-show');
                            } else {
                                if ($(this).next().css('display') == "none") {
                                    //展开未展开
                                    $('.nav-item').children('ul').slideUp(300, function () {
                                        $(this).removeAttr("style");
                                    });
                                    $(this).next('ul').slideDown(300);
                                    $(this).parent('li').addClass('nav-show').siblings('li').removeClass('nav-show');
                                } else {
                                    //收缩已展开
                                    $(this).next('ul').slideUp(300, function () {
                                        $(this).removeAttr("style");
                                    });
                                    // $('.nav-item.nav-show').removeClass('nav-show');
                                }
                            }

                        } else { //小图标样式
                            // $('.nav-item').removeClass('nav-show');
                            // $(this).parent('li').addClass('nav-show');
                            if ($(this).next().length == 0) { //没有子元素
                                $('.nav-item').removeClass('nav-show');
                                $('.nav-item').children('ul').slideUp(300, function () {
                                    $(this).removeAttr("style");
                                });
                                $(this).parent('li').addClass('nav-show');
                            }
                        }
                    });
                    // 标志点击样式
                    $('#menu').on('click', '.nav-item>ul>li', function () {
                        if (!$('.nav').hasClass('nav-mini')) { //不是小图标
                            $('.layui-nav-child dd').removeClass('layui-this')
                        } else {
                            $('.nav-item').removeClass('nav-show');
                            $(this).parents('.nav-item').addClass('nav-show');
                        }
                        // $('.nav-item>ul>li').css('background', 'none')
                        $('.nav-item>ul>li').removeClass('active');
                        $(this).addClass('active');
                        // $(this).css('background', 'yellow')
                        //  	$(this).siblings().css('background','none')
                    })

                    // layer.tips('Hi，我是tips', '吸附元素选择器，如#id');
                    $('#menu').on('click', '.nav-item', function () {
                        if ($('.nav').hasClass('nav-mini')) { //小图标
                            $('.nav').removeClass('nav-mini');
                            $('.leftNav').removeClass('minLeftNav');
                            $('.main-content').removeClass('content-mini');
                            layui.use(['layer'], function () {
                                layer.closeAll('tips');

                            })
                        }

                    })


                    $('#menu').on('mouseenter', '.nav-item', function () {
                        if ($('.nav').hasClass('nav-mini')) { //小图标
                            var that = this;
                            var text = $(this).find('span').html();
                            layui.use(['layer'], function () {
                                layer.tips(text, that, {
                                    tips: [2, "#22a3ed"],
                                    time: 0
                                });
                            })
                        }
                    })
                    $(document).on('mouseleave', '.nav-mini', function () {
                        if ($('.nav').hasClass('nav-mini')) { //小图标
                            layui.use(['layer'], function () {
                                layer.closeAll('tips');

                            })
                        }

                    });

                    //nav-mini切换
                    $('#mini').on('click', function () {
                        if (!$('.nav').hasClass('nav-mini')) { //小图标格式  
                            $('.nav-item>ul').removeAttr("style");
                            $('.nav').addClass('nav-mini');
                            $('.leftNav').addClass('minLeftNav');
                            $('.main-content').addClass('content-mini');
                        } else {  //大图标格式
                            $('.nav').removeClass('nav-mini');
                            $('.leftNav').removeClass('minLeftNav');
                            $('.main-content').removeClass('content-mini');
                        }
                    });
                },
                error:function(type){
                    console.log(type)
                }
            })

    </script>
    <script>
        layui.use('element', function () {
            var element = layui.element;

            //一些事件监听
            element.on('tab(demo)', function (data) {
                console.log(data);
            });
        });

        scrollBar()
        window.onresize = scrollBar;
    </script>
</body>

</html>