natasha před 2 týdny
rodič
revize
d86cc121c1

+ 13 - 1
src/views/book/courseware/preview/common/RecordScoreWholeBtn.vue

@@ -162,6 +162,10 @@ export default {
       type: Array,
       default: () => [],
     },
+    standardUrlList: {
+      type: Array,
+      default: () => [],
+    },
   },
   data() {
     return {
@@ -743,11 +747,15 @@ export default {
     // 单句录音评分
     async handleSingleScore(item, index) {
       let text = this.sentList[index].sentArr.map((item) => item.chs).join('');
+      let url =
+        this.standardUrlList[index] && this.standardUrlList[index].mp3_list
+          ? this.standardUrlList[index].mp3_list_url
+          : '';
       let scoreObj = await recordSocreSingle({
         text,
         base64: item.wavData,
         audio_paramter_type: item.wavData.indexOf('data:audio/wav') > -1 ? 0 : 1,
-        standard: this.standardUrl && this.wordTime[index] ? 'false' : 'true',
+        standard: (this.standardUrl && this.wordTime[index]) || url ? 'false' : 'true',
       });
       if (scoreObj) {
         let score_total = Math.min(Math.round((scoreObj.accuracy + scoreObj.fluency + scoreObj.integrity) / 3), 100); // 算单句总得分 三个值取平均值四舍五入
@@ -757,6 +765,10 @@ export default {
           this.$set(scoreObj, 'audio_url_standard', this.standardUrl);
           this.$set(scoreObj, 'audio_url_standard_bg', this.wordTime[index].bg);
           this.$set(scoreObj, 'audio_url_standard_ed', this.wordTime[index].ed);
+        } else if (url) {
+          this.$set(scoreObj, 'audio_url_standard', url);
+          this.$set(scoreObj, 'audio_url_standard_bg', 0);
+          this.$set(scoreObj, 'audio_url_standard_ed', 1000000);
         }
         this.$set(scoreObj, 'isShow', false);
       }

+ 99 - 9
src/views/book/courseware/preview/components/new_word/NewWordPreview.vue

@@ -312,6 +312,7 @@
                   type="audioLine"
                   :attrib="data.unified_attrib"
                   @handleListenRead="handleListenRead"
+                  :stop-audio="stopAudios"
                 />
               </div>
               <ul
@@ -337,6 +338,13 @@
                       isWholeRecord && sentIndex === sItem.sIndex ? 'active' : '',
                     ]"
                     @click="changeWholeIndex(sItem.sIndex)"
+                    :style="{
+                      paddingRight: !(data.property.is_enable_score && data.property.is_enable_score === 'false')
+                        ? isHasScore
+                          ? '254px'
+                          : '166px'
+                        : '',
+                    }"
                   >
                     <template v-if="isMobile">
                       <div class="content-box">
@@ -1108,6 +1116,39 @@
                             @handleWav="handleWav"
                           />
                         </span>
+                        <div v-if="data.audio_data.file_id || sItem.mp3_list" class="compare-box">
+                          <Audio-compare
+                            :theme-color="data.unified_attrib ? data.unified_attrib.topic_color : '#e35454'"
+                            :index="sItem.sIndex"
+                            :sent-index="sItem.sIndex"
+                            :url="data.audio_data.file_id ? data.audio_data.url : sItem.mp3_list_url"
+                            :bg="
+                              data.lrc_arr.length > 0 && data.lrc_arr[sItem.sIndex] ? data.lrc_arr[sItem.sIndex].bg : 0
+                            "
+                            :ed="
+                              data.lrc_arr.length > 0 && data.lrc_arr[sItem.sIndex]
+                                ? data.lrc_arr[sItem.sIndex].ed
+                                : 1000000
+                            "
+                            :wavblob="
+                              answer &&
+                              answer.answer_list &&
+                              answer.answer_list[index][sIndex] &&
+                              answer.answer_list[index][sIndex].recordList &&
+                              answer.answer_list[index][sIndex].recordList.length > 0
+                                ? answer.answer_list[index][sIndex].recordList[
+                                    answer.answer_list[index][sIndex].recordList.length - 1
+                                  ].wavData
+                                : ''
+                            "
+                            :get-cur-time="getCurTimes"
+                            :sent-pause="sentPause"
+                            :is-record="isRecord"
+                            :handle-change-stop-audio="handleChangeStopAudio"
+                            :get-play-status="getPlayStatus"
+                            :attrib="data.unified_attrib"
+                          />
+                        </div>
                         <el-button
                           v-if="!(data.property.is_enable_score && data.property.is_enable_score === 'false')"
                           type="text"
@@ -1121,7 +1162,7 @@
                               ? 'record-score-btn-has'
                               : '',
                           ]"
-                          :loading="scoreLoading"
+                          :loading="scoreIndex === sItem.sIndex && scoreLoading"
                           @click="handleSingleScore(sItem, sItem.sIndex, index, sIndex)"
                           >评分</el-button
                         >
@@ -1250,6 +1291,7 @@
               <div
                 v-if="!(data.property.is_enable_score && data.property.is_enable_score === 'false')"
                 style="display: flex; padding-left: 12px; border-top: 1px solid rgba(0, 0, 0, 10%)"
+                :style="{ width: isMobile ? '100%' : rowWidth + 'px' }"
               >
                 <RecordScoreWholeBtn
                   v-if="data && data.option_list"
@@ -1262,6 +1304,7 @@
                   record-type="word"
                   :attrib="data.unified_attrib"
                   :standard-url="data.audio_data.file_id ? data.audio_data.url : ''"
+                  :standard-url-list="data.new_word_list"
                   :word-time="data.new_word_list"
                   :sent-list="sentList"
                   @changeWholeStatus="changeWholeStatus"
@@ -1286,6 +1329,7 @@
                   type="audioLine"
                   :attrib="data.unified_attrib"
                   @handleListenRead="handleListenRead"
+                  :stop-audio="stopAudios"
                 />
               </div>
               <div
@@ -1631,6 +1675,7 @@ import writeTableZoom from './components/writeTableZoom.vue';
 import RecordScoreWholeBtn from '../../common/RecordScoreWholeBtn.vue';
 import RecordScoreSingleDetail from '../../common/RecordScoreSingleDetail.vue';
 import { recordSocreSingle } from '@/utils/recordScore.js';
+import AudioCompare from '../article/components/AudioCompare.vue';
 
 export default {
   name: 'NewWordPreview',
@@ -1643,6 +1688,7 @@ export default {
     writeTableZoom,
     RecordScoreWholeBtn,
     RecordScoreSingleDetail,
+    AudioCompare,
   },
   mixins: [PreviewMixin],
   inject: ['getCoursewareId'],
@@ -1707,6 +1753,10 @@ export default {
       whileRecordHasScoreList: [], // 保存多次整篇录音每次是否已评分
       sentList: [], // 整篇录音保存单词内容
       showRecordScoreList: [], // 显示每条生词后面分数数组
+      scoreIndex: null, // 单个评分按钮的索引
+      isHasScore: false, // 是否有录音评分分数
+      isRecord: false,
+      stopAudios: false,
     };
   },
   computed: {
@@ -1857,7 +1907,7 @@ export default {
       }
     },
     palyAudio(url, sIndex) {
-      this.stopAudio();
+      this.stopNewWordAudio();
       const mp3 = url;
       const node = document.getElementById(`word${this.indexStr}${sIndex}`);
       // 列表中的 audio 数量很多,点击时才赋 src,避免一次性创建大量媒体实例
@@ -1907,7 +1957,7 @@ export default {
       this.dataWord = this.optionRes[this.detailIndex];
       // this.getWordLiju(this.data.new_word);
     },
-    stopAudio() {
+    stopNewWordAudio() {
       this.$refs.newwordAudio.pause();
     },
     initData() {
@@ -1920,6 +1970,7 @@ export default {
       this.colHasContent = [];
       this.sentList = [];
       this.showRecordScoreList = [];
+      this.isHasScore = false;
       this.showObj = {
         pinyin: true,
         newWord: true,
@@ -2179,6 +2230,7 @@ export default {
       )
         return;
       this.scoreLoading = true;
+      this.scoreIndex = index;
       let text = item.new_word;
       let scoreObj = await recordSocreSingle({
         text,
@@ -2193,7 +2245,10 @@ export default {
             ? 0
             : 1,
         standard:
-          (this.data.audio_data.file_id && this.data.audio_data.url && this.wordTime && this.wordTime[index]) ||
+          (this.data.audio_data.file_id &&
+            this.data.audio_data.url &&
+            this.data.lrc_arr.length > 0 &&
+            this.data.lrc_arr[index]) ||
           (item.mp3_list && item.mp3_list_url)
             ? 'false'
             : 'true',
@@ -2204,17 +2259,25 @@ export default {
         this.$set(scoreObj, 'score_total', score_total);
         // 如果有音频 记录课文音频及开始结束时间
         if (
-          (this.data.audio_data.file_id && this.data.audio_data.url && this.wordTime && this.wordTime[index]) ||
+          (this.data.audio_data.file_id &&
+            this.data.audio_data.url &&
+            this.data.lrc_arr.length > 0 &&
+            this.data.lrc_arr[index]) ||
           (item.mp3_list && item.mp3_list_url)
         ) {
-          if (this.data.audio_data.file_id && this.data.audio_data.url && this.wordTime && this.wordTime[index]) {
+          if (
+            this.data.audio_data.file_id &&
+            this.data.audio_data.url &&
+            this.data.lrc_arr.length > 0 &&
+            this.data.lrc_arr[index]
+          ) {
             this.$set(scoreObj, 'audio_url_standard', this.data.audio_data.url);
-            this.$set(scoreObj, 'audio_url_standard_bg', this.wordTime[index].bg);
-            this.$set(scoreObj, 'audio_url_standard_ed', this.wordTime[index].ed);
+            this.$set(scoreObj, 'audio_url_standard_bg', this.data.lrc_arr[index].bg);
+            this.$set(scoreObj, 'audio_url_standard_ed', this.data.lrc_arr[index].ed);
           } else {
             this.$set(scoreObj, 'audio_url_standard', item.mp3_list_url);
             this.$set(scoreObj, 'audio_url_standard_bg', 0);
-            this.$set(scoreObj, 'audio_url_standard_ed', 10000);
+            this.$set(scoreObj, 'audio_url_standard_ed', 1000000);
           }
         }
       }
@@ -2225,6 +2288,7 @@ export default {
         (item.def_str ? ' · ' + item.def_str : '');
       this.$set(scoreObj, 'singleText', singleText);
       this.showRecordScoreList[index] = scoreObj;
+      this.isHasScore = true;
     },
     recordScoreStyle(score) {
       let style = {
@@ -2256,6 +2320,7 @@ export default {
     getWholeRecordIndex(index, result) {
       this.wholeRecordIndex = index;
       this.showRecordScoreList = result;
+      this.isHasScore = true;
       // let indexs = 0;
       // this.answer.answer_list.forEach((item) => {
       //   item.forEach((items) => {
@@ -2314,8 +2379,33 @@ export default {
         this.$set(item, 'singleText', singleText);
       });
       this.showRecordScoreList = score;
+      this.isHasScore = true;
       this.whileRecordScoreList[this.wholeRecordIndex] = list;
     },
+    getCurTimes(curTime) {
+      this.curTime = curTime * 1000;
+      // this.getSentIndex(this.curTime);
+    },
+    getSentIndex(curTime) {
+      for (let i = 0; i < this.data.lrc_arr.length; i++) {
+        let bg = this.data.lrc_arr[i].bg;
+        let ed = this.data.lrc_arr[i].ed;
+        if (curTime >= bg && curTime <= ed) {
+          this.sentIndex = i;
+          break;
+        }
+      }
+    },
+    sentPause(isRecord) {
+      this.isRecord = isRecord;
+    },
+    // 音频播放时改变布尔值
+    handleChangeStopAudio() {
+      this.stopAudios = false;
+    },
+    getPlayStatus(val) {
+      // this.isPlaying = val;
+    },
   },
 };
 </script>