Files
im-system/im-uniapp/App.vue
2023-12-05 20:24:36 +08:00

116 lines
2.5 KiB
Vue
Raw Permalink 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 {
data() {
return {
timer: null
}
},
onLaunch: function() {
localStorage.setItem("appId", 10000)
console.log(consoleImgs.fz)
// todo 下列两行
uni.setStorageSync('device', 'H5');
uni.setStorageSync('version', versionName);
},
onShow: function() {
console.log('App Show')
appInit(500).then((res) => {
// getAddressList
console.log("获取到token创建长链接")
this.$store.dispatch('getAddressList');
setTimeout(() => {
this.$socketTask.connectSocket(() => {
if (this.timer != null) {
console.log("连接成功,清除定时器")
clearInterval(this.timer)
this.timer = null
}
}, () => {
})
uni.setStorageSync("initReady", 1)
}, 1000)
}).then((error) => {
console.log("未获取到IM的token")
console.log(error)
})
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>