进入uniapp
This commit is contained in:
99
im-uniapp/App.vue
Normal file
99
im-uniapp/App.vue
Normal file
@@ -0,0 +1,99 @@
|
||||
<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>
|
||||
Reference in New Issue
Block a user