408249787@qq.com 6 days ago
parent
commit
2af783c613

+ 8 - 10
pages/catalog/index.uvue

@@ -20,10 +20,7 @@ const record = ref<any>()
 async function getDataList() {
   const id = dict.getValueByLabelMapByType('index_subject_id')['物理']
   const res = await querySubjectCatalog({
-    subjectId: id, dataScope: {
-      sortBy: 'asc',
-      sortName: 'sortNum',
-    }
+    subjectId: id
   })
   dataList.value = res || []
   catalog.value = res?.[0] as SubjectCatalogResult
@@ -62,12 +59,13 @@ async function handleSelect(val: SubjectCatalogResult) {
   catalog.value = val
   visible.value = false
   const res = await getSubjectCoursePage({
-    catalogId: val.id, dataScope: {
-      sortBy: 'asc',
-      sortName: 'sortNum',
-    },
+    catalogId: val.id, pageSize: 20
   })
   courseList.value = res.rows || []
+  cardsScrollView.value.scrollTo({
+    left: 0, // 减去顶部偏移
+    animated: true
+  })
   // uni.createSelectorQuery().select(`.category-${val.id}`).boundingClientRect().exec(async (rect) => {
   //   if (cardsScrollView.value && rect[0]) {
   //     cardsScrollView.value.scrollTo({
@@ -134,7 +132,7 @@ function handleClose(val: boolean) {
       <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">
+      <scroll-view class="scroll-view_H" direction="horizontal" :show-scrollbar="false" ref="cardsScrollView">
         <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"
@@ -150,7 +148,7 @@ function handleClose(val: boolean) {
             <Progress :num="6" size="12px"
               :percentage="course.courseUserProgress ? course.courseUserProgress?.status == 1 ? 6 : course.courseUserProgress?.assistantProgress : 0" />
           </view>
-          <Lock v-if="(!course.trialPlay && !record.payFlag) || !course.platFormLock || course.studyUnitLock"
+          <Lock v-if="(!course.trialPlay && !course.payFlag) || !course.platFormLock || course.studyUnitLock"
             :record="course" type="course" :studyUnitLock="course.studyUnitLock" :finish="course.platFormLock"
             @close="handleClose" />
         </view>

+ 2 - 8
pages/chinese/index.uvue

@@ -20,10 +20,7 @@ const finish = ref(false)
 async function getDataList() {
   const id = dict.getValueByLabelMapByType('index_subject_id')['语文']
   const res = await querySubjectCatalog({
-    subjectId: id, dataScope: {
-      sortBy: 'asc',
-      sortName: 'sort_num',
-    }
+    subjectId: id
   })
   dataList.value = res || []
   catalog.value = res?.[0] as SubjectCatalogResult
@@ -43,10 +40,7 @@ async function handleSelect(val: SubjectCatalogResult) {
 async function getInfo() {
   loading.value = true
   const res = await getSubjectCoursePage({
-    catalogId: catalog.value?.id, pageSize: 12, pageNum: pageNum.value, dataScope: {
-      sortBy: 'asc',
-      sortName: 'sort_num',
-    },
+    catalogId: catalog.value?.id, pageSize: 12, pageNum: pageNum.value,
   })
   courseList.value = [...courseList.value, ...(res.rows || [])]
   loading.value = false

+ 2 - 8
pages/english/index.uvue

@@ -19,10 +19,7 @@ const loading = ref(false)
 const finish = ref(false)
 async function getDataList() {
   const res = await querySubjectCatalog({
-    subjectId: router.query().id, dataScope: {
-      sortBy: 'asc',
-      sortName: 'sort_num',
-    }
+    subjectId: router.query().id
   })
   dataList.value = res || []
   catalog.value = res?.[0] as SubjectCatalogResult
@@ -42,10 +39,7 @@ async function handleSelect(val: SubjectCatalogResult) {
 async function getInfo() {
   loading.value = true
   const res = await getSubjectCoursePage({
-    catalogId: catalog.value?.id, pageSize: 12, pageNum: pageNum.value, dataScope: {
-      sortBy: 'asc',
-      sortName: 'sort_num',
-    },
+    catalogId: catalog.value?.id, pageSize: 12, pageNum: pageNum.value
   })
   courseList.value = [...courseList.value, ...(res.rows || [])]
   loading.value = false

+ 2 - 8
pages/math/index.uvue

@@ -20,10 +20,7 @@ const finish = ref(false)
 async function getDataList() {
   const id = dict.getValueByLabelMapByType('index_subject_id')['数学']
   const res = await querySubjectCatalog({
-    subjectId: id, dataScope: {
-      sortBy: 'asc',
-      sortName: 'sort_num',
-    }
+    subjectId: id
   })
   dataList.value = res || []
   catalog.value = res?.[0] as SubjectCatalogResult
@@ -43,10 +40,7 @@ async function handleSelect(val: SubjectCatalogResult) {
 async function getInfo() {
   loading.value = true
   const res = await getSubjectCoursePage({
-    catalogId: catalog.value?.id, pageSize: 12, pageNum: pageNum.value, dataScope: {
-      sortBy: 'asc',
-      sortName: 'sort_num',
-    },
+    catalogId: catalog.value?.id, pageSize: 12, pageNum: pageNum.value
   })
   courseList.value = [...courseList.value, ...(res.rows || [])]
   loading.value = false

+ 2 - 8
pages/mix/index.uvue

@@ -19,10 +19,7 @@ const loading = ref(false)
 const finish = ref(false)
 async function getDataList() {
   const res = await querySubjectCatalog({
-    subjectId: router.query().id, dataScope: {
-      sortBy: 'asc',
-      sortName: 'sort_num',
-    }
+    subjectId: router.query().id
   })
   dataList.value = res || []
   catalog.value = res?.[0] as SubjectCatalogResult
@@ -42,10 +39,7 @@ async function handleSelect(val: SubjectCatalogResult) {
 async function getInfo() {
   loading.value = true
   const res = await getSubjectCoursePage({
-    catalogId: catalog.value?.id, pageSize: 12, pageNum: pageNum.value, dataScope: {
-      sortBy: 'asc',
-      sortName: 'sort_num',
-    },
+    catalogId: catalog.value?.id, pageSize: 12, pageNum: pageNum.value
   })
   courseList.value = [...courseList.value, ...(res.rows || [])]
   loading.value = false

+ 33 - 34
pages/test/index.uvue

@@ -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>

+ 1 - 0
services/subject/course.ts

@@ -28,6 +28,7 @@ export interface SubjectCourseResult {
     ossIconPath?: string
     testItem?: any
     diaryItem?: any
+    payFlag?: boolean
     courseUserProgress?: any
     fileList?: FileList[]
 }