This commit is contained in:
Gdpao
2020-08-15 19:14:12 +08:00
parent 55742478b2
commit c2346375c8
8 changed files with 285 additions and 277 deletions

34
App.vue
View File

@@ -4,9 +4,9 @@
globalData: {
im: {}
},
computed: {
...mapState(["hasLogin"])
},
computed: {
...mapState(["hasLogin"])
},
onLaunch() {
getApp().globalData.im = this.imService
// 缓存token
@@ -16,23 +16,23 @@
this.loginIn(res.data);
}
})
// 刷新token
if (this.hasLogin) {
this.refreshToken_function();
}
// 刷新token
if (this.hasLogin) {
this.refreshToken_function();
}
},
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值
}
})
},
// 刷新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>