
const pages = [
  {
    path: 'dashboard',
    name: 'dashboard',
    component: () => import('./Dashboard.vue'),
    meta: {
      menuShow: true,
      title: 'Dashboard',
    }
  },
  {
    path: 'indexEcharts',
    name: 'indexEcharts',
    redirect: 'indexEcharts/index',
    component: () => import('./index.vue'),
    meta: {
      menuShow: true,
      title: '首页',
    },
    children:[
      {
        path: 'index',
        name: 'index',
        component: () => import('./indexEcharts/index.vue'),
        meta: {
          menuShow: false,
          // title: '首页',
        },
      },
      {
        path: 'newUsers',
        name: 'newUsers',
        component: () => import('./indexEcharts/newUsers.vue'),
        meta: {
          menuShow: false,
          title: '新增用户',
        },
      },
      {
        path: 'userSource',
        name: 'userSource',
        component: () => import('./indexEcharts/userSource.vue'),
        meta: {
          menuShow: false,
          title: '用户来源',
        },
      },
      {
        path: 'behaviorAnalysis',
        name: 'behaviorAnalysis',
        component: () => import('./indexEcharts/behaviorAnalysis.vue'),
        meta: {
          menuShow: false,
          title: '行为分析',
        },
      },
    ]
  },
  {
    path: 'consultant',
    name: 'consultant',
    redirect: 'consultant/list',
    component: () => import('./index.vue'),
    meta: {
      menuShow: true,
      title: '置业管理',
    },
    children: [
      {
        path: 'list',
        name: 'consultant.list',
        component: () => import('./consultant/list.vue'),
        meta: {
          menuShow: true,
          title: '置业列表',
        },
      },
      {
        path: 'edit/:id?',
        name: 'consultant.edit',
        component: () => import('./consultant/edit.vue'),
        meta: {
          menuShow: false,
          title: '置业管理',
        },
      },
    ]
  },
  {
    path: 'activity',
    name: 'activity',
    component: () => import('./index.vue'),
    meta: {
      menuShow: true,
      title: '活动管理',
    },
    children: [
      {
        path: 'activity',
        name: 'activity-list',
        component: () => import('./activity/list.vue'),
        meta: {
          menuShow: true,
          title: '活动列表',
        },
      },
      {
        path: 'activity/add',
        name: 'activity-add',
        component: () => import('./activity/add.vue'),
        meta: {
          menuShow: false,
          title: '活动添加',
        }
      },
      {
        path: 'activity/edit',
        name: 'activity-edit',
        component: () => import('./activity/edit.vue'),
        meta: {
          menuShow: false,
          title: '编辑活动',
        }
      },
      {
        path: 'activity/signList',
        name: 'activity-signList',
        component: () => import('./activity/signList.vue'),
        meta: {
          menuShow: false,
          title: '报名记录',
        },
      }
    ]
  },
  {
    path: 'building',
    name: 'building',
    component: () => import('./index.vue'),
    meta: {
      menuShow: true,
      title: '楼盘设置',
    },
    children: [
      {
        path: 'buildinglist',
        name: 'buildinglist',
        component: () => import('./building/list.vue'),
        meta: {
          menuShow: true,
          title: '楼盘列表',
        },
      },
      {
        path: 'buildingedit',
        name: 'buildingedit',
        component: () => import('./building/edit.vue'),
        meta: {
          menuShow: false,
        },
      }
    ]
  },
  {
    path: 'customer',
    name: 'customer',
    component: () => import('./index.vue'),
    meta: {
      menuShow: true,
      title: '客户管理',
    },
    children: [
      {
        path: 'customerlist',
        name: 'customerlist',
        component: () => import('./customer/list.vue'),
        meta: {
          menuShow: true,
          title: '客户列表',
        }
      },
      {
        path: 'recommendCustomer',
        name: 'recommendCustomer',
        component: () => import('./customer/recommendCustomer.vue'),
        meta: {
          menuShow: true,
          title: '推荐客户',
        }
      },
      {
        path: 'recommendDrift',
        name: 'recommendDrift',
        component: () => import('./customer/drift.vue'),
        meta: {
          menuShow: true,
          title: '游客列表',
        }
      },
      {
        path: 'editRecommend',
        name: 'editRecommend',
        component: () => import('./customer/editRecommend.vue'),
        meta: {
          menuShow: false,
          title: '审核',
        },
      },
      {
        path: 'customerDetails',
        name: 'customerDetails',
        component: () => import('./customer/customerDetails.vue'),
        meta: {
          menuShow: false,
          title: '客户详情',
        },
      },
      {
        path: 'integralRecord',
        name: 'integralRecord',
        component: () => import('./customer/integralRecord.vue'),
        meta: {
          menuShow: false,
          title: '积分记录',
        },
      },
      {
        path: 'editCustomer',
        name: 'editCustomer',
        component: () => import('./customer/editCustomer.vue'),
        meta: {
          menuShow: false,
          title: '编辑客户',
        },
      },
    ]
  },
  {
    path: 'carouselFigure',
    name: 'carouselFigure',
    component: () => import('./index.vue'),
    meta: {
      menuShow: true,
      title: '轮播图管理',
    },
    children: [
      {
        path: 'carouselList',
        name: 'carouselList',
        component: () => import('./carouselFigure/list.vue'),
        meta: {
          menuShow: true,
          title: '轮播图列表',
        }
      },
      {
        path: 'editCarousel',
        name: 'editCarousel',
        component: () => import('./carouselFigure/edit.vue'),
        meta: {
          menuShow: false,
          title: '编辑轮播图',
        },
      },
      {
        path: 'advertisement',
        name: 'advertisement',
        component: () => import('./carouselFigure/advertisement.vue'),
        meta: {
          menuShow: true,
          title: '开屏广告',
        }
      },
      {
        path: 'advertisementEdit',
        name: 'advertisementEdit',
        component: () => import('./carouselFigure/advertisementEdit.vue'),
        meta: {
          menuShow: false,
          title: '编辑开屏广告',
        },
      },
    ]
  },
  {

    path: 'systemManagement',
    name: 'systemManagement',
    component: () => import('./index.vue'),
    meta: {
      menuShow: true,
      title: '系统管理',
    },
    children: [
      // {
      //   path: 'pushMessage',
      //   name: 'pushMessage',
      //   component: () => import('./systemManagement/pushMessage.vue'),
      //   meta: {
      //     menuShow: true,
      //     title: '推送消息',
      //   },
      // },
      // {
      //   path: 'keyWords',
      //   name: 'keyWords',
      //   component: () => import('./systemManagement/keyWords.vue'),
      //   meta: {
      //     menuShow: true,
      //     title: '关键字维护',
      //   },
      // },
      {
        path: 'message',
        name: 'message',
        component: () => import('./systemManagement/message.vue'),
        meta: {
          menuShow: true,
          title: '客户留言',
        },
      },
      {
        path: 'report',
        name: 'report',
        component: () => import('./systemManagement/report.vue'),
        meta: {
          menuShow: true,
          title: '报表数据',
        },
      },
      {
        path: 'intention',
        name: 'intention',
        component: () => import('./systemManagement/Intention.vue'),
        meta: {
          menuShow: true,
          title: '意向值',
        },
      },
    ]
  },
  {
    path: '/news',
    name: 'news',
    component: () => import('./index.vue'),
    meta: {
      menuShow: true,
      title: '资讯管理',
    },
    children: [
      {
        path: '/news/type/list',
        name: 'news-type-list',
        component: () => import('./news/type/index.vue'),
        meta: {
          menuShow: true,
          title: '资讯类型',
        },
      },
      {
        path: '/news/type/edi',
        name: 'news-type-edi',
        component: () => import('./news/type/edi/index.vue'),
        meta: {
          menuShow: false,
          title: '编辑资讯类型',
        },
      },
      {
        path: '/news/list',
        name: 'news-list',
        component: () => import('./news/index.vue'),
        meta: {
          menuShow: true,
          title: '资讯列表',
        },
      },
      {
        path: '/news/edi',
        name: 'news-edi',
        component: () => import('./news/edi/index.vue'),
        meta: {
          menuShow: false,
          title: '编辑资讯',
        },
      },
    ]
  },
  {
    path: 'pointsmall',
    name: 'pointsmall',
    redirect: 'pointsmall/list',
    component: () => import('./index.vue'),
    meta: {
      menuShow: true,
      title: '积分商城',
    },
    children: [
      {
        path: 'list',
        name: 'goods.list',
        component: () => import('./goods/list.vue'),
        meta: {
          menuShow: true,
          title: '商品列表',
        },
      },
      {
        path: 'goods/edit',
        name: 'goods.edit',
        component: () => import('./goods/edit.vue'),
        meta: {
          menuShow: false,
          title: '编辑商品',
        },
      },
      {
        path: 'points/list',
        name: 'points.list',
        component: () => import('./points/list.vue'),
        meta: {
          menuShow: true,
          title: '积分获取',
        },
      },
      {
        path: 'points/edit',
        name: 'points.edit',
        component: () => import('./points/edit.vue'),
        meta: {
          menuShow: false,
          title: '积分编辑',
        },
      },
      {
        path: 'exchange/verify',
        name: 'exchange.verify',
        component: () => import('./exchange/verify.vue'),
        meta: {
          menuShow: true,
          title: '商品核销',
        },
      },
      {
        path: 'verify/list',
        name: 'verify.list',
        component: () => import('./exchange/verifyList.vue'),
        meta: {
          menuShow: false,
          title: '商品展示',
        },
      },
      {
        path: 'exchange/list',
        name: 'exchange.list',
        component: () => import('./exchange/list.vue'),
        meta: {
          menuShow: true,
          title: '兑换记录',
        },
      },
    ]
  },

]

const flatten = (rts, parents = []) => {
  return rts.reduce((acc, rt) => {
    const chs = rt.children && rt.children.length ?
      flatten(rt.children, parents.concat(rt)) : []

    return [...acc, { ...rt, parents }, ...chs]
  }, [])
}

const pageArray = flatten(pages)

export { pages, pageArray }
