qx
qx
2025-02-11 9fa19968f04de83a13041194b18f6aa2e0c38660
qx
6个文件已修改
49 ■■■■ 已修改文件
src/api/login.js 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/permission.js 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/router/index.js 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/store/modules/user.js 15 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/utils/request.js 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/login.vue 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/login.js
@@ -2,7 +2,7 @@
import { encrypt } from '@/utils/jsencrypt'
// 登录方法
export function login(username, password, code, uuid,type, mobile) {
export function login(username, password, code, uuid,type, mobile,hospId) {
  password = encrypt(password);
  const data = {
    username,
@@ -11,11 +11,13 @@
    uuid,
    type,
    mobile,
    hospId
  }
  return request({
    url: '/login',
    headers: {
      isToken: false
      isToken: false,
      hospId:hospId
    },
    method: 'post',
    data: data
@@ -32,7 +34,7 @@
  return request({
    url: '/cus/login',
    headers: {
      isToken: false
      isToken: false,
    },
    method: 'post',
    params: data
src/permission.js
@@ -45,7 +45,14 @@
      // 在免登录白名单,直接进入
      next()
    } else {
      next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页
      // next(`/login?redirect=${to.fullPath}&hospId=${to.meta.routerType}`) // 否则全部重定向到登录页
      next({
        path:"/login",
        query:{
          redirect:to.fullPath,
          hospId:"xamjyy"
        }
      })
      NProgress.done()
    }
  }
src/router/index.js
@@ -38,7 +38,7 @@
    children: [
      {
        path: '/redirect/:path(.*)',
        component: () => import('@/views/redirect')
        component: () => import('@/views/redirect'),
      },
      {
        path: '/emer',
@@ -203,7 +203,8 @@
        path: 'index',
        component: () => import('@/views/index'),
        name: 'Index',
        meta: { title: '首页', icon: 'dashboard', affix: true }
        meta: { title: '首页', icon: 'dashboard', affix: true ,}
        // routerType:"xamjyy",
      }
    ]
  },
src/store/modules/user.js
@@ -7,7 +7,8 @@
    name: '',
    avatar: '',
    roles: [],
    permissions: []
    permissions: [],
    // routeId: null
  },
  mutations: {
@@ -25,7 +26,10 @@
    },
    SET_PERMISSIONS: (state, permissions) => {
      state.permissions = permissions
    }
    },
    // SET_ROUTE_ID(state, id) {
    //   state.routeId = id;
    // }
  },
  actions: {
@@ -37,9 +41,10 @@
      const uuid = userInfo.uuid
      const type = userInfo.type
      const mobile = userInfo.mobile
      const hospId = userInfo.hospId
      return new Promise((resolve, reject) => {
        if(userInfo.username.length === 12){
          getlogin(username, password, code, uuid,type,mobile).then(res => {
          getlogin(username, password, code, uuid,type,mobile,hospId).then(res => {
            setToken(res.token)
            commit('SET_TOKEN', res.token);
            resolve(res)
@@ -47,9 +52,10 @@
            reject(error)
          })
        }else{
          login(username, password, code, uuid,type,mobile).then(res => {
          login(username, password, code, uuid,type,mobile,hospId).then(res => {
            setToken(res.token)
            commit('SET_TOKEN', res.token)
            // commit('SET_ROUTE_ID', hospId)
            resolve(res)
          }).catch(error => {
            reject(error)
@@ -87,6 +93,7 @@
      commit('SET_TOKEN', '')
      commit('SET_ROLES', [])
      commit('SET_PERMISSIONS', [])
      // commit('SET_ROUTE_ID', [])
      removeToken()
      resolve()
    }).catch(error => {
src/utils/request.js
@@ -6,12 +6,14 @@
import { tansParams, blobValidate } from "@/utils/ruoyi";
import cache from '@/plugins/cache'
import { saveAs } from 'file-saver'
import Cookies from "js-cookie"
let downloadLoadingInstance;
// 是否显示重新登录
export let isRelogin = { show: false };
axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8'
// 创建axios实例
const service = axios.create({
  // axios中请求配置有baseURL选项,表示请求URL公共部分
@@ -26,6 +28,8 @@
  const isRepeatSubmit = (config.headers || {}).repeatSubmit === false
  if (getToken() && !isToken) {
    config.headers['Authorization'] = 'Bearer ' + getToken()
    console.log(store)
    config.headers['hospId'] = Cookies.get("hospId");
  }
  if (config.method === 'get' && config.params) {
    let url = config.url + '?' + tansParams(config.params);
src/views/login.vue
@@ -78,6 +78,7 @@
        username: "",
        password: "",
        mobile: false,
        hospId:"",
        // username:"13800138008",
        // password:"888888",
        rememberMe: false,
@@ -136,6 +137,7 @@
  created() {
    this.getstate();
    this.getCookie();
    this.loadAll();
  },
  methods: {
    getstate() {
@@ -149,6 +151,10 @@
      })
    },
    loadAll(){
      this.loginForm.hospId = this.$route.query.hospId
      Cookies.set("hospId", this.loginForm.hospId);
    },
    hide() {
      // this.loginForm.username = "10001";