Commit 4117a6f1 authored by xxx's avatar xxx

1

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