From c097a9251cc13e6e796400db24a27b61d78a74af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=BE=81?= Date: Tue, 17 May 2022 17:47:32 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E6=94=B9im?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/BsAddress.vue | 3 ++- plugins/im.js | 16 +++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/components/BsAddress.vue b/components/BsAddress.vue index 82d8c27..a6cb15e 100644 --- a/components/BsAddress.vue +++ b/components/BsAddress.vue @@ -78,12 +78,13 @@
收货人 - + 手机号码
diff --git a/plugins/im.js b/plugins/im.js index 0798b55..8cfdc2d 100644 --- a/plugins/im.js +++ b/plugins/im.js @@ -12,7 +12,7 @@ function guid() { Vue.prototype.$startWebSockets = function () { console.log(); let token = this.$cookies.get(TOKEN_KEY); - if (token&&!Vue.prototype.Socket) { + if (token && !Vue.prototype.Socket) { let url = `wss://k8s-horse-gateway.mashibing.cn/ws?client=${token}&type=1`; Vue.prototype.Socket = new WebSocket(url); Vue.prototype.Socket.onopen = () => { @@ -40,17 +40,19 @@ Vue.prototype.$startWebSockets = function () { if (msg.traceType == 1) { let traceId = guid(); let sys = msg.content.sessionVOS.find((item) => item.type != 3); - let str = `{"traceId":"${traceId}",traceType:2,"content":{"sessionId":${sys.id}}}`; - Vue.prototype.Socket.send(str); - this.$store.commit("setUnreadCount", msg.content.totalUnreadCount); + if (sys) { + let str = `{"traceId":"${traceId}",traceType:2,"content":{"sessionId":${sys.id}}}`; + Vue.prototype.Socket.send(str); + this.$store.commit("setUnreadCount", msg.content.totalUnreadCount); + } } // 获取消息列表 if (msg.traceType == 2) { this.$store.commit("setSocketMsgData", msg.content); - setTimeout(()=>{ - console.log(this.$store.state) - },500) + setTimeout(() => { + console.log(this.$store.state); + }, 500); } // 接收消息