|
@@ -28,16 +28,16 @@ export default {
|
|
const sid = 'pc/u' + this.getters.userInfo.userid + 'epc'
|
|
const sid = 'pc/u' + this.getters.userInfo.userid + 'epc'
|
|
const protocol = process.env.NODE_ENV == 'production' ? (window.location.protocol == 'http:' ? 'ws:' : 'wss:') : 'ws:'
|
|
const protocol = process.env.NODE_ENV == 'production' ? (window.location.protocol == 'http:' ? 'ws:' : 'wss:') : 'ws:'
|
|
const wsUrl = protocol + baseUrl + sid
|
|
const wsUrl = protocol + baseUrl + sid
|
|
- console.log(process.env.NODE_ENV, wsUrl)
|
|
|
|
|
|
+ // console.log(process.env.NODE_ENV, wsUrl)
|
|
state.websock = new WebSocket(wsUrl)
|
|
state.websock = new WebSocket(wsUrl)
|
|
state.websock.onopen = function () {
|
|
state.websock.onopen = function () {
|
|
- console.log('连接成功!')
|
|
|
|
|
|
+ // console.log('连接成功!')
|
|
_this.dispatch('getUnreadMessageCount')
|
|
_this.dispatch('getUnreadMessageCount')
|
|
}
|
|
}
|
|
state.websock.onmessage = function (e) {
|
|
state.websock.onmessage = function (e) {
|
|
- console.log('ws接收!', e.data)
|
|
|
|
|
|
+ // console.log('ws接收!', e.data)
|
|
if (e.data != 'pong') {
|
|
if (e.data != 'pong') {
|
|
- console.log('进来----------')
|
|
|
|
|
|
+ // console.log('进来----------')
|
|
state.wsMessageData = JSON.parse(e.data)
|
|
state.wsMessageData = JSON.parse(e.data)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -50,7 +50,7 @@ export default {
|
|
|
|
|
|
// 发送心跳包
|
|
// 发送心跳包
|
|
state.heartInterId = setInterval(function () {
|
|
state.heartInterId = setInterval(function () {
|
|
- console.log('ws发送心跳!')
|
|
|
|
|
|
+ // console.log('ws发送心跳!')
|
|
if (state.websock.readyState == 3) {
|
|
if (state.websock.readyState == 3) {
|
|
clearInterval(state.heartInterId)
|
|
clearInterval(state.heartInterId)
|
|
_this.commit('WEBSOCKET_INIT', url)
|
|
_this.commit('WEBSOCKET_INIT', url)
|
|
@@ -63,7 +63,7 @@ export default {
|
|
clearInterval(state.heartInterId)
|
|
clearInterval(state.heartInterId)
|
|
},
|
|
},
|
|
WEBSOCKET_SEND (state, p) {
|
|
WEBSOCKET_SEND (state, p) {
|
|
- console.log('ws发送!', p)
|
|
|
|
|
|
+ // console.log('ws发送!', p)
|
|
state.websock.send(p)
|
|
state.websock.send(p)
|
|
},
|
|
},
|
|
UPDATE_HOME (state, p) {
|
|
UPDATE_HOME (state, p) {
|
|
@@ -89,7 +89,7 @@ export default {
|
|
// 此方法用来获取未读消息条数,接口只返回数值,不返回消息列表
|
|
// 此方法用来获取未读消息条数,接口只返回数值,不返回消息列表
|
|
getUnreadMessageCount ({ state, commit }) {
|
|
getUnreadMessageCount ({ state, commit }) {
|
|
getUnreadCount().then(res => {
|
|
getUnreadCount().then(res => {
|
|
- console.log(res, '---------------请求未读消息', res.data ? res.data.no_read_count : 0)
|
|
|
|
|
|
+ // console.log(res, '---------------请求未读消息', res.data ? res.data.no_read_count : 0)
|
|
commit('setMessageCount', res.data ? res.data.no_read_count : 0)
|
|
commit('setMessageCount', res.data ? res.data.no_read_count : 0)
|
|
})
|
|
})
|
|
},
|
|
},
|