initWebSocket () {
const wsuri = 'ws://op-innovative-declare.dev.ennewi.cn/wsServer'
this.websocket = new WebSocket(wsuri)
this.websocket.onopen = this.websocketonopen
this.websocket.onerror = this.websocketonerror
this.websocket.onmessage = this.websocketonmessage
this.websocket.onclose = this.websocketclose
},
websocketonopen () {
let msg = {
type: 1,
data: localStorage.getItem('userId'),
}
this.websocketsend(msg)
},
websocketonerror (e) {
},
websocketonmessage (e) {
let msg = JSON.parse(e.data)
if (msg.type === 3) {
setTimeout(() => {
this.$message.success('附件已整合完毕,请在消息列表中查看')
this.$store.commit('SET_MSGSTATUSTRUE', true)
}, 6000)
}
},
websocketsend (msg) {
let strMsg = JSON.stringify(msg)
this.websocket.send(strMsg)
},
websocketclose (e) {
},
|