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

Vue.use(VueRouter);
const routes = [
  {
    path: '/',
    component: () => import('../views/home/index.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: '/uppasswd/index',
    component: () => import('../views/uppasswd/index.vue'),
  },
  // 个人信息管理
  {
    path: '/userInfo/index',
    component: () => import('../views/userInfo/index.vue'),
  },
  // 个人信息管理
  {
    path: '/institutionInfo/index',
    component: () => import('../views/institutionInfo/index.vue'),
  },
  // 债权需求
  {
    path: '/businessneed/claim',
    component: () => import('../views/businessneed/claim.vue'),
  },
  // 债权需求详情
  {
    path: '/businessneed/claimDetail',
    component: () => import('../views/businessneed/claimDetail.vue'),
  },
  // 股权需求
  {
    path: '/businessneed/stock',
    component: () => import('../views/businessneed/stock.vue'),
  },
  // 股权需求详情
  {
    path: '/businessneed/stockDetail',
    component: () => import('../views/businessneed/stockDetail.vue'),
  },
  //授信债权管理
  {
    path: '/follow/followindex',
    component: () => import('../views/follow/followindex.vue'),
  },
  // 授信债权管理详情
  {
    path: '/follow/followDetail',
    component: () => import('../views/follow/followDetail.vue'),
  },
  //授信股权管理
  {
    path: '/follow/followstock',
    component: () => import('../views/follow/followstock.vue'),
  },
  // 授信股权管理详情
  {
    path: '/follow/followStockDetail',
    component: () => import('../views/follow/followStockDetail.vue'),
  },
  // 已经完成债权需求
  {
    path: '/done/doneclaim',
    component: () => import('../views/done/doneclaim.vue'),
  },
  // 已经完成债权需求详情
  {
    path: '/done/followHistoryDetail',
    component: () => import('../views/done/followHistoryDetail.vue'),
  },
  // 债权产品列表
  {
    path: '/financeclaims/financeClaimIndex',
    component: () => import('../views/financeclaims/financeClaimIndex.vue'),
  },
  // 债权产品信息修改（添加）
  {
    path: '/financeclaims/financeClaimDetail',
    component: () => import('../views/financeclaims/financeClaimDetail.vue'),
  },
  // 债权产品信息详情
  {
    path: '/financeclaims/financeLookClaimDetail',
    component: () => import('../views/financeclaims/financeLookClaimDetail.vue'),
  },
  // 理财产品列表
  {
    path: '/financeclaims/manageMoneyIndex',
    component: () => import('../views/financeclaims/manageMoneyIndex.vue'),
  },
  //  理财产品信息修改（添加）
  {
    path: '/financeclaims/manageMoneyDetail',
    component: () => import('../views/financeclaims/manageMoneyDetail.vue'),
  },
  //  理财产品信息详情
  {
    path: '/financeclaims/manageMoneyLookDetail',
    component: () => import('../views/financeclaims/manageMoneyLookDetail.vue'),
  },
  // 金融机构管理
  {
    path: '/financeclaims/insitionIndex',
    component: () => import('../views/financeclaims/insitionIndex.vue'),
  },
  // 申请理财产品管理
  {
    path: '/financeclaims/applymmoneyIndex',
    component: () => import('../views/financeclaims/applymmoneyIndex.vue'),
  },
  // 申请理财产品详情
  {
    path: '/financeclaims/applymmDetail',
    component: () => import('../views/financeclaims/applymmDetail.vue'),
  },
  // 银企对接数据列表
  {
    path: '/intelligentDocking/intelligentDockingIndex',
    component: () => import('../views/intelligentDocking/intelligentDockingIndex.vue'),
  },
  // 银企对接数据列表详情
  {
    path: '/intelligentDocking/intelligentDockingDetail',
    component: () => import('../views/intelligentDocking/intelligentDockingDetail.vue'),
  },
  // 银企对接已关注列表
  {
    path: '/intelligentDocking/intelligentDockingFollow',
    component: () => import('../views/intelligentDocking/intelligentDockingFollow.vue'),
  },
  // 银企对接已关注详情
  {
    path: '/intelligentDocking/intelligentDockingFinishDetail',
    component: () => import('../views/intelligentDocking/intelligentDockingFinishDetail.vue'),
  },

  // 详情
  {
    path: '/intelligentDocking/intelligentDockingFollowDetail',
    component: () => import('../views/intelligentDocking/intelligentDockingFollowDetail.vue'),
  },

  // 银企对接已完成列表
  {
    path: '/intelligentDocking/intelligentDockingFinish',
    component: () => import('../views/intelligentDocking/intelligentDockingFinish.vue'),
  },
  // 企业信息管理-列表
  {
    path: '/companyup/index',
    component: () => import('../views/companyup/index.vue'),
  },
  // 企业信息管理-详情
  {
    path: '/companyup/detail',
    component: () => import('../views/companyup/detail.vue'),
  },
  // 企业申请信息催办处理
  {
    path: '/tUrgeHandle/seeIndex',
    component: () => import('../views/tUrgeHandle/seeIndex.vue'),
  },
  // 我要融资催办处理
  {
    path: '/financingTUrgeHandle/seeIndex',
    component: () => import('../views/financingTUrgeHandle/seeIndex.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;
