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

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

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