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

fix: 修复课程详情页点击'继续学习'可能出错的问题

上级 be5471e9
......@@ -75,12 +75,21 @@ Page({
return item.children.length
})
this.setData({ loaded: true, course: response })
const activeChapter = this.findChapter(this.data.chapterId, response.chapters)
let activeChapter = null
if (this.data.chapterId) {
activeChapter = this.findChapter(this.data.chapterId, response.chapters)
} else {
activeChapter = response.chapters
.reduce((result, item) => {
return result.concat(item.children)
}, [])
.shift()
}
if (activeChapter) {
// 更新选中的章节
this.updateActiveChapter(activeChapter)
// 设置默认展开
this.setData({ 'collapseActiveNames[0]': activeChapter.parent_id })
this.setData({ 'collapseActiveNames[0]': activeChapter.parent_id, chapterId: activeChapter.id })
}
})
},
......
......@@ -256,7 +256,7 @@ Page({
*/
startLearn: function (e) {
let _data = this.data.latestVideo
let cid = _data.cid, sid = _data.sid;
let cid = this.data.headerInfo.id, sid = this.data.headerInfo.sid;
wx.navigateTo({
url: `/pages/course/player?semester_id=${sid}&id=${cid}&chapter_id=${_data.id}`
})
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论