Commit 928c441b authored by wuwangwolihui's avatar wuwangwolihui

营地2.0-整合修改

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