
layui.$(function () {
    // 从本地存储中获得最后访问记录
    var localAdmin = layui.data('layuiAdmin');
    if(localAdmin.current_url){
        layui.$("#zz-iframe").attr("src", localAdmin.current_url);
        //高亮显示左侧菜单
        layui.$('#LAY-system-side-menu a').each(function () {
            var that=layui.$(this);
            if(that.attr('href')==localAdmin.current_url){
                that.addClass('layui-this');
                that.parents('.layui-nav-item').addClass('layui-nav-itemed');
                return false;
            }
        });
    }
    else{
        layui.$('#LAY-system-side-menu a:eq(0)').addClass('layui-this').parents('.layui-nav-item').addClass('layui-nav-itemed');
        layui.$("#zz-iframe").attr("src", "?s=index/main.html");
    }


    layui.$('#LAY-system-side-menu a').click(function () {
        var target=layui.$(this).attr('href');
        if(target){
            layui.$("#zz-iframe").attr("src", target);
            //记录当前访问的url.
            layui.data('layuiAdmin', {
                key: 'current_url'
                ,value: target
            });
        }
        return false;
    });

    //用来处理弹出的框架里的,服务端返回的信息
    window.pageAction=function(msg,url,wait){
        layer.msg(msg,{icon: 7,time:wait*1000},function () {
            if(url=='javascript:history.back(-1);'){
                return;
            }
            layui.$("#zz-iframe").attr("src", url);
            //记录当前访问的url.
            layui.data('layuiAdmin', {
                key: 'current_url'
                ,value: url
            });
        });
    }
});