提交 74f029fc authored 作者: lihuihui's avatar lihuihui
<template>
<div style="width: 100%;" id="app">
<!-- <keep-alive :max="5"> -->
<router-view :key="$route.fullPath"></router-view>
<!-- </keep-alive> -->
<router-view :key="$route.fullPath"></router-view>
</div>
</template>
......
......@@ -56,28 +56,33 @@ export default {
methods: {
onClick(data) {
if (this.isTest) {
const query = {
type: 2,
tag_id: data.id,
papersUrl: 'zy/v2/examination/course-papers'
// 知识点测试
const path = `/exam/answer?type=2&tag_id=${data.id}&papersUrl=zy/v2/examination/course-papers`
if (this.isWeapp) {
wx.miniProgram.navigateTo({
url: `/pages/web/index?src=${window.location.origin}${path}`
})
} else {
this.$router.push({ path })
}
this.$router.push({ path: '/exam/answer', query })
return
} else {
this.$emit('change', data)
}
this.$emit('change', data)
},
toggleMore() {
this.showMore = !this.showMore
},
viewMore() {
this.$router.push({
name: 'courseTag',
params: {
courseId: this.courseId,
chapterId: this.data.id
},
query: { is_test: this.isTest ? '1' : '0' }
})
const path = `/course/learn/${this.courseId}/tag/${
this.data.id
}?is_test=${this.isTest ? '1' : '0'}`
if (this.isWeapp) {
wx.miniProgram.navigateTo({
url: `/pages/web/index?src=${window.location.origin}${path}`
})
} else {
this.$router.push({ path })
}
}
},
mounted() {
......
......@@ -39,6 +39,9 @@ export default {
return this.detail.contents
? this.detail.contents.replace(/\n/g, '<br/>')
: ''
},
isWeapp() {
return this.$store.state.isWeapp
}
},
methods: {
......@@ -62,12 +65,14 @@ export default {
},
// 去知识点考试页面
toExamPage() {
const query = {
type: 2,
tag_id: this.detail.id,
papersUrl: 'zy/v2/examination/course-papers'
const path = `/exam/answer?type=2&tag_id=${this.detail.id}&papersUrl=zy/v2/examination/course-papers`
if (this.isWeapp) {
wx.miniProgram.navigateTo({
url: `/pages/web/index?src=${window.location.origin}${path}`
})
} else {
this.$router.push({ path })
}
this.$router.push({ path: '/exam/answer', query })
}
},
beforeMount() {
......
......@@ -49,6 +49,9 @@ export default {
},
isTest() {
return this.$route.query.is_test === '1'
},
isWeapp() {
return this.$store.state.isWeapp
}
},
methods: {
......@@ -71,16 +74,26 @@ export default {
})
},
onClick({ id }) {
if (this.isTest) {
const query = {
type: 2,
tag_id: id,
papersUrl: 'zy/v2/examination/course-papers'
const path = `/exam/answer?type=2&tag_id=${id}&papersUrl=zy/v2/examination/course-papers`
if (this.isWeapp) {
if (this.isTest) {
// 知识点测试
wx.miniProgram.navigateTo({
url: `/pages/web/index?src=${window.location.origin}${path}`
})
} else {
wx.miniProgram.navigateTo({
url: `/pages/web/index?src=${window.location.origin}/course/tag/${id}`
})
}
} else {
if (this.isTest) {
// 知识点测试
this.$router.push({ path })
} else {
this.$router.push({ name: 'courseTagItem', params: { id } })
}
this.$router.push({ path: '/exam/answer', query })
return
}
this.$router.push({ name: 'courseTagItem', params: { id } })
}
},
beforeMount() {
......
......@@ -52,15 +52,18 @@ export default {
methods: {
onClick(data) {
if (this.isTest) {
const query = {
type: 2,
tag_id: data.id,
papersUrl: 'zy/v2/examination/course-papers'
// 知识点测试
const path = `/exam/answer?type=2&tag_id=${data.id}&papersUrl=zy/v2/examination/course-papers`
if (this.isWeapp) {
wx.miniProgram.navigateTo({
url: `/pages/web/index?src=${window.location.origin}${path}`
})
} else {
this.$router.push({ path })
}
this.$router.push({ path: '/exam/answer', query })
return
} else {
this.$emit('change', data)
}
this.$emit('change', data)
},
toggleMore() {
this.showMore = !this.showMore
......
......@@ -49,6 +49,9 @@ export default {
return this.data.contents
? this.data.contents.replace(/\n/g, '<br/>')
: ''
},
isWeapp() {
return this.$store.state.isWeapp
}
},
methods: {
......@@ -60,12 +63,14 @@ export default {
},
// 去知识点考试页面
toExamPage() {
const query = {
type: 2,
tag_id: this.data.id,
papersUrl: 'zy/v2/examination/course-papers'
const path = `/exam/answer?type=2&tag_id=${this.data.id}&papersUrl=zy/v2/examination/course-papers`
if (this.isWeapp) {
wx.miniProgram.navigateTo({
url: `/pages/web/index?src=${window.location.origin}${path}`
})
} else {
this.$router.push({ path })
}
this.$router.push({ path: '/exam/answer', query })
}
},
mounted() {
......
......@@ -86,30 +86,30 @@ export default {
mockIndex: `/pages/web/index?src=${window.location.origin}/mock/index`,
pay: `/pages/web/index?src=${window.location.origin}/pay`
}
const isLogin = requireLogin
? await this.$store.dispatch('checkLogin')
: false
// 未登录
if (requireLogin && !isLogin) {
if (this.isWeapp) {
// 小程序
wx.miniProgram.navigateTo({
url: `/pages/login/index?redirect_uri=${encodeURIComponent(
map[name]
)}`
})
} else {
this.$router.push({ name: 'login' })
}
return
}
// const isLogin = requireLogin
// ? await this.$store.dispatch('checkLogin')
// : false
// // 未登录
// if (requireLogin && !isLogin) {
// if (this.isWeapp) {
// // 小程序
// wx.miniProgram.navigateTo({
// url: `/pages/login/index?redirect_uri=${encodeURIComponent(
// map[name]
// )}`
// })
// } else {
// this.$router.push({ name: 'login' })
// }
// return
// }
if (this.isWeapp) {
// 小程序
wx.miniProgram.navigateTo({ url: map[name] })
return
} else {
// h5
this.$router.push({ name })
}
// h5
this.$router.push({ name })
}
},
beforeMount() {
......
......@@ -110,7 +110,7 @@ export default {
this.$store.commit('setToken', response.data.TGC)
if (this.isWeapp) {
wx.miniProgram.postMessage({ data: { token: response.data.TGC } })
wx.miniProgram.navigateBack({ delta })
wx.miniProgram.navigateBack()
return
}
if (this.redirectURI) {
......@@ -161,7 +161,7 @@ export default {
}
if (Cookies.get('wechat_login_error')) {
Cookies.remove('wechat_login_error', { domain: '.ezijing.com' })
wx.miniProgram.navigateBack({ delta: 2 })
wx.miniProgram.navigateBack()
}
}
}
......
......@@ -56,11 +56,14 @@ export default {
this.getList()
},
onClick(data) {
const url = data.free
? `/pages/free/item?id=${data.course_id}&chapter_id=${data.id}`
: `/pages/web/index?src=${window.location.origin}/course/learn/${data.id}`
wx.miniProgram.navigateTo({ url })
// this.$router.push({ name: 'courseLearnItem', params: { id: data.id } })
if (this.isWeapp) {
const url = data.free
? `/pages/course/free?id=${data.course_id}&chapter_id=${data.id}`
: `/pages/web/index?src=${window.location.origin}/course/learn/${data.id}`
wx.miniProgram.navigateTo({ url })
} else {
this.$router.push({ name: 'courseLearnItem', params: { id: data.id } })
}
}
},
beforeMount() {
......
......@@ -38,6 +38,11 @@ export default {
}
}
},
computed: {
isWeapp() {
return this.$store.state.isWeapp
}
},
methods: {
getList() {
this.loaded = false
......@@ -51,9 +56,12 @@ export default {
this.getList()
},
onClick(data) {
const url = `/pages/web/index?src=${window.location.origin}/course/tag/${data.id}`
wx.miniProgram.navigateTo({ url })
// this.$router.push({ name: 'courseTagItem', params: { id: data.id } })
if (this.isWeapp) {
const url = `/pages/web/index?src=${window.location.origin}/course/tag/${data.id}`
wx.miniProgram.navigateTo({ url })
} else {
this.$router.push({ name: 'courseTagItem', params: { id: data.id } })
}
}
},
beforeMount() {
......
......@@ -64,10 +64,14 @@ export default {
this.getList()
},
onClick(data) {
const url = data.free
? `/pages/free/item?id=${data.course_id}&chapter_id=${data.id}`
: `/pages/course/item?id=${data.course_id}&chapter_id=${data.id}`
wx.miniProgram.navigateTo({ url })
if (this.isWeapp) {
const url = data.free
? `/pages/course/free?id=${data.course_id}&chapter_id=${data.id}`
: `/pages/course/item?id=${data.course_id}&chapter_id=${data.id}`
wx.miniProgram.navigateTo({ url })
} else {
window.alert('请在微信小程序中打开')
}
}
},
beforeMount() {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论