im重复请求

master
2023-02-10 16:25:42 +08:00
parent 63ebf1a7c5
commit c9c0d2d171
1 changed files with 44 additions and 40 deletions

View File

@ -279,6 +279,13 @@ export default {
// this.ws.connect();
this.sokcet();
},
//
onHide () {
uni.closeSocket();
},
onUnload () {
uni.closeSocket();
},
onPullDownRefresh () {
this.params.pageNumber = this.params.pageNumber + 1
this.getTalkMessage()
@ -319,7 +326,7 @@ export default {
ws: new SocketService(),
resolve: {},
goodListData: {},
count: 0
count: 0, //socket
}
},
// watch: {
@ -354,21 +361,22 @@ export default {
talk_id: this.params.talkId,
}
let data = JSON.stringify(msg);
try {
uni.sendSocketMessage({
data: data
});
data: data,
success: () => {
this.msgList.push({
"text": this.msg,
"my": true,
"messageType": 'MESSAGE'
})
},
fail: () => {
this.sokcet()
}
});
let type = 'down';
this.msgGo(type)
this.msg = ""
} catch (e) {
uni.closeSocket();
}
},
sendGoodsMessage () {
let msg = {
@ -381,13 +389,18 @@ export default {
}
let data = JSON.stringify(msg);
uni.sendSocketMessage({
data: data
});
data: data,
success: () => {
this.msgList.push({
"text": JSON.stringify(this.goodListData),
"my": true,
"messageType": 'GOODS'
})
},
fail: () => {
this.sokcet()
}
});
this.showHide = false
// #ifdef H5
uni.setStorageSync("imGoodId", 1111111);
@ -418,27 +431,20 @@ export default {
//
uni.onSocketError(function (err) {
if (this.count < 3) {
if (err && err.code !== 1000) {
if (err && err.code != 1000) {
_this.socketOpen = true;
setTimeout(() => {
uni.connectSocket({
url: url,
});
}, 2000)
}
} else {
uni.closeSocket();
}
this.count++
});
}
//
uni.onSocketClose(function (err) {
if (err && err.code !== 1000) {
setTimeout(function () {
_this.socketOpen = true;
uni.connectSocket({
url: url,
});
}, 999999)
}
});
//
uni.onSocketMessage(function (res) {
res.data = JSON.parse(res.data)
@ -451,9 +457,8 @@ export default {
_this.msgGo()
})
} catch (e) {
uni.closeSocket();
}
},
beautifyTime,
//
@ -508,7 +513,6 @@ export default {
},
//
msgGo (type) {
console.log(type, 'typetypetype');
const query = uni.createSelectorQuery()
// 100ms
setTimeout(() => {