提交 3cfa3c2a authored 作者: 王鹏飞's avatar 王鹏飞

bug fixes

上级 6c277199
import cAction from '@action' import store from '@/store'
import { Message } from 'element-ui'
export default class Before { export default class Before {
constructor (opt) { constructor(opt) {
this.opt = opt || {} this.opt = opt || {}
} }
async update (to, from, next) { async update(to, from, next) {
if (to.name === 'studentHelp' || to.name === 'teacherHelp') { if (to.meta.requiredLogin) {
next() // 所有登录页 不进行登录校验
} else if (to.name !== 'login-normal' && to.name !== 'codeLogin' && to.name !== 'forgetPwd') { // 所有登录页 不进行登录校验 const isLogin = await store.dispatch('checkLogin')
const isLogin = await this.isLogin()
if (isLogin) { if (isLogin) {
next() next()
} else { } else {
next({ path: '/login/index?rd=' + encodeURIComponent(to.fullPath) }) // 需要传参并再传回来 store.state.isWeapp ? this.wechatLogin() : next('/login')
} }
return
} }
next()
} }
/* 获取用户信息 */ wechatLogin() {
isLogin () { const appId = 'wxc6044475caf2805a'
if (window.G.UserInfo) return true const wechatRedirectURL =
return cAction.Test.getInfo().then(res => { webConf.isDev === 'production'
window.G.UserInfo = res ? 'https://passport.ezijing.com'
return true : 'https://passport2.ezijing.com'
}).catch(res => { // 回调地址
Message({ type: 'error', message: res.message }) const redirectURI = `${wechatRedirectURL}/rest/wechat/oauth-callback?needCheck=false&identity=transport&redirectUrl=${window.location.href}`
return false // 微信的地址
}) const wechatUrl = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appId}&redirect_uri=${encodeURIComponent(
redirectURI
)}&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect`
// 打开地址
window.location.href = wechatUrl
} }
} }
...@@ -11,12 +11,13 @@ import './assets/rem/rem.js' ...@@ -11,12 +11,13 @@ import './assets/rem/rem.js'
import MetaInfo from 'vue-meta-info' import MetaInfo from 'vue-meta-info'
import modules from './modules' import modules from './modules'
import createBefore from './components/beforeEnter'
// vant // vant
import Vant from 'vant' import Vant from 'vant'
import 'vant/lib/index.css' import 'vant/lib/index.css'
Vue.use(Vant) Vue.use(Vant)
// import createBefore from './components/beforeEnter'
/* 兼容处理 start */ /* 兼容处理 start */
/* 处理低版本浏览器支持axios finally问题 */ /* 处理低版本浏览器支持axios finally问题 */
...@@ -44,11 +45,10 @@ Vue.prototype.VueEvent = new Vue() ...@@ -44,11 +45,10 @@ Vue.prototype.VueEvent = new Vue()
Vue.prototype.wx = window.wx.miniProgram Vue.prototype.wx = window.wx.miniProgram
/* 创建实例之前,通过导航守卫,处理部分逻辑,如:是否直接进入系统 */ /* 创建实例之前,通过导航守卫,处理部分逻辑,如:是否直接进入系统 */
// const before = createBefore() const before = createBefore()
/* 导航守卫 */ /* 导航守卫 */
router.beforeEach((to, from, next) => { router.beforeEach((to, from, next) => {
// before.update(to, from, next) before.update(to, from, next)
next()
}) })
window.G.$instance_vue = new Vue({ window.G.$instance_vue = new Vue({
store, store,
......
...@@ -12,37 +12,43 @@ export default [ ...@@ -12,37 +12,43 @@ export default [
{ {
path: '/exam/answer', path: '/exam/answer',
name: 'examAnswer', name: 'examAnswer',
component: () => import('../pages/courseExam/answer.vue') component: () => import('../pages/courseExam/answer.vue'),
meta: { requiredLogin: true }
}, },
/* 能力自测答题结果 */ /* 能力自测答题结果 */
{ {
path: '/exam/result', path: '/exam/result',
name: 'examResult', name: 'examResult',
component: () => import('../pages/courseExam/answerResult.vue') component: () => import('../pages/courseExam/answerResult.vue'),
meta: { requiredLogin: true }
}, },
/* 能力自测答题结果 */ /* 能力自测答题结果 */
{ {
path: '/exam/courseNode', path: '/exam/courseNode',
name: 'courseNode', name: 'courseNode',
component: () => import('../pages/courseExam/courseNode.vue') component: () => import('../pages/courseExam/courseNode.vue'),
meta: { requiredLogin: true }
}, },
/* 模拟考试 */ /* 模拟考试 */
{ {
path: '/mock/index', path: '/mock/index',
name: 'mockIndex', name: 'mockIndex',
component: () => import('../pages/mockExam/index.vue') component: () => import('../pages/mockExam/index.vue'),
meta: { requiredLogin: true }
}, },
/* 模拟考试答题页面 */ /* 模拟考试答题页面 */
{ {
path: '/mock/answer', path: '/mock/answer',
name: 'mockAnswer', name: 'mockAnswer',
component: () => import('../pages/mockExam/answer.vue') component: () => import('../pages/mockExam/answer.vue'),
meta: { requiredLogin: true }
}, },
/* 模拟考试答题页面 */ /* 模拟考试答题页面 */
{ {
path: '/mock/result', path: '/mock/result',
name: 'mockResult', name: 'mockResult',
component: () => import('../pages/mockExam/answerResult.vue') component: () => import('../pages/mockExam/answerResult.vue'),
meta: { requiredLogin: true }
}, },
/* 如果所有页面都没找到 - 指向 */ /* 如果所有页面都没找到 - 指向 */
{ path: '*', component: () => import('@/components/errorPages/404.vue') }, { path: '*', component: () => import('@/components/errorPages/404.vue') },
...@@ -62,25 +68,29 @@ export default [ ...@@ -62,25 +68,29 @@ export default [
{ {
path: '/course/learn', path: '/course/learn',
name: 'courseLearn', name: 'courseLearn',
component: () => import('../pages/course/learn/index.vue') component: () => import('../pages/course/learn/index.vue'),
meta: { requiredLogin: true }
}, },
// 课程学习详情 // 课程学习详情
{ {
path: '/course/learn/:id', path: '/course/learn/:id',
name: 'courseLearnItem', name: 'courseLearnItem',
component: () => import('../pages/course/learn/item.vue') component: () => import('../pages/course/learn/item.vue'),
meta: { requiredLogin: true }
}, },
// 课程知识点 // 课程知识点
{ {
path: '/course/learn/:courseId/tag/:chapterId', path: '/course/learn/:courseId/tag/:chapterId',
name: 'courseTag', name: 'courseTag',
component: () => import('../pages/course/tag/list.vue') component: () => import('../pages/course/tag/list.vue'),
meta: { requiredLogin: true }
}, },
// 课程知识点详情 // 课程知识点详情
{ {
path: '/course/tag/:id', path: '/course/tag/:id',
name: 'courseTagItem', name: 'courseTagItem',
component: () => import('../pages/course/tag/item.vue') component: () => import('../pages/course/tag/item.vue'),
meta: { requiredLogin: true }
}, },
// 登录 // 登录
{ {
...@@ -92,24 +102,28 @@ export default [ ...@@ -92,24 +102,28 @@ export default [
{ {
path: '/my', path: '/my',
name: 'my', name: 'my',
component: () => import('../pages/my/index.vue') component: () => import('../pages/my/index.vue'),
meta: { requiredLogin: true }
}, },
// 我的-已购课程 // 我的-已购课程
{ {
path: '/my/buyCourses', path: '/my/buyCourses',
name: 'buyCourses', name: 'buyCourses',
component: () => import('../pages/my/buyCourses.vue') component: () => import('../pages/my/buyCourses.vue'),
meta: { requiredLogin: true }
}, },
// 我的-已做试题 // 我的-已做试题
{ {
path: '/my/exam', path: '/my/exam',
name: 'examQuestions', name: 'examQuestions',
component: () => import('../pages/my/examQuestions.vue') component: () => import('../pages/my/examQuestions.vue'),
meta: { requiredLogin: true }
}, },
// 支付 // 支付
{ {
path: '/pay', path: '/pay',
name: 'pay', name: 'pay',
component: () => import('../pages/pay/index.vue') component: () => import('../pages/pay/index.vue'),
meta: { requiredLogin: true }
} }
] ]
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论