Merge branch 'develop' of http://25.13.9.101:9000/K17_AITS/tra-app into develop
This commit is contained in:
@@ -4,6 +4,7 @@ import {
|
||||
import {
|
||||
getToken
|
||||
} from '@/common/common.js'
|
||||
import common from '@/common/common';
|
||||
|
||||
|
||||
export const uploadFile = (file, data) => {
|
||||
@@ -145,9 +146,11 @@ export function downloadVoiceFile(url) {
|
||||
url: `${baseUrl}${url}`,
|
||||
header,
|
||||
success(result) {
|
||||
console.log(result)
|
||||
resolve(result)
|
||||
},
|
||||
fail(error) {
|
||||
console.log(error)
|
||||
reject(new Error(error));
|
||||
}
|
||||
});
|
||||
|
||||
+16
-3
@@ -26,13 +26,14 @@ export default class WebSocketUtil {
|
||||
close: [], // 连接关闭回调
|
||||
error: [] // 错误处理回调
|
||||
};
|
||||
this.init(); // 初始化WebSocket连接
|
||||
this.init(true); // 初始化WebSocket连接
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化WebSocket连接
|
||||
*/
|
||||
init() {
|
||||
init(flag = false) {
|
||||
if(flag) this.reconnectCount = 0
|
||||
// 创建WebSocket连接
|
||||
this.socketTask = uni.connectSocket({
|
||||
url: this.url,
|
||||
@@ -59,7 +60,17 @@ export default class WebSocketUtil {
|
||||
|
||||
// 监听WebSocket消息接收事件
|
||||
this.socketTask.onMessage((res) => {
|
||||
console.log('收到WebSocket消息', res);
|
||||
if(res.data){
|
||||
const { rtnCode } = JSON.parse(res.data)
|
||||
console.log('收到WebSocket消息', JSON.parse(res.data) );
|
||||
if(['0005', 'QQ0005'].includes(res.rtnCode)) {
|
||||
goto_login_fun();
|
||||
return
|
||||
}
|
||||
}else{
|
||||
goto_login_fun();
|
||||
return
|
||||
}
|
||||
this.triggerEvent('message', res); // 触发消息接收事件
|
||||
});
|
||||
|
||||
@@ -198,6 +209,8 @@ export default class WebSocketUtil {
|
||||
} else {
|
||||
console.error('达到最大重连次数,停止尝试');
|
||||
this.triggerEvent('error', new Error('达到最大重连次数'));
|
||||
this.reconnectTimer = null
|
||||
this.close()
|
||||
goto_login_fun()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user