// eslint-disable-next-line
import {
  UserLayout,
  BasicLayout,
  BlankLayout
} from '@/layouts'
import {
  bxAnaalyse
} from '@/core/icons'

const RouteView = {
  name: 'RouteView',
  render: (h) => h('router-view')
}

export const asyncRouterMap = [{
  path: '/',
  name: 'index',
  component: BasicLayout,
  meta: {
    title: '首页'
  },
  redirect: '/home',
  children: [
    // 首页
    {
      path: '/home',
      name: 'home',
      component: () => import('@/views/home/index'),
      meta: {
        title: '首页',
        keepAlive: true,
        icon: bxAnaalyse,
        permission: ['home']
      }
    },
    // 设备管理
    {
      path: '/device',
      name: 'device',
      component: RouteView,
      meta: {
        title: '设备',
        keepAlive: true,
        icon: bxAnaalyse,
        permission: ['device']
      },
      redirect: '/device/list',
      children: [{
          path: '/device/list',
          name: 'devicelist',
          component: () => import('@/views/device/list'),
          hideChildrenInMenu: true,
          meta: {
            title: '设备管理',
            keepAlive: true,
            permission: ['device'],
          },
        },
        {
          path: '/device/result',
          name: 'resultlist',
          component: () => import('@/views/device/result'),
          meta: {
            title: '测量记录',
            keepAlive: true,
            icon: bxAnaalyse,
            permission: ['device']
          }
        },
        {
          path: '/device/Bindcount',
          name: 'Bindcountlist',
          component: () => import('@/views/device/Bindcount'),
          meta: {
            title: '绑定用户关系管理',
            hidden: true, 
            keepAlive: true,
            permission: ['device']
          }
        }

      ]
    },
    // 公众号管理
    {
      path: '/official',
      name: 'official',
      component: RouteView,
      meta: {
        title: '公众号设置',
        keepAlive: true,
        icon: bxAnaalyse,
        permission: ['official']
      },
      redirect: '/official/List',
      children: [{
          path: '/official/List',
          name: 'officiallist',
          component: () => import('@/views/official/List'),
          meta: {
            title: '公众号管理',
            keepAlive: true,
            icon: bxAnaalyse,
            permission: ['official']
          },
        },
        {
          path: '/official/template',
          name: 'officialtemplate',
          component: () => import('@/views/official/template'),
          meta: {
            title: '模板管理',
            keepAlive: true,
            icon: bxAnaalyse,
            permission: ['official']
          }
        },
        {
          path: '/official/deviceList',
          name: 'officialdeviceList',
          component: () => import('@/views/official/deviceList'),
          meta: {
            title: '设备绑定',
            keepAlive: true,
            icon: bxAnaalyse,
            permission: ['official']
          }
        },
        {
          path: '/official/empower',
          name: 'officialempower',
          component: () => import('@/views/official/empower'),
          meta: {
            title: '公众号授权',
            keepAlive: true,
            icon: bxAnaalyse,
            permission: ['official']
          }
        },
        {
          path: '/official/components/addList',
          name: 'addList',
          component: () => import('@/views/official/components/addList'),
          meta: {
            title: '基本设置',
            keepAlive: false,
            hidden: true
          }
        },
      ]
    },
    // 营销管理
    {
      path: '/market',
      name: 'market',
      component: RouteView,
      meta: {
        title: '营销管理',
        keepAlive: true,
        icon: bxAnaalyse,
        permission: ['market']
      },
      redirect: '/market/tag',
      children: [{
          path: '/market/tag',
          name: 'markettag',
          component: () => import('@/views/market/tag'),
          meta: {
            title: '标签管理',
            keepAlive: true,
            icon: bxAnaalyse,
            permission: ['market']
          }
        },
        {
          path: '/market/message',
          name: 'marketmessage',
          component: () => import('@/views/market/message'),
          meta: {
            title: '消息群发',
            keepAlive: true,
            icon: bxAnaalyse,
            permission: ['market']
          }
        }
      ]
    },
    // 用户管理
    {
      path: '/reguser',
      name: 'reguser',
      component: RouteView,
      meta: {
        title: '用户管理',
        keepAlive: true,
        icon: bxAnaalyse,
        permission: ['reguser']
      },
      redirect: '/reguser/list',
      children: [{
          path: '/reguser/list',
          name: 'reguserlist',
          component: () => import('@/views/reguser/list'),
          meta: {
            title: '注册用户管理',
            keepAlive: true,
            icon: bxAnaalyse,
            permission: ['reguser']
          }
        },
        {
          path: '/reguser/bind',
          name: 'reguserbind',
          component: () => import('@/views/reguser/bind'),
          meta: {
            title: '绑定用户管理',
            keepAlive: true,
            icon: bxAnaalyse,
            permission: ['reguser']
          }
        },
        {
          path: '/reguser/resultlist',
          name: 'reguserresultlist',
          component: () => import('@/views/reguser/resultlist'),
          meta: {
            title: '用户测量记录',
            keepAlive: false,
            icon: bxAnaalyse
          }
        }
      ]
    },
    // 客户管理
    {
      path: '/business',
      name: 'business',
      component: () => import('@/views/business/index'),
      meta: {
        title: '渠道管理',
        keepAlive: true,
        icon: bxAnaalyse,
        permission: ['business']
      }
    },
    // 数据分析
    {
      path: '/report',
      name: 'report',
      component: RouteView,
      meta: {
        title: '数据分析',
        keepAlive: true,
        icon: bxAnaalyse,
        permission: ['report']
      },
      redirect: '/report/tag',
      children: [{
          path: '/report/tag',
          name: 'reporttag',
          component: () => import('@/views/report/tag'),
          meta: {
            title: '标签数据分析',
            keepAlive: true,
            icon: bxAnaalyse,
            permission: ['report']
          }
        },
        {
          path: '/report/user',
          name: 'reportuser',
          component: () => import('@/views/report/user'),
          meta: {
            title: '用户画像',
            keepAlive: true,
            icon: bxAnaalyse,
            permission: ['report']
          }
        },
        {
          path: '/report/health',
          name: 'reporthealth',
          component: () => import('@/views/report/health'),
          meta: {
            title: '健康数据分析',
            keepAlive: true,
            icon: bxAnaalyse,
            permission: ['report']
          }
        },
        {
          path: '/report/measure',
          name: 'reportmeasure',
          component: () => import('@/views/report/measure'),
          meta: {
            title: '测量统计',
            keepAlive: true,
            icon: bxAnaalyse,
            permission: ['report']
          }
        }
      ]
    },
    // 个人中心
    {
      path: '/user',
      name: 'user',
      component: RouteView,
      meta: {
        title: '个人中心',
        keepAlive: true,
        icon: bxAnaalyse,
        permission: ['user']
      },
      redirect: '/user/password',
      children: [{
          path: '/user/password',
          name: 'userpassword',
          component: () => import('@/views/user/password'),
          meta: {
            title: '修改密码',
            keepAlive: true,
            icon: bxAnaalyse,
            permission: ['user']
          }
        },
        {
          path: 'https://www.baidu.com/',
          name: 'userchat',
          // component: () => import ('@/views/user/chat'),
          meta: {
            title: '微信客服',
            target: '_blank'
          }
        },
        {
          path: 'https://preview.pro.antdv.com/',
          name: 'userbase',
          // component: () => import ('@/views/user/base'),
          meta: {
            title: 'QQ客服',
            target: '_blank'
          }
        },
      ]
    },
    // Exception
    {
      path: '/exception',
      name: 'exception',
      component: RouteView,
      redirect: '/exception/404',
      meta: {
        title: '异常页',
        icon: 'warning',
        permission: ['exception']
      },
      children: [{
        path: '/exception/404',
        name: 'Exception404',
        component: () => import( /* webpackChunkName: "fail" */ '@/views/exception/404'),
        meta: {
          title: '404',
          permission: ['exception']
        }
      }, ]
    },
  ]
}, ]

/**
 * 基础路由
 * @type { *[] }
 */
export const constantRouterMap = [{
    path: '/user',
    component: UserLayout,
    redirect: '/user/login',
    hidden: true,
    children: [{
        path: 'login',
        name: 'login',
        component: () => import( /* webpackChunkName: "user" */ '@/views/user/Login')
      },
      {
        path: 'recover',
        name: 'recover',
        component: undefined
      }
    ]
  },

  {
    path: '/404',
    component: () => import( /* webpackChunkName: "fail" */ '@/views/exception/404')
  }

]
