import Vue from "vue";
import VueRouter from "vue-router";

// import { getCookie } from "@/utils/getToken.js";

Vue.use(VueRouter);

const routes = [{
        path: "/home",
        name: "home",
        component: () =>
            import ("@/views/pages/home")
    },
    {
        path: "/companyinformation",
        name: "companyinformation",
        component: () =>
            import ("@/views/pages/companyinformation")
    },
    {
        path: "/",
        redirect: "/home"
    },
    {
        path: "/user",
        name: "user",
        redirect: "/user/login",
        component: () =>
            import ("@/views/pages/user"),
        children: [{
                path: "login",
                name: "login",
                component: () =>
                    import ("@/views/pages/user/login")
            },
            {
                path: "register",
                name: "register",
                component: () =>
                    import ("@/views/pages/user/register")
            },
            {
                path: "forgetpassword",
                name: "forgetpassword",
                component: () =>
                    import ("@/views/pages/user/forgetPassword")
            }
        ]
    },
    {
        path: "/cashier",
        name: "cashier",
        component: () =>
            import ("@/views/pages/cashier")
    },
    {
        path: "/productdetails",
        name: "productdetails",
        component: () =>
            import ("@/views/pages/productdetails")
    },
    {
        path: "/successfulpayment",
        name: "successfulpayment",
        component: () =>
            import ("@/views/pages/successfulpayment")
    },
    {
        path: "/placeorder",
        name: "placeorder",
        component: () =>
            import ("@/views/pages/placeorder")
    },
    {
        path: "/jdbycdetailtm",
        name: "jdbycdetailtm",
        component: () =>
            import ("@/views/pages/jdbycdetailtm")
    },
    {
        path: "/companydetail",
        name: "companydetail",
        component: () =>
            import ("@/views/pages/companydetail")
    },
    {
        path: "/jdindentlist",
        name: "jdindentdetail",
        component: () =>
            import ("@/views/pages/jdindentlist")
    },
    {
        path: "/jdindentdetail",
        name: "jdindentdetail",
        component: () =>
            import ("@/views/pages/jdindentdetail")
    },
    /////////
    {
        path: "/jdtrademark",
        name: "jdtrademark",
        component: () =>
            import ("@/views/pages/jdtrademark/Jdtrademark")
    },
    {
        path: "/selftmreg",
        name: "selftmreg",
        component: () =>
            import ("@/views/pages/selftmreg/Selftmreg")
    },
    {
        // path: "/bycnoticeindex",
        path: "/bycnoticeindex",
        name: "bycnoticeindex",
        component: () =>
            import ("@/views/pages/bycnoticeindex/Bycnoticeindex")
    }
];
const router = new VueRouter({
    routes
});

// router.beforeEach((to, from, next) => {
//     let userpin = getCookie("userpin");
//     if (
//         to.path == "/user/login" ||
//         to.path == "/user/register" ||
//         to.path == "/user/forgetPassword" ||
//         to.path == "/jdtrademark"
//     ) {
//         next();
//     } else {
//         if (userpin == "" || userpin == null) {
//             next("/user/login");
//         } else {
//             next();
//         }
//     }
// });

export default router;