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

bug fixes

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