TIANYONG 1 vuosi sitten
vanhempi
commit
9b72bbacc7
1 muutettua tiedostoa jossa 23 lisäystä ja 0 poistoa
  1. 23 0
      src/subpages/colexiu/buttons/evaluating.tsx

+ 23 - 0
src/subpages/colexiu/buttons/evaluating.tsx

@@ -43,6 +43,7 @@ const connentLoading = ref(false)
 const playUrl: Ref<string> = ref('')
 const endResult = ref(null)
 const browserInfo = browser()
+const scoreList: any[] = []
 
 /**
  * 默认按照442计算的音符频率,此处转化为按照设置进行调整
@@ -439,6 +440,7 @@ const submitEvaluationScore = async (data: any) => {
       Toast('完整演奏结束才算测验分数!')
       return
     }
+    (endResult.value as any)?.score && scoreList.push((endResult.value as any)?.score)
     /** 有单元测验时,存储分数缓存 */
     postMessage({
       api: 'setCache',
@@ -559,6 +561,26 @@ const handleComplexButton = (res?: IPostMessage) => {
 	}
 };
 
+// 离开之前再提交一次最高分数
+const submitMaxScore = () => {
+  const search = useOriginSearch()
+  if (search.unitId && scoreList.length) {
+    console.log('最高分',scoreList,Math.max(...scoreList))
+    postMessage({
+      api: 'setCache',
+      content: {
+        key: 'h5-orchestra-unit',
+        value: JSON.stringify({
+          musicId: search.id || '',
+          unitId: search.unitId || '',
+          questionId: search.questionId || '',
+          score: Math.max(...scoreList),
+        }),
+      },
+    })
+  }
+}
+
 export default defineComponent({
   name: 'ColexiuButtonEvaluating',
   setup(props, { expose }) {
@@ -595,6 +617,7 @@ export default defineComponent({
       removeListenerMessage('cloudTimeUpdae', onProgress)
       hideComplexButton(() => {}, false);
       RuntimeUtils.event.off('tickEnd', evaluatStart)
+      submitMaxScore()
     })
 
     expose({