提交 598ad6ef authored 作者: 王鹏飞's avatar 王鹏飞

bug fixes

上级 d0a345bd
...@@ -11,7 +11,10 @@ ...@@ -11,7 +11,10 @@
{{subItem.name}} {{subItem.name}}
<template v-if="subItem.free">(免费)</template> <template v-if="subItem.free">(免费)</template>
</div> </div>
<div class="progress" v-if="showProgress">{{ progressText(subItem.video_progress) }}</div> <div
class="progress"
v-if="showProgress"
>{{ progressText(subItem.video_progress, subItem.free) }}</div>
</li> </li>
</ul> </ul>
</van-collapse-item> </van-collapse-item>
...@@ -36,10 +39,10 @@ export default { ...@@ -36,10 +39,10 @@ export default {
} }
}, },
methods: { methods: {
progressText(value) { progressText(value, isFree) {
value = parseInt(value) value = parseInt(value)
if (value === 0) { if (value === 0) {
return this.isVip ? '未开始' : '未开通' return isFree || this.isVip ? '未开始' : '未开通'
} }
if (value === 100) { if (value === 100) {
return '已学完' return '已学完'
......
...@@ -24,6 +24,9 @@ import CourseListItem from './CourseListItem.vue' ...@@ -24,6 +24,9 @@ import CourseListItem from './CourseListItem.vue'
export default { export default {
name: 'CourseList', name: 'CourseList',
components: { CourseListItem }, components: { CourseListItem },
props: {
requestCallback: Function
},
data() { data() {
return { return {
loaded: false, loaded: false,
...@@ -35,7 +38,8 @@ export default { ...@@ -35,7 +38,8 @@ export default {
api api
.getCourseModule() .getCourseModule()
.then(response => { .then(response => {
this.list = response this.list = this.requestCallback ? this.requestCallback(response) : response
this.$emit('request-success', response)
}) })
.finally(() => { .finally(() => {
this.loaded = true this.loaded = true
......
...@@ -139,16 +139,19 @@ export default { ...@@ -139,16 +139,19 @@ export default {
domain: '.ezijing.com' domain: '.ezijing.com'
}) })
this.$store.commit('setToken', response.data.TGC) this.$store.commit('setToken', response.data.TGC)
if (this.isWeapp) { // 延迟1秒,要看提示语
wx.miniProgram.postMessage({ data: { token: response.data.TGC } }) setTimeout(() => {
wx.miniProgram.navigateBack() if (this.isWeapp) {
return wx.miniProgram.postMessage({ data: { token: response.data.TGC } })
} wx.miniProgram.navigateBack()
if (this.redirectURI) { return
window.location.href = this.redirectURI }
} else { if (this.redirectURI) {
this.$router.replace('/') window.location.href = this.redirectURI
} } else {
this.$router.replace('/')
}
}, 1000)
} else { } else {
this.$toast(response.msg) this.$toast(response.msg)
} }
......
<template> <template>
<div class="main-container" style="margin:0 0.15rem"> <div class="main-container" style="margin:0 0.15rem">
<course-list :show-progress="true" @on-click="handleClick"> <course-list :show-progress="true" :requestCallback="requestCallback" @on-click="handleClick">
<template #empty> <template #empty>
<van-empty description="您还没有学习课程,快快开始学习吧!" /> <van-empty description="您还没有学习课程,快快开始学习吧!" />
</template> </template>
...@@ -26,6 +26,15 @@ export default { ...@@ -26,6 +26,15 @@ export default {
} }
}, },
methods: { methods: {
requestCallback(response) {
// 扁平数据
const flattenList = response.reduce((result, item) => {
return result.concat(item.child)
}, [])
// 查找有没有进度,没有进度返回空数组
const found = flattenList.find(item => item.video_progress)
return found ? response : []
},
handleClick(data) { handleClick(data) {
if (this.isWeapp) { if (this.isWeapp) {
const url = `/pages/web/index?src=${window.location.origin}/my/learn/${data.id}` const url = `/pages/web/index?src=${window.location.origin}/my/learn/${data.id}`
......
...@@ -57,10 +57,10 @@ export default { ...@@ -57,10 +57,10 @@ export default {
}, },
onClick(data) { onClick(data) {
if (this.isWeapp) { if (this.isWeapp) {
const url = data.free // const url = data.free
? `/pages/course/free?id=${data.id}` // ? `/pages/course/free?id=${data.id}`
: `/pages/web/index?src=${window.location.origin}/course/learn/${data.id}` // : `/pages/web/index?src=${window.location.origin}/course/learn/${data.id}`
wx.miniProgram.navigateTo({ url }) wx.miniProgram.navigateTo({ url: `/pages/web/index?src=${window.location.origin}/course/learn/${data.id}` })
} else { } else {
this.$router.push({ name: 'courseLearnItem', params: { id: data.id } }) this.$router.push({ name: 'courseLearnItem', params: { id: data.id } })
} }
......
...@@ -69,10 +69,10 @@ export default { ...@@ -69,10 +69,10 @@ export default {
}, },
onClick(data) { onClick(data) {
if (this.isWeapp) { if (this.isWeapp) {
const url = data.free // const url = data.free
? `/pages/course/free?id=${data.course_id}&chapter_id=${data.id}` // ? `/pages/course/free?id=${data.course_id}&chapter_id=${data.id}`
: `/pages/course/item?id=${data.course_id}&chapter_id=${data.id}` // : `/pages/course/item?id=${data.course_id}&chapter_id=${data.id}`
wx.miniProgram.navigateTo({ url }) wx.miniProgram.navigateTo({ url: `/pages/course/item?id=${data.course_id}&chapter_id=${data.id}` })
} else { } else {
window.alert('请在微信小程序中打开') window.alert('请在微信小程序中打开')
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<div class="main-container"> <div class="main-container">
<app-search-bar v-model="searchValue" @search="onSearch" /> <app-search-bar v-model="searchValue" @search="onSearch" />
<div class="search-tips" v-if="!searchValue"> <div class="search-tips" v-if="!searchValue">
<div class="search-tips-item" v-if="historyList.length"> <div class="search-tips-item" v-if="historyList.length && isLogin">
<h3 class="search-tips__title">搜索历史</h3> <h3 class="search-tips__title">搜索历史</h3>
<ul class="search-tips__list"> <ul class="search-tips__list">
<li <li
...@@ -82,6 +82,9 @@ export default { ...@@ -82,6 +82,9 @@ export default {
} }
}, },
computed: { computed: {
isLogin() {
return this.$store.state.isLogin
},
// 搜索发现 // 搜索发现
featureList() { featureList() {
// 最多显示10条 // 最多显示10条
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论