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/schemeV2/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: '/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/schemType',
    //   name: '高级策略类型',
    //   component: () => import('@/views/newSchemeProinfo/schemType'),
    //   meta: {
    //     title: '高级策略类型',
    //   },
    // },
  ]
},

{
  path: '/schemeV2',
  component: Layout,
  redirect: '/schemeV2/',
  name: '旧-策略管理',
  children: [{
    path: '/schemeV2/index',
    name: '策略列表',
    component: () => import('@/views/schemeV2/index'),
    meta: {
      title: '旧-策略管理',
      icon: 'el-icon-s-management'
    }
  }]
}, {
  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/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: '/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
}
]

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
