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

42
App.vue

@ -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
// 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