import Vue from 'vue'
import Router from 'vue-router'
import store from '../store/store';


// 解决ElementUI导航栏中的vue-router在3.0版本以上重复点菜单报错问题
const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}
const Login = () => import('@/components/Login')

// --------------------------------------数据展示模块--------------------------------------------------
const BfourSituations = () => import('@/Pages/bigdata/fourSituations/FourSituations')
const BequipDistribute = () => import('@/Pages/bigdata/equipDistributeMap/EquipDistributeMap')
const Bcbd = () => import('@/Pages/bigdata/bcbd/Bcbd')
const Bqxz = () => import('@/Pages/bigdata/bqxz/Bqxz')
const Bsy = () => import('@/Pages/bigdata/sy/Sy')
const Bbzy = () => import('@/Pages/bigdata/bzy/Bzy')
const Bhome = () => import('@/Pages/bigdata/home/index')

//---------------------------------------农林植保----------------------------------------------------
const PlantGuard = () => import('@/components/index')
const BaseAll = () => import('@/Pages/plantGuard/plantProtection/baseAll') //管理员查看项目基地
const Base = () => import('@/Pages/plantGuard/plantProtection/base')
const CbdPhoto = () => import('@/Pages/plantGuard/plantProtection/cbdphoto') //测报灯图片
const CbdPestStats = () => import('@/Pages/plantGuard/plantProtection/cbdPestStats') //测报灯害虫统计
const BzyPhoto = () => import('@/Pages/plantGuard/plantProtection/bzyphoto') //孢子仪图片

const PersonMsg = () => import('@/Pages/plantGuard/sysManage/personMsg') //个人中心

const UserManage = () => import('@/Pages/plantGuard/sysManage/userManage') //系统管理-用户管理
const AllotEquip = () => import('@/Pages/plantGuard/sysManage/allotEquip') //系统管理-设备分配
const RoleManage = () => import('@/Pages/plantGuard/sysManage/roleManage') //系统管理-角色管理
const TopicManage = () => import('@/Pages/plantGuard/sysManage/topicManage') //系统管理-主题定制

const EquipManage = () => import('@/Pages/plantGuard/equipManage/equipManage') //设备管理-设备列表 

const Monitor = () => import('@/Pages/plantGuard/monitor/Monitor')//监控
const PhotoView = () => import('@/Pages/plantGuard/monitor/PhotoView')//监控-图片

const Page9 = () => import('@/Pages/plantGuard/page9') //水价管理-地图展示
const Page10 = () => import('@/Pages/plantGuard/page10') //水价管理-地图展示
const Page11 = () => import('@/Pages/plantGuard/page11') //水价管理-地图展示

const IrrigateProject = () => import('@/Pages/plantGuard/irrigate/index') //智能灌溉-灌溉展示
const Irrigate = () => import('@/Pages/plantGuard/irrigate/irrigate') //智能灌溉-灌溉展示
const OperatData = () => import('@/Pages/plantGuard/irrigate/operatData') //智能灌溉-操作记录
const WranData = () => import('@/Pages/plantGuard/irrigate/wranData') //智能灌溉-设备预警
const EleHistory = () => import('@/Pages/plantGuard/irrigate/eleHistory') //智能灌溉-要素历史数据

const DisasterWarnBase = () => import('@/Pages/plantGuard/disasterWarn/disasterWarnBase.vue') //灾害预警-地图展示
const DisasterWarn = () => import('@/Pages/plantGuard/disasterWarn/disasterWarn') //灾害预警-地图展示
const WarnPhoto = () => import('@/Pages/plantGuard/disasterWarn/warnPhoto') //灾害预警-图片展示
const DisasterWarnList = () => import('@/Pages/plantGuard/disasterWarn/disasterWarnList') //灾害预警-预警历史记录
const DisasterWarnSet = () => import('@/Pages/plantGuard/disasterWarn/disasterWarnSet') //灾害预警-预警历史记录


Vue.use(Router)

export default new Router({
  routes: [{
      path: '',
      redirect: '/login'
    },
    {
      path: '/login',
      component: Login
    },
    // -----------------农林植保------------------------ 
    {
      path: '/plantGuard',
      name:'PlantGuard',
      component: PlantGuard,
      children:[
        {
          path: '',
          redirect: window.sessionStorage.getItem('setHomepage') || '/plantGuard/baseAll'
        },
        {
          path: 'baseAll',
          name: 'baseAll',
          component: BaseAll,
          meta: { title: '农林植保',order:0,navname: '植保监测', }
        },
        {
          path: 'base',
          name:'base',
          component: Base,
          meta: { title: '农林植保',order:0, navname:'植保示范点',}
        },
        {
          path:'irrigateProject',
          name: 'irrigateProject',
          component: IrrigateProject,
          meta: { title: '智能灌溉',order:3 ,navname:'灌溉监测',}
        },
        {
          path: 'irrigate',
          name: 'irrigate',
          component: Irrigate,
          meta: { title: '智能灌溉',order:3 ,navname:'灌溉示范点',}
        },
        {
          path: 'operatData',
          name: 'operatData',
          component: OperatData,
          meta: { title: '智能灌溉',order:3 ,navname:'操作记录',}
        },
        {
          path: 'wranData',
          name: 'wranData',
          component: WranData,
          meta: { title: '智能灌溉',order:3 ,navname:'预警信息',}
        },
        {
          path:'eleHistory',
          name: 'eleHistory',
          component: EleHistory,
          meta: { title: '智能灌溉',order:3 ,navname:'水肥数据',}
        },
        {
          path: 'userManage',
          name: 'userManage',
          component: UserManage,
          meta: { title: '系统管理',order:7, navname: '用户管理',}
        },
        {
          path: 'allotEquip',
          name: 'allotEquip',
          component: AllotEquip,
          meta: { title: '系统管理',order:7,navname: '设备分配', }
        },
        {
          path: 'roleManage',
          name: 'roleManage',
          component: RoleManage,
          meta: { title: '系统管理',order:7,navname: '角色管理', }
        },
        {
          path: 'topicManage',
          name: 'topicManage',
          component: TopicManage,
          meta: { title: '系统管理',order:7,navname: '主题定制', }
        },
        {
          path: 'equipManage',
          name: 'equipManage',
          component: EquipManage,
          meta: { title: '系统管理',order:7,navname: '设备管理', }
        },
        {
          path: 'bzyPhoto',
          name: 'bzyPhoto',
          component: BzyPhoto,
          meta: { title: '农林植保',order:0,navname: '孢子仪图片', }
        },
        {
          path: 'cbdPhoto',
          name: 'cbdPhoto',
          component: CbdPhoto,
          meta: { title: '农林植保',order:0,navname: '测报灯图片', }
        },
        {
          path: 'cbdPestStats',
          name: 'CbdPestStats',
          component: CbdPestStats,
          meta: { title: '农林植保',order:0,navname: '害虫统计', }
        },
        {
          path: 'monitor',
          name: 'Monitor',
          component: Monitor,
          meta: { title: '可视农业',order:1,navname: '可视化', }
        },
        {
          path: 'photoView',
          name: 'PhotoView',
          component: PhotoView,
          meta: { title: '可视农业',order:0,navname: '可视化详情', }
        },
        {
          path: 'page9',
          name: 'page9',
          component: Page9,
          meta: { title: '水价管理',order:4,navname: '水价示范点', }
        },
        {
          path: 'page10',
          name: 'page10',
          component: Page10,
          meta: { title: '水价管理',order:4,navname: '消费记录', }
        },
        {
          path: 'page11',
          name: 'page11',
          component: Page11,
          meta: { title: '水价管理',order:4,navname: '充值记录', }
        },
        {
          path: 'personMsg',
          name:'PersonMsg',
          component: PersonMsg,
          meta: { title: '',order:0,navname: '个人中心', }
        },
        {
          path: 'disasterWarnBase',
          name: 'disasterWarnBase',
          component: DisasterWarnBase,
          meta: { title: '灾害预警',order:2,navname: '预警监测', }
        },
        {
          path: 'disasterWarn',
          name: 'disasterWarn',
          component: DisasterWarn,
          meta: { title: '灾害预警',order:2,navname: '预警示范点', }
        },
        {
          path: 'warnPhoto',
          name: 'warnPhoto',
          component: WarnPhoto,
          meta: { title: '灾害预警',order:2,navname: '预警图片', }
        },
        {
          path:'disasterWarnList',
          name: 'disasterWarnList',
          component: DisasterWarnList,
          meta: { title: '灾害预警',order:2,navname: '预警记录', }
        },
        {
          path:'disasterWarnSet',
          name: 'disasterWarnSet',
          component: DisasterWarnSet,
          meta: { title: '灾害预警',order:2,navname: '预警设置', }
        }
      ]
    },
    // -----------------大数据平台------------------------ 
    {
      path: '/bFourSituations',
      component: BfourSituations
    },
    {
      path: '/equipDistribute',
      component: BequipDistribute
    },
    {
      path: '/bCbd',
      component: Bcbd,
    },
    {
      path: '/bQxz',
      component: Bqxz
    },
    {
      path: '/bSy',
      component: Bsy
    },
    {
      path: '/bBzy',
      component: Bbzy
    },
    {
      path: '/bHome',
      component: Bhome
    },
  ],
  // mode:'history'
})