2022-05-05 19:48:27 +08:00
|
|
|
|
import { createWebHistory, createRouter } from "vue-router";
|
|
|
|
|
import store from "@/store";
|
|
|
|
|
import { whitelistJoinMeeting } from "@/api/meeting";
|
2022-04-29 13:22:04 +08:00
|
|
|
|
|
|
|
|
|
const router = createRouter({
|
2022-05-05 19:48:27 +08:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-04-29 13:22:04 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export default router;
|