diff --git a/src/pages/activity/activity_index.vue b/src/pages/activity/activity_index.vue index cdbe16a..97125c1 100644 --- a/src/pages/activity/activity_index.vue +++ b/src/pages/activity/activity_index.vue @@ -75,7 +75,8 @@ > - + +
+
diff --git a/src/store/modules/user.ts b/src/store/modules/user.ts index f203d56..5e21a65 100644 --- a/src/store/modules/user.ts +++ b/src/store/modules/user.ts @@ -4,7 +4,7 @@ const InitUserInfo = { // 定义的state初始值 const state = { - token: localStorage.getItem('associationToken') || 'main_token', // 默认token不走权限 + token: localStorage.getItem('associationToken') || '', // 默认token不走权限 userInfo: InitUserInfo, association:localStorage.getItem('associationInfo') || '', //apiUrl:'http://192.168.3.130', @@ -43,7 +43,7 @@ const actions = { const mockLogin = async (userInfo) => { // 登录请求流程 console.log(userInfo); - commit('setAssociation',userInfo[0]); + commit('setAssociation',userInfo); return{ code: 200, } @@ -51,23 +51,28 @@ const actions = { const res = await mockLogin(userInfo); if (res.code === 200) { - commit('setToken', 'main_token'); + console.log('token',userInfo.token); + commit('setToken',userInfo.token); } else { return res; } }, async getUserInfo({ commit, state }) { const mockRemoteUserInfo = async (token) => { - if (token === 'main_token') { return { name: 'td_main', roles: ['ALL_ROUTERS'], }; - } - return { - name: 'td_dev', - roles: ['UserIndex', 'DashboardBase', 'login'], - }; + // if (token === 'main_token') { + // return { + // name: 'td_main', + // roles: ['ALL_ROUTERS'], + // }; + // } + // return { + // name: 'td_dev', + // roles: ['UserIndex', 'DashboardBase', 'login'], + // }; }; const res = await mockRemoteUserInfo(state.token); diff --git a/src/utils/request.ts b/src/utils/request.ts index 9b23562..3c778bf 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -28,7 +28,12 @@ instance.interceptors.request.use((config) => { }else{ var association=JSON.parse(store.state.user.association); } - config.data = { ...config.data, association_id: association.id }; + const token = store.state.user.token; + if (token) { + // 添加token请求头 + config.headers.token = token; + } + config.data = { ...config.data, association_id: association.id}; } console.log(config.data);