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

// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

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 redirect 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',
        children: [{
            path: '/home',
            component: () => import('@/views/home/index'),
            name: 'Home',
            meta: { title: '首页', icon: 'home' }
        }]
    },

    {
        path: '/member',
        component: Layout,
        redirect: '/member/info',
        name: 'Member',
        meta: { title: '用户管理', icon: 'user' },
        children: [
            {
                path: 'userinfo',
                name: 'UserInfo',
                component: () => import('@/views/member/userInfo'),
                meta: { title: '用户列表' }
            },
            {
                path: 'account',
                name: 'Account',
                component: () => import('@/views/member/account'),
                meta: { title: '钱包管理' }
            }
        ]
    },

    {
        path: '/bike',
        component: Layout,
        redirect: '/bike/bikelist',
        name: 'Bike',
        meta: { title: '车辆管理', icon: 'car' },
        children: [
            {
                path: 'bikelist',
                name: 'BikeList',
                component: () => import('@/views/bike/bikeList'),
                meta: { title: '车辆列表' }
            },
            {
                path: 'bikemap',
                name: 'BikeMap',
                component: () => import('@/views/bike/bikeMap'),
                meta: { title: '车辆分布' } 
            }
        ]
    },  
    // {
    //     path: '/bike',
    //     component: Layout,
    //     redirect: '/bike/bikelist',
    //     name: 'Bike',
    //     meta: { title: '车辆管理', icon: 'car' },
    //     children: [
    //         // {
    //         //     path: 'bikelist',
    //         //     name: 'BikeList',
    //         //     component: () => import('@/views/bike/bikeList'),
    //         //     meta: { title: '车辆列表' }
    //         // },
    //         // {
    //         //     path: 'bikemap',
    //         //     name: 'BikeMap',
    //         //     component: () => import('@/views/bike/bikeMap'),
    //         //     meta: { title: '车辆分布' } 
    //         // }
    //     ]
    // },  

    {
        path: '/recharge',
        component: Layout,
        redirect: '/recharge/rechargelist',
        name: 'Recharge',
        meta: { title: '充值管理', icon: 'car' },
        children: [
            {
                path: 'rechargelist',
                name: 'rechargelist',
                component: () => import('@/views/recharge/rechargelist'),
                meta: { title: '配置列表管理' }
            },
            {
                path: 'setup',
                name: 'setup',
                component: () => import('@/views/recharge/setup'),
                meta: { title: '充值记录列表' }
            }
        ]
    },

    {
        path: '/order',
        component: Layout,
        redirect: '/order/index',
        name: 'Order',
        meta: { title: '订单管理', icon: 'order' },
        children: [
            {
                path: 'orderlist',
                name: 'OrderList',
                component: () => import('@/views/order/order'),
                meta: { title: '订单管理' }
            },
            {
                path: 'locus',
                name: 'Locus',
                component: () => import('@/views/order/locus'),
                meta: { title: '订单轨迹' }
            }
        ]
    },

    {
        path: '/repair',
        component: Layout,
        children: [
            {
                path: 'index',
                name: 'Repair',
                component: () => import('@/views/repair/repair'),
                meta: { title: '报修管理', icon: 'repair' }
            }
        ]
    },

    {
        path: '/capital',
        component: Layout,
        redirect: '/capital/deposit',
        name: 'Capital',
        meta: { title: '资金管理', icon: 'gains' },
        children: [
            {
                path: 'deposit',
                name: 'Deposit',
                component: () => import('@/views/capital/deposit'),
                meta: { title: '押金管理' }
            },
            {
                path: 'gains',
                name: 'Gains',
                component: () => import('@/views/capital/gains'),
                meta: { title: '收益管理' }}
        ]
    },

    {
        path: '/people',
        component: Layout,
        redirect: '/people/ground',
        name: 'People',
        meta: { title: '人员设置', icon: 'peoples' },
        children: [
            {
                path: 'ground',
                name: 'Ground',
                component: () => import('@/views/people/ground'),
                meta: { title: '地勤人员' }
            },
            {
                path: 'manager',
                name: 'Manager',
                component: () => import('@/views/people/manager'),
                meta: { title: '管理员' }
            }
        ]
    },

    {
        path: '/region',
        component: Layout,
        children: [
            {
                path: 'index',
                name: 'Region',
                component: () => import('@/views/region/region'),
                meta: { title: '区域设置', icon: 'nested' }
            }
        ]
    },

    {
        path: '/power',
        component: Layout,
        redirect: '/power/permission',
        name: 'Power',
        meta: { title: '权限设置', icon: 'power' },
        children: [
            {
                path: 'permission',
                name: 'Permission',
                component: () => import('@/views/power/permission'),
                meta: { title: '权限管理' }
            },
            {
                path: 'roles',
                name: 'Roles',
                component: () => import('@/views/power/roles'),
                meta: { title: '角色管理' }
            }
        ]
    },

    {
        path: '/parameter',
        component: Layout,
        children: [
            {
                path: 'index',
                name: 'parameter',
                component: () => import('@/views/parameter/parameter'),
                meta: { title: '参数设置', icon: 'table' }
            }
        ]
    },

    {
        path: 'external-link',
        component: Layout,
        hidden: true,
        children: [
            {
                path: 'https://panjiachen.github.io/vue-element-admin-site/#/',
                meta: { title: 'External Link', icon: 'link' }
            }
        ]
    },

    { path: '*', redirect: '/404', hidden: true }
]

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