660 lines
21 KiB
TypeScript
660 lines
21 KiB
TypeScript
import { createRouter, RouteRecordRaw, createWebHistory } from 'vue-router'
|
|
import test from './module/test'
|
|
import myInfo from './module/myInfo'
|
|
|
|
import { mainStore } from 'store/main'
|
|
|
|
|
|
|
|
const routes: Array<RouteRecordRaw> = [
|
|
{
|
|
path: '/index',
|
|
name: 'index',
|
|
component: () => import('views/Index.vue'),
|
|
meta: {
|
|
title: '目录页',
|
|
keepAlive: true,
|
|
AuthFlag: false
|
|
}
|
|
},
|
|
/* 登录页 */
|
|
{
|
|
path: '/login',
|
|
name: 'login',
|
|
component: () => import('views/Login.vue'),
|
|
meta: {
|
|
title: '登录页',
|
|
keepAlive: true,
|
|
AuthFlag: false
|
|
}
|
|
},
|
|
/* 注册页 */
|
|
{
|
|
path: '/register',
|
|
name: 'register',
|
|
component: () => import('views/register.vue'),
|
|
meta: {
|
|
title: '注册页',
|
|
keepAlive: true,
|
|
AuthFlag: true,
|
|
}
|
|
},
|
|
{
|
|
path: '/test', // 主路由地址
|
|
name: 'testIndex',
|
|
component: () => import('views/test/Index.vue'), // 组件加载
|
|
meta: {
|
|
title: '测试',
|
|
keepAlive: true,
|
|
AuthFlag: false
|
|
},
|
|
children: [...test]
|
|
},
|
|
{
|
|
path: '/myInfo', // 主路由地址
|
|
name: 'myInfo',
|
|
component: () => import('views/myInfo/Index.vue'), // 组件加载
|
|
meta: {
|
|
title: '我的',
|
|
keepAlive: true,
|
|
AuthFlag: false
|
|
},
|
|
children: [...myInfo]
|
|
},
|
|
|
|
|
|
|
|
|
|
// 首页
|
|
{
|
|
path: '/',
|
|
component: () => import('views/AppMain.vue'),
|
|
redirect: '/home',
|
|
meta: {
|
|
title: '首页',
|
|
keepAlive: false,
|
|
AuthFlag: false
|
|
},
|
|
|
|
children: [
|
|
// 首页
|
|
{
|
|
path: 'home',
|
|
name: 'home',
|
|
component: () => import('views/home/index.vue'),
|
|
meta: {
|
|
title: '首页',
|
|
keepAlive: true,
|
|
AuthFlag: false,
|
|
activeName: 'home',
|
|
},
|
|
},
|
|
// 自选直租
|
|
{
|
|
path: '/equipList',
|
|
name: 'equipList',
|
|
component: () => import('views/equip/list.vue'),
|
|
meta: {
|
|
title: '装备共享大厅',
|
|
activeName: 'equipList',
|
|
}
|
|
},
|
|
//装备详情
|
|
{
|
|
path: '/equipDetail',
|
|
name: 'equipDetail',
|
|
component: () => import('views/equip/detail.vue'),
|
|
meta: {
|
|
title: '',
|
|
keepAlive: false,
|
|
AuthFlag: false,
|
|
}
|
|
},
|
|
// 资讯详情
|
|
{
|
|
path: '/consultationDetails/:id',
|
|
name: 'consultationDetails',
|
|
component: () => (import('views/consultationDetails/index.vue'))
|
|
},
|
|
// 收藏夹页面
|
|
{
|
|
path: '/collect',
|
|
name: 'collect',
|
|
meta: {
|
|
title: '我的收藏',
|
|
isLogin: true
|
|
},
|
|
component: () => import('views/collect/index.vue')
|
|
},
|
|
// 寻源比价页面
|
|
{
|
|
path: '/parity',
|
|
name: 'parity',
|
|
meta: {
|
|
title: '租赁需求大厅',
|
|
isLogin: true,
|
|
AuthFlag: false,
|
|
activeName: 'parity',
|
|
},
|
|
// redirect: '/parity/hall',
|
|
component: () => import('views/parity/index.vue'),
|
|
children: [
|
|
{
|
|
path: 'hall',
|
|
name: 'hall',
|
|
meta: {
|
|
title: '租赁需求大厅',
|
|
isLogin: true,
|
|
AuthFlag: false,
|
|
activeName: 'parity',
|
|
},
|
|
component: () => import('views/parity/parityCom/hall.vue'),
|
|
},
|
|
{
|
|
path: 'notice',
|
|
name: 'notice',
|
|
meta: {
|
|
title: '寻源结果公示公告',
|
|
isLogin: true,
|
|
AuthFlag: false,
|
|
activeName: 'parity',
|
|
},
|
|
component: () => import('views/parity/parityCom/notice.vue'),
|
|
}
|
|
]
|
|
},
|
|
// 寻源比价 (报价)
|
|
{
|
|
path: '/quotation',
|
|
name: 'quotation',
|
|
meta: {
|
|
title: '企业专区',
|
|
isLogin: true,
|
|
AuthFlag: false,
|
|
|
|
},
|
|
component: () => import('views/parity/parityCom/quotation.vue')
|
|
},
|
|
// 企业专区页面
|
|
{
|
|
path: '/enterpriseZone',
|
|
name: 'enterpriseZone',
|
|
meta: {
|
|
title: '企业专区',
|
|
isLogin: true,
|
|
AuthFlag: false,
|
|
activeName: 'enterpriseZone',
|
|
},
|
|
component: () => import('views/enterpriseZone/index.vue')
|
|
},
|
|
],
|
|
},
|
|
|
|
// 个人中心
|
|
{
|
|
path: '/my-user', // 主路由地址
|
|
name: 'my-user',
|
|
component: () => import('views/user/index.vue'), // 组件加载
|
|
meta: {
|
|
title: '个人中心',
|
|
keepAlive: false,
|
|
AuthFlag: false
|
|
},
|
|
children: [
|
|
|
|
{
|
|
path: '/orderManagementCz',
|
|
name: 'orderManagementCz',
|
|
component: () => import('views/user/orderManagementCz/index.vue'),
|
|
meta: {
|
|
title: '订单管理(出租方)',
|
|
keepAlive: true,
|
|
AuthFlag: false,
|
|
isLogin: true
|
|
},
|
|
},
|
|
{
|
|
path: '/goodsManagement',
|
|
name: 'goodsManagement',
|
|
component: () => import('views/user/goodsManagement/index.vue'),
|
|
meta: {
|
|
title: '商品管理',
|
|
keepAlive: true,
|
|
AuthFlag: false,
|
|
isLogin: true
|
|
},
|
|
},
|
|
{
|
|
path: '/accept-orders',
|
|
name: 'accept-orders',
|
|
component: () => import('views/user/accept-orders/index.vue'),
|
|
meta: {
|
|
title: '接单管理',
|
|
keepAlive: true,
|
|
AuthFlag: false,
|
|
isLogin: true
|
|
},
|
|
},
|
|
{
|
|
path: '/sourcingNeed',
|
|
name: 'sourcingNeed',
|
|
component: () => import('views/user/sourcingNeed/index.vue'),
|
|
meta: {
|
|
title: '需求管理',
|
|
keepAlive: true,
|
|
AuthFlag: false,
|
|
isLogin: true
|
|
},
|
|
},
|
|
{
|
|
path: '/orderManagement',
|
|
name: 'orderManagement',
|
|
component: () => import('views/user/orderManagement/index.vue'),
|
|
meta: {
|
|
title: '订单管理',
|
|
keepAlive: true,
|
|
AuthFlag: false,
|
|
isLogin: true
|
|
},
|
|
},
|
|
|
|
// /* 基础信息 */
|
|
// {
|
|
// path: 'baseInfo',
|
|
// name: 'baseInfo',
|
|
// component: () => import('views/user/baseInfo/index.vue'),
|
|
// meta: {
|
|
// title: '基础信息',
|
|
// keepAlive: true,
|
|
// AuthFlag: false,
|
|
// isLogin: true
|
|
// },
|
|
// },
|
|
|
|
// /* 订单管理(承租方) */
|
|
// {
|
|
// path: 'orderManagement',
|
|
// name: 'orderManagement',
|
|
// component: () => import('@/views/user/orderManagement/index.vue'),
|
|
// meta: {
|
|
// title: '订单管理(求租)',
|
|
// keepAlive: true,
|
|
// AuthFlag: false,
|
|
// isLogin: true
|
|
// },
|
|
// },
|
|
// /* 订单管理(出租方) */
|
|
// {
|
|
// path: 'orderManagementBuy',
|
|
// name: 'orderManagementBuy',
|
|
// component: () => import('@/views/user/orderManagementCz/index.vue'),
|
|
// meta: {
|
|
// title: '订单管理(求租)',
|
|
// keepAlive: true,
|
|
// AuthFlag: false,
|
|
// isLogin: true
|
|
// },
|
|
// },
|
|
// /* 订单管理(订单详情出租) */
|
|
// {
|
|
// path: 'orderManagementInfoBuy',
|
|
// name: 'orderManagementInfoBuy',
|
|
// component: () => import('@/views/user/orderManagementCz/detail.vue'),
|
|
// meta: {
|
|
// title: '订单详情',
|
|
// keepAlive: true,
|
|
// AuthFlag: false,
|
|
// isLogin: false
|
|
// },
|
|
// },
|
|
// /* 订单管理(订单详情承租) */
|
|
{
|
|
path: 'orderManagementInfo',
|
|
name: 'orderManagementInfo',
|
|
component: () => import('@/views/user/orderManagement/detail.vue'),
|
|
meta: {
|
|
title: '订单详情',
|
|
keepAlive: true,
|
|
AuthFlag: false,
|
|
isLogin: false
|
|
},
|
|
},
|
|
// /* 订单管理(退租) */
|
|
{
|
|
path: 'rentinTermination',
|
|
name: 'rentinTermination',
|
|
component: () => import('views/user/orderManagement/orderCom/rentinTermination.vue'),
|
|
meta: {
|
|
title: '订单管理(退租)',
|
|
keepAlive: true,
|
|
AuthFlag: false,
|
|
isLogin: true
|
|
},
|
|
},
|
|
// /* 订单管理(续租) */
|
|
// {
|
|
// path: 'renewalOfLease',
|
|
// name: 'renewalOfLease',
|
|
// component: () => import('views/user/orderManagement/orderCom/renewalOfLease.vue'),
|
|
// meta: {
|
|
// title: '订单管理(续租)',
|
|
// keepAlive: true,
|
|
// AuthFlag: false,
|
|
// isLogin: true
|
|
// },
|
|
// },
|
|
// {
|
|
// path: 'subAccount',
|
|
// name: 'subAccount',
|
|
// component: () => import('views/user/subAccount/index.vue'),
|
|
// meta: {
|
|
// title: '子账号管理',
|
|
// keepAlive: true,
|
|
// AuthFlag: false,
|
|
// isLogin: true
|
|
// },
|
|
// },
|
|
// {
|
|
// path: 'business',
|
|
// name: 'business',
|
|
// component: () => import('views/user/business/index.vue'),
|
|
// meta: {
|
|
// title: '业务开通',
|
|
// keepAlive: true,
|
|
// AuthFlag: false,
|
|
// isLogin: true
|
|
// },
|
|
// },
|
|
// /* 寻源需求 */
|
|
// {
|
|
// path: 'sourcingNeed',
|
|
// name: 'sourcingNeed',
|
|
// component: () => import('views/user/sourcingNeed/index.vue'),
|
|
// meta: {
|
|
// title: '需求管理',
|
|
// keepAlive: true,
|
|
// AuthFlag: false,
|
|
// isLogin: true
|
|
// },
|
|
// },
|
|
// {
|
|
// path: 'orderManagementCz',
|
|
// name: 'orderManagementCz',
|
|
// component: () => import('views/user/orderManagementCz/index.vue'),
|
|
// meta: {
|
|
// title: '订单管理(承租)',
|
|
// keepAlive: true,
|
|
// AuthFlag: false,
|
|
// isLogin: true
|
|
// },
|
|
// },
|
|
// /* 订单管理(结算) */
|
|
// {
|
|
// path: 'settlement',
|
|
// name: 'settlement',
|
|
// component: () => import('views/user/orderManagementCz/settlement/index.vue'),
|
|
// meta: {
|
|
// title: '订单管理(结算)',
|
|
// keepAlive: true,
|
|
// AuthFlag: false,
|
|
// isLogin: true
|
|
// },
|
|
// },
|
|
// {
|
|
// path: 'goodsManagement',
|
|
// name: 'goodsManagement',
|
|
// component: () => import('views/user/goodsManagement/index.vue'),
|
|
// meta: {
|
|
// title: '基础信息',
|
|
// keepAlive: true,
|
|
// AuthFlag: false,
|
|
// isLogin: true
|
|
// },
|
|
// },
|
|
// {
|
|
// path: 'goodsUpdown',
|
|
// name: 'goodsUpdown',
|
|
// component: () => import('views/user/goodsUpdown/index.vue'),
|
|
// meta: {
|
|
// title: '基础信息',
|
|
// keepAlive: true,
|
|
// AuthFlag: false,
|
|
// isLogin: true
|
|
// },
|
|
// },
|
|
// {
|
|
// path: 'operatorManagement',
|
|
// name: 'operatorManagement',
|
|
// component: () => import('views/user/operatorManagement/index.vue'),
|
|
// meta: {
|
|
// title: '基础信息',
|
|
// keepAlive: true,
|
|
// AuthFlag: false,
|
|
// isLogin: true
|
|
// },
|
|
// },
|
|
// {
|
|
// path: 'orderDetails',
|
|
// name: 'orderDetails',
|
|
// component: () => import('views/user/orderManagement/orderCom/orderDetails.vue'),
|
|
// meta: {
|
|
// title: '订单详情',
|
|
// keepAlive: true,
|
|
// AuthFlag: false,
|
|
// isLogin: true
|
|
// },
|
|
// },
|
|
// {
|
|
// path: 'orderConfirm',
|
|
// name: 'orderConfirm',
|
|
// component: () => import('views/user/orderManagement/orderCom/orderConfirm.vue'),
|
|
// meta: {
|
|
// title: '订单确认',
|
|
// keepAlive: true,
|
|
// AuthFlag: false,
|
|
// isLogin: true
|
|
// },
|
|
// },
|
|
// {
|
|
// path: 'sourcingBidding',
|
|
// name: 'sourcingBidding',
|
|
// component: () => import('views/user/sourcingBidding/index.vue'),
|
|
// meta: {
|
|
// title: '寻源竞价',
|
|
// keepAlive: true,
|
|
// AuthFlag: false,
|
|
// isLogin: true
|
|
// },
|
|
// },
|
|
// /* 专区管理 */
|
|
// {
|
|
// path: 'zoneManag',
|
|
// name: 'zoneManag',
|
|
// component: () => import('views/user/zoneManag/index.vue'),
|
|
// meta: {
|
|
// title: '专区管理',
|
|
// keepAlive: true,
|
|
// AuthFlag: false,
|
|
// isLogin: true
|
|
// },
|
|
// },
|
|
// /* 申请加入专区页面 */
|
|
// {
|
|
// path: 'joinZone',
|
|
// name: 'joinZone',
|
|
// component: () => import('views/user/zoneManag/zoneCom/joinZone.vue'),
|
|
// meta: {
|
|
// title: '请加入专区',
|
|
// keepAlive: true,
|
|
// AuthFlag: false,
|
|
// isLogin: true
|
|
// },
|
|
// },
|
|
]
|
|
},
|
|
// 预约车页面
|
|
{
|
|
path: '/cart',
|
|
name: 'cart',
|
|
component: () => import('views/cart/index.vue'),
|
|
meta: {
|
|
title: '预约车',
|
|
keepAlive: false,
|
|
AuthFlag: false
|
|
},
|
|
},
|
|
// 订单确认页面
|
|
{
|
|
path: '/order-confirm',
|
|
name: 'order-confirm',
|
|
component: () => import('views/order/index.vue'),
|
|
meta: {
|
|
title: '订单提交',
|
|
keepAlive: false,
|
|
AuthFlag: false
|
|
},
|
|
},
|
|
// 需求详情页面
|
|
{
|
|
path: '/demand-details',
|
|
name: 'demand-details',
|
|
component: () => import('views/demand-details/index.vue'),
|
|
meta: {
|
|
title: '需求详情',
|
|
keepAlive: false,
|
|
AuthFlag: false
|
|
},
|
|
},
|
|
|
|
// 个人中心改造路由
|
|
/**
|
|
* 1. 出租方
|
|
*/
|
|
// {
|
|
// path: '/my-lease', // 主路由地址
|
|
// name: 'my-lease',
|
|
// component: () => import('views/user/index.vue'), // 组件加载
|
|
// meta: {
|
|
// title: '个人中心',
|
|
// keepAlive: false,
|
|
// AuthFlag: false
|
|
// },
|
|
// redirect: '/my-lease/goodsManagement',
|
|
// children: [
|
|
// {
|
|
// path: 'orderManagementCz',
|
|
// name: 'orderManagementCz',
|
|
// component: () => import('views/user/orderManagementCz/index.vue'),
|
|
// meta: {
|
|
// title: '订单管理(出租方)',
|
|
// keepAlive: true,
|
|
// AuthFlag: false,
|
|
// isLogin: true
|
|
// },
|
|
// },
|
|
// {
|
|
// path: 'goodsManagement',
|
|
// name: 'goodsManagement',
|
|
// component: () => import('views/user/goodsManagement/index.vue'),
|
|
// meta: {
|
|
// title: '商品管理',
|
|
// keepAlive: true,
|
|
// AuthFlag: false,
|
|
// isLogin: true
|
|
// },
|
|
// },
|
|
// {
|
|
// path: 'accept-orders',
|
|
// name: 'accept-orders',
|
|
// component: () => import('views/user/accept-orders/index.vue'),
|
|
// meta: {
|
|
// title: '接单管理',
|
|
// keepAlive: true,
|
|
// AuthFlag: false,
|
|
// isLogin: true
|
|
// },
|
|
// },
|
|
|
|
|
|
|
|
// ]
|
|
// },
|
|
// /**
|
|
// * 2. 承租方
|
|
// */
|
|
// {
|
|
// path: '/my-lessee', // 主路由地址
|
|
// name: 'my-lessee',
|
|
// component: () => import('views/user/index.vue'), // 组件加载
|
|
// meta: {
|
|
// title: '个人中心',
|
|
// keepAlive: false,
|
|
// AuthFlag: false
|
|
// },
|
|
// redirect: '/my-lessee/sourcingNeed',
|
|
// children: [
|
|
// {
|
|
// path: 'sourcingNeed',
|
|
// name: 'sourcingNeed',
|
|
// component: () => import('views/user/sourcingNeed/index.vue'),
|
|
// meta: {
|
|
// title: '需求管理',
|
|
// keepAlive: true,
|
|
// AuthFlag: false,
|
|
// isLogin: true
|
|
// },
|
|
// },
|
|
// {
|
|
// path: 'orderManagement',
|
|
// name: 'orderManagement',
|
|
// component: () => import('views/user/orderManagement/index.vue'),
|
|
// meta: {
|
|
// title: '订单管理',
|
|
// keepAlive: true,
|
|
// AuthFlag: false,
|
|
// isLogin: true
|
|
// },
|
|
// },
|
|
// ]
|
|
// }
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
const router = createRouter({
|
|
// 路由模式
|
|
history: createWebHistory(),
|
|
routes
|
|
})
|
|
|
|
console.log(router, '*****路由')
|
|
|
|
// 使页面跳转后滚动条恢复至顶部
|
|
router.beforeEach((to, from, next) => {
|
|
|
|
const store = mainStore()
|
|
if (to.meta.isLogin && !to.meta.AuthFlag) {
|
|
if (store.token) {
|
|
next()
|
|
} else {
|
|
next(`/login?redirect=${encodeURIComponent(to.fullPath)}`)
|
|
}
|
|
} else {
|
|
next()
|
|
}
|
|
|
|
|
|
// if (store.token || to.path == '/login' || to.path == '/' || to.path == '/home' || to.path == '/register' || to.path == '/equipList' || to.path == '/equipDetail') {
|
|
|
|
// } else {
|
|
// next('/login')
|
|
// }
|
|
// chrome
|
|
document.body.scrollTop = 0;
|
|
// firefox 兼容火狐
|
|
document.documentElement.scrollTop = 0;
|
|
})
|
|
export default router
|