启动时,增加对token的检查

This commit is contained in:
daihh
2023-03-16 16:10:18 +08:00
parent 17dd44937e
commit 13e83580d3
5 changed files with 53 additions and 43 deletions

14
App.vue
View File

@@ -1,5 +1,6 @@
<script>
import Vue from 'vue'
import apiUserbasic from '@/api/boe/userbasic.js'
export default {
name: 'App',
onLaunch: function() {
@@ -18,22 +19,21 @@
//console.log(this.$width,'$width');
}
});
//获取或加载一次用户信息
//console.log('App Launch');
//登录页面不需要,此页面用于本地测试
//console.log(location.href,'location.href');
var href=location.href;
if(href.indexOf('/pages/login/login')==-1){
//不包含登录页和加载页
if(href.indexOf('/pages/login/login')==-1 && href.indexOf('/pages/login/loading')==-1){
//先做登录校验
//每次加载增加一次对token的验证直接调用用户中心的接口,如果token不对这里会直接返回登录
apiUserbasic.getUserInfo();
this.$store.dispatch('GetUserInfo');
}
},
mounted() {
},
onShow: function() {
},
onHide: function() {