deming/App.vue

55 lines
1.3 KiB
Vue
Raw Normal View History

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-08 15:40:48 +08:00
globalData: {
im: {}
},
2020-08-05 21:06:29 +08:00
computed: {
...mapState(["hasLogin"])
},
2020-07-31 08:45:30 +08:00
onLaunch() {
2020-08-08 15:40:48 +08:00
getApp().globalData.im = this.imService
2020-07-31 08:45:30 +08:00
// 缓存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-08-09 19:08:12 +08:00
}
/* 自定义下拉 */
.load-size {
::v-deep.u-more-text {
font-size: 20rpx !important;
}
2020-08-03 21:40:22 +08:00
}
2020-07-31 08:45:30 +08:00
/* #endif */
2020-08-01 11:16:53 +08:00
</style>