Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
T
transport-show-h5
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
EzijingWeb
transport-show-h5
Commits
3cfa3c2a
提交
3cfa3c2a
authored
7月 08, 2020
作者:
王鹏飞
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
bug fixes
上级
6c277199
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
55 行增加
和
39 行删除
+55
-39
Before.js
src/components/beforeEnter/Before.js
+23
-21
main.js
src/main.js
+4
-4
routes.js
src/router/routes.js
+28
-14
没有找到文件。
src/components/beforeEnter/Before.js
浏览文件 @
3cfa3c2a
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
}
}
}
}
src/main.js
浏览文件 @
3cfa3c2a
...
@@ -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
,
...
...
src/router/routes.js
浏览文件 @
3cfa3c2a
...
@@ -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
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论