完善团课前后端交互
This commit is contained in:
@@ -18,7 +18,10 @@
|
||||
:time-range-text="timeRangeText"
|
||||
:sort-options="sortOptions"
|
||||
v-model:sort-index="sortIndex"
|
||||
:course-types="courseTypes"
|
||||
:current-course-type-id="courseType"
|
||||
@time-pick="showTimePicker = true"
|
||||
@course-type-change="onCourseTypeChange"
|
||||
ref="filterSectionRef"
|
||||
/>
|
||||
|
||||
@@ -79,7 +82,7 @@ import TimePeriodSelector from '@/components/groupCourse/TimePeriodSelector.vue'
|
||||
import TimeRangePicker from '@/components/groupCourse/TimeRangePicker.vue'
|
||||
import PageHeader from '@/components/index/PageHeader.vue'
|
||||
import { useGroupCourseList } from '@/composables/useGroupCourseList.js'
|
||||
import { getTypeLabels } from '@/api/groupCourse.js'
|
||||
import { getTypeLabels, getGroupCourseTypes } from '@/api/groupCourse.js'
|
||||
|
||||
// 组件引用
|
||||
const searchBarRef = ref(null)
|
||||
@@ -97,6 +100,8 @@ const {
|
||||
hasMore,
|
||||
searchKeyword,
|
||||
hotKeywords,
|
||||
courseType,
|
||||
courseTypes,
|
||||
sortOptions,
|
||||
sortIndex,
|
||||
timePeriodOptions,
|
||||
@@ -112,6 +117,8 @@ const {
|
||||
handleSearch,
|
||||
onTimePeriodChange,
|
||||
onTimeRangeConfirm,
|
||||
onCourseTypeChange,
|
||||
clearCourseType,
|
||||
handleBooking,
|
||||
goDetail,
|
||||
fetchCourseList,
|
||||
@@ -122,7 +129,11 @@ const {
|
||||
// 组件挂载时调用接口获取团课列表
|
||||
onMounted(async () => {
|
||||
console.log('[list.vue] 页面组件已挂载,开始获取团课列表')
|
||||
await fetchCourseList()
|
||||
// 并行获取课程类型列表和课程列表
|
||||
await Promise.all([
|
||||
fetchCourseTypes(),
|
||||
fetchCourseList()
|
||||
])
|
||||
// 获取所有团课的类型标签
|
||||
await fetchAllCourseTypeLabels()
|
||||
console.log('[list.vue] 可用的搜索参数获取方法:')
|
||||
@@ -133,9 +144,24 @@ onMounted(async () => {
|
||||
console.log(' - getAllSearchParams() 获取所有参数')
|
||||
})
|
||||
|
||||
const fetchCourseTypes = async () => {
|
||||
try {
|
||||
const result = await getGroupCourseTypes()
|
||||
if (result && Array.isArray(result)) {
|
||||
courseTypes.value = result.map(type => ({
|
||||
id: type.id,
|
||||
label: type.typeName
|
||||
}))
|
||||
console.log('[list.vue] 获取课程类型成功:', courseTypes.value)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('[list.vue] 获取课程类型失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
const fetchAllCourseTypeLabels = async () => {
|
||||
const courseTypes = [...new Set(filteredCourseList.value.map(c => c.courseType))]
|
||||
for (const type of courseTypes) {
|
||||
const types = [...new Set(filteredCourseList.value.map(c => c.courseType))]
|
||||
for (const type of types) {
|
||||
if (!courseTypeLabelsCache.value[type]) {
|
||||
try {
|
||||
const result = await getTypeLabels(type)
|
||||
|
||||
Reference in New Issue
Block a user