|
@@ -1,7 +1,8 @@
|
|
|
<script lang="ts" setup>
|
|
<script lang="ts" setup>
|
|
|
import { ref, onMounted } from 'vue'
|
|
import { ref, onMounted } from 'vue'
|
|
|
-import { fetchSubjectConfigInfo } from '@/services/subject/info'
|
|
|
|
|
|
|
+import { fetchSubjectAppInfo } from '@/services/subject/info'
|
|
|
import type { SubjectCatalogResult } from '@/services/subject/catalog'
|
|
import type { SubjectCatalogResult } from '@/services/subject/catalog'
|
|
|
|
|
+import type { SubjectCourseResult } from '@/services/subject/course'
|
|
|
import Lock from '@/components/lock.uvue'
|
|
import Lock from '@/components/lock.uvue'
|
|
|
import Progress from './components/progress.uvue'
|
|
import Progress from './components/progress.uvue'
|
|
|
import Back from '@/components/back.uvue'
|
|
import Back from '@/components/back.uvue'
|
|
@@ -14,11 +15,13 @@ const isLoading = ref(true)
|
|
|
const visible = ref<boolean>(false)
|
|
const visible = ref<boolean>(false)
|
|
|
const dataList = ref<SubjectCatalogResult[]>([])
|
|
const dataList = ref<SubjectCatalogResult[]>([])
|
|
|
const catalog = ref<SubjectCatalogResult>()
|
|
const catalog = ref<SubjectCatalogResult>()
|
|
|
|
|
+const courseList = ref<SubjectCourseResult>()
|
|
|
async function getDataList() {
|
|
async function getDataList() {
|
|
|
const id = dict.getValueByLabelMapByType('index_subject_id')['物理']
|
|
const id = dict.getValueByLabelMapByType('index_subject_id')['物理']
|
|
|
- const res = await fetchSubjectConfigInfo({ id })
|
|
|
|
|
|
|
+ const res = await fetchSubjectAppInfo({ id })
|
|
|
dataList.value = res.catalogList || []
|
|
dataList.value = res.catalogList || []
|
|
|
catalog.value = res?.catalogList?.[0]
|
|
catalog.value = res?.catalogList?.[0]
|
|
|
|
|
+ courseList.value = res?.courseList || []
|
|
|
}
|
|
}
|
|
|
onMounted(async () => {
|
|
onMounted(async () => {
|
|
|
try {
|
|
try {
|
|
@@ -29,10 +32,9 @@ onMounted(async () => {
|
|
|
isLoading.value = false
|
|
isLoading.value = false
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
-function handleSelect(item: SubjectCatalogResult) {
|
|
|
|
|
- catalog.value = item
|
|
|
|
|
- visible.value = false
|
|
|
|
|
-}
|
|
|
|
|
|
|
+const cardsScrollView = ref<any>(null)
|
|
|
|
|
+const categoryRefs = ref<any>()
|
|
|
|
|
+
|
|
|
function handleDetail(item: SubjectCatalogResult) {
|
|
function handleDetail(item: SubjectCatalogResult) {
|
|
|
// if (!item.payFlag && !item.trialPlay) {
|
|
// if (!item.payFlag && !item.trialPlay) {
|
|
|
// uni.showToast({
|
|
// uni.showToast({
|
|
@@ -48,6 +50,31 @@ function handleDetail(item: SubjectCatalogResult) {
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
+function handleSelect(val: SubjectCatalogResult) {
|
|
|
|
|
+ catalog.value = val
|
|
|
|
|
+ visible.value = false
|
|
|
|
|
+ uni.createSelectorQuery().select(`.category-${val.id}`).boundingClientRect().exec((rect) => {
|
|
|
|
|
+ if (cardsScrollView.value && rect[0]) {
|
|
|
|
|
+ cardsScrollView.value.scrollTo({
|
|
|
|
|
+ left: rect[0].left - 215, // 减去顶部偏移
|
|
|
|
|
+ animated: true
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+}
|
|
|
|
|
+async function onScroll(e: any) {
|
|
|
|
|
+ dataList.value.forEach(async (category) => {
|
|
|
|
|
+ const selector = `.category-${category.id}`
|
|
|
|
|
+ await uni.createSelectorQuery().selectAll(selector).boundingClientRect().exec((rects) => {
|
|
|
|
|
+ // 检查元素是否在可视区域内
|
|
|
|
|
+ for (const rect of rects[0]) {
|
|
|
|
|
+ if (rect.left <= 215) {
|
|
|
|
|
+ catalog.value = category
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ })
|
|
|
|
|
+}
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
<template>
|
|
@@ -69,9 +96,10 @@ function handleDetail(item: SubjectCatalogResult) {
|
|
|
<cl-icon name="arrow-left-right-line" color="primary"></cl-icon>
|
|
<cl-icon name="arrow-left-right-line" color="primary"></cl-icon>
|
|
|
</view>
|
|
</view>
|
|
|
<view class="boxs">
|
|
<view class="boxs">
|
|
|
- <scroll-view class="scroll-view_H" direction="horizontal" :show-scrollbar="false">
|
|
|
|
|
- <view class="scroll-view-item_H bg-[white]" v-for="course in catalog?.courseList || []" :key="course.id"
|
|
|
|
|
- @tap="handleDetail(course)">
|
|
|
|
|
|
|
+ <scroll-view class="scroll-view_H" direction="horizontal" :show-scrollbar="false" ref="cardsScrollView"
|
|
|
|
|
+ @scroll="onScroll">
|
|
|
|
|
+ <view class="scroll-view-item_H bg-[white]" v-for="course in courseList || []"
|
|
|
|
|
+ :class="`category-${course.catalogId}`" :key="course.id" @tap="handleDetail(course)" ref="categoryRefs">
|
|
|
<cl-image :src="config.baseUrl + course?.fileList?.[0]?.url" mode="heightFix"
|
|
<cl-image :src="config.baseUrl + course?.fileList?.[0]?.url" mode="heightFix"
|
|
|
class="!w-full !h-[26vh] mb-[2px] rounded-xl"></cl-image>
|
|
class="!w-full !h-[26vh] mb-[2px] rounded-xl"></cl-image>
|
|
|
<text class="text-[16px] font-bold">{{
|
|
<text class="text-[16px] font-bold">{{
|
|
@@ -79,7 +107,7 @@ function handleDetail(item: SubjectCatalogResult) {
|
|
|
<text class="text-[14px] text-[#666]">{{
|
|
<text class="text-[14px] text-[#666]">{{
|
|
|
course.assistantTitle }}</text>
|
|
course.assistantTitle }}</text>
|
|
|
<view>
|
|
<view>
|
|
|
- <Progress :num="2" :percentage="course.sortNum" />
|
|
|
|
|
|
|
+ <Progress :num="2" :percentage="course.courseUserProgress?.mainProgress || 0" />
|
|
|
</view>
|
|
</view>
|
|
|
<Lock v-if="!course.trialPlay && !course.payFlag" :record="course" />
|
|
<Lock v-if="!course.trialPlay && !course.payFlag" :record="course" />
|
|
|
</view>
|
|
</view>
|