From 44cf46fed3e77a4132ec6033a49e396e3c6e1a90 Mon Sep 17 00:00:00 2001 From: Chopper711 Date: Fri, 10 Feb 2023 14:29:18 +0800 Subject: [PATCH] =?UTF-8?q?=E7=95=A5=E5=BE=AE=E5=AE=8C=E5=96=84=E6=B3=A8?= =?UTF-8?q?=E9=87=8A=E4=B8=8E=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/mine/im/index.vue | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/pages/mine/im/index.vue b/pages/mine/im/index.vue index ffd12f0..972a462 100644 --- a/pages/mine/im/index.vue +++ b/pages/mine/im/index.vue @@ -228,7 +228,7 @@ export default { uni.closeSocket(); } }, - onLoad (options) { + onReady (options) { // 没有goodsid则不显示 发送商品弹窗 this.showHideModel = options.goodsid // 发送后刷新页面不显示 发送商品弹窗 local里面imGoodId不为空显示 @@ -318,8 +318,7 @@ export default { scrollHeight: 0, ws: new SocketService(), resolve: {}, - goodListData: {}, - count: 0 + goodListData: {} } }, // watch: { @@ -417,15 +416,15 @@ export default { if (!this.socketOpen) { // 监听连接失败 uni.onSocketError(function (err) { - if (this.count < 3) { if (err && err.code !== 1000) { + //断线重连等待3秒 + setTimeout(()=>{},3000) _this.socketOpen = true; uni.connectSocket({ url: url, }); } } - this.count++ }); } // 监听连接关闭 @@ -452,7 +451,10 @@ export default { }) } catch (e) { - } + }finally{ + + uni.closeSocket() + } }, beautifyTime,