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: "综合展示平台",
                    introName: "",
                    fn: "openWindow",
                    param: {
                        inline: "http://192.168.175.8:8081",
                        outline: "http://222.88.149.44:8011"
                    }
                },
                {
                    id: 3,
                    className: ["nav-three-wrap"],
                    menuName: "管网GIS地理系统",
                    introName: "",
                    fn: "openWindow",
                    param: {
                        inline: "https://192.168.175.6:8001",
                        outline: "https://222.88.149.44:8001"
                    }
                },
                {
                    id: 4,
                    className: ["nav-four-wrap"],
                    menuName: "巡检抢修系统",
                    introName: "",
                    fn: "openWindow",
                    param: {
                        inline: "https://192.168.175.6:8000",
                        outline: "https://222.88.149.44:8000"
                    }
                },
                {
                    id: 5,
                    className: ["nav-five-wrap"],
                    menuName: "生产自控系统",
                    introName: "",
                    
                },
                {
                    id: 6,
                    className: ["nav-six-wrap"],
                    menuName: "自动化控制系统",
                    introName: "",
                    fn: "",
                    param: {
                        inline: "",
                        outline: ""
                    }
                },
                {
                    id: 7,
                    className: ["nav-seven-wrap"],
                    menuName: "视频监控系统",
                    introName: "",
                    fn: "openWindow",
                    param: {
                        inline: "http://192.168.175.9/portal/ui/login",
                        outline: "http://192.168.175.9/portal/ui/login"
                    }
                },
                {
                    id: 8,
                    className: ["nav-eight-wrap"],
                    menuName: "",
                    fn: "",
                    param: {
                        inline: "",
                        outline: ""
                    }
                },
            ],
            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;
        }
    },
});
