/*
 * @Descripttion: 当前组件信息
 * @version: 1.0.0
 * @Author: 无尘
 * @Date: 2018-10-10 14:44:45
 * @LastEditors  : 无尘
 * @LastEditTime : 2020-02-18 08:46:29
 */
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: '/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: '/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 })
});
