11
WXL
2024-08-14 0ac2d43fce4d74f6eea5a51a2e16af4e6a536c7c
src/store/modules/user.js
@@ -1,6 +1,8 @@
import { login, logout, getInfo } from '@/api/login'
import { getToken, setToken, removeToken } from '@/utils/auth'
import {  Message } from 'element-ui'
import { listOrganization } from "@/api/project/organization";
const user = {
@@ -8,13 +10,22 @@
    token: getToken(),
    name: '',
    avatar: '',
    code: '',
    msg: '',
    roles: [],
    permissions: []
    permissions: [],
    organization:[],
  },
  mutations: {
    SET_TOKEN: (state, token) => {
      state.token = token
    },
    SET_LOGCODE: (state, code) => {
      state.code = code
    },
    SET_LOGMSG: (state, msg) => {
      state.msg = msg
    },
    SET_NAME: (state, name) => {
      state.name = name
@@ -27,6 +38,9 @@
    },
    SET_PERMISSIONS: (state, permissions) => {
      state.permissions = permissions
    },
    SET_organization: (state, organization) => {
      state.organization = organization
    }
  },
@@ -37,16 +51,21 @@
      const password = userInfo.password
      const code = userInfo.code
      const uuid = userInfo.uuid
      const authCode = userInfo.authCode
      console.log(authCode,'authCode');
      return new Promise((resolve, reject) => {
        login(username, password, code, uuid).then(res => {
        login(username, password, code, uuid, authCode).then(res => {
          console.log(res,'log');
          setToken(res.token)
          commit('SET_TOKEN', res.token)
          commit('SET_LOGCODE', res.code)
          commit('SET_LOGMSG', res.msg)
          resolve()
        }).catch(error => {
          reject(error)
          // this.$message.error('登陆信息错误请重试');
       Message({
        message: '登陆失败',
        message: error.message,
        type: 'error'
      })
        })
@@ -73,7 +92,7 @@
        })
      })
    },
    // 退出系统
    LogOut({ commit, state }) {
      return new Promise((resolve, reject) => {
@@ -88,6 +107,21 @@
        })
      })
    },
    // 拿取机构信息
    getdataList({commit}){
      return new Promise((resolve, reject) => {
        listOrganization({
          organizationtype: 4, //传入的类型
          pageNum: 1,
          pageSize: 100000
        }).then((res) => {
          commit('SET_organization', res.rows)
          resolve()
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 前端 登出
    FedLogOut({ commit }) {