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