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

111

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