var app = new Vue({
    el: "#app",
    data() {
        // let isinline = /^(192.168)/.test(location.hostname);
        return {
            companyName: "许昌市建安区中州水务",
            sysName: "信息管理平台",
            inline: /^(192.168)/.test(location.hostname),
            memuList: [
                {
                    id: 1,
                    className: ["nav-one-wrap"],
                    menuName: "管网GIS相关系统",
                    introName: "",
                },
                {
                    id: 2,
                    className: ["nav-two-wrap"],
                    menuName: "管网GIS",
                    introName: "",
                    fn: "openWindow",
                    param: {
                        inline: "//192.168.100.12:8200",
                        outline: "//42.227.69.38:8200"
                    }
                },
                {
                    id: 3,
                    className: ["nav-three-wrap"],
                    menuName: "巡检抢修",
                    introName: "",
                    fn: "openWindow",
                    param: {
                        inline: "//192.168.100.12:8000",
                        outline: "//42.227.69.38:8000"
                    }
                },
                {
                    id: 4,
                    className: ["nav-four-wrap"],
                    menuName: "综合管理",
                    introName: "",
                    fn: "openWindow",
                    param: {
                        inline: "//192.168.100.12:8000/#/large-screen",
                        outline: "//42.227.69.38:8000/#/large-screen"
                    }
                },
                {
                    id: 5,
                    className: ["nav-five-wrap"],
                    menuName: "营业相关系统",
                    introName: "",
                    
                },
                {
                    id: 6,
                    className: ["nav-six-wrap"],
                    menuName: "营业管理",
                    introName: "",
                    fn: "openWindow",
                    param: {
                        inline: "https://sales.zzwatercloud.com//smallPortal/#/login?tenantCode=%20",
                        outline: "https://sales.zzwatercloud.com//smallPortal/#/login?tenantCode=%20"
                    }
                },
                {
                    id: 7,
                    className: ["nav-seven-wrap"],
                    menuName: "抄表平台",
                    introName: "",
                    fn: "openWindow",
                    param: {
                        inline: "https://sales.zzwatercloud.com//smallPortal/#/login?tenantCode=%20",
                        outline: "https://sales.zzwatercloud.com//smallPortal/#/login?tenantCode=%20"
                    }
                },
                {
                    id: 8,
                    className: ["nav-eight-wrap"],
                    menuName: "报装系统",
                    fn: "openWindow",
                    param: {
                        inline: "https://sales.zzwatercloud.com//smallPortal/#/login?tenantCode=%20",
                        outline: "https://sales.zzwatercloud.com//smallPortal/#/login?tenantCode=%20"
                    }
                },
            ],
            dateObj: {},
            timer: null,
            time: "--",
            scaleNum: 1,

        };
    },
    methods: {
        initScale() {
            let clientWidth = document.body.clientWidth;
            let num = clientWidth / 1920;
            let scaleNum = num.toFixed(2);
            this.scaleNum = scaleNum;
        },
        initDate() {
            let date = new Date();
            let year = date.getFullYear();
            let month = date.getMonth() + 1;
            let day = date.getDate();
            this.dateObj = { year, month, day };
        },
        initTimer() {
            if (this.timer) {
                clearInterval(this.timer);
                this.timer = null;
            }
            let date = new Date();
            this.time = date.toLocaleTimeString();

            this.timer = setInterval(() => {
                let date = new Date();
                this.time = date.toLocaleTimeString();
            }, 1000);
        },
        menuClick(item) {
            if (item.fn && this[item.fn]) {
                this[item.fn](item.param);
            }
        },
        openWindow(param, target) {
            let href = param[this.inline ? 'inline' : 'outline'];
            if (!href) return;
            window.open(href, target || "_blank");
        },
        oneInfo() {
            window.open("http://42.227.69.38:8000", "_blank");
        },
        twoInfo() {
            window.open("http://42.227.69.38:8000/#/large-screen", "_blank");
        },
        fiveInfo() {
            window.open("http://42.227.69.38:8200", "_blank");
        },
    },
    created() {
        this.initDate();
        this.initTimer();
        this.initScale();
    },
    destroyed() {
        if (this.timer) {
            clearInterval(this.timer);
            this.timer = null;
        }
    },
});
