Commit 4117a6f1 authored by xxx's avatar xxx

1

parent 82f2d7a3
......@@ -171,10 +171,13 @@ export default {
audioTishiViewShow:false,
//路障申报数量
roadblockNum:0,
//websocket对象
websocketIndex:null,
}
},
mounted(){
let that = this;
//that.initWebSocketIndex();
this.loadData();
this.setNowTimes();
this.zongTimer1 = setInterval(() => {
......@@ -230,74 +233,78 @@ export default {
}
}
})
//WebSocket重连
//that.reconnectIndex();
}, 8000)
},
methods:{
// getSerialSend() {
// //console.log(123);
// window.SerialPort.send("hello");
// },
// getSerialReceive() {
// //console.log(123);
// let cont = "";
// cont = window.SerialPort.receive()
// window.alert(cont);
// },
// //初始化weosocket
// initWebSocket(){
// const wsuri = "ws://8.143.203.103:9095";//连接地址,可加参数
// // const wsuri = process.env.VUE_APP_WS_API + "/" + 'pcBigScreen';
// this.websocket = new WebSocket(wsuri);
// this.websocket.onopen = this.websocketonopen;
// this.websocket.onerror = this.websocketonerror;
// this.websocket.onmessage = this.websocketonmessage;
// this.websocket.onclose = this.websocketclose;
// this.websocketonmessage();
// },
// //WebSocket连接成功
// websocketonopen() {
// console.log("WebSocket连接成功");
// },
// //WebSocket连接错误
// websocketonerror(e) {
// console.log("WebSocket连接发生错误");
// },
// //WebSocket数据接收
// websocketonmessage(e){
// //console.log("e",e);
// if(e == undefined){
// return
// }else{
// let obj1 = JSON.parse(e.data);
// console.log(obj1);
// }
// },
// //WebSocket数据发送
// websocketsend(agentData){
// this.websocket.send(agentData);
// },
// //WebSocket关闭
// websocketclose(e){
// //console.log("connection closed (" + e.code + ")");
// console.log("connection closed !");
// },
// //WebSocket重连
// reconnect(){
// var This=this;
// if (this.websocket.readyState === 1) { // that.websock.readyState = 1 表示连接成功,可以立即发送信息
// This.websocketonmessage();
// } else if (this.websocket.readyState === 0) { // 表示正在连接,设置300ms后发送信息
// setTimeout(function () {
// This.websocketonmessage();
// }, 300);
// } else { // 连接未创建或者创建失败,则重新创建连接,并设置500ms后发送信息
// This.initWebSocket();
// setTimeout(function () {
// This.websocketonmessage();
// }, 500);
// }
// },
getSerialSendIndex() {
//console.log(123);
window.SerialPort.send("hello");
},
getSerialReceiveIndex() {
//console.log(123);
let cont = "";
console.log(window.SerialPort.receive());
cont = window.SerialPort.receive()
window.alert(cont);
},
//初始化weosocket
initWebSocketIndex(){
const wsuri1 = "ws://8.143.203.103:9095";//连接地址,可加参数
this.websocketIndex = new WebSocket(wsuri1);
this.websocketIndex.onopen = this.websocketonopenIndex;
this.websocketIndex.onerror = this.websocketonerrorIndex;
this.websocketIndex.onmessage = this.websocketonmessageIndex;
this.websocketIndex.onclose = this.websocketcloseIndex;
// this.websocketsendIndex('gpsclient');
// this.websocketonmessageIndex();
},
//WebSocket连接成功
websocketonopenIndex() {
console.log("9095WebSocket连接成功")
},
//WebSocket连接错误
websocketonerrorIndex(e) {
console.log("9095WebSocket连接发生错误");
},
//WebSocket数据接收
websocketonmessageIndex(e){
console.log("indexWebsocketMessage",e);
if(e == undefined){
return
}else{
let obj1 = JSON.parse(e.data);
console.log(obj1);
}
},
//WebSocket数据发送
websocketsendIndex(agentData){
this.websocketIndex.send(agentData);
},
//WebSocket关闭
websocketcloseIndex(e){
console.log("connection closed !");
},
//WebSocket重连
reconnectIndex(){
var This=this;
if (this.websocketIndex.readyState === 1) { // that.websock.readyState = 1 表示连接成功,可以立即发送信息
This.websocketonmessageIndex();
} else if (this.websocketIndex.readyState === 0) { // 表示正在连接,设置300ms后发送信息
setTimeout(function () {
This.websocketonmessageIndex();
}, 300);
} else { // 连接未创建或者创建失败,则重新创建连接,并设置500ms后发送信息
console.log(3);
This.initWebSocketIndex();
setTimeout(function () {
This.websocketonmessageIndex();
}, 500);
}
},
loadData(){
let that = this;
let href1 = window.location.href;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment