| | |
| | | }, |
| | | methods: { |
| | | // 匹配orgid - 优化为对象映射 |
| | | mateOrgid(orgid) { |
| | | mateOrgid(campusid, orgid) { |
| | | const orgMap = { |
| | | "30001002": { |
| | | 30001002: { |
| | | orgname: "省立同德翠苑院区", |
| | | ZuHuID: "1400361376454545408", |
| | | deptCode: "1017", |
| | | }, |
| | | "30001003": { |
| | | 30001003: { |
| | | orgname: "省立同德之江院区", |
| | | ZuHuID: "1400360867068907520", |
| | | deptCode: "01040201", |
| | | }, |
| | | "30001004": { |
| | | 30001004: { |
| | | orgname: "省立同德闲林院区", |
| | | ZuHuID: "1429338802177000002", |
| | | deptCode: "", |
| | | }, |
| | | "30001005": { |
| | | 30001005: { |
| | | orgname: "省立同德天目山路院区", |
| | | ZuHuID: "1429338802177000003", |
| | | deptCode: "", |
| | | }, |
| | | "30001006": { |
| | | 30001006: { |
| | | orgname: "省立同德青山湖院区", |
| | | ZuHuID: "1429338802177000004", |
| | | deptCode: "", |
| | | }, |
| | | "30001007": { |
| | | orgname: "测试院区", |
| | | 30001007: { |
| | | orgname: "省立同德翠苑院区", //测试 |
| | | ZuHuID: "1429338802177000005", |
| | | deptCode: "", |
| | | }, |
| | | }; |
| | | |
| | | const orgInfo = orgMap[orgid]; |
| | | const orgInfo = orgMap[campusid]; |
| | | if (orgInfo) { |
| | | localStorage.setItem("orgname", orgInfo.orgname); |
| | | localStorage.setItem("ZuHuID", orgInfo.ZuHuID); |
| | | localStorage.setItem("deptCode", orgInfo.deptCode); |
| | | localStorage.setItem("campusid", campusid); |
| | | localStorage.setItem("orgid", orgid); |
| | | return orgInfo; |
| | | } |
| | | return null; |
| | |
| | | // 3. 清理旧系统数据 |
| | | this.clearOldSystemData(); |
| | | |
| | | const { token, orgid, orgname, ZuHuID, deptCode, redirect } = params; |
| | | const { token, orgid, orgname, ZuHuID, deptCode, redirect, campusid } = |
| | | params; |
| | | console.log( |
| | | token, |
| | | orgid, |
| | | orgname, |
| | | ZuHuID, |
| | | deptCode, |
| | | redirect, |
| | | campusid, |
| | | "参数日志" |
| | | ); |
| | | |
| | | // 4. 存储token |
| | | setToken(token); |
| | |
| | | // 5. 处理机构信息 |
| | | if (orgid) { |
| | | // 优先使用mateOrgid映射 |
| | | const orgInfo = this.mateOrgid(orgid); |
| | | const orgInfo = this.mateOrgid(campusid, orgid); |
| | | if (!orgInfo) { |
| | | // 如果没有映射,使用传入的参数 |
| | | if (orgname) localStorage.setItem("orgname", orgname); |
| | |
| | | } |
| | | |
| | | localStorage.setItem("orgid", orgid); |
| | | if (this.$store.dispatch && typeof this.$store.dispatch === "function") { |
| | | if ( |
| | | this.$store.dispatch && |
| | | typeof this.$store.dispatch === "function" |
| | | ) { |
| | | await this.$store.dispatch("UpdateOrgId", orgid); |
| | | } |
| | | } |
| | | this.loadingDetail = "设置机构信息..."; |
| | | |
| | | // 6. 获取用户信息 |
| | | if (this.$store.dispatch && typeof this.$store.dispatch === "function") { |
| | | // 6. 获取用户信息 + 生成动态路由 |
| | | if ( |
| | | this.$store.dispatch && |
| | | typeof this.$store.dispatch === "function" |
| | | ) { |
| | | await this.$store.dispatch("GetInfo"); |
| | | // SSO 免登在跳转前已完成 GetInfo,路由守卫不会再触发 GenerateRoutes |
| | | // 必须在此处显式调用,否则动态路由不会注册 |
| | | await this.$store.dispatch("GenerateRoutes").then((accessRoutes) => { |
| | | this.$router.addRoutes(accessRoutes); |
| | | }); |
| | | } |
| | | this.loadingDetail = "获取用户信息..."; |
| | | |
| | |
| | | console.log("准备跳转到:", redirectPath); |
| | | |
| | | // ✅ 使用 push 而不是 replace,保留历史记录 |
| | | this.$router.push({ path: redirectPath }).then(() => { |
| | | console.log("SSO登录成功,跳转完成"); |
| | | }).catch((error) => { |
| | | console.error("路由跳转失败:", error); |
| | | // 回退到默认页面 |
| | | this.$router.push({ path: "/followvisit/discharge" }); |
| | | }); |
| | | this.$router |
| | | .push({ path: redirectPath }) |
| | | .then(() => { |
| | | console.log("SSO登录成功,跳转完成"); |
| | | }) |
| | | .catch((error) => { |
| | | console.error("路由跳转失败:", error); |
| | | // 回退到默认页面 |
| | | this.$router.push({ path: "/followvisit/discharge" }); |
| | | }); |
| | | }, 500); |
| | | |
| | | } catch (error) { |
| | | console.error("SSO登录失败:", error); |
| | | this.errorMessage = `单点登录失败: ${error.message || "未知错误"}`; |
| | |
| | | } |
| | | |
| | | @keyframes spin { |
| | | 0% { transform: rotate(0deg); } |
| | | 100% { transform: rotate(360deg); } |
| | | 0% { |
| | | transform: rotate(0deg); |
| | | } |
| | | 100% { |
| | | transform: rotate(360deg); |
| | | } |
| | | } |
| | | |
| | | .loading-content p { |