Commit 1b5afb1b authored by xinzhedeai's avatar xinzhedeai

首页区分跳转问题处理,登录错误提示新增, 数据概览页面init

parent 979ae3bb
...@@ -58,28 +58,26 @@ export const constantRouterMap = [ ...@@ -58,28 +58,26 @@ export const constantRouterMap = [
//component: Layout, //component: Layout,
component: HomeLayout, component: HomeLayout,
redirect: "noredirect", redirect: "noredirect",
hidden:true, hidden:false,
children: [ children: [
{ {
path: "enterprise", path: "enterprise",
component: resolve => require(["@/views/system/home/enterprise"], resolve), component: resolve => require([localStorage.getItem('groupIdByloginType')*1 === 1 ? "@/views/system/home/enterprise" : "@/views/system/home/tech"], resolve),
name: "首页-企业", name: "首页-企业",
meta: { title: "首页", affix:true , icon: "index"} meta: { title: "首页", affix:true , icon: "index"}
}
]
}, },
// {
// path: "tech",
// component: resolve => require(["@/views/system/home/tech"], resolve),
// name: "首页-科技局",
// meta: { title: "首页", affix:true , icon: "index"}
// },
{ {
path: "/home", path: "overview",
//component: Layout, component: resolve => require(["@/views/system/home/overview"], resolve),
component: HomeLayout, name: "概览",
redirect: "noredirect", hidden: true,
hidden:true, meta: { title: "数据概览", icon: "index"}
children: [
{
path: "tech",
component: resolve => require(["@/views/system/home/tech"], resolve),
name: "首页-科技局",
meta: { title: "首页", affix:true , icon: "index"}
} }
] ]
}, },
......
import { login, getInfo, logout } from '@/api/login' import { login, getInfo, logout } from '@/api/login'
import { getToken, setToken, removeToken } from '@/utils/auth' import { getToken, setToken, removeToken } from '@/utils/auth'
import { Message } from 'element-ui';
const user = { const user = {
state: { state: {
token: getToken(), token: getToken(),
...@@ -34,7 +34,7 @@ const user = { ...@@ -34,7 +34,7 @@ const user = {
const rememberMe = userInfo.rememberMe; const rememberMe = userInfo.rememberMe;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
login(userInfo).then(res => { login(userInfo).then(res => {
if(/* res.head.code === '0000' || */ !res.code){ if(!res.code){ // 登录成功不返回code状态码。
var body = res.body || res; var body = res.body || res;
setToken(body.token, rememberMe); setToken(body.token, rememberMe);
commit('SET_TOKEN', body.token); commit('SET_TOKEN', body.token);
...@@ -42,8 +42,14 @@ const user = { ...@@ -42,8 +42,14 @@ const user = {
// 第一次加载菜单时用到, 具体见 src 目录下的 permission.js // 第一次加载菜单时用到, 具体见 src 目录下的 permission.js
commit('SET_LOAD_MENUS', true); commit('SET_LOAD_MENUS', true);
};
resolve(res) resolve(res)
}else{
Message({
message: res.msg,
type: 'warning', // 可以是 'success', 'warning', 'info', 'error'
});
resolve(null)
}
}).catch(error => { }).catch(error => {
reject(error) reject(error)
}) })
......
...@@ -409,15 +409,16 @@ export default { ...@@ -409,15 +409,16 @@ export default {
}, },
methods: { methods: {
goBackendHome(){ goBackendHome(){
if(localStorage.getItem('groupIdByloginType')*1 == 1){ // 孵化器用户 // if(localStorage.getItem('groupIdByloginType')*1 == 1){ // 孵化器用户
// location.href = '/home/enterprise'
// return
// }
// if(localStorage.getItem('groupIdByloginType')*1 == 2){ // 科技据用户
// location.href = '/home/tech'
// return
// }
// location.reload()
location.href = '/home/enterprise' location.href = '/home/enterprise'
return
}
if(localStorage.getItem('groupIdByloginType')*1 == 2){ // 科技据用户
location.href = '/home/tech'
return
}
location.reload()
}, },
// 首页 // 首页
module0(m, t, f, dmIndex, view){ module0(m, t, f, dmIndex, view){
......
This diff is collapsed.
...@@ -165,29 +165,35 @@ export default { ...@@ -165,29 +165,35 @@ export default {
Cookies.remove('password') Cookies.remove('password')
Cookies.remove('rememberMe') Cookies.remove('rememberMe')
} }
this.$store.dispatch('Login', user).then(() => { this.$store.dispatch('Login', user).then((res) => {
if(!res){ // 登录失败
this.loading = false this.loading = false
if (this.userStyle) { this.getCode()
if (this.userStyle === '应急局' && this.user.enterpriseId !== 0) {
this.$message.error('您是企业用户,请使用企业端登录')
setTimeout(() => {
this.$store.dispatch('LogOut').then(() => {
location.reload()
})
}, 1000)
return
}
if (this.userStyle === '企业' && this.user.enterpriseId === 0) {
this.$message.error('您是应急局用户,请使用应急局端登录')
setTimeout(() => {
this.$store.dispatch('LogOut').then(() => {
location.reload()
})
}, 1000)
return
}
} }
this.$router.push({ path: /* 记住上次退出时的页面 */ /* this.redirect || */'/home4Login' }) this.$router.push({ path: '/edge/Screen' }) // 跳转大屏
// debugger
// this.loading = false
// if (this.userStyle) {
// if (this.userStyle === '应急局' && this.user.enterpriseId !== 0) {
// this.$message.error('您是企业用户,请使用企业端登录')
// setTimeout(() => {
// this.$store.dispatch('LogOut').then(() => {
// location.reload()
// })
// }, 1000)
// return
// }
// if (this.userStyle === '企业' && this.user.enterpriseId === 0) {
// this.$message.error('您是应急局用户,请使用应急局端登录')
// setTimeout(() => {
// this.$store.dispatch('LogOut').then(() => {
// location.reload()
// })
// }, 1000)
// return
// }
// }
// this.$router.push({ path: /* 记住上次退出时的页面 */ /* this.redirect || */'/home4Login' })
}).catch(() => { }).catch(() => {
this.loading = false this.loading = false
this.getCode() this.getCode()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment