From 51cacf8f4d7b0b2cc30a22ea4f660e73e82da458 Mon Sep 17 00:00:00 2001
From: cqf
Date: Fri, 17 Jun 2022 09:17:53 +0800
Subject: [PATCH] 换取账号-修改
---
src/views/login/index.vue | 24 +++++++++++++++++++++++-
1 files changed, 23 insertions(+), 1 deletions(-)
diff --git a/src/views/login/index.vue b/src/views/login/index.vue
index d35ac25..15a9a2f 100644
--- a/src/views/login/index.vue
+++ b/src/views/login/index.vue
@@ -35,7 +35,7 @@
</template>
<script>
- import { loginByUsername } from '@/api/login'
+ import { getAccount,loginByUsername,getUserInfo } from '@/api/login'
import { getToken, setToken, removeToken } from '@/utils/auth'
import Cookies from 'js-cookie'
import { initRouter } from '@/utils/router'
@@ -95,6 +95,7 @@
const res = response.data
if (res.code == 200) {
localStorage.setItem('loginForm',JSON.stringify(loginForm))
+ // this.$store.dispatch('user/getClassifyOne',1)
_this.loading = false
const data = res.result
if (data.type != 1 && data.type != 2) {
@@ -113,6 +114,7 @@
_this.$store.commit('SET_ROLES', data.roles)
Cookies.set('roles', JSON.stringify(data.roles))
setToken(data.token)
+ Cookies.set('loginForm',data)
Cookies.set('userName', data.username)
Cookies.set('name', data.username)
Cookies.set('userId', data.id)
@@ -131,6 +133,26 @@
Cookies.set('token_expired_at', data.tokenexpired)
_this.$store.commit('SET_NAME', data.realname)
_this.$store.commit('SET_USER_TYPE', data.type)
+ //换取账号密码
+ getUserInfo().then(res => {
+ if (res.data.code == 200) {
+ loginForm.department = res.data.result.department
+ // loginForm.department = "公司领导"
+ getAccount(loginForm).then(res => {
+ if (res.data.code == "00000") {
+ //缓存账号密码
+ Cookies.set("hiddenDangerUsername",res.data.data.username)
+ Cookies.set("hiddenDangerPassword",res.data.data.password)
+ } else {
+ this.$message({type: 'error', message: res.data.msg, duration: 3000})
+ }
+ })
+
+ } else {
+ this.$message({type: 'error', message: "用户信息获取失败!请重试", duration: 3000})
+ }
+ })
+
// 加载菜单
initRouter(_this)
_this.$router.replace('/')
--
Gitblit v1.9.2