im断线重连

master
2023-02-13 10:56:11 +08:00
parent fc5a6a6f7f
commit 8001622be2
1 changed files with 12 additions and 2 deletions

View File

@ -283,6 +283,9 @@ export default {
onHide () { onHide () {
uni.closeSocket(); uni.closeSocket();
}, },
onUnload () {
uni.closeSocket();
},
onPullDownRefresh () { onPullDownRefresh () {
this.params.pageNumber = this.params.pageNumber + 1 this.params.pageNumber = this.params.pageNumber + 1
this.getTalkMessage() this.getTalkMessage()
@ -381,7 +384,7 @@ export default {
} }
let data = JSON.stringify(msg); let data = JSON.stringify(msg);
uni.sendSocketMessage({ uni.sendSocketMessage({
data: data, data: data
}); });
this.msgList.push({ this.msgList.push({
"text": JSON.stringify(this.goodListData), "text": JSON.stringify(this.goodListData),
@ -416,6 +419,7 @@ export default {
}); });
if (!this.socketOpen) { if (!this.socketOpen) {
// //
uni.onSocketError(function (err) { uni.onSocketError(function (err) {
if (this.count < 3) { if (this.count < 3) {
if (err && err.code != 1000) { if (err && err.code != 1000) {
@ -446,6 +450,12 @@ export default {
} catch (e) { } catch (e) {
uni.closeSocket(); uni.closeSocket();
} }
// 线线
uni.onSocketClose((res) => {
if (res.code != null && res.code != 1000) {
this.sokcet()
}
})
}, },
beautifyTime, beautifyTime,
// //
@ -890,7 +900,7 @@ export default {
height: 65rpx; height: 65rpx;
border-radius: 30rpx; border-radius: 30rpx;
padding-left: 15rpx; padding-left: 15rpx;
font-size: 35rpx; font-size: 22rpx;
background-color: #FFFFFF; background-color: #FFFFFF;
} }