考试和问卷弹窗
This commit is contained in:
@ -1,26 +1,67 @@
|
||||
import { createRouter, createWebHistory } from "vue-router";
|
||||
import HomeView from "../views/HomeView.vue";
|
||||
|
||||
const routes = [
|
||||
{
|
||||
path: "/",
|
||||
name: "home",
|
||||
component: HomeView,
|
||||
},
|
||||
{
|
||||
path: "/about",
|
||||
name: "about",
|
||||
// route level code-splitting
|
||||
// this generates a separate chunk (about.[hash].js) for this route
|
||||
// which is lazy-loaded when the route is visited.
|
||||
component: () =>
|
||||
import(/* webpackChunkName: "about" */ "../views/AboutView.vue"),
|
||||
},
|
||||
];
|
||||
import { createWebHistory, createRouter } from "vue-router";
|
||||
import store from "@/store";
|
||||
import { whitelistJoinMeeting } from "@/api/meeting";
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHistory(process.env.BASE_URL),
|
||||
routes,
|
||||
history: createWebHistory(),
|
||||
routes: [
|
||||
{
|
||||
path: "/appointment/:meetingId",
|
||||
name: "Appointment",
|
||||
component: () => import("@/views/appointment.vue"),
|
||||
},
|
||||
{
|
||||
path: "/verify/:meetingId",
|
||||
name: "Verify",
|
||||
component: () => import("@/views/verify.vue"),
|
||||
},
|
||||
{
|
||||
path: "/meeting/:meetingId",
|
||||
name: "Meeting",
|
||||
component: () => import("@/views/meeting.vue"),
|
||||
},
|
||||
{
|
||||
path: "/:pathMatch(.*)*",
|
||||
name: "NotFound",
|
||||
component: () => import("@/views/NotFound.vue"),
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
router.beforeEach(async (to) => {
|
||||
// 判断会议信息是否存在,不存在则请求数据
|
||||
if (!store.state.meeting.id && to.params.meetingId) {
|
||||
await store.dispatch("getMeetingInfo", to.params.meetingId);
|
||||
}
|
||||
// 如果要前往参会页面
|
||||
if (to.name === "Meeting") {
|
||||
// 如果是白名单模式
|
||||
if (store.state.meeting.joinType === "1") {
|
||||
if (store.state.joinUser.icCard) {
|
||||
// 检测输入的IC卡号是否在白名单范围内,是则放行,否则返回原地址
|
||||
try {
|
||||
const { data } = await whitelistJoinMeeting({
|
||||
meetingId: to.params.meetingId,
|
||||
icCard: store.state.joinUser.icCard,
|
||||
});
|
||||
store.commit("setPassword", data);
|
||||
return true;
|
||||
} catch (error) {
|
||||
store.commit("setJoinUser", {});
|
||||
return `/verify/${to.params.meetingId}`;
|
||||
}
|
||||
} else {
|
||||
store.commit("setJoinUser", {});
|
||||
return `/verify/${to.params.meetingId}`;
|
||||
}
|
||||
} else {
|
||||
if (!store.state.password) {
|
||||
return `/verify/${to.params.meetingId}`;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
export default router;
|
||||
|
Reference in New Issue
Block a user