2020-05-29 11:13:55 +08:00
|
|
|
<script>
|
2020-08-05 21:06:29 +08:00
|
|
|
import { mapMutations, mapState } from 'vuex';
|
2020-07-31 08:45:30 +08:00
|
|
|
export default {
|
2020-08-05 21:06:29 +08:00
|
|
|
computed: {
|
|
|
|
...mapState(["hasLogin"])
|
|
|
|
},
|
2020-07-31 08:45:30 +08:00
|
|
|
onLaunch() {
|
|
|
|
// 缓存token
|
|
|
|
uni.getStorage({
|
|
|
|
key: "token",
|
|
|
|
success: (res) => {
|
|
|
|
this.loginIn(res.data);
|
|
|
|
}
|
|
|
|
})
|
2020-08-05 21:06:29 +08:00
|
|
|
// 刷新token
|
|
|
|
if (this.hasLogin) {
|
|
|
|
this.refreshToken_function();
|
|
|
|
}
|
2020-07-31 08:45:30 +08:00
|
|
|
},
|
|
|
|
methods: {
|
2020-08-05 21:06:29 +08:00
|
|
|
...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值
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
2020-07-31 08:45:30 +08:00
|
|
|
}
|
|
|
|
}
|
2020-05-29 11:13:55 +08:00
|
|
|
</script>
|
2020-06-02 08:47:57 +08:00
|
|
|
<style lang="scss">
|
2020-07-31 08:45:30 +08:00
|
|
|
/* #ifndef APP-PLUS-NVUE */
|
|
|
|
@import "/static/css/normalize";
|
2020-08-03 21:40:22 +08:00
|
|
|
/* 顶部自定义导航留白 */
|
|
|
|
.status_bar {
|
|
|
|
width: 100%;
|
|
|
|
height: var(--status-bar-height);
|
|
|
|
}
|
2020-07-31 08:45:30 +08:00
|
|
|
/* #endif */
|
2020-08-01 11:16:53 +08:00
|
|
|
</style>
|