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

182
App.vue

@ -2,115 +2,101 @@
import store from '@/store'
import socketStore from '@/uni_modules/vrapile-im/store'
import { getToken } from '@/utils/token'
import { getNodeId } from '@/utils/nodeId'
export default {
globalData: {
// appId
appId: "nine-demo-im",
//
os: "android",
//
msgTabBarIndex: 0,
//
version: "1.0.0",
//
systemInfo: {},
},
onLaunch(options) {
//
this.initConfig(options);
},
onShow() {
// websocket
this.initWebSocket();
},
onHide() {
},
methods: {
initConfig(options) {
//
this.globalData.systemInfo = uni.getSystemInfoSync()
this.globalData.os = this.globalData.systemInfo.platform
// #ifdef APP-PLUS
plus.runtime.getProperty(plus.runtime.appid, (wgtinfo) => {
if(wgtinfo.version){
this.globalData.version = wgtinfo.version;
}else{
//
this.globalData.version = plus.runtime.version;
}
});
// #endif
//
this.globalData.terminal = "udemo_im_other";
// #ifdef MP-WEIXIN
this.globalData.terminal = "udemo_im_wx";
// #endif
// #ifdef H5
this.globalData.terminal = "udemo_im_h5";
// #endif
// #ifdef APP-PLUS
this.globalData.terminal = "udemo_im_app";
// #endif
getNodeId();
//
if(options && options.query && options.query.invitee){
this.globalData.invitee = options.query.invitee;
}
},
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() });
});
// #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
}
}
}
}
import { getNodeId } from '@/utils/nodeId'
export default {
globalData: {
appId: "nine-demo-im",
//
os: "android",
//
version: "1.0.0",
//
systemInfo: {},
//
chatIndex: 0,
},
// http://localhost:38081/udemo/im/#/?shopId=001&seatId=001
onLaunch(options) {
this.initSysConfig(options);
},
onShow() {
this.initWebSocket();
},
onHide() {
},
methods: {
initSysConfig(options) {
//
this.globalData.systemInfo = uni.getSystemInfoSync()
this.globalData.os = this.globalData.systemInfo.platform
// #ifdef APP-PLUS
plus.runtime.getProperty(plus.runtime.appid, (wgtinfo) => {
if(wgtinfo.version){
this.globalData.version = wgtinfo.version;
}else{
this.globalData.version = plus.runtime.version;
}
});
// #endif
//
this.globalData.terminal = import.meta.env.VITE_APP_FLAG + "_other";
// #ifdef MP-WEIXIN
this.globalData.terminal = import.meta.env.VITE_APP_FLAG + "_wx";
// #endif
// #ifdef H5
this.globalData.terminal = import.meta.env.VITE_APP_FLAG + "_h5";
// #endif
// #ifdef APP-PLUS
this.globalData.terminal = import.meta.env.VITE_APP_FLAG + "_app";
// #endif
getNodeId();
//
if(options && options.query && options.query.invitee){
this.globalData.invitee = options.query.invitee;
}
},
initWebSocket(){
if(getToken()){
store.dispatch('GetChatList').then(res => {
store.dispatch('ConnSocket');
});
}
}
}
}
</script>
<style lang="scss">
html, body, #app{
height: 100%;
background-color: #f1f1f1;
height: 100%;
background-color: #f1f1f1;
}
.nine-content-001{
padding: 0;
margin: 0;
width: 750rpx;
height: calc(100vh - 0px);
background-color: #f1f1f1;
display: flex;
flex-direction: column;
padding: 0;
margin: 0;
width: 750rpx;
height: calc(100vh - 0px);
background-color: #f1f1f1;
display: flex;
flex-direction: column;
}
.nine-content-002{
padding: 0;
margin: 0;
width: 750rpx;
height: calc(100vh - 50px);
/* #ifndef H5 */
height: calc(100vh - 0px);
/* #endif */
background-color: #f1f1f1;
display: flex;
flex-direction: column;
padding: 0;
margin: 0;
width: 750rpx;
height: calc(100vh - 50px);
/* #ifndef H5 */
height: calc(100vh - 0px);
/* #endif */
background-color: #f1f1f1;
display: flex;
flex-direction: column;
}
// uni.showModal
.uni-modal__bd{
text-align: left
text-align: left
}
@import './static/style/nine-image-001.scss';

Loading…
Cancel
Save