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.203:8200",
                        outline: "//42.227.69.38:8200"
                    }
                },
                {
                    id: 3,
                    className: ["nav-three-wrap"],
                    menuName: "巡检抢修",
                    introName: "",
                    fn: "openWindow",
                    param: {
                        inline: "//192.168.100.203:8000",
                        outline: "//42.227.69.38:8000"
                    }
                },
                {
                    id: 4,
                    className: ["nav-four-wrap"],
                    menuName: "综合管理",
                    introName: "",
                    fn: "openWindow",
                    param: {
                        inline: "//192.168.100.203: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"
                    }
                },
            ],
            memuList: [
                {   
                    id: 1,
                    menuName: "管网地理信息系统",
                    className: ["nav-one-wrap"],
                    children: [
                        {
                            id: 1,
                            className: ["sub-nav-one"],
                            menuName: "综合展示",
                            introName: "",
                            fn: "openWindow",
                            param: {
                                inline: "//192.168.100.203:8000/#/large-screen",
                                outline: "//42.227.69.38:8000/#/large-screen"
                            }
                        },
                        {
                            id: 2,
                            className: ["sub-nav-two"],
                            menuName: "地理信息",
                            introName: "",
                            fn: "openWindow",
                            param: {
                                inline: "//192.168.100.203:8200",
                                outline: "//42.227.69.38:8200"
                            }
                        },
                        {
                            id: 3,
                            className: ["sub-nav-three"],
                            menuName: "巡检抢修",
                            introName: "",
                            fn: "openWindow",
                            param: {
                                inline: "//192.168.100.203:8000",
                                outline: "//42.227.69.38:8000"
                            }
                        }
                    ]
                },
                {   
                    id: 5,
                    menuName: "营业综合管理平台",
                    className: ["nav-five-wrap"],
                    children: [
                        {
                            id: 4,
                            className: ["sub-nav-one"],
                            menuName: "营业收费",
                            introName: "",
                            fn: "openWindow",
                            param: {
                                inline: "https://sales.zzwatercloud.com//smallPortal/#/login?tenantCode=%20",
                                outline: "https://sales.zzwatercloud.com//smallPortal/#/login?tenantCode=%20"
                            }
                        },
                        {
                            id: 5,
                            className: ["sub-nav-two"],
                            menuName: "抄表平台",
                            introName: "",
                            fn: "openWindow",
                            param: {
                                inline: "https://sales.zzwatercloud.com//smallPortal/#/login?tenantCode=%20",
                                outline: "https://sales.zzwatercloud.com//smallPortal/#/login?tenantCode=%20"
                            }
                        },
                        {
                            id: 6,
                            className: ["sub-nav-three"],
                            menuName: "报装系统",
                            introName: "",
                            fn: "openWindow",
                            param: {
                                inline: "https://sales.zzwatercloud.com//smallPortal/#/login?tenantCode=%20",
                                outline: "https://sales.zzwatercloud.com//smallPortal/#/login?tenantCode=%20"
                            }
                        }
                    ]
                },
                {
                    id: 3,
                    menuName: "生产自动化系统",
                    className: ["nav-three-wrap"],
                    children: [
                        {
                            id: 7,
                            className: ["sub-nav-one"],
                            menuName: "制水工艺自控",
                            fn: "",
                            param: {
                                inline: "",
                                outline: ""
                            }
                        },
                        {
                            id: 8,
                            className: ["sub-nav-two"],
                            menuName: "送水泵站自控",
                            fn: "",
                            param: {
                                inline: "",
                                outline: ""
                            }
                        },
                        {
                            id: 9,
                            className: ["sub-nav-three"],
                            menuName: "水质监测",
                            fn: "",
                            param: {
                                inline: "",
                                outline: ""
                            }
                        }
                    ]
                },
                {
                    id: 7,
                    menuName: "视频监控平台",
                    className: ["nav-seven-wrap"],
                    children: [
                        {
                            id: 10,
                            className: ["sub-nav-one"],
                            menuName: "水厂监控系统",
                            fn: "",
                            param: {
                                inline: "",
                                outline: ""
                            }
                        },
                        {
                            id: 10,
                            className: ["sub-nav-one"],
                            menuName: "水站监控系统",
                            fn: "",
                            param: {
                                inline: "",
                                outline: ""
                            }
                        }
                        // {
                        //     id: 5,
                        //     className: ["sub-nav-two"],
                        //     menuName: "送水泵站自控",
                        //     fn: "",
                        //     param: {
                        //         inline: "",
                        //         outline: ""
                        //     }
                        // },
                        // {
                        //     id: 5,
                        //     className: ["sub-nav-three"],
                        //     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");
        },
    },
    created() {
        this.initDate();
        this.initTimer();
        this.initScale();
    },
    destroyed() {
        if (this.timer) {
            clearInterval(this.timer);
            this.timer = null;
        }
    },
});
