123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270 |
- import Vue from 'vue';
- import VueRouter from 'vue-router';
- import store from '@/store/index';
- const jwt = require('jsonwebtoken');
- Vue.use(VueRouter);
- const routes = [
- // 公众号第一版开始
- // 直播大厅
- {
- path: '/live/index',
- name: 'live_index',
- meta: { title: '直播大厅', isleftarrow: false },
- component: () => import('../views/live/index.vue'),
- },
- // 直播大厅-在线展会详情
- {
- path: '/live/liveDetail',
- name: 'liveDetail',
- meta: { title: '展会详情', isleftarrow: true },
- component: () => import('../views/live/liveDetail.vue'),
- },
- // 直播大厅-科技频道详情
- {
- path: '/live/channelDetail',
- name: 'channelDetail',
- meta: { title: '科技频道', isleftarrow: true },
- component: () => import('../views/live/channelDetail.vue'),
- },
- // 直播大厅-嘉宾访谈详情
- {
- path: '/live/interviewDeatil',
- name: 'interviewDeatil',
- meta: { title: '嘉宾访谈详情', isleftarrow: true },
- component: () => import('../views/live/interviewDeatil.vue'),
- },
- // 直播大厅-项目路演详情
- {
- path: '/live/roadshowDetail',
- name: 'roadshowDetail',
- meta: { title: '项目路演详情', isleftarrow: true },
- component: () => import('../views/live/roadshowDetail.vue'),
- },
- // 科技超市
- {
- path: '/market/index',
- name: 'market_index',
- meta: { title: '科技超市', isleftarrow: false },
- component: () => import('../views/market/index.vue'),
- },
- // 科技超市详情
- {
- path: '/market/detail',
- name: 'detail',
- meta: { title: '科技超市详情', isleftarrow: true },
- component: () => import('../views/market/detail.vue'),
- },
- // 个人中心
- {
- path: '/user/index',
- name: 'user',
- meta: { title: '个人中心', isleftarrow: false },
- component: () => import('../views/user/index.vue'),
- },
- // 公众号第一版结束
- // 公众号第二版开始 viewTwo
- // 在线展会
- {
- path: '/viewTwo/live/index',
- name: 'live',
- meta: { title: '在线展会', isleftarrow: true },
- component: () => import('../viewTwo/live/index.vue'),
- },
- // 在线展会详情
- {
- path: '/viewTwo/live/detail',
- name: 'live',
- meta: { title: '在线展会详情', isleftarrow: true },
- component: () => import('../viewTwo/live/detail.vue'),
- },
- // 人才对接详情
- {
- path: '/viewTwo/live/personalDetail',
- name: 'live',
- meta: { title: '人才对接详情', isleftarrow: true },
- component: () => import('../viewTwo/live/personalDetail.vue'),
- },
- // 专家培训详情
- {
- path: '/viewTwo/live/exportsDetail',
- name: 'live',
- meta: { title: '专家培训详情', isleftarrow: true },
- component: () => import('../viewTwo/live/exportsDetail.vue'),
- },
- // 科技频道
- {
- path: '/viewTwo/channel/index',
- name: 'channel',
- meta: { title: '科技频道', isleftarrow: false },
- component: () => import('../viewTwo/channel/index.vue'),
- },
- {
- path: '/viewTwo/channel/detail',
- name: 'detail',
- meta: { title: '科技频道详情', isleftarrow: true },
- component: () => import('../viewTwo/channel/detail.vue'),
- },
- // 培训访谈
- {
- path: '/viewTwo/interview/index',
- name: 'interview',
- meta: { title: '培训访谈', isleftarrow: false },
- component: () => import('../viewTwo/interview/index.vue'),
- },
- {
- path: '/viewTwo/interview/detail',
- name: 'detail',
- meta: { title: '培训访谈详情', isleftarrow: true },
- component: () => import('../viewTwo/interview/detail.vue'),
- },
- // 项目路演
- {
- path: '/viewTwo/roadshow/index',
- name: 'roadshow',
- meta: { title: '项目路演', isleftarrow: false },
- component: () => import('../viewTwo/roadshow/index.vue'),
- },
- {
- path: '/viewTwo/roadshow/detail',
- name: 'roadshow',
- meta: { title: '项目路演详情', isleftarrow: true },
- component: () => import('../viewTwo/roadshow/detail.vue'),
- },
- // 技术成果
- {
- path: '/viewTwo/achieve/index',
- name: 'achieve',
- meta: { title: '技术成果', isleftarrow: false },
- component: () => import('../viewTwo/achieve/index.vue'),
- },
- {
- path: '/viewTwo/achieve/detail',
- name: 'achieve',
- meta: { title: '技术成果详情', isleftarrow: true },
- component: () => import('../viewTwo/achieve/detail.vue'),
- },
- // e专利
- {
- path: '/viewTwo/patent/index',
- name: 'patent',
- meta: { title: 'e专利', isleftarrow: false },
- component: () => import('../viewTwo/patent/index.vue'),
- },
- {
- path: '/viewTwo/patent/detail',
- name: 'patent',
- meta: { title: 'e专利详情', isleftarrow: true },
- component: () => import('../viewTwo/patent/detail.vue'),
- },
- // 科技需求
- {
- path: '/viewTwo/techol/index',
- name: 'techol',
- meta: { title: '科技需求', isleftarrow: false },
- component: () => import('../viewTwo/techol/index.vue'),
- },
- {
- path: '/viewTwo/techol/detail',
- name: 'techol',
- meta: { title: '科技需求详情', isleftarrow: true },
- component: () => import('../viewTwo/techol/detail.vue'),
- },
- // 专家智库
- {
- path: '/viewTwo/expert/index',
- name: 'expert',
- meta: { title: '专家智库', isleftarrow: false },
- component: () => import('../viewTwo/expert/index.vue'),
- },
- {
- path: '/viewTwo/expert/detail',
- name: 'expert',
- meta: { title: '专家智库详情', isleftarrow: true },
- component: () => import('../viewTwo/expert/detail.vue'),
- },
- // 在线服务
- {
- path: '/viewTwo/service/index',
- name: 'service',
- meta: { title: '在线服务', isleftarrow: false },
- component: () => import('../viewTwo/service/index.vue'),
- },
- {
- path: '/viewTwo/service/detail',
- name: 'service',
- meta: { title: '在线服务', isleftarrow: true },
- component: () => import('../viewTwo/service/detail.vue'),
- },
- // 调查问卷
- {
- path: '/viewTwo/question/index',
- name: 'question',
- meta: { title: '调查问卷', isleftarrow: false },
- component: () => import('../viewTwo/question/index.vue'),
- },
- // 通知通告
- {
- path: '/viewTwo/notice/index',
- name: 'notice',
- meta: { title: '通知通告', isleftarrow: false },
- component: () => import('../viewTwo/notice/index.vue'),
- },
- {
- path: '/viewTwo/notice/detail',
- name: 'notice',
- meta: { title: '通知通告详情', isleftarrow: true },
- component: () => import('../viewTwo/notice/detail.vue'),
- },
- // 新闻资讯
- {
- path: '/viewTwo/news/index',
- name: 'news',
- meta: { title: '新闻资讯', isleftarrow: false },
- component: () => import('../viewTwo/news/index.vue'),
- },
- // 账号管理
- {
- path: '/viewTwo/account/index',
- name: 'account',
- meta: { title: '账号管理', isleftarrow: false },
- component: () => import('../viewTwo/account/index.vue'),
- },
- // 公众号第二版结束
- ];
- const router = new VueRouter({
- mode: 'history',
- base: process.env.NODE_ENV === 'development' ? '' : process.env.VUE_APP_ROUTER,
- routes,
- });
- router.beforeEach(async (to, form, next) => {
- if (to.name == 'user_index') {
- let res = await store.dispatch('login/toGetUser');
- if (res && res.uid) {
- next();
- } else {
- let key = sessionStorage.getItem('token');
- let user = jwt.decode(key);
- if (user && user.uid) {
- store.commit('setUser', user, { root: true });
- next();
- } else {
- next({ name: 'login' });
- }
- }
- } else {
- let res = await store.dispatch('login/toGetUser');
- next();
- }
- });
- const originalPush = VueRouter.prototype.push;
- VueRouter.prototype.push = function push(location, onResolve, onReject) {
- if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject);
- return originalPush.call(this, location).catch(err => err);
- };
- export default router;
|