| | |
| | | </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' |
| | |
| | | .then((response) => { |
| | | const res = response.data |
| | | if (res.code == 200) { |
| | | sessionStorage.setItem('isdepartment',res.result.isdepartment) |
| | | sessionStorage.setItem('company',res.result.company) |
| | | sessionStorage.setItem('department',res.result.department) |
| | | sessionStorage.setItem('realname',res.result.realname) |
| | | 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) { |
| | |
| | | // return |
| | | } |
| | | } |
| | | |
| | | Cookies.set('token',data.token) |
| | | _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) |
| | | Cookies.set('company', data.company) |
| | | Cookies.set('companyid', data.companyid) |
| | | let address = ''; |
| | | if (data.city != null && data.city != 'null'){ |
| | | address = data.city |
| | |
| | | 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('/') |
| | |
| | | display: inline-block; |
| | | height: 474px; |
| | | width: 572px; |
| | | background: url("../../assets/img_bg_login.png") center no-repeat; |
| | | background: url("../../assets/bg.jpg") center no-repeat; |
| | | } |
| | | .login-main-form{ |
| | | display: inline-block; |