deming/App.vue

55 lines
1.3 KiB
Vue
Raw Permalink Normal View History

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