|
@@ -27,7 +27,7 @@
|
|
|
:key="idx"
|
|
:key="idx"
|
|
|
class="tag-item"
|
|
class="tag-item"
|
|
|
:class="{ active: categoryIndex === idx }"
|
|
:class="{ active: categoryIndex === idx }"
|
|
|
- @click="categoryIndex = idx"
|
|
|
|
|
|
|
+ @click="onSelectCategory(idx)"
|
|
|
>
|
|
>
|
|
|
<text>{{ cat }}</text>
|
|
<text>{{ cat }}</text>
|
|
|
</view>
|
|
</view>
|
|
@@ -141,6 +141,8 @@
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
|
|
+import { listPublicCourseCategory, listPublicCourse } from '@/api/home.js'
|
|
|
|
|
+
|
|
|
export default {
|
|
export default {
|
|
|
data() {
|
|
data() {
|
|
|
return {
|
|
return {
|
|
@@ -148,15 +150,9 @@ export default {
|
|
|
tabIndex: 0,
|
|
tabIndex: 0,
|
|
|
categoryExpand: true,
|
|
categoryExpand: true,
|
|
|
categoryIndex: 0,
|
|
categoryIndex: 0,
|
|
|
- categories: ['全部', '歌唱艺术', '太极养生', '防骗指南', '手机摄影', '棋牌益智', '用药指导', '膳食营养', '慢病管理'],
|
|
|
|
|
- courseList: [
|
|
|
|
|
- { title: '刘金的《0基础金曲演唱速练课》', views: '9239', cover: '' },
|
|
|
|
|
- { title: '邹方斌讲《毛笔书法修心课》', views: '10.8w', cover: '' },
|
|
|
|
|
- { title: '张斌《元气八段锦》系列课', views: '2.5w', cover: '' },
|
|
|
|
|
- { title: '翔哥精讲摄影课—手机微距拍摄技巧...', views: '100w+', cover: '' },
|
|
|
|
|
- { title: '道家智慧 入门21讲', views: '1.2w', cover: '' },
|
|
|
|
|
- { title: '入门进阶必修 瑜伽呼吸全精讲', views: '3.6w', cover: '' }
|
|
|
|
|
- ],
|
|
|
|
|
|
|
+ categories: [],
|
|
|
|
|
+ categoryRows: [],
|
|
|
|
|
+ courseList: [],
|
|
|
recentList: [
|
|
recentList: [
|
|
|
{
|
|
{
|
|
|
date: '2026-02-08',
|
|
date: '2026-02-08',
|
|
@@ -181,13 +177,55 @@ export default {
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
onLoad() {
|
|
onLoad() {
|
|
|
- // 若无最近学习,可置空 recentList 显示空态
|
|
|
|
|
- // this.recentList = [];
|
|
|
|
|
|
|
+ // 默认先查一次课程(不带分类参数),再加载分类标签
|
|
|
|
|
+ this.initPublicCourseData()
|
|
|
},
|
|
},
|
|
|
methods: {
|
|
methods: {
|
|
|
|
|
+ async initPublicCourseData() {
|
|
|
|
|
+ await this.getCategoryList()
|
|
|
|
|
+ await this.getCourseList()
|
|
|
|
|
+ },
|
|
|
|
|
+ async getCategoryList() {
|
|
|
|
|
+ try {
|
|
|
|
|
+ const res = await listPublicCourseCategory({ pageNum: 1, pageSize: 10 })
|
|
|
|
|
+ const list = (res && res.data && res.data.list) || []
|
|
|
|
|
+ this.categoryRows = [{ cateId: null, cateName: '全部' }, ...list]
|
|
|
|
|
+ this.categories = this.categoryRows.map(item => item.cateName || '')
|
|
|
|
|
+ } catch (e) {
|
|
|
|
|
+ this.categoryRows = [{ cateId: null, cateName: '全部' }]
|
|
|
|
|
+ this.categories = ['全部']
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ async getCourseList(subCateId) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ const params = { pageNum: 1, pageSize: 10 }
|
|
|
|
|
+ if (subCateId) {
|
|
|
|
|
+ params.subCateId = subCateId
|
|
|
|
|
+ }
|
|
|
|
|
+ const res = await listPublicCourse(params)
|
|
|
|
|
+ const list = (res && res.data && res.data.list) || []
|
|
|
|
|
+ this.courseList = list.map(item => ({
|
|
|
|
|
+ courseId: item.courseId,
|
|
|
|
|
+ title: item.courseTitle || item.courseName || '',
|
|
|
|
|
+ views: item.watchUserCount || 0,
|
|
|
|
|
+ cover: item.imgUrl || ''
|
|
|
|
|
+ }))
|
|
|
|
|
+ } catch (e) {
|
|
|
|
|
+ this.courseList = []
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ onSelectCategory(idx) {
|
|
|
|
|
+ this.categoryIndex = idx
|
|
|
|
|
+ const selected = this.categoryRows[idx]
|
|
|
|
|
+ const subCateId = selected && selected.cateId ? selected.cateId : null
|
|
|
|
|
+ this.getCourseList(subCateId)
|
|
|
|
|
+ },
|
|
|
onCourseClick(course) {
|
|
onCourseClick(course) {
|
|
|
|
|
+ if (course && course.courseId) {
|
|
|
|
|
+ uni.navigateTo({ url: '/pages_course/learn?courseId=' + course.courseId + '&type=1' })
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
uni.showToast({ title: course.title || '立即观看', icon: 'none' })
|
|
uni.showToast({ title: course.title || '立即观看', icon: 'none' })
|
|
|
- // uni.navigateTo({ url: '/pages_course/videovip?id=' + (course.id || '') })
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|