deming/App.vue

92 lines
2.3 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 { mapMutations, mapState } from 'vuex';
export default {
globalData: {
im: {}
},
computed: {
...mapState(["hasLogin"])
},
onLaunch() {
// 禁止旋转
// #ifdef APP-PLUS
plus.screen.lockOrientation('portrait-primary');
// #endif
getApp().globalData.im = this.imService
// 缓存token
uni.getStorage({
key: "token",
success: (res) => {
this.loginIn(res.data);
}
})
// 刷新token
if (this.hasLogin) {
this.refreshToken_function();
}
// #ifdef APP-PLUS
//app关闭默认的启动 方法关闭启动图。但是这个时间不能太晚6s 超时后依旧会主动关闭。
setTimeout(()=>{
plus.navigator.closeSplashscreen();
},3000)
// #endif
},
onShow(){
// this.getVersion();
// console.log(this.$u.os())
let device_type = this.$u.os()
console.log({appversion:this.$app_version,device_type})
this.$u.api.recordAppOpenTimes({appversion:this.$app_version,device_type}).then((res)=>{
console.log(JSON.stringify(res))
});
},
onLoad() {
},
onHide(){
},
methods: {
...mapMutations(['loginIn']),
// 刷新token
refreshToken_function(){
this.$u.api.refreshToken({}).then((res) => {
// console.log(res);
if (res.errCode == 0) {
let token = res.data.token;
uni.setStorageSync('token', token);//存储toke值
}
})
},
getVersion() {
this.$u.post("Specialci/checkVersion",{ app_version: this.$app_version }).then(res => {
// console.log(res);
if(res.data.app_version != this.$app_version) {
this.$u.route('/pageE/setting/updateVersion', {
status: res.data.is_focus_upgrade
});
}
})
},
}
}
</script>
<style lang="scss">
/* #ifndef APP-PLUS-NVUE */
@import "/static/css/normalize";
/* 顶部自定义导航留白 */
.status_bar {
width: 100%;
height: var(--status-bar-height);
}
/* 自定义下拉 */
.load-size {
::v-deep.u-more-text {
font-size: 20rpx !important;
}
}
/* #endif */
</style>