import Main from '@/views/Main.vue';

// 不作为Main组件的子页面展示的页面单独写，如下
export const loginRouter = {
    path: '/login',
    name: 'login',
    meta: {
        title: 'Login - 登录'
    },
    component: resolve => {
        require(['@/views/login.vue'], resolve);
    }
};

export const page404 = {
    path: '/*',
    name: 'error-404',
    meta: {
        title: '404-页面不存在'
    },
    component: resolve => {
        require(['@/views/error-page/404.vue'], resolve);
    }
};

export const page403 = {
    path: '/403',
    meta: {
        title: '403-权限不足'
    },
    name: 'error-403',
    component: resolve => {
        require(['@//views/error-page/403.vue'], resolve);
    }
};

export const page500 = {
    path: '/500',
    meta: {
        title: '500-服务端错误'
    },
    name: 'error-500',
    component: resolve => {
        require(['@/views/error-page/500.vue'], resolve);
    }
};

export const locking = {
    path: '/locking',
    name: 'locking',
    component: resolve => {
        require(['@/views/main-components/lockscreen/components/locking-page.vue'], resolve);
    }
};

// 作为Main组件的子页面展示但是不在左侧菜单显示的路由写在otherRouter里
export const otherRouter = {
    path: '/',
    name: 'otherRouter',
    redirect: '/home',
    component: Main,
    children: [{
        path: 'home',
        name: 'home_index',
        redirect: '/order/housekeeper'
    }]
};

// 作为Main组件的子页面展示并且在左侧菜单显示的路由写在appRouter里
export const appRouter = [{
        path: '/order',
        icon: 'clipboard',
        name: 'order',
        title: '订单管理',
        access: [1, 2, 3, 4],
        component: Main,
        children: [{
                path: 'housekeeper',
                title: '通用服务订单',
                name: 'order_housekeeper',
                access: [1, 2],
                component: resolve => {
                    require(['@/views/housekeeper/index.vue'], resolve);
                }
            },
            {
                path: 'matron',
                title: '月嫂订单',
                name: 'order_matron',
                access: [1, 3],
                component: resolve => {
                    require(['@/views/matron/index.vue'], resolve);
                }
            },
            {
                path: 'product',
                title: '母婴产品订单',
                name: 'order_product',
                access: [1, 4],
                component: resolve => {
                    require(['@/views/product-order/index.vue'], resolve);
                }
            }
            // { path: 'comment', title: '订单评论', name: 'order_comment', component: resolve => { require(['@/views/comment/index.vue'], resolve); } },
            // { path: 'status', title: '订单状态', name: 'order_status', component: resolve => { require(['@/views/comment/index.vue'], resolve); } }
        ]
    },
    {
        path: '/product',
        icon: 'bag',
        name: 'product',
        title: '母婴产品管理',
        access: [1],
        component: Main,
        children: [{
                path: 'classify',
                title: '产品分类',
                name: 'product_classify',
                component: resolve => {
                    require(['@/views/product-classify/index.vue'], resolve);
                },
            },
            {
                path: 'index',
                title: '产品管理',
                name: 'product_index',
                component: resolve => {
                    require(['@/views/product/index.vue'], resolve);
                }
            }
        ]
    },
    {
        path: '/service',
        icon: 'grid',
        name: 'service',
        title: '分类管理',
        component: Main,
        access: [1],
        children: [{
            path: 'index',
            title: '分类管理',
            name: 'service_index',
            component: resolve => {
                require(['@/views/service/index.vue'], resolve);
            }
        }]
    },
    {
        path: '/reward',
        icon: 'social-usd',
        name: 'reward',
        title: '打赏金额',
        access: [1],
        component: Main,
        children: [{
            path: 'index',
            title: '打赏金额',
            name: 'reward_index',
            component: resolve => {
                require(['@/views/reward/index.vue'], resolve);
            }
        }]
    },
    {
        path: '/introduce',
        icon: 'ios-person',
        name: 'introduce',
        title: '企业介绍',
        access: [1],
        component: Main,
        children: [{
            path: 'index',
            title: '企业介绍',
            name: 'introduce_index',
            component: resolve => {
                require(['@/views/introduce/index.vue'], resolve);
            }
        }]
    },
    {
        path: '/image',
        icon: 'home',
        name: 'image',
        title: '首页介绍和图片配置',
        access: [1],
        component: Main,
        children: [{
            path: 'index',
            title: '首页服务介绍和底部图片配置',
            name: 'image_index',
            component: resolve => {
                require(['@/views/image/index.vue'], resolve);
            }
        }]
    }
    // {
    //     path: '/act',
    //     icon: 'images',
    //     name: 'act',
    //     title: '活动管理',
    //     component: Main,
    //     children: [{
    //         path: 'index',
    //         title: '活动管理',
    //         name: 'act_index',
    //         component: resolve => {
    //             require(['@/views/act/index.vue'], resolve);
    //         }
    //     }]
    // },
    // {
    //     path: '/product',
    //     icon: 'images',
    //     name: 'product',
    //     title: '产品管理',
    //     component: Main,
    //     children: [
    //         { path: 'index', title: '产品管理', name: 'product_index', component: resolve => { require(['@/views/product/index.vue'], resolve); } }
    //     ]
    // },
    // {
    //     path: '/product-order',
    //     icon: 'images',
    //     name: 'productOrder',
    //     title: '产品订单',
    //     component: Main,
    //     children: [
    //         { path: 'index', title: '产品订单', name: 'productOrder_index', component: resolve => { require(['@/views/product-order/index.vue'], resolve); } }
    //     ]
    // },
    // {
    //     path: '/hourse-clean',
    //     icon: 'images',
    //     name: 'hourseClean',
    //     title: '家居清洁',
    //     component: Main,
    //     children: [
    //         { path: 'index', title: '家居清洁', name: 'hourseClean_index', component: resolve => { require(['@/views/house-clean/index.vue'], resolve); } }
    //     ]
    // },
    // {
    //     path: '/appliance-clean',
    //     icon: 'images',
    //     name: 'applianceClean',
    //     title: '家电清洁',
    //     component: Main,
    //     children: [
    //         { path: 'index', title: '家电清洁', name: 'applianceClean_index', component: resolve => { require(['@/views/appliance-clean/index.vue'], resolve); } }
    //     ]
    // }
];

var other = [{
        path: '/banner',
        icon: 'images',
        name: 'banner',
        title: 'banner轮播图',
        component: Main,
        children: [{
            path: 'index',
            title: 'banner轮播图',
            name: 'banner_index',
            component: resolve => {
                require(['@/views/banner/banner.vue'], resolve);
            }
        }]
    }
];

// 所有上面定义的路由都要写在下面的routers里
export const routers = [
    loginRouter,
    otherRouter,
    ...other,
    locking,
    ...appRouter,
    page500,
    page403,
    page404
];