Files
im-system/im-uniapp/App.vue
2023-12-01 23:57:44 +08:00

100 lines
2.2 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<script>
import {
version,
name
} from './package.json'
import {
versionName
} from '@/manifest.json'
import {appInit} from "@/common/utils.js"
import consoleImgs from '@/common/consoleImgs.js'
// #ifdef APP-PLUS
import appUpgrade from '@/common/appUpgrade.js';
const TUICalling = uni.requireNativePlugin("TUICallingUniPlugin-TUICallingModule");
// #endif
export default {
onLaunch: function() {
localStorage.setItem("appId",10000)
appInit(500).then((res)=>{
console.log("获取到token创建长链接")
this.$store.dispatch('getAddressList');
setTimeout(()=>{
this.$socketTask.connectSocket()
uni.setStorageSync("initReady",1)
},1000)
}).then((error)=>{
console.log("未获取到IM的token")
console.log(error)
})
console.log(consoleImgs.fz)
// todo 下列两行
uni.setStorageSync('device', 'H5');
uni.setStorageSync('version', versionName);
},
onShow: function() {
console.log('App Show')
uni.getStorage({
key: 'call',
success: (res) => {
var callx=res.data
if(callx){
var call=JSON.parse(callx)
function getInervalHour(startDate) {//获取两个时间之间的小时
if (!startDate) {
return '0秒'
}
var ms = new Date().getTime() - startDate;
if (ms < 0) return '0秒';
if((ms/1000)<60){
return Math.floor(ms / 1000)+'';
}else{
return Math.floor(ms / 1000 /60)+'';
}
}
var msgType=''
if(call.type=='audio'){
msgType='TRTC_VOICE_END'
}
if(call.type=='video'){
msgType='TRTC_VIDEO_END'
}
this.$fc.pushOutMsg({
msgContent:getInervalHour(call.startTime),
msgType:msgType,
windowType:'SINGLE',
userId:call.userId,
})
uni.removeStorageSync('call')
}
}
});
},
onHide: function() {
console.log('App Hide')
}
}
</script>
<style lang="scss">
/*每个页面公共css */
@import '@/uni_modules/uni-scss/index.scss';
@import "@/static/styles/animation.css";
/* #ifndef APP-NVUE */
@import '@/static/customicons.css';
// 设置整个项目的背景色
page {
box-sizing: border-box;
}
/* #endif */
// 以下内容最好转移到单页
</style>