|
|
@ -9,7 +9,6 @@ import UNI_APP from '@/.env.js' |
|
|
export default { |
|
|
export default { |
|
|
data() { |
|
|
data() { |
|
|
return { |
|
|
return { |
|
|
isInit: false, // 是否已经初始化 |
|
|
|
|
|
isExit: false, // 是否已退出 |
|
|
isExit: false, // 是否已退出 |
|
|
audioTip: null, |
|
|
audioTip: null, |
|
|
reconnecting: false // 正在重连标志 |
|
|
reconnecting: false // 正在重连标志 |
|
|
@ -18,13 +17,12 @@ export default { |
|
|
methods: { |
|
|
methods: { |
|
|
init() { |
|
|
init() { |
|
|
this.reconnecting = false; |
|
|
this.reconnecting = false; |
|
|
this.isExit = false; |
|
|
this.configStore.setAppInit(false); |
|
|
// 加载数据 |
|
|
// 加载数据 |
|
|
this.loadStore().then(() => { |
|
|
this.loadStore().then(() => { |
|
|
// 初始化websocket |
|
|
// 初始化websocket |
|
|
this.initWebSocket(); |
|
|
this.initWebSocket(); |
|
|
this.isInit = true; |
|
|
}).catch(e => { |
|
|
}).catch((e) => { |
|
|
|
|
|
console.log(e); |
|
|
console.log(e); |
|
|
this.exit(); |
|
|
this.exit(); |
|
|
}) |
|
|
}) |
|
|
@ -40,7 +38,7 @@ export default { |
|
|
// 加载离线消息 |
|
|
// 加载离线消息 |
|
|
this.pullPrivateOfflineMessage(this.chatStore.privateMsgMaxId); |
|
|
this.pullPrivateOfflineMessage(this.chatStore.privateMsgMaxId); |
|
|
this.pullGroupOfflineMessage(this.chatStore.groupMsgMaxId); |
|
|
this.pullGroupOfflineMessage(this.chatStore.groupMsgMaxId); |
|
|
|
|
|
this.configStore.setAppInit(true); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
wsApi.onMessage((cmd, msgInfo) => { |
|
|
wsApi.onMessage((cmd, msgInfo) => { |
|
|
@ -66,7 +64,7 @@ export default { |
|
|
console.log("ws断开", res); |
|
|
console.log("ws断开", res); |
|
|
// 重新连接 |
|
|
// 重新连接 |
|
|
this.reconnectWs(); |
|
|
this.reconnectWs(); |
|
|
|
|
|
this.configStore.setAppInit(false); |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
loadStore() { |
|
|
loadStore() { |
|
|
@ -92,7 +90,11 @@ export default { |
|
|
url: "/message/private/pullOfflineMessage?minId=" + minId, |
|
|
url: "/message/private/pullOfflineMessage?minId=" + minId, |
|
|
method: 'GET' |
|
|
method: 'GET' |
|
|
}).catch(() => { |
|
|
}).catch(() => { |
|
|
this.chatStore.setLoadingPrivateMsg(false) |
|
|
uni.showToast({ |
|
|
|
|
|
title: "消息拉取失败,请重新登陆", |
|
|
|
|
|
icon: 'none' |
|
|
|
|
|
}) |
|
|
|
|
|
this.exit() |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
pullGroupOfflineMessage(minId) { |
|
|
pullGroupOfflineMessage(minId) { |
|
|
@ -101,7 +103,11 @@ export default { |
|
|
url: "/message/group/pullOfflineMessage?minId=" + minId, |
|
|
url: "/message/group/pullOfflineMessage?minId=" + minId, |
|
|
method: 'GET' |
|
|
method: 'GET' |
|
|
}).catch(() => { |
|
|
}).catch(() => { |
|
|
this.chatStore.setLoadingGroupMsg(false) |
|
|
uni.showToast({ |
|
|
|
|
|
title: "消息拉取失败,请重新登陆", |
|
|
|
|
|
icon: 'none' |
|
|
|
|
|
}) |
|
|
|
|
|
this.exit() |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
handlePrivateMessage(msg) { |
|
|
handlePrivateMessage(msg) { |
|
|
@ -421,6 +427,7 @@ export default { |
|
|
// 加载离线消息 |
|
|
// 加载离线消息 |
|
|
this.pullPrivateOfflineMessage(this.chatStore.privateMsgMaxId); |
|
|
this.pullPrivateOfflineMessage(this.chatStore.privateMsgMaxId); |
|
|
this.pullGroupOfflineMessage(this.chatStore.groupMsgMaxId); |
|
|
this.pullGroupOfflineMessage(this.chatStore.groupMsgMaxId); |
|
|
|
|
|
this.configStore.setAppInit(true); |
|
|
}).catch((e) => { |
|
|
}).catch((e) => { |
|
|
console.log(e); |
|
|
console.log(e); |
|
|
this.exit(); |
|
|
this.exit(); |
|
|
|