|
|
@@ -3,7 +3,7 @@ import { user } from '@/.cool'
|
|
|
import { ref, onMounted, computed } from 'vue'
|
|
|
import { fetchSubjectAppInfo } from '@/services/subject/info'
|
|
|
import { querySubjectCourseTest } from '@/services/subject/test'
|
|
|
-import type { SubjectCatalogResult } from '@/services/subject/catalog'
|
|
|
+import { type SubjectCatalogResult, querySubjectCatalog } from '@/services/subject/catalog'
|
|
|
import type { SubjectCourseTestResult } from '@/services/subject/test'
|
|
|
import Lock from '@/components/lock.uvue'
|
|
|
import Back from '@/components/back.uvue'
|
|
|
@@ -20,11 +20,10 @@ const catalog = ref<SubjectCatalogResult>()
|
|
|
const testList = ref<SubjectCourseTestResult[]>()
|
|
|
async function getDataList() {
|
|
|
const id = dict.getValueByLabelMapByType('index_subject_id')['物理']
|
|
|
- const res = await fetchSubjectAppInfo({ id })
|
|
|
- dataList.value = res.catalogList || []
|
|
|
- catalog.value = res?.catalogList?.[0]
|
|
|
- const testRes = await querySubjectCourseTest()
|
|
|
- testList.value = testRes || []
|
|
|
+ const res = await querySubjectCatalog({ subjectId: id })
|
|
|
+ dataList.value = res || []
|
|
|
+ catalog.value = res?.[0] as SubjectCatalogResult
|
|
|
+ handleSelect(catalog.value)
|
|
|
|
|
|
}
|
|
|
onMounted(async () => {
|
|
|
@@ -47,57 +46,57 @@ function handleDetail(item: SubjectCourseTestResult) {
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
-const scrollLeft = ref<any>(0)
|
|
|
-function handleSelect(val: SubjectCatalogResult) {
|
|
|
+// const scrollLeft = ref<any>(0)
|
|
|
+async 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:scrollLeft.value + rect[0].left - 50, // 减去顶部偏移
|
|
|
- animated: true
|
|
|
- })
|
|
|
- }
|
|
|
+ const res = await querySubjectCourseTest({
|
|
|
+ catalogId: val.id, pageSize: 20
|
|
|
})
|
|
|
-}
|
|
|
-async function onScroll(e: any) {
|
|
|
- scrollLeft.value = e.detail.scrollLeft
|
|
|
- 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 <= 50&&rect.left>0) {
|
|
|
- catalog.value = category
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
+ testList.value = res || []
|
|
|
+ cardsScrollView.value.scrollTo({
|
|
|
+ left: 0, // 减去顶部偏移
|
|
|
+ animated: true
|
|
|
})
|
|
|
}
|
|
|
+// async function onScroll(e: any) {
|
|
|
+// scrollLeft.value = e.detail.scrollLeft
|
|
|
+// 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 <= 50 && rect.left > 0) {
|
|
|
+// catalog.value = category
|
|
|
+// }
|
|
|
+// }
|
|
|
+// })
|
|
|
+// })
|
|
|
+// }
|
|
|
</script>
|
|
|
|
|
|
<template>
|
|
|
<Loading v-show="isLoading" />
|
|
|
<cl-page v-show="!isLoading">
|
|
|
<Back />
|
|
|
- <image mode="aspectFill" src="https://oss.xiaoxiongcode.com/static/home/2.png" alt="" class="w-full h-full object-cover" />
|
|
|
+ <image mode="aspectFill" src="https://oss.xiaoxiongcode.com/static/home/2.png" alt=""
|
|
|
+ class="w-full h-full object-cover" />
|
|
|
<!-- 顶部右侧光标签 -->
|
|
|
<view class="light-tag" @tap="visible = true">
|
|
|
- <image class="light-icon" v-if="catalog?.fileList?.[0]?.url" :src="config.baseUrl + catalog?.fileList?.[0]?.url">
|
|
|
+ <image class="light-icon" lazy-load v-if="catalog?.ossIconPath" :src="catalog?.ossIconPath">
|
|
|
</image>
|
|
|
<text class="light-text">{{ catalog?.name }}</text>
|
|
|
<cl-icon name="arrow-left-right-line" color="primary"></cl-icon>
|
|
|
</view>
|
|
|
<view class="boxs">
|
|
|
- <scroll-view class="scroll-view_H" direction="horizontal" :show-scrollbar="false" ref="cardsScrollView"
|
|
|
- @scroll="onScroll">
|
|
|
+ <scroll-view class="scroll-view_H" direction="horizontal" :show-scrollbar="false" ref="cardsScrollView">
|
|
|
<view class="scroll-view-item_H bg-[white]" v-for="test in testList || []" :class="`category-${test.catalogId}`"
|
|
|
:key="test.id" @tap="handleDetail(test)" ref="categoryRefs">
|
|
|
<cl-image :src="test.animationImagePath" mode="heightFix"
|
|
|
class="!w-full !h-[28vh] mb-[10px] rounded-xl"></cl-image>
|
|
|
<text class="text-[4vh] font-bold">{{
|
|
|
test.name }}</text>
|
|
|
- <Lock v-if="test?.lockFlag" :record="test" type="course" :finish="test.lockFlag" />
|
|
|
+ <Lock v-if="test?.lockFlag" :record="test" type="course" :finish="!test.lockFlag" />
|
|
|
</view>
|
|
|
</scroll-view>
|
|
|
</view>
|
|
|
@@ -108,7 +107,7 @@ async function onScroll(e: any) {
|
|
|
className: '!p-2'
|
|
|
}" @tap="handleSelect(item)">
|
|
|
<view class="select-item" :class="{ selected: item.id === catalog?.id }">
|
|
|
- <image :src="config.baseUrl + item?.fileList?.[0]?.url" class="w-[30rpx] h-[30rpx] mb-[2px]"></image>
|
|
|
+ <image :src="item?.ossIconPath" class="w-[30rpx] h-[30rpx] mb-[2px]"></image>
|
|
|
<text>{{ item.name }}</text>
|
|
|
</view>
|
|
|
</cl-col>
|