import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'

/**
 * hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
 *                                if not set alwaysShow, only more than one route under the children
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noredirect           if `redirect:noredirect` will no redirct in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
 **/
export const constantRouterMap = [
  {path: '/login', component: () => import('@/views/login/index'), hidden: true},
  {path: '/404', component: () => import('@/views/404'), hidden: true},
  {
    path: '',
    component: Layout,
    redirect: '/home',
    meta: {title: '首页', icon: 'home'},
    children: [{
      path: 'home',
      name: 'home',
      component: () => import('@/views/home/index'),
      meta: {title: '首页', icon: 'home'}
    },] 
  }

]

export const asyncRouterMap = [
  {
    path: '/channel',
    component: Layout,
    redirect: '/channel/info',
    name: 'channel',
    meta: {title: '渠道管理', icon: 'cms-subject'},
    children: [{
      path: 'info',
      name: 'info',
      component: () => import('@/views/channel/info/index'),
      meta: {title: '基础信息', icon: 'BasicsInfo'},
    },
    {
      path: 'useCondition',
      name: 'useCondition',
      component: () => import('@/views/channel/useCondition/index'),
      meta: {title: '使用情况', icon: 'useCondition'}
    },
    {
      path: 'upCheck',
      name: 'upCheck',
      component: () => import('@/views/channel/upCheck/index'),
      meta: {title: '上账情况', icon: 'settleAccounts'}
    },
    ]
  },
  {
    path: '/distribution',
    component: Layout,
    redirect: '/distribution/userList',
    name: 'distribution',
    meta: {title: '分销管理', icon: 'total-yesterday'},
    children: [{
      path: 'distributionSet',
      name: 'distributionSet',
      component: () => import('@/views/distribution/distributionSet/index'),
      meta: {title: '分销设置', icon: 'setting'}
    },
    {
      path: 'userList',
      name: 'userList',
      component: () => import('@/views/distribution/userList/index'),
      meta: {title: '用户列表', icon: 'user'}
    },
    {
      path: 'peopleManage',
      name: 'peopleManage',
      component: () => import('@/views/distribution/peopleManage/index'),
      meta: {title: '分销员管理', icon: 'peopleChannel'}
    },
    {
      path: 'junior',
      name: 'junior',
      component: () => import('@/views/distribution/peopleManage/junior'),
      meta: {title: '下级查看', icon: 'peopleChannel'},
      hidden: true
    },
    {
      path: 'setCommission',
      name: 'setCommission',
      component: () => import('@/views/distribution/peopleManage/setCommission'),
      meta: {title: '电站列表', icon: 'peopleChannel'},
      hidden: true
    },
    {
      path: 'settingsPrice',
      name: 'settingsPrice',
      component: () => import('@/views/distribution/peopleManage/settingsPrice'),
      meta: {title: '价格设置', icon: 'peopleChannel'},
      hidden: true
    },
    {
      path: 'firstSetPrice',
      name: 'firstSetPrice',
      component: () => import('@/views/distribution/peopleManage/firstSetPrice'),
      meta: {title: '价格设置', icon: 'peopleChannel'},
      hidden: true
    },
    {
      path: 'statistics',
      name: 'statistics',
      component: () => import('@/views/distribution/statistics/index'),
      meta: {title: '业绩统计', icon: 'performance'}
    },
    {
      path: 'records',
      name: 'records',
      component: () => import('@/views/distribution/records/index'),
      meta: {title: '分销记录', icon: 'example'}
    },
    {
      path: 'finance',
      name: 'finance',
      component: () => import('@/views/distribution/finance/index'),
      meta: {title: '结算记录', icon: 'order-return-reason'}
    },
    {
      path: 'changePwd',
      name: 'changePwd',
      component: () => import('@/views/distribution/changePwd/index'),
      meta: {title: '修改密码'},
      hidden: true
    }
    ]
  },
  {
    path:'/ums',
    component: Layout,
    redirect: '/ums/admin',
    name: 'ums',
    meta: {title: '权限管理', icon: 'ums'},
    children: [
      {
        path: 'admin',
        name: 'admin',
        component: () => import('@/views/ums/admin/index'),
        meta: {title: '平台成员', icon: 'ums-admin'}
      },
      {
        path: 'role',
        name: 'role',
        component: () => import('@/views/ums/role/index'),
        meta: {title: '角色列表', icon: 'ums-role'}
      },
      {
        path: 'allocMenu',
        name: 'allocMenu',
        component: () => import('@/views/ums/role/allocMenu'),
        meta: {title: '分配菜单'},
        hidden: true
      },
      {
        path: 'allocResource',
        name: 'allocResource',
        component: () => import('@/views/ums/role/allocResource'),
        meta: {title: '分配资源'},
        hidden: true
      },
      {
        path: 'menu',
        name: 'menu',
        component: () => import('@/views/ums/menu/index'),
        meta: {title: '菜单列表', icon: 'ums-menu'}
      },
      {
        path: 'addMenu',
        name: 'addMenu',
        component: () => import('@/views/ums/menu/add'),
        meta: {title: '添加菜单'},
        hidden: true
      },
      {
        path: 'updateMenu',
        name: 'updateMenu',
        component: () => import('@/views/ums/menu/update'),
        meta: {title: '修改菜单'},
        hidden: true
      },
      {
        path: 'resource',
        name: 'resource',
        component: () => import('@/views/ums/resource/index'),
        meta: {title: '资源列表', icon: 'ums-resource'}
      },
      {
        path: 'resourceCategory',
        name: 'resourceCategory',
        component: () => import('@/views/ums/resource/categoryList'),
        meta: {title: '资源分类'},
        hidden: true
      }
    ]
  },
  {path: '*', redirect: '/404', hidden: true}
]

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({y: 0}),
  routes: constantRouterMap
})

