$().ready(function () {
    check();
    hasBackManangePerm();
});

/**
 * sso 回话超时 页面嵌套问题处理
 */
function check() {
    window.setInterval(function () {
        $.ajax({
            cache: true,
            type: "GET",
            url: "/code",
            async: false,
            error: function (request) {
            },
            success: function (data) {
                if (!data) {
                    layer.alert('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;当前会话已超时，请重新登陆！', {
                        time: 5 * 1000,
                        btn: ['确认'],
                        btnAlign: 'c'
                        , success: function (layero, index) {
                            var timeNum = this.time / 1000, setText = function (start) {
                                layer.title((start ? timeNum : --timeNum) + ' 秒后关闭', index);
                            };
                            setText(!0);
                            this.timer = setInterval(setText, 1000);
                            if (timeNum <= 0) clearInterval(this.timer);
                        }
                        , end: function () {
                            clearInterval(this.timer);
                            location.reload();
                        }
                    });
                }
            }
        });
    }, 240000);
}

function hasBackManangePerm(){
    $.ajax({
        url: '/sys/user/hasBackManangePerm',
        success: function (data) {
           if(!data){
               $('#back_manange').hide();
           }
        }
    });

}