import Vue from "vue";
import Router from "vue-router";
import preview from "vue-photo-preview";
import "vue-photo-preview/dist/skin.css";
Vue.use(Router).use(preview);

/* Layout */
import Layout from "@/views/layout/Layout";

import role from "./modules/role";
import article from "./modules/article";
import member from "./modules/member";
import org from "./modules/org";
import marketing_tool from "./modules/marketing_tool";
import system from "./modules/system";
import site from "./modules/site";
import kefu from "./modules/kefu";

/** note: submenu only apppear when children.length>=1
 *   detail see  https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 **/

/**
* 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

// 详见 xt_permission.xt_filterAsyncRouter 函数的逻辑
is_menu: false               加载路由时验证用的(即该路由是否要在侧边栏展示，需要展示的即需要)，为 false 时表示该路由不需要进行权限验证

*                                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 redirct 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,
    noCache: true                if true ,the page will no be cached(default is false)

    // 详见 xt_permission.xt_filterAsyncRouter 函数的逻辑
    is_menu: false               加载路由时验证用的，为 false 时表示该路由不需要进行权限验证
    hidden: false                加载路由时验证用的，is_menu 为true时才有作用，为 true 时表示该路由需要进行权限验证
  }
**/
var _constant_router_map = [
  {
    path: "/token/verify",
    component: () => import("@/scrm_pages/index/verify_token"),
    hidden: true
  },
  {
    path: "/404",
    component: () => import("@/views/errorPage/404"),
    hidden: true
  },
  {
    path: "/401",
    component: () => import("@/views/errorPage/401"),
    hidden: true
  },
  {
    path: "/qrcode",
    component: () => import("@/scrm_pages/micro/micro")
  },
  // mirco
  {
    path: "/microHome",
    component: () => import("@/scrm_pages/microHome/microHome")
  },

  // 医院介绍详情
  {
    path: "/hospitalIntroduction",
    component: () =>
      import("@/scrm_pages/hospitalIntroduction/hospitalIntroduction")
  },

  // 科室介绍详情
  {
    path: "/officeIntroduction",
    component: () =>
      import("@/scrm_pages/officeIntroduction/officeIntroduction")
  },

  {
    path: "/medicalTeam",
    component: () => import("@/scrm_pages/medicalTeam/medicalTeam")
  },

  // 名医介绍详情

  {
    path: "/doctorIntroduction",
    component: () =>
      import("@/scrm_pages/doctorIntroduction/doctorIntroduction")
  },

  {
    path: "/news",
    component: () => import("@/scrm_pages/news/news")
  },
  {
    path: "/activity",
    component: () => import("@/scrm_pages/activity/activity")
  },
  {
    path: "/activityDetail",
    component: () => import("@/scrm_pages/activityDetail/activityDetail")
  },
  {
    path: "/apply",
    component: () => import("@/scrm_pages/apply/apply")
  },
  {
    path: "/newsDetail",
    component: () => import("@/scrm_pages/newsDetail/newsDetail")
  },
  {
    path: "/contact",
    component: () => import("@/scrm_pages/contact/contact")
  },
  {
    path: "/",
    component: () => import("@/scrm_pages/contact/contact")
  },

  // 医院介绍详情路由
  {
    path: "/hospital",
    component: () => import("@/scrm_pages/hospital/hospital"),
    name: "hospital"
  },

  // 科室介绍详情
  {
    path: "/office",
    component: () => import("@/scrm_pages/office/office"),
    name: "office"
  },

  // 名医介绍详情
  {
    path: "/doctor",
    component: () => import("@/scrm_pages/doctor/doctor"),
    name: "doctor"
  },
  // 单个医生介绍详情
  {
    path: "/docdetail",
    component: () => import("@/scrm_pages/doctor/docdetail"),
    name: "docdetail"
  },

  //文章列表详情
  {
    path: "/articlelist",
    component: () => import("@/scrm_pages/articlelist/articlelist"),
    name: "articlelist"
  },

  //单个文章列表详情
  {
    path: "/articlelistdetail",
    component: () => import("@/scrm_pages/articlelist/articlelistdetail")
  },

  //活动列表详情
  {
    path: "/activitylist",
    component: () => import("@/scrm_pages/activitylist/activitylist")
  },
  //单个文章列表详情
  {
    path: "/activitylistdetail",
    component: () => import("@/scrm_pages/activitylist/activitylistdetail")
  },

  //联系我们
  {
    path: "/contactus",
    component: () => import("@/scrm_pages/contactus/contactus")
  },

  {
    path: "/activity/preview",
    component: () => import("@/scrm_pages/marketing_tool/activity_preview"),
    hidden: true
  }
];

var _asy_router_map = [
  member,
  kefu,
  article,
  marketing_tool,
  org,
  system,
  site,
  role
];

var is_asy_router = process.env.NODE_ENV === "production"; // true; 设置为 true 强制进行路由验证
if (!is_asy_router) {
  _constant_router_map = _constant_router_map.concat(_asy_router_map);
  _asy_router_map = [];
} else {
}

export const xt_constantRouterMap = _constant_router_map;
export const xt_asyncRouterMap = _asy_router_map;

export default new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({
    y: 0
  }),
  routes: xt_constantRouterMap
});
