北京经济技术开发区经开区虚拟城市项目-【前端】--政府服务中心-2号屏Web
lixuliang
2023-10-12 32a74e421964aa589a13944e4949e35273fc629f
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
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 acceptData =mapData.msgMach.acceptMsg;
        console.log(result)
        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
        }
        var accept = acceptData.filter(res => {
            if (param.indexOf(res) > -1) {
                return res;
            }
        })
        if (accept.length > 0) {
            rpc.getFuzzyQuery(result)
        }else{
            vueEvents.$emit("queryData", false);
            rpc.setClearAllMsg();
            rpc.setMapRest();
        }
 
 
 
    },
};
export default mapMsg