import Magix from 'magix' import View from '../../../../view' Magix.applyStyle('@./index.less') Magix.applyStyle('@./advance-classes.less') export default View.extend({ tmpl: '@advance-classes.html', init (options) { this.options = options }, async render () { const lessons = await this.getLessons() this.updater.digest({ lessons }) }, async getLessons () { try { const loc = Magix.Router.parse() const { channelKey, lessonCount } = this.options const index = parseInt(loc.get('index') || '0', 10) const params = { query: JSON.stringify({ size: 30, channelKey }) } const models = [{ name: 'yx_channel_content_findContent_get', params }] const [model] = await this.fetch(models) const data = model.get('data.result', []) if (lessonCount !== undefined) { // 万堂的课程,按周报index获取对应的课程 return data.slice(index * lessonCount, (index + 1) * lessonCount) } else { return data } } catch (error) { this.alert('错误提示', error.msg || error.message || error) } } })