济菏高速业务端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

107 lines
3.1 KiB

2 years ago
<!--
* @Author: Praise-Sun 18053314396@163.com
* @Date: 2022-09-25 08:41:42
* @LastEditors: Praise-Sun 18053314396@163.com
* @LastEditTime: 2023-01-30 09:10:22
* @FilePath: \tunnel-ui\src\views\websocket.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template></template>
2 years ago
<script>
2 years ago
import { mapState } from "vuex";
2 years ago
export default {
name: "Websocket",
data() {
return {};
},
computed: {
...mapState({
2 years ago
token: (state) => state.user.token,
websocket: (state) => state.user.websocket,
}),
2 years ago
},
watch: {
2 years ago
websocket({ password, path, port, interval }) {
// debugger
// console.log(path)
// console.log(port)
// console.log(location.hostname )
2 years ago
// 建立 websocket 连接
this.socket.initialize({
2 years ago
// url: 'ws://' + location.hostname + ':' + port + path,
url: "ws://10.7.179.15" + ":" + port + path,
// url: "ws://10.168.64.171" + ":" + port + path,
// url: 'ws://10.168.78.127'+ ':' + port + path,
2 years ago
password: password,
tokenSN: this.token,
2 years ago
heartRate: interval,
2 years ago
});
2 years ago
this.socket.onopen = () => {};
2 years ago
this.socket.onmessage = (message) => {
2 years ago
// debugger
message = JSON.parse(message);
2 years ago
const method = message.method;
2 years ago
if (method !== "event") {
2 years ago
return;
}
const params = message.params;
const subEvent = params.subEvent;
const content = params.content;
2 years ago
var contentList = JSON.parse(content);
switch (subEvent) {
case "payment_webSocket_send":
this.$store.commit("PAYMENT", content);
break;
case "carList":
this.$store.commit("CARLIST", content);
break;
case "realTimeLaneTrajectory":
this.$store.commit("REALTIMELANETRAJECTORY", content);
break;
case "sdEventList":
//弹窗
this.$store.commit("SDEVENTLIST", contentList.sdEventList);
break;
case "sdSvgEventList":
//弹窗
this.$store.commit("SDSVGEVENTLIST", contentList.sdSvgEventList);
2 years ago
break;
2 years ago
case "radarDataList":
this.$store.commit("RADARDATALIST", contentList.radarDataList);
break;
case "deviceStatus":
this.$store.commit("DEVICESTATUS", contentList.deviceStatus);
break;
case "deviceStatusChangeLog":
this.$store.commit(
"DEVICESTATUSCHANGELOG",
contentList.deviceStatusChangeLog
);
break;
case "eventFlow":
this.$store.commit("EVENTFLOW", contentList.eventFlow);
break;
case "eventUntreatedNum":
this.$nextTick(() => {
this.$store.commit("EVENTUNTREATEDNUM", contentList);
});
2 years ago
break;
default:
}
2 years ago
};
},
2 years ago
},
2 years ago
created() {},
methods: {},
2 years ago
};
</script>