weather copy 2.html 5.49 KB
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <title></title>
    <script src="../js/jquery-3.4.1.min.js"></script>
    <script src="../js/JavaScript.js"></script>
    <script src="../js/popupJS.js"></script>
    <link rel="stylesheet" href="../css/popupHtml.css">

    <!-- import Vue before Element -->
    <script src="../js/vue.min.js"></script>
    <!-- import JavaScript -->
    <!-- <script src="https://unpkg.com/element-ui/lib/index.js"></script> -->
    <script src="../js/element.js"></script>
    <!-- <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css"> -->
    <link rel="stylesheet" href="../js/element.css">

    <style>
        #weather {
            width: 100%;
            height: 100%;
            /* background: url(../img/bg.png) no-repeat center center; */
            /* background-color: aliceblue; */
            background-size: 100% 100%;
            /* display:flex; */
            flex-direction: column;
        }

        .title {
            display: block;
            height: 30px;
            line-height: 30px;
            text-align: center;
            color: #00EEF6;
            font-size: 14px;
            font-weight: inherit;
        }

        .iconfont {
            display: inline-block;
            font-size: 30px;
            padding: 10px 12px;
            width: 24px;
            height: 24px;
            text-align: center;
            cursor: default;
        }
    </style>
</head>

<body marginwidth="0" marginheight="0">

    <div id="weather">
        <h1 class="title" onmousedown="MouseDown(event)" onmouseup="MouseUp(event)" onmouseout="MouseUp(event)">
            天气<i class=" icon-guanbi" onclick="Close()">X</i>
        </h1>
        <div class="main">
            <div class="row">
                <el-checkbox v-model="fog.is"></el-checkbox>
                <el-slider v-model="fog.snowfall" :min="20" @change="fall(fog.snowfall, 'fog')"></el-slider>
            </div>
            <div class="row">
                <el-checkbox v-model="rain.is"></el-checkbox>
                <el-slider v-model="rain.rainfall" :min="20" @change="fall(rain.rainfall, 'rain')"></el-slider>
            </div>
            <div class="row">
                <el-checkbox v-model="snow.is"></el-checkbox>
                <el-slider v-model="snow.snowfall" :min="20" @change="fall(snow.snowfall, 'snow')"></el-slider>
            </div>
        </div>

    </div>

</body>
<script>
    new Vue({
        el: '#weather',
        data: function () {
            return {
                rain: {
                    rainfall: 20,
                    is: false,
                    func: "Command.Execute",
                    args: [2206, 1],
                    fallarg: 2206
                },
                snow: {
                    snowfall: 20,
                    is: false,
                    func: "Command.Execute",
                    args: [2207, 1],
                    fallarg: 2200
                },
                fog: {
                    snowfall: 80,
                    is: false,
                    func: "Command.Execute",
                    args: [2208, 1],
                    fallarg: 2204
                },
                target: {},
            }
        },
        watch: {
            "rain.is"(val) {
                this.target = {
                    rain: Object.assign(this.rain, { args: [2206, val ? 1 : 0] })
                };
                this.eventSky("rain");
            },
            "snow.is"(val) {
                this.target = {
                    snow: Object.assign(this.snow, { args: [2207, val ? 1 : 0] })
                };
                this.eventSky("snow");
            },
            "fog.is"(val) {
                this.target = {
                    fog: Object.assign(this.fog, { args: [2208, val ? 1 : 0] })
                };
                this.eventSky("fog");
            }
        },
        methods: {
            // currency(a, b) {
            //     maps.sgWorld.Command.Execute(a, b);
            // },
            eventSky(key) {
                let func = this.target[key].func.split("."),
                    args = this.target[key].args,
                    a = args[0],
                    b = args[1];
                let sgWorld = this.CreateSGObj();
                args.length > 1
                    ? sgWorld[func[0]][func[1]](a, b)
                    : sgWorld[func[0]][func[1]](a);
                this.target[key].callback && this[this.target[key].callback]();
            },
            fall(v, k) {
                this.target = {
                    [k]: Object.assign(this[k], { args: [this[k].fallarg, v] })
                };
                this.eventSky(k);
            },
            CreateSGObj() {
                try {
                    var obj = document.getElementById("SGWorld");
                    if (obj === null) {
                        obj = document.createElement('object');
                        obj.setAttribute("name", "SGWorld");
                        obj.setAttribute("id", "SGWorld");
                        obj.style.height = "1px";
                        obj.style.width = "1px";
                        //定义TerraExplorer对象
                        obj.setAttribute("classid", "CLSID:3A4F919C-65A8-11D5-85C1-0001023952C1");
                        document.body.appendChild(obj);
                    }
                    return obj;
                }
                catch (e) { alert("CreateSGWorld " + e); }
            }
        }
    })
</script>

</html>