| | |
| | | </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' |
| | |
| | | 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 == 200) { |
| | | //缓存账号密码 |
| | | Cookies.set("hiddenDangerUsername",res.data.result.username) |
| | | Cookies.set("hiddenDangerPassword",res.data.result.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('/') |