/*
 * @Descripttion: 当前组件信息
 * @version: 1.0.0
 * @Author: 无尘
 * @Date: 2018-10-10 14:44:45
 * @LastEditors: 无尘
 * @LastEditTime: 2020-03-16 15:34:46
 */
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: '/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: '/enterprise',
    name: '企业设置',
    redirect: 'enterpriseSet',
    component: _import('enterprise', 'index'),
    children: [{
          path: '/enterpriseSet',
          name: '企业信息',
          component: _import('enterprise', 'enterpriseSet')
        },
        {
          path: '/adminList',
          name: '企业信息',
          component: _import('enterprise', 'adminList')
        },
    ]
  },

  {
    // 溢出门店
    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: '/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: '/trafficTask',
        name: '话务任务',
        redirect: '/taskRecord',
        component: _import('apps/trafficTask', 'index'),
        children: [
          {
            path: '/taskRecord',
            name: '话务任务记录',
            component: _import('apps/trafficTask', 'taskRecord')
          },
          {
            path: '/taskView',
            name: '话务任务记录',
            component: _import('apps/trafficTask', 'taskView')
          },
          {
            path: '/taskDetail',
            name: '话务任务详情',
            component: _import('apps/trafficTask', 'taskDetail')
          },
          {
            path: '/taskViewDetail',
            name: '话务任务详情',
            component: _import('apps/trafficTask', 'taskViewDetail')
          },
          {
            path: '/trafficTaskSet',
            name: '话务任务设置',
            component: _import('apps/trafficTask', 'trafficTaskSet')
          },
          {
            path: '/badEvaluateSet',
            name: '不良评价设置',
            component: _import('apps/badEvaluate', 'badEvaluateSet')
          }
        ]
      },
      {
        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: '/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 })
});
