执行顺序

This commit is contained in:
魏啾
2024-06-13 13:45:33 +08:00
parent 84b5632d23
commit 4465ddf666
3 changed files with 15 additions and 22 deletions

View File

@@ -25,24 +25,22 @@ class webSocketUtils {
// 进入这个页面的时候创建websocket连接【整个页面随时使用】
connectSocketInit(data) {
this.data = data;
this.socketTask ? this.socketTask.Close() : null
this.socketTask = uni.connectSocket({
url: this.url,
success: () => {
console.log('正准备建立websocket中...');
// uni.hideLoading();
// 返回实例
uni.hideLoading()
return this.socketTask;
},
});
this.socketTask.onOpen((res) => {
uni.hideLoading()
this.connectNum = 1;
console.log('WebSocket连接正常');
if (this.params) { //是否初始化请求
this.send(this.params);
}
clearInterval(this.reconnectTimeOut);
clearInterval(this.heartbeatInterval);
this.is_open_socket = true;