|
@@ -1,8 +1,8 @@
|
|
|
<script lang="ts" setup>
|
|
<script lang="ts" setup>
|
|
|
import { ref, onMounted } from 'vue'
|
|
import { ref, onMounted } from 'vue'
|
|
|
import { fetchSubjectAppInfo } from '@/services/subject/info'
|
|
import { fetchSubjectAppInfo } from '@/services/subject/info'
|
|
|
-import type { SubjectCatalogResult } from '@/services/subject/catalog'
|
|
|
|
|
-import type { SubjectCourseResult } from '@/services/subject/course'
|
|
|
|
|
|
|
+import { type SubjectCatalogResult, querySubjectCatalog } from '@/services/subject/catalog'
|
|
|
|
|
+import { type SubjectCourseResult, getSubjectCoursePage } 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'
|
|
@@ -19,11 +19,16 @@ const courseList = ref<SubjectCourseResult[]>()
|
|
|
const record = ref<any>()
|
|
const record = ref<any>()
|
|
|
async function getDataList() {
|
|
async function getDataList() {
|
|
|
const id = dict.getValueByLabelMapByType('index_subject_id')['物理']
|
|
const id = dict.getValueByLabelMapByType('index_subject_id')['物理']
|
|
|
- const res = await fetchSubjectAppInfo({ id })
|
|
|
|
|
- record.value = res
|
|
|
|
|
- dataList.value = res.catalogList || []
|
|
|
|
|
- catalog.value = res?.catalogList?.[0]
|
|
|
|
|
- courseList.value = res?.courseList || []
|
|
|
|
|
|
|
+ const res = await querySubjectCatalog({
|
|
|
|
|
+ subjectId: id, dataScope: {
|
|
|
|
|
+ sortBy: 'asc',
|
|
|
|
|
+ sortName: 'sortNum',
|
|
|
|
|
+ },
|
|
|
|
|
+ })
|
|
|
|
|
+ dataList.value = res || []
|
|
|
|
|
+ catalog.value = res?.[0] as SubjectCatalogResult
|
|
|
|
|
+ handleSelect(catalog.value)
|
|
|
|
|
+ // courseList.value = res?.courseList || []
|
|
|
}
|
|
}
|
|
|
onShow(async () => {
|
|
onShow(async () => {
|
|
|
isLoading.value = true
|
|
isLoading.value = true
|
|
@@ -52,18 +57,25 @@ function handleDetail(item: SubjectCatalogResult) {
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
-const scrollLeft = ref<any>(0)
|
|
|
|
|
|
|
+// const scrollLeft = ref<any>(0)
|
|
|
async function handleSelect(val: SubjectCatalogResult) {
|
|
async function handleSelect(val: SubjectCatalogResult) {
|
|
|
catalog.value = val
|
|
catalog.value = val
|
|
|
visible.value = false
|
|
visible.value = false
|
|
|
- uni.createSelectorQuery().select(`.category-${val.id}`).boundingClientRect().exec(async (rect) => {
|
|
|
|
|
- if (cardsScrollView.value && rect[0]) {
|
|
|
|
|
- cardsScrollView.value.scrollTo({
|
|
|
|
|
- left: scrollLeft.value + rect[0].left - dict.getWindowHeight() / 2, // 减去顶部偏移
|
|
|
|
|
- animated: true
|
|
|
|
|
- })
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ const res = await getSubjectCoursePage({
|
|
|
|
|
+ catalogId: val.id, dataScope: {
|
|
|
|
|
+ sortBy: 'asc',
|
|
|
|
|
+ sortName: 'sortNum',
|
|
|
|
|
+ },
|
|
|
})
|
|
})
|
|
|
|
|
+ courseList.value = res.rows || []
|
|
|
|
|
+ // uni.createSelectorQuery().select(`.category-${val.id}`).boundingClientRect().exec(async (rect) => {
|
|
|
|
|
+ // if (cardsScrollView.value && rect[0]) {
|
|
|
|
|
+ // cardsScrollView.value.scrollTo({
|
|
|
|
|
+ // left: scrollLeft.value + rect[0].left - dict.getWindowHeight() / 2, // 减去顶部偏移
|
|
|
|
|
+ // animated: true
|
|
|
|
|
+ // })
|
|
|
|
|
+ // }
|
|
|
|
|
+ // })
|
|
|
}
|
|
}
|
|
|
// const debouncedOnScroll = debounce(async () => {
|
|
// const debouncedOnScroll = debounce(async () => {
|
|
|
// if(isScrolling.value){
|
|
// if(isScrolling.value){
|
|
@@ -81,21 +93,20 @@ async function handleSelect(val: SubjectCatalogResult) {
|
|
|
// })
|
|
// })
|
|
|
// })
|
|
// })
|
|
|
// }, 300)
|
|
// }, 300)
|
|
|
-function debouncedOnScroll(e: any) {
|
|
|
|
|
- console.log(e);
|
|
|
|
|
- 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 <= (dict.getWindowHeight() / 2) && rect.left > 0) {
|
|
|
|
|
- catalog.value = category
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
- })
|
|
|
|
|
-}
|
|
|
|
|
|
|
+// function debouncedOnScroll(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 <= (dict.getWindowHeight() / 2) && rect.left > 0) {
|
|
|
|
|
+// catalog.value = category
|
|
|
|
|
+// return
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
+// })
|
|
|
|
|
+// })
|
|
|
|
|
+// }
|
|
|
function handleClose(val: boolean) {
|
|
function handleClose(val: boolean) {
|
|
|
if (val) {
|
|
if (val) {
|
|
|
getDataList()
|
|
getDataList()
|
|
@@ -124,11 +135,10 @@ function handleClose(val: boolean) {
|
|
|
<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" ref="cardsScrollView"
|
|
|
|
|
- @scroll="debouncedOnScroll">
|
|
|
|
|
- <view class="scroll-view-item_H bg-[white]" v-for="course in courseList || []"
|
|
|
|
|
- :class="`category-${course.catalogId}`" :key="course.id" @tap="handleDetail(course)">
|
|
|
|
|
- <cl-image lazy-load :src="config.baseUrl + course?.fileList?.[0]?.url" mode="scaleToFill"
|
|
|
|
|
|
|
+ <scroll-view class="scroll-view_H" direction="horizontal" :show-scrollbar="false">
|
|
|
|
|
+ <view class="scroll-view-item_H bg-[white]" v-for="course in courseList || []" :key="course.id"
|
|
|
|
|
+ @tap="handleDetail(course)">
|
|
|
|
|
+ <cl-image lazy-load :src="course?.ossIconPath" mode="scaleToFill"
|
|
|
class="!w-full !h-[28vh] mb-[5px] rounded-xl"></cl-image>
|
|
class="!w-full !h-[28vh] mb-[5px] rounded-xl"></cl-image>
|
|
|
<cl-text ellipsis :pt="{
|
|
<cl-text ellipsis :pt="{
|
|
|
className: '!text-[4vh] !font-bold'
|
|
className: '!text-[4vh] !font-bold'
|
|
@@ -141,8 +151,9 @@ function handleClose(val: boolean) {
|
|
|
<Progress :num="6" size="12px"
|
|
<Progress :num="6" size="12px"
|
|
|
:percentage="course.courseUserProgress ? course.courseUserProgress?.status == 1 ? 6 : course.courseUserProgress?.assistantProgress : 0" />
|
|
:percentage="course.courseUserProgress ? course.courseUserProgress?.status == 1 ? 6 : course.courseUserProgress?.assistantProgress : 0" />
|
|
|
</view>
|
|
</view>
|
|
|
- <Lock v-if="(!course.trialPlay && !record.payFlag) || !course.platFormLock" :record="course" type="course"
|
|
|
|
|
- :finish="course.platFormLock" @close="handleClose" />
|
|
|
|
|
|
|
+ <Lock v-if="(!course.trialPlay && !record.payFlag) || !course.platFormLock || course.studyUnitLock"
|
|
|
|
|
+ :record="course" type="course" :studyUnitLock="course.studyUnitLock" :finish="course.platFormLock"
|
|
|
|
|
+ @close="handleClose" />
|
|
|
</view>
|
|
</view>
|
|
|
</scroll-view>
|
|
</scroll-view>
|
|
|
</view>
|
|
</view>
|
|
@@ -170,7 +181,7 @@ function handleClose(val: boolean) {
|
|
|
className: '!p-2'
|
|
className: '!p-2'
|
|
|
}" @tap="handleSelect(item)">
|
|
}" @tap="handleSelect(item)">
|
|
|
<view class="select-item" :class="{ selected: item.id === catalog?.id }">
|
|
<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>
|
|
<text>{{ item.name }}</text>
|
|
|
</view>
|
|
</view>
|
|
|
</cl-col>
|
|
</cl-col>
|