import Vue from 'vue';
import VueRouter from 'vue-router';
import store from '@/store/index';

Vue.use(VueRouter);
const routes = [
  {
    path: '/',
    component: () => import('../views/dockingresults/TotalResult.vue'),
  },
  // 测试菜单+列表
  {
    path: '/test/index',
    component: () => import('../views/test/index.vue'),
  },
  // 测试菜单+添加
  {
    path: '/test/detail',
    component: () => import('../views/test/detail.vue'),
  },
  // 登录
  {
    path: '/login',
    name: 'login',
    component: () => import('../views/login.vue'),
  },
  // 大屏
  {
    path: '/bigAll',
    component: () => import('../views/bigAll/bigAll.vue'),
  },
  // 修改密码
  {
    path: '/uppasswd/index',
    component: () => import('../views/uppasswd/index.vue'),
  },
  // 个人信息管理
  {
    path: '/userInfo/index',
    component: () => import('../views/userInfo/index.vue'),
  },
  //政策申报管理
  {
    path: '/tPolicyDeclaration/index',
    component: () => import('../views/tPolicyDeclaration/index.vue'),
  },
  {
    path: '/tPolicyDeclaration/detail',
    component: () => import('../views/tPolicyDeclaration/detail.vue'),
  },
  {
    path: '/tDeclarationApproval/index',
    component: () => import('../views/tDeclarationApproval/index.vue'),
  },
  {
    path: '/tDeclarationApproval/detail',
    component: () => import('../views/tDeclarationApproval/detail.vue'),
  },
  // 企业信息管理-列表
  {
    path: '/companyup/index',
    component: () => import('../views/companyup/index.vue'),
  },
  // 企业信息管理-详情
  {
    path: '/companyup/detail',
    component: () => import('../views/companyup/detail.vue'),
  },

  //对接成果 总
  {
    path: '/TotalResult',
    //name: 'companyInfo',
    component: () => import('../views/dockingresults/TotalResult.vue'),
  },
  //对接成果 注册对接
  {
    path: '/RegisterResult',
    //name: 'companyInfo',
    component: () => import('../views/dockingresults/RegisterResult.vue'),
  },
  //对接成果 服务金融机构
  {
    path: '/ServiceResult',
    //name: 'companyInfo',
    component: () => import('../views/dockingresults/ServiceResult.vue'),
  },
  {
    path: '/tPolicyInterpretation/index',
    component: () => import('../views/tPolicyInterpretation/index.vue'),
  },
  {
    path: '/tPolicyInterpretation/detail',
    component: () => import('../views/tPolicyInterpretation/detail.vue'),
  },
  // 企业申请信息催办
  {
    path: '/tUrgeHandle/index',
    component: () => import('../views/tUrgeHandle/index.vue'),
  },
  {
    path: '/tUrgeHandle/detail',
    component: () => import('../views/tUrgeHandle/detail.vue'),
  },
  {
    path: '/tUrgeHandle/seeIndex',
    component: () => import('../views/tUrgeHandle/seeIndex.vue'),
  },
  // 企业申请信息指派
  {
    path: '/tNewAssign/index',
    component: () => import('../views/tNewAssign/index.vue'),
  },
  {
    path: '/tNewAssign/detail',
    component: () => import('../views/tNewAssign/detail.vue'),
  },
  // 我要融资催办
  {
    path: '/financingTUrgeHandle/index',
    component: () => import('../views/financingTUrgeHandle/index.vue'),
  },
  {
    path: '/financingTUrgeHandle/detail',
    component: () => import('../views/financingTUrgeHandle/detail.vue'),
  },
  {
    path: '/financingTUrgeHandle/seeIndex',
    component: () => import('../views/financingTUrgeHandle/seeIndex.vue'),
  },
  // 我要融资指派
  {
    path: '/financingTNewAssign/index',
    component: () => import('../views/financingTNewAssign/index.vue'),
  },
  {
    path: '/financingTNewAssign/detail',
    component: () => import('../views/financingTNewAssign/detail.vue'),
  },

  // 金融超市
  {
    path: '/moneySupermarket/index',
    component: () => import('../views/moneySupermarket/index.vue'),
  },
  {
    path: '/moneySupermarket/detail',
    component: () => import('../views/moneySupermarket/detail.vue'),
  },
  // 智能匹配
  {
    path: '/intelligentMatching/index',
    component: () => import('../views/intelligentMatching/index.vue'),
  },
  {
    path: '/intelligentMatching/detail',
    component: () => import('../views/intelligentMatching/detail.vue'),
  },


  //对接成果 金融产品
  {
    path: '/FinancialProducts',
    //name: 'companyInfo',
    component: () => import('../views/dockingresults/FinancialProducts.vue'),
  },
  //对接成果 企业发布需求
  {
    path: '/CompanyResult',
    //name: 'companyInfo',
    component: () => import('../views/dockingresults/CompanyResult.vue'),
  },
  //对接成果 企业发布需求金额
  {
    path: '/ReleaseResult',
    //name: 'companyInfo',
    component: () => import('../views/dockingresults/ReleaseResult.vue'),
  },
  //对接成果 企业发布需求详情
  {
    path: '/ServiceResultDetail',
    //name: 'companyInfo',
    component: () => import('../views/dockingresults/ServiceResultDetail.vue'),
  },
  //对接成果 帮助企业
  {
    path: '/HelpResult',
    //name: 'companyInfo',
    component: () => import('../views/dockingresults/HelpResult.vue'),
  },
  //对接成果 解决融资
  {
    path: '/SolutionResult',
    //name: 'companyInfo',
    component: () => import('../views/dockingresults/SolutionResult.vue'),
  },
  //对接成果 解决融资
  {
    path: '/BankResult',
    //name: 'companyInfo',
    component: () => import('../views/dockingresults/bankTotal.vue'),
  },
];
const router = new VueRouter({
  mode: 'history',
  base: process.env.NODE_ENV === 'development' ? '' : process.env.VUE_APP_ROOT_URL,
  routes,
});
router.beforeEach((to, form, next) => {
  store.commit('setUser');
  if (to.name === 'login') {
    next();
    return;
  }
  let user = store.state.user;
  if (user) {
    next();
  }
  //下面是没登录的情况,需要跳转页面到用户未登录页
  else {
    next({ name: 'login' });

  }
});

export default router;
