import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

/**
 * Note: 路由配置项
 *
 * hidden: true                     // 当设置 true 的时候该路由不会再侧边栏出现 如401，login等页面，或者如一些编辑页面/edit/1
 * alwaysShow: true                 // 当你一个路由下面的 children 声明的路由大于1个时，自动会变成嵌套的模式--如组件页面
 *                                  // 只有一个时，会将那个子路由当做根路由显示在侧边栏--如引导页面
 *                                  // 若你想不管路由下面的 children 声明的个数都显示你的根路由
 *                                  // 你可以设置 alwaysShow: true，这样它就会忽略之前定义的规则，一直显示根路由
 * redirect: noRedirect             // 当设置 noRedirect 的时候该路由在面包屑导航中不可被点击
 * name:'router-name'               // 设定路由的名字，一定要填写不然使用<keep-alive>时会出现各种问题
 * query: '{"id": 1, "name": "ry"}' // 访问路由的默认传递参数
 * meta : {
    noCache: true                   // 如果设置为true，则不会被 <keep-alive> 缓存(默认 false)
    title: 'title'                  // 设置该路由在侧边栏和面包屑中展示的名字
    icon: 'svg-name'                // 设置该路由的图标，对应路径src/assets/icons/svg
    breadcrumb: false               // 如果设置为false，则不会在breadcrumb面包屑中显示
    activeMenu: '/system/user'      // 当路由设置了该属性，则会高亮相对应的侧边栏。
  }
 */

// 公共路由
export const constantRoutes = [

  {
    path: '/login',
    component: (resolve) => require(['@/views/login'], resolve),
    hidden: true
  },

  {
    path: '/404',
    component: (resolve) => require(['@/views/error/404'], resolve),
    hidden: true
  },
  {
    path: '/401',
    component: (resolve) => require(['@/views/error/401'], resolve),
    hidden: true
  },
  {
    path: '/',
    component: Layout,
    redirect: 'index',
    children: [
      {
        path: 'index',
        component: (resolve) => require(['@/views/index'], resolve),
        name: 'Index',
        meta: { title: '店铺看板', icon: 'dashboard', affix: false }
      }
    ]
  },


  {
    path: '/store',
    component: Layout,
    hidden: true,
    redirect: 'noredirect',
    children: [
      {
        path: 'profile',
        component: (resolve) => require(['@/views/store/profile/index'], resolve),
        name: 'Profile',
        meta: { title: '店铺中心', icon: 'user' }
      },

    ]
  },
  {
    path: '/',
    component: Layout,
    redirect: 'noredirect',
    children: [
      {
        path: 'Config',
        component: (resolve) => require(['@/views/store/storeConfig/index'], resolve),
        name: '店铺配置',
        meta: { title: '店铺配置', icon: 'textarea', noCache: true, affix: false }
      },
    ]
  },
  {
    path: '/Platform',
    component: Layout,
    meta: { title: '总库商品', icon: 'dict', noCache: true, affix: false },
    redirect: 'noredirect',
    children: [
      {
        path: 'DrugList',
        component: (resolve) => require(['@/views/store/platformProduct/index.vue'], resolve),
        name: '总库商品',
        meta: { title: '总库商品列表', icon: 'dict', noCache: true, affix: false }
      }
    ]
  },
  {
    path: '/Drug',
    component: Layout,
    meta: { title: '药品管理', icon: 'user', noCache: true, affix: false },
    redirect: 'noredirect',
    children: [
      {
        path: 'DrugList',
        component: (resolve) => require(['@/views/store/storeProduct/index.vue'], resolve),
        name: '药品列表',
        meta: { title: '药品列表', icon: 'list', noCache: true, affix: false }
      }
      // ,
      // {
      //   path: 'category',
      //   component: (resolve) => require(['@/views/store/storeProductCategory/index'], resolve),
      //   name: '商品分类',
      //   meta: { title: '商品分类', icon: 'dashboard', noCache: true, affix: false }
      // }
    ]
  },
 {
    path: '/order',
    component: Layout,
    meta: { title: '订单管理', icon: 'list', noCache: true, affix: false },
    redirect: 'noredirect',
    children: [
      {
        path: 'storeOrder',
        component: (resolve) => require(['@/views/store/storeOrder/index'], resolve),
        name: '药品订单',
        meta: { title: '药品订单', icon: 'dashboard', noCache: true, affix: false }
      },
      {
        path: 'storeAfterSales',
        component: (resolve) => require(['@/views/store/storeAfterSales/index'], resolve),
        name: '售后订单',
        meta: { title: '售后订单', icon: 'dict', noCache: true, affix: false }
      },
      {
        path: 'prescribeOrder',
        component: (resolve) => require(['@/views/store/prescribeOrder/index'], resolve),
        name: '处方订单',
        meta: { title: '处方订单', icon: 'dict', noCache: true, affix: false }
      }
    ]
  },
  {
    path: '/operation',
    component: Layout,
    redirect: 'noredirect',
    children: [
      {
        path: 'complaint',
        component: (resolve) => require(['@/views/store/complaint/index'], resolve),
        name: '投诉管理',
        meta: { title: '投诉管理', icon: 'textarea', noCache: true, affix: false }
      },
    ]
 },
  {
     path: '/finance',
     component: Layout,
     meta: { title: '财务管理', icon: 'money', noCache: true, affix: false },
     redirect: 'noredirect',
     children: [
       {
         path: 'extract',
         component: (resolve) => require(['@/views/store/storeExtract/index'], resolve),
         name: '提现管理',
         meta: { title: '提现管理', icon: 'log', noCache: true, affix: false }
       },
       {
         path: 'bill',
         component: (resolve) => require(['@/views/store/storeBill/index'], resolve),
         name: '收支明细',
         meta: { title: '收支明细', icon: 'guide', noCache: true, affix: false }
       }
     ]
   },
   {
      path: '/statistics',
      component: Layout,
      meta: { title: '统计管理', icon: 'post', noCache: true, affix: false },
      redirect: 'noredirect',
      children: [
        {
          path: 'OrderStatistics',
          component: (resolve) => require(['@/views/store/statistics/oredr'], resolve),
          name: '订单统计',
          meta: { title: '订单统计', icon: 'tab', noCache: true, affix: false }
        },
        {
          path: 'DrugStatistics',
          component: (resolve) => require(['@/views/store/statistics/product'], resolve),
          name: '药品销售统计',
          meta: { title: '药品销售统计', icon: 'textarea', noCache: true, affix: false }
        }
      ]
   }
   /* ,
    {
      path: '/storeLog',
      component: Layout,
      redirect: 'noredirect',
      children: [
        {
          path: 'StoreLog',
          component: (resolve) => require(['@/views/store/storeLog/storeLog'], resolve),
          name: '日志查询',
          meta: { title: '日志查询', icon: 'log', noCache: true, affix: false }
        },
      ]
    } */


]

export const storeRouter=[

  {
    path: '/login',
    component: (resolve) => require(['@/views/login'], resolve),
    hidden: true
  },

  {
    path: '/404',
    component: (resolve) => require(['@/views/error/404'], resolve),
    hidden: true
  },
  {
    path: '/401',
    component: (resolve) => require(['@/views/error/401'], resolve),
    hidden: true
  },
  {
    path: '/store',
    component: Layout,
    hidden: true,
    redirect: '/store/profile',
    children: [
      {
        path: 'profile',
        component: (resolve) => require(['@/views/store/profile/index'], resolve),
        name: 'Profile',
        meta: { title: '店铺中心', icon: 'user' }
      },

    ]
  },
  {
    path: '/',
    component: Layout,
    redirect: 'index',
    children: [
      {
        path: 'index',
        component: (resolve) => require(['@/views/store/storeConfig/index'], resolve),
        name: '店铺配置',
        meta: { title: '店铺配置', icon: 'textarea', noCache: true, affix: false }
      },
    ]
  }
]

export default new Router({
  mode: 'history', // 去掉url中的#
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})
