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

Vue.use(Router)
import Layout from '@/layout'
import Close from '@/layout/close'

export const constantRoutes = [{
  path: '/login',
  component: () => import('@/views/login/index'),
  hidden: true
},
{
  path: '/',
  component: Layout,
  redirect: '/dashboard',
  children: [{
    path: '/dashboard',
    name: '首页',
    component: () => import('@/views/strategy/index'),
    meta: {
      title: '首页',
      icon: 'dashboard'
    }
  }]
},
{
  path: '/productManagement',
  component: Layout,
  redirect: '/productManagement/',
  name: '产品管理',
  meta: {
    title: '产品管理',
    icon: 'el-icon-s-goods'
  },
  children: [{
    path: '/produce/produceClass/index',
    component: () => import('@/views/produce/produceClass/index'),
    name: '产品分类',
    meta: {
      title: '产品分类'
    }
  }, {
    path: '/productV2/productManagement/',
    name: '产品管理',
    component: () => import('@/views/productV2/productManagement'),
    meta: {
      title: '产品管理',
    }
  },
  {

    path: '/produce/prodeceHistory/history/',
    name: '产品日志',
    component: () => import('@/views/produce/produceHistory/history'),
    meta: {
      title: '产品日志',
    }
  },
  ]
},
{
  path: '/addProduct',
  component: Close,
  redirect: '/addProduct/',
  name: '新增产品',
  children: [{
    path: '/productV2/addProduct',
    name: '新增产品',
    component: () => import('@/views/productV2/addProduct')
  }]
},
{
  path: '/editProduct',
  component: Close,
  redirect: '/editProduct/',
  name: '新增产品',
  children: [{
    path: '/productV2/editProduct',
    name: '新增产品',
    component: () => import('@/views/productV2/editProduct')
  }]
},

{
  path: "/directional",
  component: Layout,
  redirect: "/directional/",
  name: "定向产品管理",
  meta: {
    title: "定向产品管理",
    icon: "el-icon-s-goods",
  },
  children: [
    {
      path: "/directional/mutualExclusion",
      component: () => import("@/views/directional/mutualExclusion"),
      name: "产品互斥管理",
      meta: {
        title: "产品互斥管理",
      },
    },
    {
      path: "/directional/directionalList",
      component: () => import("@/views/directional/list"),
      name: "产品管理",
      meta: {
        title: "产品管理",
      },
    },

    {
      path: "/directional/directionalEdit",
      component: () => import("@/views/directional/edit"),
      name: "产品编辑",
      meta: {
        title: "产品编辑",
      },
      hidden: true,
    },
    {
      path: "/directional/directionalAdd",
      component: () => import("@/views/directional/edit"),
      name: "新增产品",
      meta: {
        title: "新增产品",
      },
      hidden: true,
    },
    {
      path: "/directional/directionalDetail",
      component: () => import("@/views/directional/edit"),
      name: "产品详情",
      meta: {
        title: "产品详情",
      },
      hidden: true,
    },
    // draft
    {
      path: "/directional/draft",
      component: () => import("@/views/directional/draft"),
      name: "草稿箱",
      meta: {
        title: "草稿箱",
      },
    },
  ],
},


{
  path: '/channel',
  component: Layout,
  name: '渠道管理',
  children: [{
    path: '/channel',
    name: '渠道列表',
    component: () => import('@/views/schemeV2/channel'),
    meta: {
      title: '渠道管理',
      icon: 'el-icon-s-flag'
    }
  }]
}, {
  path: '/channelView',
  component: Layout,
  redirect: '/channelView/',
  name: '查看渠道',
  children: [{
    path: '/schemeV2/channelView',
    name: '查看渠道',
    component: () => import('@/views/schemeV2/channelView')
  }]
}, {
  path: '/channelSubList',
  component: Layout,
  redirect: '/channelSubList/',
  name: '所有二级渠道',
  children: [{
    path: '/schemeV2/channelSubList',
    name: '所有二级渠道',
    component: () => import('@/views/schemeV2/channelSubList')
  }]
}, {
  path: '/channelEdit',
  component: Close,
  redirect: '/channelEdit/',
  name: '修改渠道',
  children: [{
    path: '/schemeV2/channelEdit',
    name: '修改渠道',
    component: () => import('@/views/schemeV2/channelEdit')
  }]
},
{
  path: '/strategy',
  component: Layout,
  redirect: '/strategy/',
  name: '策略管理',
  meta: {
    title: '策略管理',
    icon: 'el-icon-s-tools'
  },
  children: [{
    path: '/strategy/index',
    component: () => import('@/views/strategy/index'),
    name: '策略列表',
    meta: {
      title: '策略列表'
    }
  },
  {
    path: '/strategy/add',
    component: () => import('@/views/strategy/add'),
    name: '新增策略',
    meta: {
      title: '新增策略'
    }
  },
  ]
},


{
  path: '/newSchemeProinfo',
  component: Layout,
  redirect: '/newSchemeProinfo/',
  name: '高级策略',
  meta: {
    title: '高级策略',
    icon: 'el-icon-s-claim'
  },
  children: [
    {
      path: '/newSchemeProinfo/index',
      name: '高级策略',
      component: () => import('@/views/newSchemeProinfo/index'),
      meta: {
        title: '高级策略',
      },
    },
    {
      path: '/newSchemeProinfo/schemeAb',
      name: '高级策略添加',
      component: () => import('@/views/newSchemeProinfo/schemeAb'),
      meta: {
        title: '高级策略添加',
      },
    },
    {
      path: '/newSchemeProinfo/userGroup',
      name: '用户分群',
      component: () => import('@/views/newSchemeProinfo/userGroup'),
      meta: {
        title: '用户分群',
      },
    },
    // {
    //   path: '/newSchemeProinfo/schemType',
    //   name: '高级策略类型',
    //   component: () => import('@/views/newSchemeProinfo/schemType'),
    //   meta: {
    //     title: '高级策略类型',
    //   },
    // },
  ]
},
{
  path: '/schemeAdd',
  component: Close,
  redirect: '/schemeAdd/',
  name: '新增策略',
  children: [{
    path: '/schemeV2/schemeAdd',
    name: '新增策略',
    component: () => import('@/views/schemeV2/schemeAdd')
  }]
},


// 高级策略
// {
//   path: '/schemeProinfo',
//   component: Layout,
//   redirect: '/schemeProinfo/',
//   name: '高级策略',
//   meta: {
//     title: '高级策略',
//     icon: 'el-icon-star-on'
//   },
//   children: [
//     // {
//     //   path: '/schemeProinfo/index',
//     //   name: '高级策略',
//     //   component: () => import('@/views/schemeProinfo/index'),
//     //   meta: {
//     //     title: '高级策略管理-内测',
//     //   },
//     // },
//     // {
//     //   path: '/schemeProinfo/number',
//     //   component: () => import('@/views/schemeProinfo/number'),
//     //   name: '认证方式管理',
//     //   meta: {
//     //     title: '认证方式管理'
//     //   }
//     // },
//     // {
//     //   path: '/schemeProinfo/numberIntercept',
//     //   component: () => import('@/views/schemeProinfo/numberIntercept'),
//     //   name: '虚商号码管理',
//     //   meta: {
//     //     title: '虚商号码管理'
//     //   }
//     // }
//   ]
// },
{
  path: '/ProinfoEdit',
  component: Close,
  redirect: '/ProinfoEdit/',
  name: '新增策略',
  children: [{
    path: '/schemeProinfo/ProinfoEdit',
    name: '新增策略',
    component: () => import('@/views/schemeProinfo/ProinfoEdit')
  }]
},
// 全局策略
{
  path: '/schemeGlobal',
  component: Layout,
  redirect: '/schemeGlobal/',
  name: '全局策略',
  meta: {
    title: '全局策略',
    icon: 'el-icon-message-solid'
  },
  children: [{
    path: '/schemeGlobal/index',
    name: '策略列表',
    component: () => import('@/views/schemeGlobal/index'),
    meta: {
      title: '全局策略控制',
    },
  }, {
    path: '/schemeGlobal/itemGlobal',
    name: '全局策略-管理项登记',
    component: () => import('@/views/schemeGlobal/itemGlobal'),
    meta: {
      title: '全局策略-管理项登记',
    },

  }, {
    path: '/schemeGlobal/itemEdit',
    name: '全局策略-管理项登记',
    component: () => import('@/views/schemeGlobal/itemEdit')
  }, {
    path: '/schemeProinfo/number',
    component: () => import('@/views/schemeProinfo/number'),
    name: '认证方式管理',
    meta: {
      title: '认证方式管理'
    }
  },
  {
    path: '/schemeProinfo/numberIntercept',
    component: () => import('@/views/schemeProinfo/numberIntercept'),
    name: '虚商号码管理',
    meta: {
      title: '虚商号码管理'
    }
  }]
},
// {
//   path: '/ABtest',
//   component: Layout,
//   redirect: '/ABtest/',
//   name: 'A/B测试',
//   meta: {
//     // title: 'A/B测试',
//     title: 'A/B实验-内测',
//     icon: 'el-icon-s-opportunity'
//   },
//   children: [{
//     path: '/ABtest/index',
//     component: () => import('@/views/ABtest/index'),
//     name: '测试列表',
//     meta: {
//       title: '实验室'
//     }
//   },
//   {
//     path: '/ABtest/edit',
//     component: () => import('@/views/ABtest/edit'),
//     name: '编辑测试'
//   },
//   {
//     path: '/ABtest/ABclass/index',
//     component: () => import('@/views/ABtest/ABclass/list'),
//     name: '类型管理',
//     meta: {
//       title: '类型管理'
//     }
//   },
//   {
//     path: '/ABtest/ABclass/edit',
//     component: () => import('@/views/ABtest/ABclass/edit'),
//     name: '编辑类型'
//   },
//   {
//     path: '/ABtest/testData',
//     component: () => import('@/views/ABtest/testData'),
//     name: '测试数据',
//     meta: {
//       title: '测试数据'
//     }
//   },
//
//   ]
// },
{
  path: '/model',
  component: Layout,
  redirect: '/model/',
  name: '模板管理',
  children: [{
    path: '/model/index',
    name: '模板管理',
    component: () => import('@/views/model/index'),
    meta: {
      title: '模板管理',
      icon: 'el-icon-s-open'
    }
  }]
},
{
  path: '/dataPage',
  component: Layout,
  redirect: '/dataPage/',
  name: '数据管理',
  meta: {
    title: '数据管理',
    icon: 'el-icon-s-data'
  },
  children: [{
    path: '/dataPage/orderData/index',
    component: () => import('@/views/dataPage/orderData/index'),
    name: '订单数据',
    meta: {
      title: '订单数据'
    }
  },
  {
    path: '/dataPage/receData/index',
    component: () => import('@/views/dataPage/receData/index'),
    name: '会员领取数据',
    meta: {
      title: '会员领取数据'
    }
  },
  {
    path: '/dataPage/recharge/index',
    component: () => import('@/views/dataPage/recharge/index'),
    name: 'C+产品充值',
    meta: {
      title: 'C+产品充值'
    }
  },
  {
    path: '/dataPage/feedback/index',
    component: () => import('@/views/dataPage/feedback/index'),
    name: '求助反馈',
    meta: {
      title: '求助反馈'
    }
  },
  {
    path: '/dataPage/returnData/index',
    component: () => import('@/views/dataPage/returnData/index'),
    name: '退订原因',
    meta: {
      title: '退订原因'
    }
  }
  ]
},

{
  path: '/examine',
  component: Layout,
  redirect: '/examine/',
  name: '审核管理',
  meta: {
    title: '审核管理',
    icon: 'el-icon-s-management'
  },
  children: [
    {
      path: '/examine/index',
      name: '我的审批',
      component: () => import('@/views/examine/apply'),
      meta: {
        title: '我的审批'
      }
    }, {
      path: '/examine/flowPath/index',
      name: '流程模板',
      component: () => import('@/views/examine/flowPath/index'),
      meta: {
        title: '流程模板'
      }
    },

  ]
},
{
  path: '/order',
  component: Layout,
  redirect: '/order/',
  name: '免流合作伙伴管理',
  meta: {
    title: '免流合作伙伴管理',
    icon: 'el-icon-s-management'
  },
  children: [
    {
      path: '/order/index',
      name: 'orderTransfer',
      component: () => import('@/views/order/transfer/index'),
      meta: {
        title: '配置产品转接'
      }
    }, {
      path: '/order/authority/index',
      name: 'orderAuthority',
      component: () => import('@/views/order/authority/index'),
      meta: {
        title: '配置产品权限'
      }
    }, {
      path: '/order/manage/index',
      name: '合作伙伴管理',
      component: () => import('@/views/order/manage/index'),
      meta: {
        title: '合作伙伴管理'
      }
    }, {
      path: '/order/draft/index',
      name: '草稿箱',
      component: () => import('@/views/order/draft/index'),
      meta: {
        title: '草稿箱'
      }
    },

  ]
}, {
  path: '/synchronous',
  component: Layout,
  redirect: '/synchronous/',
  name: '合作伙伴同步管理',
  meta: {
    title: '合作伙伴同步管理',
    icon: 'el-icon-s-management'
  },
  children: [
    {
      path: '/synchronous/index',
      name: 'flowSynchronous',
      component: () => import('@/views/synchronous/flowSynchronous/index'),
      meta: {
        title: '流量数据同步参数'
      }
    }, {
      path: '/synchronous/orderSynchronous/index',
      name: 'orderSynchronous',
      component: () => import('@/views/synchronous/orderSynchronous/index'),
      meta: {
        title: '订购同步参数'
      }
    }, {
      path: '/synchronous/draft/index',
      name: 'draftSynchronous',
      component: () => import('@/views/synchronous/draft/index'),
      meta: {
        title: '草稿箱'
      }
    },

  ]
},
{
  path: '/activity',
  component: Layout,
  name: '活动管理',
  children: [{
    path: '/activity',
    name: '活动管理',
    component: () => import('@/views/activity/index'),
    meta: {
      title: '活动管理',
      icon: 'el-icon-s-flag'
    }
  }]
},

{
  path: '/userRight',
  component: Layout,
  redirect: '/userRight/',
  name: '系统管理',
  meta: {
    title: '系统管理',
    icon: 'el-icon-s-tools'
  },
  children: [
    //   {
    //   path: '/userRight/rightList/index',
    //   component: () => import('@/views/userRight/rightList/index'),
    //   name: '权限管理',
    //   meta: {
    //     title: '权限管理'
    //   }
    // },
    // {
    //   path: '/userRight/roleList/index',
    //   component: () => import('@/views/userRight/roleList/index'),
    //   name: '角色管理',
    //   meta: {
    //     title: '角色管理'
    //   }
    // },
    {
      path: '/userRight/userList/index',
      component: () => import('@/views/userRight/userList/index'),
      name: '用户管理',
      meta: {
        title: '用户管理'
      }
    }
  ]
},
{
  path: '*',
  redirect: '/404',
  hidden: true
},
{
  path: '/404',
  component: () => import('@/views/404'),
  hidden: true
},
{
  path: '/kongbai',
  component: () => import('@/views/kongbai'),
  hidden: true
},
]

const createRouter = () => new Router({
  scrollBehavior: () => ({
    y: 0
  }),
  routes: constantRoutes
})

const router = createRouter()

export function resetRouter () {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
