67 lines
1.5 KiB
Vue
67 lines
1.5 KiB
Vue
<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
|
||
},
|
||
onShow(){
|
||
|
||
},
|
||
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值
|
||
}
|
||
})
|
||
},
|
||
}
|
||
}
|
||
</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>
|