You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
104 lines
2.6 KiB
104 lines
2.6 KiB
<script>
|
|
import store from '@/store'
|
|
import socketStore from '@/uni_modules/vrapile-im/store'
|
|
import { getToken } from '@/utils/token'
|
|
export default {
|
|
globalData: {
|
|
// appId
|
|
appId: "nine-demo-im",
|
|
// 系统平台
|
|
platform: "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.platform = 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
|
|
},
|
|
initWebSocket(){
|
|
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() });
|
|
});
|
|
// #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
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss">
|
|
html, body, #app{
|
|
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;
|
|
}
|
|
.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;
|
|
}
|
|
// uni.showModal 左对齐
|
|
.uni-modal__bd{
|
|
text-align: left
|
|
}
|
|
|
|
@import './static/style/nine-image-001.scss';
|
|
@import './static/style/nine-btn-001.scss';
|
|
@import './static/style/nine-list-001.scss';
|
|
@import './static/style/nine-nav-001.scss';
|
|
@import './static/style/nine-base-002.scss';
|
|
@import './static/style/nine-base-001.scss';
|
|
</style>
|