import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)
const [routerPush, routerReplace] = [VueRouter.prototype.push, VueRouter.prototype.replace];
VueRouter.prototype.push = function push (to) {
    return routerPush.call(this, to).catch(err => err)
}
VueRouter.prototype.replace = function replace (location) {
    return routerReplace.call(this, location).catch(error => error);
};
const routes = [
    {
        path: '/502',
        name: '502',
        component: () =>
            import('@/views/502.vue'),
        meta: {
            title: '502',
        }
    },
    {
        path: '/',
        name: 'Home',
        component: () =>
            import('@/views/Home.vue'),
        meta: {
            title: '绍兴研学'
        }
    },
    {
        path: '/Find',
        name: 'Find',
        component: () =>
            import('@/views/Find.vue'),
        meta: {
            title: '发现'
        }
    }, {
        path: '/Foot',
        name: 'Foot',
        component: () =>
            import('@/views/Foot.vue'),
        meta: {
            title: '足迹'
        }
    }, {
        path: '/Authorize',
        name: 'Authorize',
        component: () =>
            import('@/views/Authorize.vue'),
        meta: {
            title: '授权中...'
        }
    },
    {
        path: '/MyClassList',
        name: 'MyClassList',
        component: () =>
            import('@/views/MyClassList.vue'),
        meta: {
            title: '基地签到'
        }
    }, {
        path: '/BaseDetail',
        name: 'BaseDetail',
        component: () =>
            import('@/views/BaseDetail.vue')
    }, {
        path: '/CourseDetail',
        name: 'CourseDetail',
        component: () =>
            import('@/views/CourseDetail.vue'),
        meta: {
            title: '课程详情'
        }
    }, {
        path: '/ReleaseStory',
        name: 'ReleaseStory',
        component: () =>
            import('@/views/ReleaseStory.vue'),
    }, {
        path: '/ReleaseEvaluate',
        name: 'ReleaseEvaluate',
        component: () =>
            import('@/views/ReleaseEvaluate.vue'),
    }, {
        path: '/MyCollection',
        name: 'MyCollection',
        component: () =>
            import('@/views/MyCollection.vue'),
    }, {
        path: '/EvaluateDetail',
        name: 'EvaluateDetail',
        component: () =>
            import('@/views/EvaluateDetail.vue'),
    }, {
        path: '/BannerDetail',
        name: 'BannerDetail',
        component: () =>
            import('@/views/BannerDetail.vue'),
    }, {
        path: '/SearchDetail',
        name: 'SearchDetail',
        component: () =>
            import('@/views/SearchDetail.vue'),
    }, {
        path: '/FeedBack',
        name: 'FeedBack',
        component: () =>
            import('@/views/FeedBack.vue'),
    }, {
        path: '/About',
        name: 'About',
        component: () =>
            import('@/views/About.vue'),
    }, {
        path: '/Tips',
        name: 'Tips',
        component: () =>
            import('@/views/Tips.vue'),
    }, {
        path: '/HomeYX',
        name: 'HomeYX',
        component: () =>
            import('@/views/Home/HomeYX.vue'),
        meta: {
            title: '个人中心'
        }
    },
    {
        path: '/service_order',
        name: 'ServiceOrder',
        component: () =>
            import('@/views/Home/ServiceOrder.vue'),
        meta: {
            title: '我的订单'
        }
    },
    {
        path: '/YanxueCode',
        name: 'YanxueCode',
        component: () =>
            import('@/views/Home/YanxueCode.vue'),
    },
    {
        path: '/YanxueInfo',
        name: 'YanxueInfo',
        component: () =>
            import('@/views/Home/YanxueInfo.vue'),
    },
    {
        path: '/select_contact',
        name: 'SelectContact',
        component: () =>
            import('@/views/Home/SelectContact.vue'),
        meta: {
            title: '选择联系人'
        }
    },
    {
        path: '/edit_contact',
        name: 'EditContact',
        component: () =>
            import('@/views/Home/EditContact.vue'),
        meta: {
            title: '修改联系人'
        }
    },
    {
        path: '/StudentDetail',
        name: 'StudentDetail',
        component: () =>
            import('@/views/Home/StudentDetail.vue'),
        meta: {
            title: '学生信息'
        }
    },
    {
        path: '/login_public',
        name: 'LoginPublic',
        component: () =>
            import('@/views/Home/LoginPublic.vue'),
        meta: {
            title: '绑定手机号'
        }
    },
    {
        path: '/evaluateCourse',
        name: 'evaluateCourse',
        component: () =>
            import('@/views/Home/evaluateCourse.vue'),
        meta: {
            title: '评价'
        }
    },
    {
        path: '/evaluateBase',
        name: 'evaluateBase',
        component: () =>
            import('@/views/Home/evaluateBase.vue'),
        meta: {
            title: '基地评价'
        }
    },
    {
        path: '/evaluateDetail',
        name: 'evaluateDetail',
        component: () =>
            import('@/views/Home/evaluateDetail.vue'),
        meta: {
            title: '评价详情'
        }
    },
    {
        path: '/schoolFollow',
        name: 'schoolFollow',
        component: () =>
            import('@/views/Travel/schoolFollow.vue'),
        meta: {
            title: '关注学校'
        }
    },
    {
        path: '/schoolAttestation',
        name: 'schoolAttestation',
        component: () =>
            import('@/views/Travel/schoolAttestation.vue'),
        meta: {
            title: '已认证学校'
        }
    },
    {
        path: '/classAttestation',
        name: 'classAttestation',
        component: () =>
            import('@/views/Travel/classAttestation.vue'),
        meta: {
            title: '集团认领'
        }
    },
    {
        path: '/MyCollect',
        name: 'MyCollect',
        component: () =>
            import('@/views/Home/MyCollect.vue'),
        meta: {
            title: '我的收藏'
        }
    },
    {
        path: '/SelectionCourse',
        name: 'SelectionCourse',
        component: () =>
            import('@/views/Service/CourseBaseList/SelectionCourse.vue'),
        meta: {
            title: '精选课程',
        }
    },
    {
        path: '/SelectionBase',
        name: 'SelectionBase',
        component: () =>
            import('@/views/Service/CourseBaseList/SelectionBase.vue'),
        meta: {
            title: '研学基地',
        }
    },
    {
        path: '/SearchResult',
        name: 'SearchResult',
        component: () =>
            import('@/views/Service/CourseBaseList/SearchResult.vue'),
        meta: {
            title: '搜索结果',
        }
    },
    {
        path: '/RankingList',
        name: 'RankingList',
        component: () =>
            import('@/views/Service/CourseBaseList/RankingList.vue'),
        meta: {
            title: '热门榜单',
        }
    },
    {
        path: '/base_detail',
        name: 'ServiceBaseDetail',
        component: () =>
            import('@/views/Service/BaseDetail/BaseDetail.vue'),
        meta: {
            title: '基地详情'
        }
    },
    {
        path: '/abroad_detail',
        name: 'ServiceAbroadDetail',
        component: () =>
            import('@/views/Service/AbroadDetail/AbroadDetail.vue'),
        meta: {
            title: '课程详情'
        }
    },
    {
        path: '/abroad_detail_next',
        name: 'ServiceAbroadDetailNext',
        component: () =>
            import('@/views/Service/AbroadDetailNext/AbroadDetailNext.vue'),
        meta: {
            title: '课程详情'
        }
    },
    {
        path: '/talent_reserve',
        name: 'TalentReserve',
        component: () =>
            import('@/views/Service/TalentReserve.vue'),
        meta: {
            title: '预约'
        }
    },
    {
        path: '/check_order_reserve',
        name: 'ServiceCheckOrderReserve',
        component: () =>
            import('@/views/Service/CheckOrderReserve.vue'),
        meta: {
            title: '提交信息'
        }
    },
    {
        path: '/article',
        name: 'Article',
        component: () =>
            import('@/views/Article/Article.vue'),
        meta: {
            title: '官方资讯'
        }
    },
    {
        path: '/article_detail',
        name: 'ArticleDetail',
        component: () =>
            import('@/views/Article/ArticleDetail.vue'),
        meta: {
            title: '官方资讯'
        }
    },
    {

        path: '/teacher',
        name: 'Teacher',
        component: () =>
            import('@/views/Teacher/Teacher.vue'),
        meta: {
            title: '研学导师'
        }
    },
    {
        path: '/GrowUpRecord',
        name: 'GrowUpRecord',
        component: () =>
            import('@/views/GrowUp/GrowUpRecord.vue'),
        meta: {
            title: '成长记录'

        }
    },
    {
        path: '/MyAlbum',
        name: 'MyAlbum',
        component: () =>
            import('@/views/GrowUp/MyAlbum.vue'),
        meta: {
            title: '我的相册',
        }
    },
    {
        path: '/StoryRelease',
        name: 'StoryRelease',
        component: () =>
            import('@/views/GrowUp/StoryRelease.vue'),
        meta: {
            title: '我的游记',
        }
    },
    {
        path: '/StoryList',
        name: 'StoryList',
        component: () =>
            import('@/views/GrowUp/StoryList.vue'),
        meta: {
            title: '研学游记',
        }
    },
    {
        path: '/StoryDetail',
        name: 'StoryDetail',
        component: () =>
            import('@/views/GrowUp/StoryDetail.vue'),
        meta: {
            title: '研学游记',
        }
    },
    {
        path: '/MyStory',
        name: 'MyStory',
        component: () =>
            import('@/views/GrowUp/MyStory.vue'),
        meta: {
            title: '我的游记',
        }
    },
    {
        path: '/FeedbookList',
        name: 'FeedbookList',
        component: () =>
            import('@/views/Feedbook/FeedbookList.vue'),
        meta: {
            title: '意见反馈',
        }
    },
    {
        path: '/FeedbookReply',
        name: 'FeedbookReply',
        component: () =>
            import('@/views/Feedbook/FeedbookReply.vue'),
        meta: {
            title: '回复',
        }
    },
    {
        path: '/FeedbookEdit',
        name: 'FeedbookEdit',
        component: () =>
            import('@/views/Feedbook/FeedbookEdit.vue'),
        meta: {
            title: '撰写意见',
        }
    },
    {
        path: '/ZXCode',
        name: 'ZXCode',
        component: () =>
            import('@/views/Home/ZXCode.vue'),
        meta: {
            title: '浙学码'

        }
    },
    {
        path: '/YanxuePage',
        name: 'YanxuePage',
        component: () =>
            import('@/views/Yanxue/YanxuePage.vue'),
        meta: {
            title: '研学'

        }
    }, {
        path: '/YanxueDetail',
        name: 'YanxueDetail',
        component: () =>
            import('@/views/Yanxue/YanxueDetail.vue'),
        meta: {
            title: '研学'

        }
    }, {
        path: '/achievements',
        name: 'achievements',
        component: () =>
            import('@/views/Yanxue/achievements.vue'),
        meta: {
            title: '研学成果'

        }
    }, {
        path: '/achievementsOne',
        name: 'achievementsOne',
        component: () =>
            import('@/views/Yanxue/achievementsOne.vue'),
        meta: {
            title: '研学成果'

        }
    }, {
        path: '/chooseSchoolOne',
        name: 'chooseSchoolOne',
        component: () =>
            import('@/views/Yanxue/chooseSchoolOne.vue'),
        meta: {
            title: '研学成果'

        }
    }, {
        path: '/pageDetails',
        name: 'pageDetails',
        component: () =>
            import('@/views/Yanxue/pageDetails.vue'),
        meta: {
            title: '研学成果'

        }
    },
]

const router = new VueRouter({
    mode: 'hash',
    base: process.env.BASE_URL,
    routes
})
router.beforeEach((to, from, next) => {
    /* 路由发生变化修改页面title */
    if (to.meta.title) {
        // console.log(to)
        // document.title = to.meta.title
        ZWJSBridge.setTitle({
            "title": to.meta.title
        })
    }
    next()
})

export default router