|
|
|
@ -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 |
|
|
|
// 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 |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
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'; |
|
|
|
|