|
|
@ -162,17 +162,19 @@ export default {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
created() {
|
|
|
|
created() {
|
|
|
|
this.getList();
|
|
|
|
this.getList();
|
|
|
|
this.initWebSocket();
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
methods: {
|
|
|
|
initWebSocket() {
|
|
|
|
initWebSocket(deviceData) {
|
|
|
|
if (typeof WebSocket == "undefined") {
|
|
|
|
if (typeof WebSocket == "undefined") {
|
|
|
|
console.log("您的浏览器不支持WebSocket");
|
|
|
|
this.$message({
|
|
|
|
|
|
|
|
message: "您的浏览器不支持WebSocket",
|
|
|
|
|
|
|
|
type: "warning"
|
|
|
|
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
console.log("您的浏览器支持WebSocket");
|
|
|
|
this.$message({
|
|
|
|
const a = "123:0";
|
|
|
|
message: "您的浏览器支持WebSocket",
|
|
|
|
const arr = a.split(":");
|
|
|
|
type: "success"
|
|
|
|
console.log(arr[0]);
|
|
|
|
});
|
|
|
|
if (this.socket != null) {
|
|
|
|
if (this.socket != null) {
|
|
|
|
this.socket.close();
|
|
|
|
this.socket.close();
|
|
|
|
this.socket = null;
|
|
|
|
this.socket = null;
|
|
|
@ -186,20 +188,12 @@ export default {
|
|
|
|
console.log("websocket已打开");
|
|
|
|
console.log("websocket已打开");
|
|
|
|
};
|
|
|
|
};
|
|
|
|
//获得消息事件
|
|
|
|
//获得消息事件
|
|
|
|
listMusic(this.queryParams).then(result => {
|
|
|
|
|
|
|
|
this.deviceData = result.rows;
|
|
|
|
|
|
|
|
this.loading = false;
|
|
|
|
|
|
|
|
console.log(this.deviceData,888)
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
this.socket.onmessage = function(msg) {
|
|
|
|
this.socket.onmessage = function(msg) {
|
|
|
|
// deviceId:0 status:'1'
|
|
|
|
// deviceId:0 status:'1'
|
|
|
|
console.log(msg.data);
|
|
|
|
|
|
|
|
const deviceMsg = msg.data.split(":");
|
|
|
|
const deviceMsg = msg.data.split(":");
|
|
|
|
// this.deviceData = msg.data;
|
|
|
|
// this.deviceData = msg.data;
|
|
|
|
|
|
|
|
deviceData.forEach(element => {
|
|
|
|
console.log(999)
|
|
|
|
if (element.deviceId == deviceMsg[0]) {
|
|
|
|
this.deviceData.forEach(element => {
|
|
|
|
|
|
|
|
if (element.deviceId === deviceMsg[0]) {
|
|
|
|
|
|
|
|
element.status = deviceMsg[1];
|
|
|
|
element.status = deviceMsg[1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -224,6 +218,7 @@ export default {
|
|
|
|
listMusic(this.queryParams).then(result => {
|
|
|
|
listMusic(this.queryParams).then(result => {
|
|
|
|
this.deviceData = result.rows;
|
|
|
|
this.deviceData = result.rows;
|
|
|
|
this.loading = false;
|
|
|
|
this.loading = false;
|
|
|
|
|
|
|
|
this.initWebSocket(this.deviceData);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
//新增按钮
|
|
|
|
//新增按钮
|
|
|
|