Commit 928c441b authored by wuwangwolihui's avatar wuwangwolihui

营地2.0-整合修改

parent b614583b
...@@ -91,7 +91,6 @@ ...@@ -91,7 +91,6 @@
}, },
// 去登录页 // 去登录页
toLogin() { toLogin() {
console.log(this.type)
if (this.type == 1) { if (this.type == 1) {
this.$router.push("/baseLogin"); this.$router.push("/baseLogin");
} else if (this.type == 2) { } else if (this.type == 2) {
......
...@@ -108,6 +108,7 @@ export function request(config) { ...@@ -108,6 +108,7 @@ export function request(config) {
const LabelType = '/activity/labelType'; const LabelType = '/activity/labelType';
const HotList = '/activityCenter/hotList'; const HotList = '/activityCenter/hotList';
const GetActiveInfo = '/activityCenter/detail/'; const GetActiveInfo = '/activityCenter/detail/';
const HomeHot = '/activityCenter/hot';
if ((config.url.indexOf(loginUrl) != -1 && config.url.indexOf(loginOut) == -1) || if ((config.url.indexOf(loginUrl) != -1 && config.url.indexOf(loginOut) == -1) ||
config.url.indexOf(setAccountInfo) != -1 || config.url.indexOf(setAccountInfo) != -1 ||
config.url.indexOf(passMsgOld) != -1 || config.url.indexOf(passMsgOld) != -1 ||
...@@ -121,27 +122,32 @@ export function request(config) { ...@@ -121,27 +122,32 @@ export function request(config) {
config.url.indexOf(setLog) != -1 || config.url.indexOf(setLog) != -1 ||
config.url.indexOf(LabelType) != -1 || config.url.indexOf(LabelType) != -1 ||
config.url.indexOf(HotList) != -1 || config.url.indexOf(HotList) != -1 ||
config.url.indexOf(GetActiveInfo) != -1) { config.url.indexOf(GetActiveInfo) != -1 ||
config.url.indexOf(HomeHot) != -1) {
return config return config
} }
const token = localStorage.getItem('index-token-all'); const token = localStorage.getItem('index-token-all');
console.log(token, store.state.isLogin)
if (token) { if (token) {
config.headers.token = token; config.headers.token = token;
} else { } else {
// router.push({
// path: '/login',
// query: {
// redirect: router.currentRoute.fullPath
// } // 从哪个页面跳转
// })
router.push({ router.push({
path: '/login', path: '/' + store.state.indexIdentity,
query: {
redirect: router.currentRoute.fullPath
} // 从哪个页面跳转
}) })
const error = new Error('请登录!') const error = new Error('请登录!');
return Promise.reject(error) return Promise.reject(error);
} }
let cancel let cancel;
// 设置cancelToken对象 // 设置cancelToken对象
config.cancelToken = new axios.CancelToken((c) => { config.cancelToken = new axios.CancelToken((c) => {
cancel = c cancel = c;
}) })
if (config.url.indexOf('/web/config/getUniversity') == -1 && if (config.url.indexOf('/web/config/getUniversity') == -1 &&
config.url.indexOf('/web/config/getProfession') == -1) { config.url.indexOf('/web/config/getProfession') == -1) {
...@@ -174,7 +180,6 @@ export function request(config) { ...@@ -174,7 +180,6 @@ export function request(config) {
(res) => { (res) => {
if (res.data.code == 400034 || if (res.data.code == 400034 ||
res.data.code == 400035 || res.data.code == 400035 ||
// res.data.code == 400001 ||
res.data.code == 400002 || res.data.code == 400002 ||
res.data.code == 400003) { res.data.code == 400003) {
router.push({ router.push({
...@@ -184,7 +189,7 @@ export function request(config) { ...@@ -184,7 +189,7 @@ export function request(config) {
message: res.data.message, message: res.data.message,
duration: 1000, duration: 1000,
}); });
return return false;
} }
if (res.data.code == 400023) { if (res.data.code == 400023) {
let isLogout = res.config.url == '/web/auth/loginOut'; let isLogout = res.config.url == '/web/auth/loginOut';
...@@ -199,30 +204,35 @@ export function request(config) { ...@@ -199,30 +204,35 @@ export function request(config) {
duration: 3000, duration: 3000,
}); });
} }
return return false;
} }
if (res.data.code == 400003) { if (res.data.code == 400003 || res.data.code == 401) {
// 清除本地缓存 除了特殊缓存 // 清除本地缓存 除了特殊缓存
store.commit('removeLocalStorage'); store.commit('removeLocalStorage');
// router.push({
// path: '/login',
// query: {
// redirect: router.currentRoute.fullPath
// } // 从哪个页面跳转
// })
router.push({ router.push({
path: '/login', path: '/' + store.state.indexIdentity,
query: {
redirect: router.currentRoute.fullPath
} // 从哪个页面跳转
}) })
} }
loadingInstance && loadingInstance.close() loadingInstance && loadingInstance.close()
setTimeout(() => { setTimeout(() => {
allowRequest(reqList, res.config.url) allowRequest(reqList, res.config.url)
}, 1000) }, 1000)
return res return res;
}, },
(error) => { (error) => {
console.log(error, 'err') Message.closeAll();
Message.closeAll()
if (error.message == '请登录!') { if (error.message == '请登录!') {
// router.push({
// path: "/login?code=" + store.state.indexIdentity,
// })
router.push({ router.push({
path: "/login?code=" + store.state.indexIdentity, path: '/' + store.state.indexIdentity,
}) })
} }
if (error.response.status == 404) { if (error.response.status == 404) {
...@@ -236,15 +246,14 @@ export function request(config) { ...@@ -236,15 +246,14 @@ export function request(config) {
} else { } else {
// 增加延迟,相同请求不得在短时间内重复发送 // 增加延迟,相同请求不得在短时间内重复发送
setTimeout(() => { setTimeout(() => {
console.log(error)
allowRequest(reqList, error.config.url) allowRequest(reqList, error.config.url)
}, 1000) }, 1000)
} }
loadingInstance && loadingInstance.close() loadingInstance && loadingInstance.close()
return Promise.reject(error) return Promise.reject(error);
} }
) )
return instance(config) return instance(config);
} }
/** /**
......
...@@ -239,17 +239,19 @@ router.beforeEach((to, from, next) => { ...@@ -239,17 +239,19 @@ router.beforeEach((to, from, next) => {
if (!token) { if (!token) {
checkCam(code, (res) => { checkCam(code, (res) => {
if (res) { if (res) {
return next(toLogin); // return next(toLogin);
return next("/" + code);
} }
}); });
} else { } else {
checkCam(code, (res) => { checkCam(code, (res) => {
if (res) { if (res) {
if (token) {
return next(); return next();
} else { // if (token) {
next("/" + code); // return next();
} // } else {
// next("/" + code);
// }
} }
}); });
} }
......
...@@ -12,7 +12,6 @@ let state = { ...@@ -12,7 +12,6 @@ let state = {
fullPath: localStorage.getItem("index-fullPath") || "/", fullPath: localStorage.getItem("index-fullPath") || "/",
// 数据 // 数据
data: [], data: [],
token: '',
indexIdentity: localStorage.getItem("index-identity") || "", indexIdentity: localStorage.getItem("index-identity") || "",
human: 0,//清华人文学院 human: 0,//清华人文学院
baseSchool: 0,//基地 baseSchool: 0,//基地
...@@ -23,6 +22,7 @@ let state = { ...@@ -23,6 +22,7 @@ let state = {
info: {}, info: {},
isCloseCamp: 0,//是否关闭营地 isCloseCamp: 0,//是否关闭营地
signUpInfo: {}, signUpInfo: {},
token: localStorage.getItem("index-token-all") || "",
isLogin: localStorage.getItem("isLogin") || "0", // 只有1为已登录 isLogin: localStorage.getItem("isLogin") || "0", // 只有1为已登录
activeIndex: window.localStorage.getItem('index-active-path') || "0", activeIndex: window.localStorage.getItem('index-active-path') || "0",
}; };
......
...@@ -8,14 +8,17 @@ export default { ...@@ -8,14 +8,17 @@ export default {
setData(state, city) { setData(state, city) {
state.data = city; state.data = city;
}, },
login(state) { login(state, token) {
state.isLogin = "1"; state.isLogin = "1";
state.token = token;
localStorage.setItem("isLogin", "1"); localStorage.setItem("isLogin", "1");
localStorage.setItem("index-token-all", token);
}, },
loginOut(state) { loginOut(state) {
state.isLogin = "0"; state.isLogin = "0";
localStorage.removeItem("token"); state.token = "";
localStorage.removeItem("isLogin"); localStorage.removeItem("isLogin");
localStorage.removeItem("index-token-all");
}, },
setIndexIdentity(state, code) { setIndexIdentity(state, code) {
state.indexIdentity = code; state.indexIdentity = code;
...@@ -26,11 +29,11 @@ export default { ...@@ -26,11 +29,11 @@ export default {
state.activeIndex = key; state.activeIndex = key;
window.localStorage.setItem('index-active-path', key); window.localStorage.setItem('index-active-path', key);
}, },
setFullPath(state, path){ setFullPath(state, path) {
state.fullPath = path; state.fullPath = path;
window.localStorage.setItem('index-fullPath', path); window.localStorage.setItem('index-fullPath', path);
}, },
removeLocalStorage(state){ removeLocalStorage(state) {
for (let key in window.localStorage) { for (let key in window.localStorage) {
if (key.indexOf('email') == -1 && if (key.indexOf('email') == -1 &&
key.indexOf('multiform') == -1 && key.indexOf('multiform') == -1 &&
...@@ -42,5 +45,7 @@ export default { ...@@ -42,5 +45,7 @@ export default {
window.localStorage.removeItem(key); window.localStorage.removeItem(key);
} }
} }
state.isLogin = "0";
state.token = "";
}, },
}; };
...@@ -117,7 +117,8 @@ ...@@ -117,7 +117,8 @@
url: banner2 url: banner2
}], }],
activeList: [], activeList: [],
reflectionsList: [{ reflectionsList: [
{
name: '同学', name: '同学',
think: '我想小鸟肯定是害怕了,小鸟失去了自由,一定高兴不起来了,只有外面的天空才是小鸟的家,小鸟被细绳牵着失去自由实在是太可怜了,我决心把小鸟放走我轻轻的走过去,把小鸟腿上的细绳解开了。我把小鸟放在窗台上,我站在远处看着它,只见小鸟趴在窗台上还是一动也不动,嘴巴张着。妈妈说小鸟可能吓坏了,我有点后悔。后来过了好一会儿,小鸟才回过神来,它眨了眨眼睛,慢慢飞了起来。我看我觉的小鸟是我们人类的朋友,我们不能伤害小鸟,只有让小鸟在天空中自由的飞翔,它才会感到快乐', think: '我想小鸟肯定是害怕了,小鸟失去了自由,一定高兴不起来了,只有外面的天空才是小鸟的家,小鸟被细绳牵着失去自由实在是太可怜了,我决心把小鸟放走我轻轻的走过去,把小鸟腿上的细绳解开了。我把小鸟放在窗台上,我站在远处看着它,只见小鸟趴在窗台上还是一动也不动,嘴巴张着。妈妈说小鸟可能吓坏了,我有点后悔。后来过了好一会儿,小鸟才回过神来,它眨了眨眼睛,慢慢飞了起来。我看我觉的小鸟是我们人类的朋友,我们不能伤害小鸟,只有让小鸟在天空中自由的飞翔,它才会感到快乐',
tag: ['北京市第八中序', '2023南开历史营'] tag: ['北京市第八中序', '2023南开历史营']
...@@ -166,11 +167,10 @@ ...@@ -166,11 +167,10 @@
getHot() { getHot() {
hot().then((res) => { hot().then((res) => {
if (res.data.code != 200) { if (res.data.code != 200) {
return this.$message.error(res.data.message); return this.$message.error(res.data.msg);
} }
this.$message.success(res.data.message);
this.activeList = res.data.data; this.activeList = res.data.data;
}) }).catch(err=>{})
}, },
} }
} }
......
...@@ -283,7 +283,7 @@ ...@@ -283,7 +283,7 @@
return this.$message.error(res.data.message); return this.$message.error(res.data.message);
} }
this.$message.success("登录成功"); this.$message.success("登录成功");
window.localStorage.setItem("index-token-all", res.data.token); this.$store.commit('login', res.data.token);
window.localStorage.setItem("index-phone-all", this.loginForm.phone); window.localStorage.setItem("index-phone-all", this.loginForm.phone);
window.localStorage.setItem("email", res.data.email); window.localStorage.setItem("email", res.data.email);
let fullPath = this.$store.state.fullPath; let fullPath = this.$store.state.fullPath;
......
...@@ -289,7 +289,7 @@ ...@@ -289,7 +289,7 @@
} }
// this.$message.success(res.data.message); // this.$message.success(res.data.message);
// token存储 // token存储
window.localStorage.setItem("index-token-all", res.data.token); this.$store.commit('login', res.data.token);
window.localStorage.setItem("index-phone-all", this.registerForm.phone); window.localStorage.setItem("index-phone-all", this.registerForm.phone);
// 跳转到报名 // 跳转到报名
this.$router.replace("/signUpList"); this.$router.replace("/signUpList");
......
...@@ -298,7 +298,7 @@ ...@@ -298,7 +298,7 @@
// 跳转到报名 // 跳转到报名
const code = this.$store.state.indexIdentity; const code = this.$store.state.indexIdentity;
// token存储 // token存储
window.localStorage.setItem("index-token-all", res.data.token); this.$store.commit('login', res.data.token);
window.localStorage.setItem("index-phone-all", this.loginForm.phone); window.localStorage.setItem("index-phone-all", this.loginForm.phone);
window.localStorage.setItem("email" + code, res.data.email); window.localStorage.setItem("email" + code, res.data.email);
// 报名信息 // 报名信息
......
...@@ -301,7 +301,7 @@ ...@@ -301,7 +301,7 @@
// this.$message.success(res.data.message); // this.$message.success(res.data.message);
let code = this.$store.state.indexIdentity; let code = this.$store.state.indexIdentity;
// token存储 // token存储
window.localStorage.setItem("index-token-all", res.data.token); this.$store.commit('login', res.data.token);
window.localStorage.setItem("index-phone-all", this.registerForm.phone); window.localStorage.setItem("index-phone-all", this.registerForm.phone);
// window.localStorage.setItem("email" + code, this.registerForm.email); // window.localStorage.setItem("email" + code, this.registerForm.email);
// 报名信息 // 报名信息
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment