diff --git a/pkg_common/views/room.vue b/pkg_common/views/room.vue index 95d81ee..9238697 100644 --- a/pkg_common/views/room.vue +++ b/pkg_common/views/room.vue @@ -132,13 +132,19 @@ export default { this.token = uni.getStorageSync("login_status"); this.userInfo = uni.getStorageSync("userInfo"); this.uid = this.userInfo.uid - this.content = uni.getStorageSync(this.merName+this.uid+this.storeId) - this.connectSocketInit() + }, - onHide() { + onShow() { + this.content = uni.getStorageSync(this.merName+this.uid+this.storeId) + this.connectSocketInit(); + }, + onUnload() { if (this.socketOpen) { this.socketTask.close(); } + uni.onSocketClose(res => { + console.log('WebSocket 已关闭!', res); + }); uni.setStorageSync(this.merName+this.uid+this.storeId, this.content) }, methods: { @@ -247,7 +253,6 @@ export default { console.log('WebSocket连接已打开!', res); this.socketOpen = true; this.createRoom(); - }); uni.onSocketError(err => {