408249787@qq.com 16 jam lalu
induk
melakukan
48b022fbdd
3 mengubah file dengan 14 tambahan dan 7 penghapusan
  1. 7 2
      .cool/store/user.ts
  2. 3 2
      pages/catalog/detail.uvue
  3. 4 3
      pages/catalog/index.uvue

+ 7 - 2
.cool/store/user.ts

@@ -17,7 +17,10 @@ export class User {
 	 * 用户信息,响应式对象
 	 */
 	info = ref<UserInfo | null>(null);
-
+	/**
+	 * 用户信息,响应式对象
+	 */
+	courseId = ref<string | null>(null);
 	/**
 	 * 当前token,字符串或null
 	 */
@@ -71,7 +74,9 @@ export class User {
 		// 持久化到本地存储
 		storage.set("userInfo", data, 0);
 	}
-
+	setCourseId(id: string) {
+		this.courseId.value = id
+	}
 	/**
 	 * 更新用户信息(本地与服务端同步)
 	 * @param data 新的用户信息

+ 3 - 2
pages/catalog/detail.uvue

@@ -3,7 +3,7 @@ import Back from '@/components/back.uvue'
 import Loading from '@/components/loading.uvue'
 import { ref, onMounted, watch, nextTick, onUnmounted } from 'vue'
 import { type SubjectCourseResult, fetchSubjectCourseApp, updateSubjectProgress } from '@/services/subject/course'
-import { router } from '@/.cool'
+import { router, user } from '@/.cool'
 const isLoading = ref(true)
 const showControls = ref(true)
 const showVideo = ref(true)
@@ -93,12 +93,13 @@ onShow(async () => {
   if (status.value === 'success') {
     if (progress2.value === 6) {
       if (progressStatus.value === 0) {
-        await updateSubjectProgress({
+        const res = await updateSubjectProgress({
           courseId: course.value?.id,
           mainProgress: 1,
           assistantProgress: 6,
           status: 1
         })
+        user.setCourseId(res as string)
       }
       router.back()
       return

+ 4 - 3
pages/catalog/index.uvue

@@ -9,7 +9,7 @@ import Back from '@/components/back.uvue'
 import Loading from '@/components/loading.uvue'
 import { config } from '@/config'
 import { dict } from '@/.cool/store'
-import { router, debounce } from "@/.cool";
+import { router, debounce, user } from "@/.cool";
 
 const isLoading = ref(true)
 const visible = ref<boolean>(false)
@@ -27,7 +27,7 @@ async function getDataList() {
   handleSelect(catalog.value)
   // courseList.value = res?.courseList || []
 }
-onShow(async () => {
+onMounted(async () => {
   isLoading.value = true
   try {
     await getDataList()
@@ -147,7 +147,8 @@ 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 && !course.payFlag) || !course.platFormLock || course.studyUnitLock"
+          <Lock
+            v-if="user.courseId.value !== course.id && ((!course.trialPlay && !course.payFlag) || !course.platFormLock || course.studyUnitLock)"
             :record="course" type="course" :studyUnitLock="course.studyUnitLock" :finish="course.platFormLock"
             @close="handleClose" />
         </view>