emis-app/App.vue

167 lines
3.7 KiB
Vue
Raw Normal View History

2023-11-25 16:30:38 +00:00
<script>
import {
mapMutations
} from 'vuex'
import {
version
} from './package.json'
2024-06-15 17:56:52 +00:00
// import checkUpdate from '@/uni_modules/uni-upgrade-center-app/utils/check-update';
2024-04-24 07:15:06 +00:00
import { USERKEY, COMMONKEY } from "@/store/actionKey"
2024-06-15 17:56:52 +00:00
import { checkUpdate } from "@/common/appUpdate"
2024-07-30 06:01:00 +00:00
import { setSessionSystemInfo, getSessionSystemInfo } from "@/session"
2024-06-16 14:35:23 +00:00
import { onPushMessage } from "@/common/messageNotice"
2023-11-25 16:30:38 +00:00
export default {
2023-12-18 16:30:33 +00:00
globalData: {
},
2023-11-25 16:30:38 +00:00
onLaunch: function() {
this.$store.dispatch(USERKEY.GETUSERINFO)
2024-04-24 08:59:00 +00:00
this.$store.dispatch(COMMONKEY.GETDIC)
2024-06-16 14:35:23 +00:00
// 监听消息通知
onPushMessage()
2023-11-25 16:30:38 +00:00
// #ifdef H5
console.log(
`%c hello uniapp %c v${version} `,
'background:#35495e ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff',
'background:#007aff ;padding: 1px; border-radius: 0 3px 3px 0; color: #fff; font-weight: bold;'
)
// #endif
// 线上示例使用
console.log('App Launch');
// #ifdef APP-PLUS
// 一键登录预登陆,可以显著提高登录速度
uni.preLogin({
provider: 'univerify',
success: (res) => {
// 成功
this.setUniverifyErrorMsg();
console.log("preLogin success: ", res);
},
fail: (res) => {
this.setUniverifyLogin(false);
this.setUniverifyErrorMsg(res.errMsg);
// 失败
console.log("preLogin fail res: ", res);
}
})
// #endif
},
onShow: function() {
console.log('HHH Show')
2024-07-30 06:01:00 +00:00
this.updateActiveTime()
2024-06-19 05:05:13 +00:00
this.appCheckUpdate()
2023-11-25 16:30:38 +00:00
},
onHide: function() {
2024-07-30 06:01:00 +00:00
this.updateActiveTime({ directUpdate: true })
2023-11-25 16:30:38 +00:00
console.log('HHH Hide')
},
globalData: {
test: ''
},
methods: {
2024-06-19 05:05:13 +00:00
...mapMutations(['setUniverifyErrorMsg', 'setUniverifyLogin']),
appCheckUpdate(){
console.log("appCheckUpdate=============")
checkUpdate()
2024-07-30 06:01:00 +00:00
},
async updateActiveTime(opt = {}){
let { directUpdate } = opt
let { lastActiveTime } = getSessionSystemInfo()
let curTime = new Date().valueOf()
let diff = (curTime - lastActiveTime)
// 活跃时间间隔超过一个小时 需要重新登录
if(diff > 1000 * 60 * 60 && !directUpdate) {
await this.$store.dispatch(USERKEY.LOGOUT)
this.goto(`login/login`, 2)
} else {
setSessionSystemInfo({ lastActiveTime: curTime })
}
2024-06-19 05:05:13 +00:00
}
2023-11-25 16:30:38 +00:00
}
}
</script>
<style lang="scss">
2023-12-18 16:30:33 +00:00
@import '@/common/custom.scss';
2023-12-05 04:27:07 +00:00
@import '@/uni_modules/uview-plus/index.scss';
2023-11-30 23:16:07 +00:00
/* 注意要写在第一行,同时给style标签加入lang="scss"属性 */
2023-11-25 16:30:38 +00:00
@import '@/uni_modules/uni-scss/index.scss';
/* #ifndef APP-PLUS-NVUE */
/* uni.css - 通用组件、模板样式库,可以当作一套ui库应用 */
@import './common/uni.css';
@import '@/static/customicons.css';
/* H5 兼容 pc 所需 */
/* #ifdef H5 */
@media screen and (min-width: 768px) {
body {
overflow-y: scroll;
}
}
/* 顶栏通栏样式 */
/* .uni-top-window {
left: 0;
right: 0;
} */
uni-page-body {
background-color: #F5F5F5 !important;
min-height: 100% !important;
height: auto !important;
}
.uni-top-window uni-tabbar .uni-tabbar {
background-color: #fff !important;
}
.uni-app--showleftwindow .hideOnPc {
display: none !important;
}
/* #endif */
/* 以下样式用于 hello uni-app 演示所需 */
page {
background-color: #efeff4;
height: 100%;
font-size: 28rpx;
/* line-height: 1.8; */
}
.fix-pc-padding {
padding: 0 50px;
}
.uni-header-logo {
padding: 30rpx;
flex-direction: column;
justify-content: center;
align-items: center;
margin-top: 10rpx;
}
.uni-header-image {
width: 100px;
height: 100px;
}
.uni-hello-text {
color: #7A7E83;
}
.uni-hello-addfile {
text-align: center;
line-height: 300rpx;
background: #FFF;
padding: 50rpx;
margin-top: 10px;
font-size: 38rpx;
color: #808080;
}
/* #endif*/
</style>