| | |
| | | import { getCodeImg, getconfigKey } from "@/api/login"; |
| | | import Cookies from "js-cookie"; |
| | | import { encrypt, decrypt } from '@/utils/jsencrypt' |
| | | |
| | | import ini from 'ini'; |
| | | import fs from 'fs'; // Node.js 文件系统模块 |
| | | export default { |
| | | name: "Login", |
| | | data() { |
| | |
| | | |
| | | }, |
| | | loadAll() { |
| | | const env = process.env.VUE_APP_ENV |
| | | if (env === 'development') { |
| | | this.loginForm.hospId = this.$route.query.hospId |
| | | Cookies.set("hospId", this.loginForm.hospId); |
| | | } else if (env === 'production') { |
| | | // 获取当前URL的端口号 |
| | | const port = window.location.port; |
| | | const env = process.env.VUE_APP_ENV; |
| | | const port = window.location.port; |
| | | |
| | | switch (port) { |
| | | // yuanqu.ini加载hospId |
| | | fetch('/yuanqu.ini') |
| | | .then(response => { |
| | | if (!response.ok) { |
| | | throw new Error('Failed to fetch config.ini'); |
| | | } |
| | | return response.text(); |
| | | }) |
| | | .then(text => { |
| | | const config = ini.parse(text); |
| | | |
| | | case '8094': |
| | | |
| | | this.loginForm.hospId = "pbkwyy"; |
| | | break; |
| | | case '8095': |
| | | this.loginForm.hospId = "jdczgzyy"; |
| | | break; |
| | | case '8096': |
| | | this.loginForm.hospId = "sqyy"; |
| | | break; |
| | | case '8097': |
| | | this.loginForm.hospId = "wbzxyy"; |
| | | break; |
| | | case '8098': |
| | | this.loginForm.hospId = "bjxjyy"; |
| | | break; |
| | | case '8099': |
| | | this.loginForm.hospId = "bjfhyy"; |
| | | break; |
| | | case '8100': |
| | | this.loginForm.hospId = "ssyjyy"; |
| | | break; |
| | | case '8101': |
| | | this.loginForm.hospId = "bjsqyy"; |
| | | break; |
| | | } |
| | | Cookies.set("hospId", this.loginForm.hospId); |
| | | } else if (env === 'staging') { |
| | | // 获取当前URL的端口号 |
| | | const port = window.location.port; |
| | | |
| | | switch (port) { |
| | | case '9013': |
| | | this.loginForm.hospId = "pbkwyy"; |
| | | break; |
| | | |
| | | case '9014': |
| | | this.loginForm.hospId = "jdczgzyy"; |
| | | break; |
| | | case '9015': |
| | | this.loginForm.hospId = "sqyy"; |
| | | break; |
| | | case '9016': |
| | | this.loginForm.hospId = "wbzxyy"; |
| | | break; |
| | | case '9017': |
| | | this.loginForm.hospId = "bjxjyy"; |
| | | break; |
| | | case '9018': |
| | | this.loginForm.hospId = "ssyjyy"; |
| | | break; |
| | | case '9019': |
| | | this.loginForm.hospId = "bjsqyy"; |
| | | break; |
| | | } |
| | | Cookies.set("hospId", this.loginForm.hospId); |
| | | } |
| | | // 存储hospId到Cookie |
| | | // 更新URL参数 |
| | | if (this.loginForm.hospId) { |
| | | const query = { ...this.$route.query, hospId: this.loginForm.hospId }; |
| | | this.$router.replace({ query }); |
| | | } |
| | | if (config[env] && config[env][port]) { |
| | | this.loginForm.hospId = config[env][port]; |
| | | Cookies.set("hospId", this.loginForm.hospId); |
| | | } else { |
| | | console.error(`No hospId found for environment ${env} and port ${port}`); |
| | | this.$message.error(`配置错误:未找到环境 ${env} 和端口 ${port} 对应的医院ID`); |
| | | } |
| | | }) |
| | | .catch(error => { |
| | | console.error('Error fetching or parsing config.ini:', error); |
| | | this.$message.error('无法加载配置文件,请联系管理员'); |
| | | }); |
| | | }, |
| | | |
| | | hide() { |
| | | // this.loginForm.username = "10001"; |
| | | // this.loginForm.password = "admin123"; |