소스 검색

下一题

skyblued 2 년 전
부모
커밋
aebdf27730
1개의 변경된 파일7개의 추가작업 그리고 3개의 파일을 삭제
  1. 7 3
      src/views/exercise-after-class/index.tsx

+ 7 - 3
src/views/exercise-after-class/index.tsx

@@ -72,6 +72,10 @@ export default defineComponent({
     })
 
     const route = useRoute()
+    watch(() => route.query, () => {
+      getDetail()
+      trainingRecord()
+    })
     const router = useRouter()
     const query = route.query
     const browserInfo = browser()
@@ -155,7 +159,7 @@ export default defineComponent({
     const getTrainingTimes = (res: any) => {
       let trainingTimes = 0
       if (Array.isArray(res?.trainings)) {
-        const train = res.trainings.find((n: any) => n.materialId === query.materialId)
+        const train = res.trainings.find((n: any) => n.materialId === route.query?.materialId)
         if (train) {
           trainingTimes = train.trainingTimes
         }
@@ -217,6 +221,7 @@ export default defineComponent({
     // 达到指标,记录
     const addTrainingRecord = async (m: any) => {
       data.recordLoading = true
+      const query = route.query
       const body = {
         materialType: 'VIDEO',
         record: {
@@ -270,7 +275,7 @@ export default defineComponent({
           if (!isLastIndex) {
             const nextItem = data.details[itemIndex + 1]
             if (nextItem?.type === materialType.视频) {
-              // console.log('下一题视频', nextItem)
+              console.log('下一题视频',data.details[itemIndex].materialId, nextItem.materialId)
               router.replace({
                 path: '/exerciseAfterClass',
                 query: {
@@ -278,7 +283,6 @@ export default defineComponent({
                   materialId: nextItem.materialId
                 }
               })
-              history.go(0)
             }
             if (nextItem?.type === materialType.曲目) {
               handleInit(1)