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

bug fixes

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