
function show_desktop() {
    $(".qmsoft_deskpage").hide();
    $('#rightMenu').hide();
}

function closeall() {
    art.dialog({
        content: '是否确定关闭所有窗口?',
        icon: 'error',
        zindex: '99999',
        ok: function() {
            var list = art.dialog.list;
            for (var i in list) {
                list[i].close();
            };
        },
        cancelVal: '关闭',
        cancel: true //为true等价于function(){}
    });
    $('#rightMenu').hide();
}
$("#desk_lock_btn").on("click", function() {
    //询问框
    layer.confirm('是否立即锁屏？', {
        btn: ['确定', '取消'],
        icon: 7
    }, function(index) {
        $.ajax({
            url: "/index.php/login/locks",
            data: {
                action: 'lock'
            },
            type: 'post',
            dataType: 'json',
            success: function(data) {
                if (data.code == '100') {
                    $(".qmsoft_lock").show();
                } else {
                    layer.msg('失败：' + data.msg, {
                        icon: 5,
                        zIndex: 9999999999,
                        time: 2000
                    });
                }
            },
            error: function(data) {
                layer.msg('失败：' + data.msg, {
                    icon: 5,
                    zIndex: 9999999999,
                    time: 2000
                });
            }
        });
        layer.close(index);
    });
});
$("#unlock_btn").on("click", function() {
    var unlock_pwd = $.trim($("#unlock_pwd").val());
    if (unlock_pwd == "") {
        layer.msg("请输入登录密码 ^_^ ", {
            icon: 5,
            anim: 5,
            zIndex: 9999999999,
            time: 2000
        });
        return false;
    }
    $.ajax({
        url: "/index.php/login/locks",
        data: {
            action: 'unlock',
            userpwd: unlock_pwd
        },
        type: 'post',
        dataType: 'json',
        success: function(data) {
            if (data.code == '100') {
                $(".qmsoft_lock").hide();
            } else {
                layer.msg('失败：' + data.msg, {
                    icon: 5,
                    zIndex: 9999999999,
                    time: 2000
                });
            }
        },
        error: function(data) {
            layer.msg('失败：' + data.msg, {
                icon: 5,
                zIndex: 9999999999,
                time: 2000
            });
        }
    });
});
//任务栏时间开始 qmsoft
get_qmsoft_time()

function get_qmsoft_time() {
    var date = new Date();
    var seperator1 = "-";
    var seperator2 = ":";
    var month = date.getMonth() + 1;
    var minutes = date.getMinutes();
    var strDate = date.getDate();
    if (month >= 1 && month <= 9) {
        month = "0" + month;
    }
    if (minutes >= 0 && minutes <= 9) {
        minutes = "0" + minutes;
    }
    if (strDate >= 0 && strDate <= 9) {
        strDate = "0" + strDate;
    }
    var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate + " " + date.getHours() + seperator2 + minutes + seperator2 + date.getSeconds();
    var time_ymd = date.getFullYear() + seperator1 + month + seperator1 + strDate;
    var time_hs = date.getHours() + seperator2 + minutes;
    $("#time-ymd").html(time_ymd);
    $("#time-hs").html(time_hs);
}
setInterval("get_qmsoft_time()", 1000);
//任务栏时间结束
//企孟CRM系统
function save_theme_id(themeid, bgurl) {
    $("body").css("background-image", "url(" + bgurl + ")");
    $.post("index.php/setting/theme_save_ajax", {
        id: themeid
    }, function(data) {
        if (data == "success") {
            layer.msg("设置成功");
        } else {
            layer.msg("设置失败")
        }
    })
}
//色彩设置
function save_theme_color(color) {
    //$(".aui_header").css("border-color",color);
    //$(".mainleft .nav .icon>li.on span .fa, .mainleft .nav .icon>li.on span p").css("color",color);
    //$(".mainleft .nav .icon,.mainleft .nav .menuul ol li.select a,.maintop .maxmin .btn,.aui_title").css("background-color",color);
    $(".maintop").append("<style>.aui_header{border-color:" + color + ";}.mainleft .nav .icon>li.on span .fa, .mainleft .nav .icon>li.on span p{color:" + color + ";}.mainleft .nav .icon,.mainleft .nav .menuul ol li.select a,.maintop .maxmin .btn,.aui_title{background-color:" + color + ";}.mainleft .nav .menuul ol li a:before{background:" + color + " !important;}</style>");
    $.post("index.php/setting/theme_color_ajax", {
        color: color
    }, function(data) {
        if (data == "success") {
            layer.msg("设置成功");
        } else {
            layer.msg("设置失败")
        }
    })
}

function msg_close_all() {
    layer.closeAll('iframe');
}
//注销登录
$(".logout").on("click", function() {
    $('#rightMenu').hide();
    $(".desktop-menu").hide();
    layer.alert("确定要注销登录吗?", {
        icon: 0,
        btn: ["确定", "取消"],
        zIndex: parseInt(99999999 + 1000),
        yes: function(index, layero) {
            $.post("/index.php/login/logout", {}, function(data) {
                if (data.code == '100') {
                    layer.msg("注销成功");
                    location.href = '/';
                } else {
                    layer.msg("操作失败")
                }
            }, 'json')
        },
        end: function() {}
    })
});
$("#layui-layim-new").on("click", function() {
    $(".layui-layim").toggle();
});
$("#changefg").on("click", function() {
    layer.alert("是否要切换系统风格?", {
        icon: 0,
        zIndex: 10000001,
        btn: ["确定", "取消"],
        yes: function(index, layero) {
            $.post("/index.php/home/theme_change", {}, function(data) {
                if (data.code == '1') {
                    layer.msg(data.msg, {
                        zIndex: 10000001,
                        anim: 1,
                        maxWidth: 500,
                        icon: 1,
                        time: 1000,
                        end: function() {
                            window.location.reload();
                        }
                    });
                } else {
                    layer.msg("操作失败")
                }
            }, 'json')
        },
        end: function() {}
    })
});
$(".start-win-btn").on("click", function() {
    $('#menu_start').slideToggle("fast");
    $(".desk_more").hide();
    $('.desk_rili').hide();
    $('.desk_div').show();
    var listdata = '';
    $(".qmsoft_deskpage").each(function() {
        listdata += parseInt($(this).css("z-index")) + ",";
        return listdata;
    });
    var indexarr = listdata.split(',');
    var qmsoft_zindex = Math.max.apply(null, indexarr) + 1;
    $("#menu_start").css("z-index", qmsoft_zindex + 99);
});
$(".taskbar-more").on("click", function() {
    $(".desk_more").slideToggle();
    $('#menu_start').hide();
    $('.desk_rili').hide();
    $('.desk_div').show();
});
$('.taskbar-time').on('click', function() {
    $('.desk_rili').slideToggle();
    $('#menu_start').hide();
    $('.desk_more').hide();
    $('.desk_div').show();
})
$('.desk_div').on('click', function() {
    $('#menu_start').hide();
    $('.desk_rili').hide();
    $('.desk_more').hide();
    $('.desk_div').hide();
})
setTimeout(function() {
    $.ajax({
        type: 'post',
        url: '/index.php/user/safecheck',
        data: {},
        dataType: 'json',
        success: function(data) {
            if (data.code == "101") {
                layer.confirm(data.tips, {
                    title: "安全提示",
                    skin: "layui-layer-aqts",
                    zIndex: 9999999,
					closeBtn:0,
                    btn: ['立即修改'] //按钮
                }, function(index) {
                    layer.close(index);
                    layer.open({
                        type: 2,
                        title: '修改密码',
                        area: ['600px', '630px'],
                        content: '/index.php/user/info' //iframe的url
                    });
                });
            }
        },
    });
}, 0.9 * 1000)