袁磊 8 months ago
parent
commit
219db9e575
  1. 42
      App.vue

42
App.vue

@ -5,29 +5,27 @@
import { getNodeId } from '@/utils/nodeId'
export default {
globalData: {
// appId
appId: "nine-demo-im",
//
//
os: "android",
//
msgTabBarIndex: 0,
//
version: "1.0.0",
//
systemInfo: {},
//
chatIndex: 0,
},
// http://localhost:38081/udemo/im/#/?shopId=001&seatId=001
onLaunch(options) {
//
this.initConfig(options);
this.initSysConfig(options);
},
onShow() {
// websocket
this.initWebSocket();
},
onHide() {
},
methods: {
initConfig(options) {
initSysConfig(options) {
//
this.globalData.systemInfo = uni.getSystemInfoSync()
this.globalData.os = this.globalData.systemInfo.platform
@ -36,21 +34,21 @@
if(wgtinfo.version){
this.globalData.version = wgtinfo.version;
}else{
//
this.globalData.version = plus.runtime.version;
}
});
// #endif
//
this.globalData.terminal = "udemo_im_other";
//
this.globalData.terminal = import.meta.env.VITE_APP_FLAG + "_other";
// #ifdef MP-WEIXIN
this.globalData.terminal = "udemo_im_wx";
this.globalData.terminal = import.meta.env.VITE_APP_FLAG + "_wx";
// #endif
// #ifdef H5
this.globalData.terminal = "udemo_im_h5";
this.globalData.terminal = import.meta.env.VITE_APP_FLAG + "_h5";
// #endif
// #ifdef APP-PLUS
this.globalData.terminal = "udemo_im_app";
this.globalData.terminal = import.meta.env.VITE_APP_FLAG + "_app";
// #endif
getNodeId();
@ -61,21 +59,9 @@
},
initWebSocket(){
if(getToken()){
// #ifdef APP-PLUS
// appwebsocket
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
}
}
}

Loading…
Cancel
Save