|
@@ -66,12 +66,14 @@ const store = new Vuex.Store({
|
|
|
// 创建通知消息websocket
|
|
|
$webSocket(state, params) {
|
|
|
let _this = this
|
|
|
- let userInfo = state.vuex_userData
|
|
|
+ let token = getApp().globalData.token
|
|
|
let url = getApp().globalData.baseUrl
|
|
|
let wsBaseUrl = url.indexOf("https:")>=0 ? url.replace("https:","wss:") : url.replace("http:","ws:")
|
|
|
let wsUrl = wsBaseUrl + 'websocket/16546'
|
|
|
+ console.log(token,wsUrl)
|
|
|
// 开始连接
|
|
|
state.vuex_socket = uni.connectSocket({
|
|
|
+ header: {'X-AUTH-TOKEN':token},
|
|
|
url: wsUrl, // ws 请求地址
|
|
|
complete: ()=> {
|
|
|
console.log('连接complete回调!')
|
|
@@ -102,6 +104,7 @@ const store = new Vuex.Store({
|
|
|
console.log(state.vuex_socket.readyState)
|
|
|
if(state.vuex_socket.readyState != 1){
|
|
|
state.vuex_socket = uni.connectSocket({
|
|
|
+ header: {'X-AUTH-TOKEN':token},
|
|
|
url: wsUrl, // ws 请求地址
|
|
|
complete: ()=> {
|
|
|
console.log('连接complete回调!')
|