提交 2e3bc05f authored 作者: CRS's avatar CRS

nwe

上级 15ae2122
...@@ -42,6 +42,9 @@ export default { ...@@ -42,6 +42,9 @@ export default {
console.log(res.data.data) console.log(res.data.data)
this.$store.commit('changeUserData', res.data.data); this.$store.commit('changeUserData', res.data.data);
this.$router.push({name: 'firstHome'}) this.$router.push({name: 'firstHome'})
this.$store.commit('changeSession', { // 存值
session: res.data.data.sessionId
});
} else { } else {
this.$message.error(res.data.msg); this.$message.error(res.data.msg);
} }
......
import axios from 'axios'; import axios from 'axios';
// import Qs from 'qs'; // import Qs from 'qs';
import baseUrl from '../../config'; import baseUrl from '../../config';
import store from '../store';
// axios.defaults.withCredentials = true; // axios.defaults.withCredentials = true;
// 添加请求拦截器 // 添加请求拦截器
axios.interceptors.request.use(function (config) { axios.interceptors.request.use(function (config) {
// console.log(store.getters.getSession.session)
config.headers.session = store.getters.getSession.session;
// 预处理请求信息(config 发出的数据) 下方是三种请求,李迪凡的 // 预处理请求信息(config 发出的数据) 下方是三种请求,李迪凡的
if (config.method === 'post' || config.method === 'put' || config.method === 'delete') { if (config.method === 'post' || config.method === 'put' || config.method === 'delete') {
// POST传参序列化 // POST传参序列化
......
...@@ -30,6 +30,12 @@ const actions = { ...@@ -30,6 +30,12 @@ const actions = {
jumpOther: payload jumpOther: payload
}) })
}, },
changeSession(store, payload) {
store.commit({
type: 'changeSession',
session: payload
})
},
}; };
export default actions; export default actions;
...@@ -14,7 +14,10 @@ const getters = { ...@@ -14,7 +14,10 @@ const getters = {
}, },
getJumpOther(state) { getJumpOther(state) {
return state.jumpOther return state.jumpOther
} },
getSession(state) {
return state.session
},
}; };
export default getters; export default getters;
...@@ -15,6 +15,9 @@ const mutations = { ...@@ -15,6 +15,9 @@ const mutations = {
changeJumpOther(state, payload) { changeJumpOther(state, payload) {
state.jumpOther = payload; state.jumpOther = payload;
}, },
changeSession(state, payload) {
state.session = payload;
},
}; };
export default mutations; export default mutations;
...@@ -5,6 +5,7 @@ const state = { ...@@ -5,6 +5,7 @@ const state = {
homeClick: {}, // 首页点击的模块 homeClick: {}, // 首页点击的模块
nowPath: '', // 当前页面路径 nowPath: '', // 当前页面路径
jumpOther: '', // 跳转到其他页面,修改顶部子菜单样式 jumpOther: '', // 跳转到其他页面,修改顶部子菜单样式
session: '', // 请求session
}; };
export default state; export default state;
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论