|
@@ -2,6 +2,7 @@ import { defineStore } from 'pinia'
|
|
import { setToken, removeToken, setRefreshToken, getToken } from '@/utils/auth'
|
|
import { setToken, removeToken, setRefreshToken, getToken } from '@/utils/auth'
|
|
import { smsLogin, passwordLogin, getBaseInfo, passwordLoginOfEnterprise, smsLoginOfEnterprise, switchLoginOfEnterprise, getEnterprisingUserInfo, logoutToken, logout } from '@/api/common'
|
|
import { smsLogin, passwordLogin, getBaseInfo, passwordLoginOfEnterprise, smsLoginOfEnterprise, switchLoginOfEnterprise, getEnterprisingUserInfo, logoutToken, logout } from '@/api/common'
|
|
import { getUserInfo } from '@/api/personal/user'
|
|
import { getUserInfo } from '@/api/personal/user'
|
|
|
|
+import { getEnterpriseUserAccount, getUserAccount } from '@/api/common'
|
|
import Snackbar from '@/plugins/snackbar'
|
|
import Snackbar from '@/plugins/snackbar'
|
|
import { timesTampChange } from '@/utils/date'
|
|
import { timesTampChange } from '@/utils/date'
|
|
import { updateEventList } from '@/utils/eventList'
|
|
import { updateEventList } from '@/utils/eventList'
|
|
@@ -15,7 +16,8 @@ export const useUserStore = defineStore('user',
|
|
accountInfo: {}, // 登录返回的信息
|
|
accountInfo: {}, // 登录返回的信息
|
|
userInfo: {}, // 当前登录账号信息
|
|
userInfo: {}, // 当前登录账号信息
|
|
baseInfo: {}, // 人才信息
|
|
baseInfo: {}, // 人才信息
|
|
- isEnterpriseAdmin: false // 企业管理员
|
|
|
|
|
|
+ userAccount: {}, // 用户账户信息
|
|
|
|
+ enterpriseUserAccount: {}, // 企业账户信息
|
|
}),
|
|
}),
|
|
actions: {
|
|
actions: {
|
|
// 短信登录
|
|
// 短信登录
|
|
@@ -62,6 +64,7 @@ export const useUserStore = defineStore('user',
|
|
this.userInfo = data
|
|
this.userInfo = data
|
|
localStorage.setItem('userInfo', JSON.stringify(data))
|
|
localStorage.setItem('userInfo', JSON.stringify(data))
|
|
updateEventList() // 获取规则配置跟踪列表
|
|
updateEventList() // 获取规则配置跟踪列表
|
|
|
|
+ this.getUserAccountInfo()
|
|
} catch (error) {
|
|
} catch (error) {
|
|
Snackbar.error(error.msg)
|
|
Snackbar.error(error.msg)
|
|
}
|
|
}
|
|
@@ -116,6 +119,7 @@ export const useUserStore = defineStore('user',
|
|
localStorage.setItem('expiresTime', data.expiresTime)
|
|
localStorage.setItem('expiresTime', data.expiresTime)
|
|
localStorage.setItem('currentRole', 'enterprise')
|
|
localStorage.setItem('currentRole', 'enterprise')
|
|
await this.getEnterpriseInfo()
|
|
await this.getEnterpriseInfo()
|
|
|
|
+ await this.getEnterpriseUserAccountInfo()
|
|
Snackbar.success('切换成功')
|
|
Snackbar.success('切换成功')
|
|
},
|
|
},
|
|
// 获取当前登录的企业用户信息
|
|
// 获取当前登录的企业用户信息
|
|
@@ -128,6 +132,20 @@ export const useUserStore = defineStore('user',
|
|
localStorage.setItem('isAdmin', isAdmin)
|
|
localStorage.setItem('isAdmin', isAdmin)
|
|
|
|
|
|
localStorage.setItem('baseInfo', JSON.stringify(result))
|
|
localStorage.setItem('baseInfo', JSON.stringify(result))
|
|
|
|
+ },
|
|
|
|
+ // 获取企业账户信息
|
|
|
|
+ async getEnterpriseUserAccountInfo () {
|
|
|
|
+ const data = await getEnterpriseUserAccount()
|
|
|
|
+ if (!data) return
|
|
|
|
+ this.enterpriseUserAccount = data
|
|
|
|
+ localStorage.setItem('enterpriseUserAccount', JSON.stringify(data))
|
|
|
|
+ },
|
|
|
|
+ // 获取用户账户信息
|
|
|
|
+ async getUserAccountInfo () {
|
|
|
|
+ const data = await getUserAccount()
|
|
|
|
+ if (!data) return
|
|
|
|
+ this.userAccount = data
|
|
|
|
+ localStorage.setItem('userAccount', JSON.stringify(data))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
},
|