用户身份切换
This commit is contained in:
@ -1,5 +1,5 @@
|
|||||||
# 页面标题
|
# 页面标题
|
||||||
VITE_APP_TITLE = 1管理系统
|
VITE_APP_TITLE = v1xxx管理系统
|
||||||
|
|
||||||
# 开发环境配置
|
# 开发环境配置
|
||||||
VITE_APP_ENV = 'development'
|
VITE_APP_ENV = 'development'
|
||||||
|
@ -12,6 +12,14 @@ export function settled() {
|
|||||||
url: '/enterprise/v1/settled'
|
url: '/enterprise/v1/settled'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
// 当前状态切换
|
||||||
|
export function identitySwitch(data) {
|
||||||
|
return request({
|
||||||
|
url: '/enterprise/v1/user/identity/switch',
|
||||||
|
method:'post',
|
||||||
|
data
|
||||||
|
});
|
||||||
|
}
|
||||||
// 公司企业入驻
|
// 公司企业入驻
|
||||||
export function company(data) {
|
export function company(data) {
|
||||||
return request({
|
return request({
|
||||||
|
@ -106,9 +106,11 @@
|
|||||||
</div>
|
</div>
|
||||||
<template #dropdown>
|
<template #dropdown>
|
||||||
<el-dropdown-menu>
|
<el-dropdown-menu>
|
||||||
<router-link to="/identity/index">
|
<!-- <router-link to="/identity/index"> -->
|
||||||
<el-dropdown-item>个人中心</el-dropdown-item>
|
<el-dropdown-item @click="handlePage"
|
||||||
</router-link>
|
>个人中心</el-dropdown-item
|
||||||
|
>
|
||||||
|
<!-- </router-link> -->
|
||||||
<el-dropdown-item divided @click="logout">
|
<el-dropdown-item divided @click="logout">
|
||||||
<span>退出登录</span>
|
<span>退出登录</span>
|
||||||
</el-dropdown-item>
|
</el-dropdown-item>
|
||||||
@ -143,7 +145,16 @@ watch(
|
|||||||
pagePath.value = route.path;
|
pagePath.value = route.path;
|
||||||
|
|
||||||
function handlePage() {
|
function handlePage() {
|
||||||
router.push("/identity/index");
|
// router.push("/identity/index");
|
||||||
|
|
||||||
|
let routeData = "";
|
||||||
|
const selectRole = localStorage.getItem("select_identity");
|
||||||
|
if (selectRole > 0) {
|
||||||
|
routeData = router.resolve({ path: "/admin" });
|
||||||
|
} else {
|
||||||
|
routeData = router.resolve({ path: "/identity/index" });
|
||||||
|
}
|
||||||
|
window.open(routeData.href, "_blank");
|
||||||
}
|
}
|
||||||
|
|
||||||
function handlePath(path) {
|
function handlePath(path) {
|
||||||
|
@ -58,8 +58,16 @@ defineProps({
|
|||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
const route = useRoute();
|
||||||
const title = ref("这是xx管理系统");
|
const selectRole = localStorage.getItem("select_identity");
|
||||||
|
const roles = {
|
||||||
|
1: "企业",
|
||||||
|
2: "专家",
|
||||||
|
4: "研究机构",
|
||||||
|
8: "实验室",
|
||||||
|
16: "科技经纪人",
|
||||||
|
};
|
||||||
|
const title = ref(`${roles[selectRole]}管理系统`);
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
const sideTheme = computed(() => store.state.settings.sideTheme);
|
const sideTheme = computed(() => store.state.settings.sideTheme);
|
||||||
</script>
|
</script>
|
||||||
|
@ -13,7 +13,7 @@ const whiteList = ['/login', '/auth-redirect', '/bind', '/register'];
|
|||||||
router.beforeEach((to, from, next) => {
|
router.beforeEach((to, from, next) => {
|
||||||
NProgress.start()
|
NProgress.start()
|
||||||
// 跳过登录验证
|
// 跳过登录验证
|
||||||
next();
|
// next();
|
||||||
if (getToken()) {
|
if (getToken()) {
|
||||||
to.meta.title && store.dispatch('settings/setTitle', to.meta.title)
|
to.meta.title && store.dispatch('settings/setTitle', to.meta.title)
|
||||||
/* has token*/
|
/* has token*/
|
||||||
@ -27,6 +27,7 @@ router.beforeEach((to, from, next) => {
|
|||||||
// 判断当前用户是否已拉取完user_info信息
|
// 判断当前用户是否已拉取完user_info信息
|
||||||
store.dispatch('GetInfo').then((res) => {
|
store.dispatch('GetInfo').then((res) => {
|
||||||
store.dispatch('GenerateRoutes',res.data.select_identity).then(accessRoutes => {
|
store.dispatch('GenerateRoutes',res.data.select_identity).then(accessRoutes => {
|
||||||
|
// store.dispatch('GenerateRoutes',0).then(accessRoutes => { // 测试
|
||||||
// 根据roles权限生成可访问的路由表
|
// 根据roles权限生成可访问的路由表
|
||||||
// accessRoutes.forEach(route => {
|
// accessRoutes.forEach(route => {
|
||||||
// if (!isHttp(route.path)) {
|
// if (!isHttp(route.path)) {
|
||||||
|
@ -277,14 +277,32 @@ export const constantRoutes = [
|
|||||||
|
|
||||||
export const enterpriseRoutes = [
|
export const enterpriseRoutes = [
|
||||||
{
|
{
|
||||||
path: '/one',
|
path: '/technology',
|
||||||
component: Layout,
|
component: Layout,
|
||||||
|
meta: { title: '技术管理', icon: 'dashboard' },
|
||||||
|
alwaysShow:true,
|
||||||
|
redirect: 'noRedirect',
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
path: 'enterprise',
|
path: 'achievement',
|
||||||
component: () => import('@/views/admin/one/index'),
|
component: ParentView,
|
||||||
name: 'Enterprise',
|
meta: { title: '成果列表', icon: 'list' },
|
||||||
meta: { title: '账号管理', icon: 'dashboard' }
|
alwaysShow:true,
|
||||||
|
redirect: 'noRedirect',
|
||||||
|
children:[
|
||||||
|
{
|
||||||
|
path: 'release',
|
||||||
|
component: () => import('@/views/admin/two/technology/release'),
|
||||||
|
name: 'release',
|
||||||
|
meta: { title: '发布成果', icon: 'dashboard' }
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'research',
|
||||||
|
component: () => import('@/views/admin/two/technology/research'),
|
||||||
|
name: 'Research',
|
||||||
|
meta: { title: '科研项目列表', icon: 'dashboard' }
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -40,6 +40,7 @@ const permission = {
|
|||||||
GenerateRoutes({ commit },role) {
|
GenerateRoutes({ commit },role) {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
let data = []
|
let data = []
|
||||||
|
// localStorage.setItem('select_identity',role) // 测试
|
||||||
if (role == 1) {
|
if (role == 1) {
|
||||||
// 企业
|
// 企业
|
||||||
data = enterpriseRoutes
|
data = enterpriseRoutes
|
||||||
|
@ -63,6 +63,7 @@ const user = {
|
|||||||
commit('SET_NAME', res.data.name)
|
commit('SET_NAME', res.data.name)
|
||||||
commit('SET_AVATAR', avatar)
|
commit('SET_AVATAR', avatar)
|
||||||
localStorage.setItem('select_identity',res.data.select_identity)
|
localStorage.setItem('select_identity',res.data.select_identity)
|
||||||
|
// localStorage.setItem('select_identity',0) // 测试
|
||||||
resolve(res)
|
resolve(res)
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
reject(error)
|
reject(error)
|
||||||
|
@ -28,7 +28,7 @@ export default {
|
|||||||
},
|
},
|
||||||
chartData: {
|
chartData: {
|
||||||
type: Object,
|
type: Object,
|
||||||
required: true,
|
// required: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
|
@ -51,7 +51,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
import { identity, settled } from "@/api/identity/index";
|
import store from "@/store";
|
||||||
|
import { identity, settled, identitySwitch } from "@/api/identity/index";
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const identityList = ref([]);
|
const identityList = ref([]);
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
@ -107,7 +108,7 @@ function handlePage(item) {
|
|||||||
let routeData = "";
|
let routeData = "";
|
||||||
if (item.id == 1) {
|
if (item.id == 1) {
|
||||||
// 企业
|
// 企业
|
||||||
routeData = router.resolve({ path: "/one" });
|
routeData = router.resolve({ path: "/admin" });
|
||||||
} else if (item.id == 2) {
|
} else if (item.id == 2) {
|
||||||
// 专家
|
// 专家
|
||||||
routeData = router.resolve({ path: "/admin" });
|
routeData = router.resolve({ path: "/admin" });
|
||||||
@ -121,6 +122,15 @@ function handlePage(item) {
|
|||||||
// 科技经纪人
|
// 科技经纪人
|
||||||
routeData = router.resolve({ path: "/five" });
|
routeData = router.resolve({ path: "/five" });
|
||||||
}
|
}
|
||||||
window.open(routeData.href, "_blank");
|
// return window.open(routeData.href, "_blank");
|
||||||
|
// TODO ...... 切换身份待处理
|
||||||
|
identitySwitch({ identity: item.id - 0 }).then((res) => {
|
||||||
|
console.log(res);
|
||||||
|
window.open(routeData.href, "_blank");
|
||||||
|
});
|
||||||
|
// store.dispatch("GenerateRoutes", 1).then(() => {
|
||||||
|
// console.log(localStorage.getItem("select_identity"));
|
||||||
|
// window.open(routeData.href, "_blank");
|
||||||
|
// });
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
Reference in New Issue
Block a user