This commit is contained in:
2024-03-30 21:10:51 +08:00
parent 79feb3d159
commit 8a25ea3075

View File

@ -173,9 +173,9 @@
// });
},
onLoad(options) {
// if (uni.getStorageSync('patientId') && !this.$store.state.socketOpen) {
// this.scoket();
// }
if (uni.getStorageSync('patientId')) {
this.scoket();
}
this.baseurl = baseurl;
// uni.closeSocket()
this.currentItem = JSON.parse(options.item)
@ -192,42 +192,45 @@
// scrollTop: 9999999
// })
},
onUnload() {
clearInterval(this.timeoutObj);
},
methods: {
messagescoket() {
const that = this
this.SOCKETURL = socketurl + this.currentItem.patientId
this.socketOpen = false
// this.SOCKETURL = socketurl + this.currentItem.patientId
// this.socketOpen = false
try {
uni.connectSocket({
url: that.SOCKETURL
})
uni.onSocketOpen(res => {
console.log('webScoket连接已打开', res);
that.socketOpen = true
that.reset()
})
uni.onSocketError(err => {
console.log('webScoket连接打开失败', err);
if (err && err.code != 1000) {
setTimeout(() => {
that.socketOpen = true
uni.connectSocket({
url: that.SOCKETURL
})
}, 3000)
}
})
uni.onSocketClose(err => {
console.log('webScoket连接关闭', err);
if (err && err.code !== 1000) {
setTimeout(() => {
that.socketOpen = true
uni.connectSocket({
url: that.SOCKETURL
})
}, 3000)
}
})
// uni.connectSocket({
// url: that.SOCKETURL
// })
// uni.onSocketOpen(res => {
// console.log('webScoket', res);
// that.socketOpen = true
// that.reset()
// })
// uni.onSocketError(err => {
// console.log('webScoket', err);
// if (err && err.code != 1000) {
// setTimeout(() => {
// that.socketOpen = true
// uni.connectSocket({
// url: that.SOCKETURL
// })
// }, 3000)
// }
// })
// uni.onSocketClose(err => {
// console.log('webScoket', err);
// if (err && err.code !== 1000) {
// setTimeout(() => {
// that.socketOpen = true
// uni.connectSocket({
// url: that.SOCKETURL
// })
// }, 3000)
// }
// })
uni.onSocketMessage(res => {
console.log("webScoket监听收到的信息", res);
that.getPageHistory()