text: import Vue from 'vue'
  import VueRouter from 'vue-router'
  import {
    Message
  } from 'element-ui';
  
  const Login = () => import("views/login/Login")
  const Home = () => import("views/home/Home")
  
  // 用户管理
  const Users = () => import("components/userControl/userList")
  
  //权限管理
  const UserJur = () => import("components/jurControl/userJur")
  const jurList = () => import("components/jurControl/jurList")
  
  // 商品管理
  const goodsList = () => import("components/goodsControl/goodsList")
  const goodsParams = () => import("components/goodsControl/goodsParams")
  const goodsCategory = () => import("components/goodsControl/goodsCategory")
  const goodsAdd = () => import("components/goodsControl/goodsAdd")
  
  // 订单管理
  const orderControl = () => import("components/orderControl/orderControl")
  
  // 数据报表
  const dataDes = () => import("components/dataDes/dataDes")
  
  Vue.use(VueRouter)
  
  const routes = [{
      path: '/',
      redirect: '/home'
    },
    {
      path: '/login',
      component: Login
    },
    {
      path: '/home',
      component: Home,
      children: [{
          path: '/users',
          component: Users
        },
        // 权限管理
        {
          path: '/userjur',
          component: UserJur
        }, {
          path: '/jurlist',
          component: jurList
        },
        // 商品管理
        {
          path: '/goodslist',
          component: goodsList
        }, {
          path: '/goodsparams',
          component: goodsParams
        }, {
          path: '/goodscategory',
          component: goodsCategory
        },{
          path:'/goodsadd',
          component:goodsAdd
        },
        // 订单管理
        {
          path: '/ordercontrol',
          component: orderControl
        },
        // 数据报表
        {
          path: "/datades",
          component: dataDes
        }
      ]
    }
  ]
  
  const router = new VueRouter({
    mode: 'history',
    base: process.env.BASE_URL,
    routes
  })
  
  router.beforeEach((to, from, next) => {
    if (to.path === '/login') {
      next()
    } else {
      // 判断本地有无token（用户之前是否登录过），无则返回登陆页面
      const token = localStorage.getItem('token')
      if (!token) {
        Message.warning("请先登录！")
        router.push('/login')
        return
      }
      next()
    }
  })
  
  export default router