/*
 * @Descripttion: 当前组件信息
 * @version: 1.0.0
 * @Author: 无尘
 * @Date: 2018-10-10 14:44:45
 * @LastEditors: 无尘
 * @LastEditTime: 2020-12-14 16:54:50
 */
import Vue from 'vue';
import Router from 'vue-router';
import _import from './_import.js';
Vue.use(Router);

// const error403 = (r) => {
//   import('views/errorPage/403.vue').then((module) => {
//     r(module)
//   })
// };
// const error404 = (r) => {
//   import('views/errorPage/404.vue').then((module) => {
//     r(module)
//   })
// };
// const error500 = (r) => {
//   import('views/errorPage/500.vue').then((module) => {
//     r(module)
//   })
// };
const errorPage = r => {
  import('views/errorPage/index.vue').then(module => {
    r(module);
  });
};
// 页面刷新时，重新赋值token

if (window.sessionStorage.getItem('token')) {
  /* eslint-disable */
    store.commit(types.LOGIN, window.sessionStorage.getItem('token'));
}
export const constantRouterMap = [{
        path: '/',
        name: '/',
        redirect: 'login'
    },
    {
        path: '/login',
        name: '登录',
        component: _import('login', 'index')
    },
    {
        path: '/loginMore',
        name: '登录',
        component: _import('login', 'login-more')
    },
    {
        path: '/index',
        name: 'index',
        component: _import('index', 'index')
    },

    {
        // 通讯录
        path: '/contacts',
        name: '通讯录',
        redirect: 'contactsList',
        component: _import('business', 'index'),
        children: [{
                path: '/contactsList',
                name: '通讯录',
                component: _import('business', 'contacts')
            },
            /* {
                                       path: '/orgStructSet',
                                       name: '组织架构管理',
                                       component: _import('business', 'orgStructSet')
                                     },
                                     {
                                       path: '/recycle',
                                       name: '组织架构管理',
                                       component: _import('business', 'recycle')
                                     }, */
            {
                path: '/syncLog',
                name: '通讯录日志',
                component: _import('business', 'syncLog')
            },
            {
                path: '/authMerchant',
                name: '授权商户',
                component: _import('business', 'authMerchant')
            },
            {
                path: '/authMerchantForm',
                name: '新建授权商户',
                component: _import('business', 'authMerchant-form')
            },
            {
                path: '/merchantStoreList',
                name: '绑定门店列表',
                component: _import('business', 'storeList')
            }
        ]
    },

    {
        // 企业设置
        path: '/enterprise',
        name: '企业设置',
        redirect: 'enterpriseSet',
        component: _import('enterprise', 'index'),
        children: [{
                path: '/enterpriseSet',
                name: '企业信息',
                component: _import('enterprise', 'enterpriseSet')
            },
            {
                path: '/adminList',
                name: '企业信息',
                component: _import('enterprise', 'adminList')
            },
            {
                path: '/material',
                name: '素材库',
                component: _import('enterprise', 'material')
            },
            {
                path: '/salutatory',
                name: '欢迎语',
                component: _import('enterprise', 'salutatory')
            },
            {
                path: '/salutatorySet',
                name: '欢迎语',
                component: _import('enterprise', 'salutatorySet')
            },
            {
                path: '/setting',
                name: '操作设置',
                component: _import('setting', 'index')
            },
            {
                // 审核中心
                path: '/reviewCenter',
                name: '审核中心',
                redirect: '/unreview',
                component: _import('reviewCenter', 'index'),
                children: [
                    {
                        path: '/unreview',
                        name: '未审核',
                        component: _import('reviewCenter', 'unreview')
                    },
                    {
                        path: '/reviewed',
                        name: '已审核',
                        component: _import('reviewCenter', 'reviewed')
                    },
                    {
                        path: '/reviewSet',
                        name: '审核设置',
                        component: _import('reviewCenter', 'reviewSet')
                    }
                ]
            }
        ]
    },
    // 销售线索
    {
        path: '/salesleads',
        name: '销售线索',
        redirect: 'trafficTaskSet',
        component: _import('salesleads', 'index'),
        children: [{
                path: '/taskRecord',
                name: '话务任务记录',
                component: _import('salesleads/trafficTask', 'taskRecord')
            },
            {
                path: '/taskView',
                name: '话务任务记录',
                component: _import('salesleads/trafficTask', 'taskView')
            },
            {
                path: '/taskDetail',
                name: '话务任务详情',
                component: _import('salesleads/trafficTask', 'taskDetail')
            },
            {
                path: '/taskViewDetail',
                name: '话务任务详情',
                component: _import('salesleads/trafficTask', 'taskViewDetail')
            },
            {
                path: '/trafficTaskSet',
                name: '话务任务设置',
                component: _import('salesleads/trafficTask', 'trafficTaskSet')
            },
            {
                path: '/grStoreList', // 群发任务-门店视图
                name: '门店视图',
                component: _import('salesleads/groupSend', 'grStoreList')
            },
            {
                path: '/grStoreDetail/:id', // 群发任务-门店视图-任务详情
                name: '门店视图',
                component: _import('salesleads/groupSend', 'grStoreDetail')
            },
            {
                path: '/grTaskList', // 群发任务-计划视图
                name: '计划视图',
                component: _import('salesleads/groupSend', 'grTaskList')
            }
        ]
    },
    {
        // 企业数据
        path: '/enterpriseData',
        name: '企业数据',
        redirect: 'enterpriseUseData',
        component: _import('enterpriseData', 'index'),
        children: [{
                path: '/enterpriseUseData',
                name: '好办使用详情',
                component: _import('enterpriseData', 'enterpriseUseData')
            },
            {
                path: '/activeDetail',
                name: '激活人员明细',
                component: _import('enterpriseData', 'activeDetail')
            },
            {
                path: '/loginDetail',
                name: '登录人员明细',
                component: _import('enterpriseData', 'loginDetail')
            },
            {
                path: '/areaLoginDetail',
                name: '区域登录人员明细',
                component: _import('enterpriseData', 'areaLoginDetail')
            }
        ]
    },

    {
        // 溢出门店
        path: '/overStore',
        name: '溢出门店',
        redirect: 'unreview',
        component: _import('overstore', 'index'),
        children: [{
            path: '/overStoreList',
            name: '溢出门店',
            component: _import('overstore', 'overStoreList')
        }]
    },

    {
        // 企业应用
        path: '/apps',
        name: '企业应用',
        redirect: 'mycustomer',
        component: _import('apps', 'index'),
        children: [
            /*  {
                                      path: '/appcenter',
                                      name: '企业应用中心',
                                      component: _import('enterpriseApp', 'appcenter')
                                    }, */
            /* 我的顾客应用 */
            {
                path: '/mycustomer',
                name: '我的顾客的',
                redirect: '/memberShowSet',
                component: _import('apps/customerApp', 'index'),
                children: [{
                        path: '/memberShowSet',
                        name: '会员展示设置',
                        component: _import('apps/customerApp', 'memberShowSet')
                    },
                    {
                        path: '/memberGroupSet',
                        name: '会员分组设置',
                        component: _import('apps/customerApp', 'memberGroupSet')
                    },
                    {
                        path: '/memberSearchSet',
                        name: '会员搜索设置',
                        component: _import('apps/customerApp', 'memberSearchSet')
                    },
                    {
                        path: '/memberDetailSet',
                        name: '会员详情设置',
                        component: _import('apps/customerApp', 'memberDetailSet')
                    },
                    {
                        path: '/memberTagSet',
                        name: '会员标签设置',
                        component: _import('apps/customerApp', 'memberTagSet')
                    },
                    {
                        path: '/syncHistory',
                        name: '同步历史',
                        component: _import('apps/customerApp', 'syncHistory')
                    },
                    {
                        path: '/myCustomerList',
                        name: '我的顾客列表',
                        component: _import('apps/customerApp', 'myCustomerList')
                    },
                    {
                        path: '/addGroupTemplate',
                        name: '添加模板',
                        component: _import('apps/customerApp', 'addGroupTemplate')
                    },
                    {
                        path: '/storeRangeSet',
                        name: '门店范围设置',
                        component: _import('apps/customerApp', 'storeRangeSet')
                    }
                ]
            },
            {
                path: '/cloudDaily',
                name: '云日报',
                redirect: '/dailyRecord',
                component: _import('apps/cloudDaily', 'index'),
                children: [{
                        path: '/dailyRecord',
                        name: '云日报记录',
                        component: _import('apps/cloudDaily', 'dailyRecord')
                    },
                    {
                        path: '/dailyExport',
                        name: '云日报导出',
                        component: _import('apps/cloudDaily', 'dailyExport')
                    },
                    {
                        path: '/dailyDetail',
                        name: '日报详情',
                        component: _import('apps/cloudDaily', 'dailyDetail')
                    },
                    {
                        path: '/taskAssign',
                        name: '任务下发设置',
                        component: _import('apps/cloudDaily', 'taskAssign')
                    },
                    {
                        path: '/systemReport',
                        name: '系统报表',
                        component: _import('apps/cloudDaily', 'systemReport')
                    },
                    {
                        path: '/customReport',
                        name: '自定义报表',
                        component: _import('apps/cloudDaily', 'customReport')
                    },
                    {
                        path: '/customReportSet',
                        name: '自定义报表设置',
                        component: _import('apps/cloudDaily', 'customReportSet')
                    }
                ]
            },
            {
                path: '/quota',
                name: '指标管理',
                redirect: '/monthList',
                component: _import('apps/quota', 'index'),
                children: [{
                        path: '/monthList',
                        name: '月指标列表',
                        component: _import('apps/quota', 'monthList')
                    },
                    {
                        path: '/storeMonthTask',
                        name: '门店月指标',
                        component: _import('apps/quota', 'storeMonthTask')
                    },
                    {
                        path: '/salerMonthDetail',
                        name: '导购月指标详情',
                        component: _import('apps/quota', 'salerMonthDetail')
                    },
                    {
                        path: '/companyDaySet',
                        name: '商户日权重',
                        component: _import('apps/quota', 'companyDaySet')
                    },
                    {
                        path: '/monthTask',
                        name: '月指标任务',
                        component: _import('apps/quota', 'monthTask'),
                        meta: {
                            keepAlive: true
                        }
                    },
                    {
                        path: '/monthTaskDetail',
                        name: '月指标任务详情',
                        component: _import('apps/quota', 'monthTaskDetail'),
                        meta: {
                            keepAlive: true
                        }
                    }
                ]
            },
            {
                path: '/cardList',
                name: '卡券赠送',
                redirect: '/cardList',
                component: _import('apps/card', 'index'),
                children: [{
                        path: '/cardList',
                        name: '卡券列表',
                        component: _import('apps/card', 'cardList')
                    },
                    {
                        path: '/cardRecord',
                        name: '卡券记录',
                        component: _import('apps/card', 'cardRecord')
                    },
                    {
                        path: '/newCard',
                        name: '新建卡券',
                        component: _import('apps/card', 'newCard')
                    }
                ]
            },
            {
                path: '/protectCard',
                name: '内购券',
                redirect: '/cardTemplate',
                component: _import('apps/protectCard', 'index'),
                children: [{
                        path: '/cardTemplate',
                        name: '卡券模板',
                        component: _import('apps/protectCard', 'cardTemplate')
                    },
                    {
                        path: '/newCardTemp',
                        name: '新建模板',
                        component: _import('apps/protectCard', 'newCardTemp')
                    },
                    {
                        path: '/cardStrategy',
                        name: '卡券策略',
                        component: _import('apps/protectCard', 'cardStrategy')
                    },
                    {
                        path: '/newCardStrategy',
                        name: '新建策略',
                        component: _import('apps/protectCard', 'newCardStrategy')
                    },
                    {
                        path: '/cardPut',
                        name: '内购券投放',
                        component: _import('apps/protectCard', 'cardPut')
                    },
                    {
                        path: '/newCardPut',
                        name: '新建补发',
                        component: _import('apps/protectCard', 'newCardPut')
                    },
                    {
                        path: '/cardPutRecord',
                        name: '投放记录',
                        component: _import('apps/protectCard', 'cardPutRecord')
                    },
                    {
                        path: '/cardGetRecord',
                        name: '领取记录',
                        component: _import('apps/protectCard', 'cardGetRecord')
                    }
                ]
            },
            // 商品中心
            {
                path: '/shoppingCenter',
                name: '商品中心',
                redirect: '/goodsShowSet',
                component: _import('apps/shoppingCenter', 'index'),
                children: [{
                    path: '/goodsShowSet',
                    name: '商品展示设置',
                    component: _import('apps/shoppingCenter', 'goodsShowSet')
                }]
            },
            // 订单评价
            {
                path: '/order-evaluate',
                name: '订单评价设置',
                redirect: '/evaluate-set',
                component: _import('apps/order-evaluate', 'index'),
                children: [{
                    path: '/evaluate-set',
                    name: '订单评价',
                    component: _import('apps/order-evaluate', 'evaluate-set')
                },{
                    path: '/bad-evaluate',
                    name: '不良评价回访设置',
                    component: _import('apps/order-evaluate', 'bad-evaluate-set')
                }]
            }
        ]
    },
    // {
    //     // 审核中心
    //     path: '/reviewCenter',
    //     name: '审核中心',
    //     redirect: 'unreview',
    //     component: _import('reviewCenter', 'index'),
    //     children: [{
    //             path: '/reviewed',
    //             name: '已审核',
    //             component: _import('reviewCenter', 'reviewed')
    //         },
    //         {
    //             path: '/unreview',
    //             name: '未审核',
    //             component: _import('reviewCenter', 'unreview')
    //         },
    //         {
    //             path: '/reviewSet',
    //             name: '审核设置',
    //             component: _import('reviewCenter', 'reviewSet')
    //         }
    //     ]
    // },

    {
        path: '/gic-error',
        name: 'gic跳转失败页',
        component: _import('errorPage', 'gic-error')
    },
    {
        path: '/403',
        name: '无权访问',
        component: errorPage
    },
    {
        path: '/404',
        name: 'error404',
        component: errorPage
    },
    {
        path: '/500',
        name: 'error500',
        component: errorPage
    },
    { path: '*', redirect: '/404', hidden: true }
];
export default new Router({
    // mode:'history',
    routes: constantRouterMap,
    scrollBehavior: () => ({ y: 0 })
});
