Эх сурвалжийг харах

token失效跳转到启动页

jwyu 3 жил өмнө
parent
commit
92d5e43c2c

+ 1 - 2
src/api/http.js

@@ -8,8 +8,6 @@ import { ElMessage } from 'element-plus'
 // axios.defaults.headers.common['Authorization'] = AUTH_TOKEN;
 // axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
 
-// 请求数
-console.log(import.meta.env.VITE_APP_API_URL);
 let config = {
   baseURL: import.meta.env.VITE_APP_API_URL,
   timeout: 10*60 * 1000, // Timeout
@@ -42,6 +40,7 @@ _axios.interceptors.response.use(
     }
     if(data.code===401){//token失效
       ElMessage.error('请重新登录')
+      wx.miniProgram.switchTab({url: '/pages/activity/activity'})
     }
     if(data.code!==200&&data.code!==403&&data.code!==4001&&data.code!==401){
       ElMessage.error(data.msg)

+ 1 - 0
src/layout/Index.vue

@@ -7,6 +7,7 @@ import { useRouter } from "vue-router";
 const router=useRouter()
 
 const store = useStore();
+store.dispatch('getUserInfo')//获取个人信息
 const userInfo = computed(() => store.state.userInfo);
 const lastTime = computed(() => {
   let timeArr = [];