import Vue from 'vue'
import Router from 'vue-router'
import layout from '../views/layout/layout'

const _import = require('./_import_' + process.env.NODE_ENV)

if (Router.version >= '3.1.0') {
  const originalPush = Router.prototype.push
  Router.prototype.push = function push (location) {
    return originalPush.call(this, location).catch(err => err)
  }
}

Vue.use(Router)

export const constantRouterMap = [
  {path: '/', redirect: '/login'},
  {path: '/login', component: _import('login/index'), name: 'login'},
  {path: '/login-by-backend', component: _import('login/login-by-backend'), name: 'login-by-backend'},
  {path: '/modify-password/:username', component: _import('login/modify-password'), name: 'modify-password'},
  // { path: '/authredirect', component: _import('login/authredirect'), hidden: true },
  // { path: '/404', component: _import('errorPage/404'), hidden: true },
  // { path: '/401', component: _import('errorPage/401'), hidden: true },
  {
    path: '/dashboard/index',
    component: layout,
    redirect: '/dashboard/index',
    children: [{
      path: '/dashboard/index',
      component: _import('dashboard/index'),
      name: 'dashboard_index',
      meta: {
        title: 'Dashboard', // 控制台
        breadcrumb: [
          {title: 'Dashboard', path: '/dashboard/index'} // 首页
        ]
      }
    },
      {
        path: '/dashboard/ba-index',
        component: _import('dashboard/ba-index'),
        name: 'dashboard_ba_index',
        meta: {
          title: 'Dashboard', // 控制台
          breadcrumb: [
            {title: 'Dashboard', path: '/dashboard/ba-index'} // 首页
          ]
        }
      },
      ]
  },
  {
    path: '/shop',
    component: layout,
    redirect: '/shop/dec-order-list',
    children: [
      {
        path: '/shop/dec-order-list',
        component: _import('shop/dec-order-list'),
        name: 'shop_dec-order-list',
        meta: {
          title: 'Welcome Pack Listing', // 报单列表
          breadcrumb: [
            {title: 'Dashboard', path: '/dashboard/index'}, // 首页
            {title: 'Shopping Mall', path: '/shop/dec-order-list'} // 商城管理
          ]
        }
      },
      {
        path: '/shop/order-list',
        component: _import('shop/order-list'),
        name: 'shop_order-list',
        meta: {
          title: 'Order List', // 订单列表
          breadcrumb: [
            {title: 'Dashboard', path: '/dashboard/index'}, // 首页
            {title: 'Shopping Mall', path: '/shop/dec-order-list'} // 商城管理
          ]
        }
      },
      {
        path: '/shop/index',
        component: _import('shop/index'),
        name: 'shop_index',
        meta: {
          title: 'Products list', // 商品列表
          breadcrumb: [
            {title: 'Dashboard', path: '/dashboard/index'}, // 首页
            {title: 'Shopping Mall', path: '/shop/dec-order-list'} // 商城管理
          ]
        }
      },
      {
        path: '/shop/order-backing-out',
        component: _import('shop/order-backing-out'),
        name: 'shop_order-list',
        meta: {
          title: '订单退货', // 订单退货
          breadcrumb: [
            {title: 'Dashboard', path: '/dashboard/index'}, // 首页
            {title: 'Shopping Mall', path: '/shop/dec-order-list'} // 商城管理
          ]
        }
      },
      {
        path: '/shop/order',
        component: _import('shop/order'),
        name: 'shop_order',
        meta: {
          title: 'Products settlement',
          breadcrumb: [
            {title: 'Dashboard', path: '/dashboard/index'}, // 首页
            {title: 'Shopping Mall', path: '/shop/dec-order-list'}// 商城管理
          ]
        }
      },
      {
        path: '/shop/goods-detail/:id',
        component: _import('shop/goods-detail'),
        name: 'shop_goods-detail',
        meta: {
          title: '商品详情',
          breadcrumb: [
            {title: 'Dashboard', path: '/dashboard/index'},
            {title: 'Shopping Mall', path: '/shop/dec-order-list'}
          ]
        }
      },
      {
        path: '/shop/ba-product-list',
        component: _import('shop/ba-product-list'),
        name: 'ba_product_list',
        meta: {
          title: 'Products list', // BA商品列表
          breadcrumb: [
            {title: 'Dashboard', path: '/dashboard/index'}, // 首页
            {title: 'Shopping Mall', path: '/shop/ba-order-list'} // 商城管理
          ]
        }
      },
      {
        path: '/shop/ba-shopping-cart',
        component: _import('shop/ba-shopping-cart'),
        name: 'ba-shopping-cart',
        meta: {
          title: 'Products settlement', // 购物车
          breadcrumb: [
            {title: 'Dashboard', path: '/dashboard/index'}, // 首页
            {title: 'Shopping Mall', path: '/shop/ba-shopping-cart'}// 商城管理
          ]
        }
      },
      {
        path: '/shop/ba-order-list',
        component: _import('shop/ba-order-list'),
        name: 'ba_order_list',
        meta: {
          title: 'Order List', // BA订单列表
          breadcrumb: [
            {title: 'Dashboard', path: '/dashboard/index'}, // 首页
            {title: 'Shopping Mall', path: '/shop/ba-order-list'}// 商城管理
          ]
        }
      },
      {
        path: '/shop/ba-dec-order-list',
        component: _import('shop/ba-dec-order-list'),
        name: 'shop_ba-dec-order-list',
        meta: {
          title: 'Welcome Listing', // BA报单列表
          breadcrumb: [
            {title: 'Dashboard', path: '/dashboard/index'}, // 首页
            {title: 'Shopping Mall', path: '/shop/dec-order-list'} // 商城管理
          ]
        }
      }
      // {
      //     path: '/shop/reconsume',
      //     component: _import('shop/reconsume'),
      //     name: 'shop_reconsume',
      //     meta: {
      //         title: '复消商品',
      //         breadcrumb: [
      //             {title: '首页', path: '/dashboard/index'},
      //             {title: '商城管理', path: '/shop/dec-order-list'},
      //         ],
      //     },
      // },
      // {
      //     path: '/shop/reconsume-order',
      //     component: _import('shop/reconsume-order'),
      //     name: 'reconsume-order',
      //     meta: {
      //         title: '复消商品结算',
      //         breadcrumb: [
      //             {title: '首页', path: '/dashboard/index'},
      //             {title: '商城管理', path: '/shop/dec-order-list'}
      //         ],
      //     },
      // },
    ]
  },
  {
    path: '/user',
    component: layout,
    redirect: '/user/index',
    children: [
      {
        path: '/user/index',
        component: _import('user/index'),
        name: 'user_index',
        meta: {
          title: 'Personal info', // 个人资料
          breadcrumb: [
            {title: 'Dashboard', path: '/dashboard/index'}, // 首页
            {title: 'Member management', path: '/user/index'} // 会员管理
          ]
        }
      },
      {
        path: '/user/password',
        component: _import('user/password'),
        name: 'user_password',
        meta: {
          title: 'Reset Password', // 重置密码
          breadcrumb: [
            {title: 'Dashboard', path: '/dashboard/index'}, // 首页
            {title: 'Member management', path: '/user/index'} // 会员管理
          ]
        }
      },
      {
        path: '/user/id-card',
        component: _import('user/id-card'),
        name: 'user_id-card',
        meta: {
          title: '上传身份证',
          breadcrumb: [
            {title: 'Dashboard', path: '/dashboard/index'},
            {title: 'Member management', path: '/user/index'}
          ]
        }
      },
      {
        path: '/user/rec-user',
        component: _import('user/rec-user'),
        name: 'user_rec-user',
        meta: {
          title: '开拓会员列表',
          breadcrumb: [
            {title: 'Dashboard', path: '/dashboard/index'},
            {title: 'Member management', path: '/user/index'}
          ]
        }
      },
      {
        path: '/user/bind',
        component: _import('user/bind'),
        name: 'user_bind',
        meta: {
          title: '点位绑定列表',
          breadcrumb: [
            {title: 'Dashboard', path: '/dashboard/index'},
            {title: 'Member management', path: '/user/index'}
          ]
        }
      },
      {
        path: '/user/bind-edit/:id',
        component: _import('user/bind-edit'),
        name: 'user_bind-edit',
        meta: {
          title: '点位绑定编辑',
          highLight: '/user/bind',
          breadcrumb: [
            {title: 'Dashboard', path: '/dashboard/index'},
            {title: 'Member management', path: '/user/index'},
            {title: '点位绑定列表', path: '/user/bind'}
          ]
        }
      },
      {
        path: '/user/dec',
        component: _import('user/dec'),
        name: 'user_dec',
        meta: {
          title: 'Welcome Pack management', // 报单管理
          breadcrumb: [
            {title: 'Dashboard', path: '/dashboard/index'}, // 首页
            {title: 'Member management', path: '/user/index'} // 会员管理
          ]
        }
      },
      {
        path: '/user/upgrade',
        component: _import('user/upgrade'),
        name: 'user_upgrade',
        meta: {
          title: 'Upgrade management', // 升级管理
          highLight: '/user/bind',
          breadcrumb: [
            {title: 'Dashboard', path: '/dashboard/index'}, // 首页
            {title: 'Member management', path: '/user/index'} // 会员管理
          ]
        }
      },
      {
        path: '/user/ba-dec',
        component: _import('user/ba-dec'),
        name: 'user_ba-dec',
        meta: {
          title: 'Welcome BA', // 个人资料
          breadcrumb: [
            {title: 'Dashboard', path: '/dashboard/index'}, // 首页
            {title: 'Member management', path: '/user/index'} // 会员管理
          ]
        }
      },
      {
        path: '/user/ba-info',
        component: _import('user/ba-info'),
        name: 'ba-info',
        meta: {
          title: 'Personal info', // 个人资料
          breadcrumb: [
            {title: 'Dashboard', path: '/dashboard/index'}, // 首页
            {title: 'Member management', path: '/user/index'} // 会员管理
          ]
        }
      },
      {
        path: '/user/ba-password',
        component: _import('user/ba-password'),
        name: 'ba-password',
        meta: {
          title: 'Reset Password', // 重置密码
          breadcrumb: [
            {title: 'Dashboard', path: '/dashboard/index'}, // 首页
            {title: 'Member management', path: '/user/index'} // 会员管理
          ]
        }
      }
    ]
  },
  {
    path: '/atlas',
    component: layout,
    redirect: '/atlas/network',
    children: [
      {
        path: '/atlas/network',
        component: _import('atlas/network'),
        name: 'atlas_network',
        meta: {
          title: 'Placement network',
          breadcrumb: [
            {title: 'Dashboard', path: '/dashboard/index'},
            {title: 'Network Chart', path: '/atlas/network'}
          ]
        }
      }
    ]
  },
  {
    path: '/atlas',
    component: layout,
    redirect: '/atlas/network',
    children: [
      {
        path: '/atlas/network',
        component: _import('atlas/network'),
        name: 'atlas_network',
        meta: {
          title: 'Placement network',
          breadcrumb: [
            {title: 'Dashboard', path: '/dashboard/index'},
            {title: 'Network Chart', path: '/atlas/network'},
          ]
        }
      },
      {
        path: '/atlas/relation',
        component: _import('atlas/relation'),
        name: 'atlas_relation',
        meta: {
          title: 'Sponsor network',
          breadcrumb: [
            {title: 'Dashboard', path: '/dashboard/index'},
            {title: 'Sponsor Chart', path: '/atlas/relation'}
          ]
        }
      },
      {
        path: '/atlas/brand-ambassador-list',
        component: _import('atlas/brand-ambassador-list'),
        name: 'brand-ambassador-list',
        meta: {
          title: 'Brand Ambassador List',
          breadcrumb: [
            {title: 'Dashboard', path: '/dashboard/index'},
            {title: 'Brand Ambassador List', path: '/atlas/brand-ambassador-list'}
          ]
        }
      }
    ]
  },
  {
    path: '/bonus',
    component: layout,
    redirect: '/bonus/index',
    children: [
      {
        path: '/bonus/index',
        component: _import('bonus/index'),
        name: 'bonus_index',
        meta: {
          title: 'My account', // 我的账户
          breadcrumb: [
            {title: 'Dashboard', path: '/dashboard/index'}, // 首页
            {title: 'Bonus management', path: '/bonus/index'} // 奖金管理
          ]
        }
      },
      {
        path: '/bonus/new',
        component: _import('bonus/new'),
        name: 'bonus_new',
        meta: {
          title: '最新奖金',
          breadcrumb: [
            {title: 'Dashboard', path: '/dashboard/index'},
            {title: 'Bonus management', path: '/bonus/index'}
          ]
        }
      },
      {
        path: '/bonus/other',
        component: _import('bonus/other'),
        name: 'bonus_other',
        meta: {
          title: 'Previous bonus', // 往期奖金
          breadcrumb: [
            {title: 'Dashboard', path: '/dashboard/index'}, // Dashboard
            {title: 'Bonus management', path: '/bonus/index'} // 奖金管理
          ]
        }
      },
      {
        path: '/bonus/historical-cumulative-bonus',
        component: _import('bonus/historical-cumulative-bonus'),
        name: 'historical-cumulative-bonus',
        meta: {
          title: 'Historical cumulative bonus', // 往期历史奖金累积
          breadcrumb: [
            {title: 'Dashboard', path: '/dashboard/index'}, // Dashboard
            {title: 'Bonus management', path: '/bonus/index'} // 奖金管理
          ]
        }
      },
      {
        path: '/bonus/real-time-perf',
        component: _import('bonus/real-time-perf'),
        name: 'bonus_real-time-perf',
        meta: {
          title: '实时业绩',
          breadcrumb: [
            {title: 'Dashboard', path: '/dashboard/index'},
            {title: 'Bonus management', path: '/bonus/index'}
          ]
        }
      },
      {
        path: '/bonus/fc-point',
        component: _import('bonus/fc-point'),
        name: 'bonus_fc-point',
        meta: {
          title: '房产积分',
          breadcrumb: [
            {title: 'Dashboard', path: '/dashboard/index'},
            {title: 'Bonus management', path: '/bonus/index'}
          ]
        }
      },
      {
        path: '/bonus/teams',
        component: _import('bonus/teams'),
        name: 'bonus_teams',
        meta: {
          title: 'Team inquiry', // 团队查询
          breadcrumb: [
            {title: 'Dashboard', path: '/dashboard/index'},
            {title: 'Bonus management', path: '/bonus/index'},
          ],
        },
      },

    ]
  },
  {
    path: '/article',
    component: layout,
    redirect: '/article/list',
    children: [
      {
        path: '/article/list/:cid',
        component: _import('article/list'),
        name: 'article_list',
        meta: {
          title: 'Article List',
          breadcrumb: [
            {title: 'Dashboard', path: '/dashboard/index'},
            {title: 'Article Management', path: '/article/list'}
          ]
        }
      },
      {
        path: '/article/detail/:id',
        component: _import('article/detail'),
        name: 'article_detail',
        meta: {
          title: 'Article Detail',
          breadcrumb: [
            {title: 'Dashboard', path: '/dashboard/index'},
            {title: 'Article Management', path: '/article/list'}
          ]
        }
      }
    ]
  },
  {
    path: '/message',
    component: layout,
    redirect: '/message/list',
    children: [
      {
        path: '/message/list',
        component: _import('message/list'),
        name: 'message_list',
        meta: {
          title: '站内信列表',
          breadcrumb: [
            {title: 'Dashboard', path: '/dashboard/index'},
            {title: '站内信', path: '/message/list'}
          ]
        }
      },
      {
        path: '/message/detail/:id',
        component: _import('message/detail'),
        name: 'message_detail',
        meta: {
          title: '站内信详情',
          breadcrumb: [
            {title: 'Dashboard', path: '/dashboard/index'},
            {title: '站内信', path: '/message/list'}
          ]
        }
      }
    ]
  },
  {
    path: '/finance',
    component: layout,
    redirect: '/finance/withdraw',
    children: [
      {
        path: '/finance/reconsume-pool-flow',
        component: _import('finance/reconsume-pool-flow'),
        name: 'finance_reconsume-pool-flow',
        meta: {
          title: '会员复销池余额流水',
          breadcrumb: [
            {title: 'Dashboard', path: '/dashboard/index'},
            {title: 'Financial management', path: '/finance/withdraw'}
          ]
        }
      },
      {
        path: '/finance/withdraw',
        component: _import('finance/withdraw'),
        name: 'finance_withdraw',
        meta: {
          title: 'Withdrawal details', // 提现明细
          breadcrumb: [
            {title: 'Dashboard', path: '/dashboard/index'}, // 首页
            {title: 'Financial management', path: '/finance/index'} // 财务管理
          ]
        }
      },
      {
        path: '/finance/withdraw-add',
        component: _import('finance/withdraw-add'),
        name: 'finance_withdraw-add',
        meta: {
          title: 'Withdraw', // 我要提现
          highLight: '/finance/withdraw',
          breadcrumb: [
            {title: 'Dashboard', path: '/dashboard/index'}, // 首页
            {title: 'Financial management', path: '/finance/index'}, // 财务管理
            {title: 'Withdrawal details', path: '/finance/withdraw'} // 提现明细
          ]
        }
      },
      {
        path: '/finance/dec-list',
        component: _import('finance/dec-list'),
        name: 'finance_dec-list',
        meta: {
          title: '报单订货单列表',
          breadcrumb: [
            {title: 'Dashboard', path: '/dashboard/index'},
            {title: 'Financial management', path: '/finance/index'}
          ]
        }
      },
      {
        path: '/finance/transfer-list',
        component: _import('finance/transfer-list'),
        name: 'finance_transfer-list',
        meta: {
          title: 'Transfer',
          breadcrumb: [
            {title: 'Dashboard', path: '/dashboard/index'},
            {title: 'Financial management', path: '/finance/index'}
          ]
        }
      },
      {
        path: '/finance/transfer-add',
        component: _import('finance/transfer-add'),
        name: 'finance_transfer-add',
        meta: {
          title: 'Transfer',
          highLight: '/finance/transfer-list',
          breadcrumb: [
            {title: 'Dashboard', path: '/dashboard/index'},
            {title: 'Financial management', path: '/finance/index'}
          ]
        }
      },
      {
        path: '/finance/recharge',
        component: _import('finance/recharge'),
        name: 'finance_recharge',
        meta: {
          title: 'Recharge details', // 充值明细
          breadcrumb: [
            {title: 'Dashboard', path: '/dashboard/index'}, // 首页
            {title: 'financial management', path: '/finance/index'} // 财务管理
          ]
        }
      },
      {
        path: '/finance/recharge-add',
        component: _import('finance/recharge-add'),
        name: 'finance_recharge-add',
        meta: {
          title: 'Recharge', // 我要充值
          highLight: '/finance/recharge',
          breadcrumb: [
            {title: 'Dashboard', path: '/dashboard/index'}, // 首页
            {title: 'financial management', path: '/finance/index'}, // 财务管理
            {title: 'Recharge details', path: '/finance/recharge'}
          ]
        }
      }
    ]
  },
  {
    path: '/config',
    component: layout,
    redirect: '/config/base',
    children: [
      {
        path: '/config/receive-address-list',
        component: _import('config/receive-address-list'),
        name: 'config_receive-address-list',
        meta: {
          title: 'Shipping Address', // 收货地址管理
          breadcrumb: [
            {title: 'Dashboard', path: '/dashboard/index'}, // 首页
            {title: 'Setting', path: '/config/base'} // 设置
          ]
        }
      },
      {
        path: '/config/receive-address-add',
        component: _import('config/receive-address-edit'),
        name: 'config_receive-address-add',
        meta: {
          title: 'Add shipping address', // 添加收货地址
          highLight: '/config/receive-address-list',
          breadcrumb: [
            {title: 'Dashboard', path: '/dashboard/index'}, // 首页
            {title: 'Setting', path: '/config/base'}, // 设置
            {title: 'Shipping Address', path: '/config/receive-address-list'} // 收货地址管理
          ]
        }
      },
      {
        path: '/config/receive-address-edit/:id',
        component: _import('config/receive-address-edit'),
        name: 'config_receive-address-edit',
        meta: {
          title: 'Edit address',
          highLight: '/config/receive-address-list',
          breadcrumb: [
            {title: 'Dashboard', path: '/dashboard/index'}, // 首页
            {title: 'Setting', path: '/config/base'}, // 设置
            {title: 'Shipping Address', path: '/config/receive-address-list'} // 收货地址管理
          ]
        }
      },

      {
        path: '/config/ba-receive-address-list',
        component: _import('config/ba-receive-address-list'),
        name: 'ba-receive-address-list',
        meta: {
          title: 'Shipping Address', // 收货地址管理
          breadcrumb: [
            {title: 'Dashboard', path: '/dashboard/index'}, // 首页
            {title: 'Setting', path: '/config/base'} // 设置
          ]
        }
      },
      {
        path: '/config/ba-receive-address-add',
        component: _import('config/ba-receive-address-edit'),
        name: 'ba-receive-address-add',
        meta: {
          title: 'Add Shipping Address', // 添加收货地址
          highLight: '/config/ba-receive-address-list',
          breadcrumb: [
            {title: 'Dashboard', path: '/dashboard/index'}, // 首页
            {title: 'Setting', path: '/config/base'}, // 设置
            {title: 'Shipping Address', path: '/config/ba-receive-address-list'} // 收货地址管理
          ]
        }
      },
      {
        path: '/config/ba-receive-address-edit/:id',
        component: _import('config/ba-receive-address-edit'),
        name: 'ba-receive-address-edit',
        meta: {
          title: 'Edit Address',
          highLight: '/config/ba-receive-address-list',
          breadcrumb: [
            {title: 'Dashboard', path: '/dashboard/index'}, // 首页
            {title: 'Setting', path: '/config/base'}, // 设置
            {title: 'Shipping Address', path: '/config/ba-receive-address-list'} // 收货地址管理
          ]
        }
      }
    ]
  }
]

export default new Router({
  routes: constantRouterMap
})
