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;
|
}, 70000);
|
});
|
|
|
},
|
|
//消息匹配
|
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;
|