|
|
@ -5,29 +5,27 @@ |
|
|
import { getNodeId } from '@/utils/nodeId' |
|
|
import { getNodeId } from '@/utils/nodeId' |
|
|
export default { |
|
|
export default { |
|
|
globalData: { |
|
|
globalData: { |
|
|
// appId |
|
|
|
|
|
appId: "nine-demo-im", |
|
|
appId: "nine-demo-im", |
|
|
// 系统平台 |
|
|
|
|
|
|
|
|
// 操作系统 |
|
|
os: "android", |
|
|
os: "android", |
|
|
// 消息页所在索引 |
|
|
|
|
|
msgTabBarIndex: 0, |
|
|
|
|
|
// 版本号 |
|
|
// 版本号 |
|
|
version: "1.0.0", |
|
|
version: "1.0.0", |
|
|
// 手机信息 |
|
|
// 手机信息 |
|
|
systemInfo: {}, |
|
|
systemInfo: {}, |
|
|
|
|
|
// 消息页所在索引 |
|
|
|
|
|
chatIndex: 0, |
|
|
}, |
|
|
}, |
|
|
|
|
|
// http://localhost:38081/udemo/im/#/?shopId=001&seatId=001 |
|
|
onLaunch(options) { |
|
|
onLaunch(options) { |
|
|
// 初始化应用配置 |
|
|
|
|
|
this.initConfig(options); |
|
|
|
|
|
|
|
|
this.initSysConfig(options); |
|
|
}, |
|
|
}, |
|
|
onShow() { |
|
|
onShow() { |
|
|
// 连接websocket |
|
|
|
|
|
this.initWebSocket(); |
|
|
this.initWebSocket(); |
|
|
}, |
|
|
}, |
|
|
onHide() { |
|
|
onHide() { |
|
|
}, |
|
|
}, |
|
|
methods: { |
|
|
methods: { |
|
|
initConfig(options) { |
|
|
|
|
|
|
|
|
initSysConfig(options) { |
|
|
// 获取手机信息 |
|
|
// 获取手机信息 |
|
|
this.globalData.systemInfo = uni.getSystemInfoSync() |
|
|
this.globalData.systemInfo = uni.getSystemInfoSync() |
|
|
this.globalData.os = this.globalData.systemInfo.platform |
|
|
this.globalData.os = this.globalData.systemInfo.platform |
|
|
@ -36,21 +34,21 @@ |
|
|
if(wgtinfo.version){ |
|
|
if(wgtinfo.version){ |
|
|
this.globalData.version = wgtinfo.version; |
|
|
this.globalData.version = wgtinfo.version; |
|
|
}else{ |
|
|
}else{ |
|
|
// 获取当前版本号 |
|
|
|
|
|
this.globalData.version = plus.runtime.version; |
|
|
this.globalData.version = plus.runtime.version; |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
// #endif |
|
|
// #endif |
|
|
// 终端 |
|
|
|
|
|
this.globalData.terminal = "udemo_im_other"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 终端和节点 |
|
|
|
|
|
this.globalData.terminal = import.meta.env.VITE_APP_FLAG + "_other"; |
|
|
// #ifdef MP-WEIXIN |
|
|
// #ifdef MP-WEIXIN |
|
|
this.globalData.terminal = "udemo_im_wx"; |
|
|
|
|
|
|
|
|
this.globalData.terminal = import.meta.env.VITE_APP_FLAG + "_wx"; |
|
|
// #endif |
|
|
// #endif |
|
|
// #ifdef H5 |
|
|
// #ifdef H5 |
|
|
this.globalData.terminal = "udemo_im_h5"; |
|
|
|
|
|
|
|
|
this.globalData.terminal = import.meta.env.VITE_APP_FLAG + "_h5"; |
|
|
// #endif |
|
|
// #endif |
|
|
// #ifdef APP-PLUS |
|
|
// #ifdef APP-PLUS |
|
|
this.globalData.terminal = "udemo_im_app"; |
|
|
|
|
|
|
|
|
this.globalData.terminal = import.meta.env.VITE_APP_FLAG + "_app"; |
|
|
// #endif |
|
|
// #endif |
|
|
getNodeId(); |
|
|
getNodeId(); |
|
|
|
|
|
|
|
|
@ -61,21 +59,9 @@ |
|
|
}, |
|
|
}, |
|
|
initWebSocket(){ |
|
|
initWebSocket(){ |
|
|
if(getToken()){ |
|
|
if(getToken()){ |
|
|
// #ifdef APP-PLUS |
|
|
|
|
|
// app无法获取本地存储的websocket状态,只能进行重连 |
|
|
|
|
|
socketStore.dispatch('GetChatList', {userId: store.state.user.userInfo.userId}).then( res => { |
|
|
|
|
|
socketStore.dispatch('ConnSocket', { url: import.meta.env.VITE_APP_SOCKET_URL, token: getToken() }); |
|
|
|
|
|
|
|
|
store.dispatch('GetChatList').then(res => { |
|
|
|
|
|
store.dispatch('ConnSocket'); |
|
|
}); |
|
|
}); |
|
|
// #endif |
|
|
|
|
|
// #ifndef APP-PLUS |
|
|
|
|
|
if(!socketStore.state.socket.websocket |
|
|
|
|
|
|| !socketStore.state.socket.websocket.getReadyState |
|
|
|
|
|
|| socketStore.state.socket.websocket.getReadyState() != 1){ |
|
|
|
|
|
socketStore.dispatch('GetChatList', {userId: store.state.user.userInfo.userId}).then( res => { |
|
|
|
|
|
socketStore.dispatch('ConnSocket', { url: import.meta.env.VITE_APP_SOCKET_URL, token: getToken() }); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
// #endif |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|