import Vue from 'vue'
import VueRouter from 'vue-router'

import Layout from '@/layout' //布局页

Vue.use(VueRouter)

// // 通用页面, 这里的配置不需要权限
export const constRouter = [
  {
      path: '/login',
      component: () => import('@/views/login/Login'),
      hidden: true //导航菜单忽略选项
  },
  {
      path: '',
      component: Layout, //应用布局页
      redirect: '/index',
      hidden: true,
  },
  {
      path: '/index',
      component: Layout, //应用布局页
      name: 'index',
      meta:{
          title: "首页", //导航菜单项标题
          icon: 'el-icon-s-home' //导航菜单图标
      },
      children: [
        {
          path: '',
          component: () => import('@/views/index/index.vue'),
          name: 'indexs',
          meta: {
            title: "首页",
            icon: 'el-icon-s-home',
            // roles: ['1','2','3']
            roles: ['管理员','销售','运营']
          }
        }
      ]
  }
]

// 动态路由 communication
export const asyncRoutes = [
  {
    path: '/index',
    component: Layout, //应用布局页
    name: 'index',
    meta:{
        title: "首页", //导航菜单项标题
        icon: 'el-icon-s-home' //导航菜单图标
    },
    children: [
      {
        path: '',
        component: () => import('@/views/index/index.vue'),
        name: 'indexs',
        meta: {
          title: "首页",
          icon: 'el-icon-s-home',
          // roles: ['1','2','3']
          roles: ['管理员','销售','运营']
        }
      }
    ]
  },
  {
    path: '/goods',
    component: Layout,
    redirect: '/goods/index',
    meta:{
      title: "客户列表",
      icon: 'el-icon-s-goods',
      hidden: false,
    },
    children: [
      {
        path: 'index',
        component: () => import('@/views/goods/Index.vue'),
        name: 'goodsindex',
        meta: {
          title: "客户列表",
          icon: 'el-icon-tickets',
          hidden: false,
          // roles: ['1','2','3']
          roles: ['管理员','销售','运营']
        }
      },
      {
        path: 'onindex',
        component: () => import('@/views/goods/OnIndex.vue'),
        name: 'onindex',
        meta: {
          title: "客户列表详情",
          icon: 'el-icon-tickets',
          hidden: false,
          // roles: ['1','2','3']
          roles: ['管理员','销售','运营']
        },
        is_menu: false,
        hidden: true
      },
    ]
  },
  {
    path: '/analyze',
    component: Layout,
    redirect: '/goods/index',
    meta: {
      title: "客户审核",
      icon: 'el-icon-s-marketing',
      hidden: false
    },
    children: [
      {
        path: 'analyzeindex',
        component: () => import('@/views/analyze/Index.vue'),
        name: 'analyzeindex',
        meta: {
          title: "客户审核",
          icon: 'el-icon-tickets',
          hidden: false,
          // roles: ['1','2','3'],'销售','运营'Index
          roles: ['管理员','销售','运营']
        }
      },
      {
        path: 'analyzemonitor',
        component: () => import('@/views/analyze/OnIndex.vue'),
        name: 'analyzemonitor',
        meta: {
          title: "审核详情",
          icon: 'el-icon-tickets',
          hidden: false,
          // roles: ['1','2','3'],'销售','运营'
          roles: ['管理员','销售','运营']
        },
        is_menu: false,
        hidden: true
      },
    ]
  },
  {
    path: '/control',
    component: Layout,
    redirect: '/control/keycode',
    meta:{
      title: "员工管理",
      icon: 'el-icon-s-platform',
      hidden: false,
      roles: ['管理员','销售','运营']
    },
    children: [
      {
        path: 'keycode',
        component: () => import('@/views/control/KeyCode.vue'),
        name: 'keycode',
        meta: {
          title: "员工管理",
          icon: 'el-icon-message',
          hidden: false,
          // roles: ['1','2','3'],'销售','运营'
          roles: ['管理员','销售','运营']
        }
      },
      
    ]
  },
]
const router = new VueRouter({
  // scrollBehavior: () => ({y: 0}),
  // routes: constRouter
  mode: 'hash',
  base: process.env.BASE_URL,
  routes: constRouter
})
// console.log('process.env.BASE_URL',process.env.BASE_URL);
export default router

