123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- import Vue from 'vue';
- import VueRouter from 'vue-router';
- import store from '@/store/index';
- Vue.use(VueRouter);
- const routes = [
- // 首页
- {
- path: '/home/index',
- name: 'home_index',
- meta: { title: '首页', isleftarrow: false },
- component: () => import('../views/home/index.vue'),
- },
- // 错误
- {
- path: '/home/error',
- name: '',
- meta: { title: '错误页面', isleftarrow: false },
- component: () => import('../views/home/error.vue'),
- },
- // 直播大厅
- {
- path: '/live/index',
- name: 'live_index',
- meta: { title: '直播大厅', isleftarrow: true },
- component: () => import('../views/live/index.vue'),
- },
- // 科技超市
- {
- path: '/market/index',
- name: 'market_index',
- meta: { title: '科技超市', isleftarrow: true },
- component: () => import('../views/market/index.vue'),
- },
- // 科技超市-技术-产品-服务详情
- {
- path: '/market/prodDetail',
- name: 'market_prodDetail',
- meta: { title: '产品详情', isleftarrow: true },
- component: () => import('../views/market/prodDetail.vue'),
- },
- // 科技超市-专家详情
- {
- path: '/market/exportDetail',
- name: 'market_exportDetail',
- meta: { title: '专家详情', isleftarrow: true },
- component: () => import('../views/market/exportDetail.vue'),
- },
- // 科技超市-发布产品
- {
- path: '/market/detail',
- name: 'market_detail',
- meta: { title: '发布产品', isleftarrow: true },
- component: () => import('../views/market/detail.vue'),
- },
- // 用户-我的发布
- {
- path: '/userCenter/myProduct/index',
- name: 'myProduct_index',
- meta: { title: '我的发布', isleftarrow: true },
- component: () => import('../views/userCenter/myProduct/index.vue'),
- },
- // 用户-发布产品
- {
- path: '/userCenter/myProduct/detail',
- name: 'myProduct_detail',
- meta: { title: '发布产品', isleftarrow: true },
- component: () => import('../views/userCenter/myProduct/detail.vue'),
- },
- // 用户-事项管理
- {
- path: '/userCenter/matter/index',
- name: 'matter_index',
- meta: { title: '事项管理', isleftarrow: true },
- component: () => import('../views/userCenter/matter/index.vue'),
- },
- // 用户-事项管理详情
- {
- path: '/userCenter/matter/detailinfo',
- name: 'matter_idetailinfo',
- meta: { title: '事项详情', isleftarrow: true },
- component: () => import('../views/userCenter/matter/detailinfo.vue'),
- },
- // 用户-展会管理
- {
- path: '/userCenter/dock/index',
- name: 'dock_index',
- meta: { title: '展会管理', isleftarrow: true },
- component: () => import('../views/userCenter/dock/index.vue'),
- },
- // 用户-申请对接会
- {
- path: '/userCenter/dock/apply',
- name: 'dock_apply',
- meta: { title: '申请对接会', isleftarrow: true },
- component: () => import('../views/userCenter/dock/apply.vue'),
- },
- // 用户-个人中心
- {
- path: '/userCenter/user/index',
- name: 'user_index',
- meta: { title: '个人中心', isleftarrow: true },
- component: () => import('../views/userCenter/user/index.vue'),
- },
- // // 个人中心
- {
- path: '/user/index',
- name: 'user_index',
- meta: { title: '个人中心', isleftarrow: true },
- component: () => import('../views/user/index.vue'),
- },
- ,
- ];
- const router = new VueRouter({
- mode: 'history',
- base: process.env.NODE_ENV === 'development' ? '' : process.env.VUE_APP_ROUTER,
- routes,
- });
- router.beforeEach((to, form, next) => {
- if (to.name === 'user_index') {
- store.commit('setUser');
- if (to.name === 'home_index') {
- next();
- return;
- }
- let user = store.state.user;
- if (user) {
- next();
- }
- //下面是没登录的情况,需要跳转页面到用户未登录页
- else next({ name: 'home_index' });
- } else {
- store.commit('setUser');
- next();
- }
- });
- export default router;
|