Commit 021af906 authored by 孟飞's avatar 孟飞

111

parent ee7a5caa
......@@ -9,7 +9,8 @@ import indexCamp from './index/camp'
import {
getCam
} from "r/index/login";
import { Message } from 'element-ui';
Vue.prototype.$message = Message;
Vue.use(VueRouter)
......@@ -76,9 +77,20 @@ router.onError((error) => {
})
function checkCam(code, cb) {
if(!code){
Message({
message: "请访问正确的营地链接地址",
type: 'waring'
});
cb && cb(false);
return false;
}
getCam(code).then((res) => {
if (res.data.code != 200) {
this.$store.$message.error(res.data.message);
Message({
message: "请访问正确的营地链接地址",
type: 'waring'
});
cb && cb(false);
return false;
}
......@@ -113,37 +125,38 @@ router.beforeEach((to, from, next) => {
toLogin = "/login",
toRegister = "/register",
toReset = "/reset"
// toRecruit = "/:code"
let token = localStorage.getItem(tokenKey);
let nextUrl = false;
let code = false;
document.title = to.meta.title;
if (to.path == toLogin || to.path == toRegister || to.path == toReset) {
// nextUrl = false;
code = to.params.code;
code = to.params.code ? to.params.code : to.query.code;
checkCam(code, (res) => {
if (res) {
nextUrl = false;
return next();
}
});
} else if (to.name == "recruit") {
code = to.params.code;
console.log(code,'code')
to.path == "/:code"
checkCam(code, (res) => {
if (res) {
nextUrl = false;
return next();
}
});
} else {
if (!token) {
nextUrl = toLogin;
return next(toLogin);
} else {
nextUrl = false;
code = to.params.code ? to.params.code : to.query.code;
checkCam(code, (res) => {
if (res) {
return next();
}
});
}
}
document.title = to.meta.title;
return nextUrl ? next(nextUrl) : next();
// return nextUrl ? next(nextUrl) : next();
})
// 页面跳转之后页面回滚到顶部
......
......@@ -78,7 +78,6 @@ export default {
if (res.data.code != 200) {
return this.$message.error(res.data.message);
}
this.$message.success(res.data.message);
this.info = res.data;
});
},
......
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