北京经济技术开发区经开区虚拟城市项目-【前端】--政府服务中心-1号屏Web
Surpriseplus
2023-10-08 5c70cfe1f51eab3091b49cf1d3590b98693f5fd5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import mapData from "../../../static/mapData";
import rpc from "./rpc";
import vueEvents from '@/utils/vueEvent.js'
window.mapMsg = {
    setTimeInterval: null,
    testMsg(res) {
        this.setMsgMatching({
            message: res,
            baidu_keys: {
                results: [{
                    word: res
                }]
            }
        });
    },
    init() {
        var that = this;
        window.addEventListener("message", res => {
            if (this.setTimeInterval) {
                clearInterval(this.setTimeInterval);
                this.setTimeInterval = null;
 
            }
            if (res.data.status === "ok") {
                that.setMsgMatching(res.data.params);
            }
            this.setTimeInterval = setTimeout((res) => {
                vueEvents.$emit("queryData", false);
                rpc.setClearAllMsg();
                rpc.setLineRoaming()
                clearInterval(this.setTimeInterval);
                this.setTimeInterval = null;
            }, 90000)
 
        });
    },
    //消息匹配
    setMsgMatching(result) {
        var param = result.message;
        var rest = mapData.msgMach.rest;
        var rom = mapData.msgMach.lineRoam;
        var closeRomData = mapData.msgMach.closeRoam;
        var valRest = rest.filter((rs) => {
            if (param.indexOf(rs) > -1) {
                return rs;
            }
        })
 
        // 地图复位
        if (valRest.length > 0) {
 
            vueEvents.$emit("queryData", false);
            rpc.setClearAllMsg();
            rpc.setMapRest();
            return
        }
        //漫游
        var valRom = rom.filter((rs) => {
            if (param.indexOf(rs) > -1) {
                return rs;
            }
        })
        if (valRom.length > 0) {
 
            vueEvents.$emit("queryData", false);
            rpc.setClearAllMsg();
            rpc.setLineRoaming()
            return
        }
        // 停止漫游
        var closeRom = closeRomData.filter((rs) => {
            if (param.indexOf(rs) > -1) {
                return rs
            }
        });
        if (closeRom.length > 0) {
            rpc.setCloseLineRomaing();
            return
        }
 
        rpc.getFuzzyQuery(result)
 
    },
};
export default mapMsg