deming/App.vue
2020-08-17 16:57:23 +08:00

61 lines
1.4 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 { mapMutations, mapState } from 'vuex';
export default {
globalData: {
im: {}
},
computed: {
...mapState(["hasLogin"])
},
onLaunch() {
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
},
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值
}
})
},
}
}
</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>