Browse Source

课文单句评分详情页面最终版

natasha 4 tuần trước cách đây
mục cha
commit
fc94b33f5f

+ 4 - 4
src/utils/recordScore.js

@@ -1,15 +1,15 @@
 import { ToolVoiceEval } from '@/api/app';
 /**
- * 录音 dataURL 上传到文件服务器
- * @param {string} dataUrl
- * @returns {Promise<{ file_id: string, file_url: string }>}
+ * 录音评分
  */
 export function recordSocreSingle(data) {
   return ToolVoiceEval({
     audio_bytes_base64: data.audio_paramter_type === 0 ? String(data.base64).replace(/^data:audio\/[^;]+;base64,/, '') : null,
     audio_file_id: data.audio_paramter_type === 1 ? data.base64 : null,
     text: data.text,
-    audio_paramter_type: data.audio_paramter_type
+    audio_paramter_type: data.audio_paramter_type,
+    is_attach_audio_url_user: 'true',
+    is_attach_audio_url_standard: data.standard
   }).then((res) => {
     if (!res ) {
       throw new Error((res && (res.error || res.message)) || '评分接口失败');

+ 1 - 1
src/views/book/courseware/data/article.js

@@ -85,7 +85,7 @@ export function getArticleProperty() {
     emotion: '', // 风格,情感
     speed_ratio: '', // 语速
     remarkWidth: '30', // 气泡预览宽度%
-    is_enable_score: switchOption[1].value, // 是否开启录音评分
+    is_enable_score: switchOption[0].value, // 是否开启录音评分
   };
 }
 

+ 1 - 1
src/views/book/courseware/data/dialogueArticle.js

@@ -128,7 +128,7 @@ export function getArticleProperty() {
     notice_color: '#000',
     noitce_family: '',
     remarkWidth: '30', // 气泡预览宽度%
-    is_enable_score: switchOption[1].value, // 是否开启录音评分
+    is_enable_score: switchOption[0].value, // 是否开启录音评分
   };
 }
 

+ 1 - 1
src/views/book/courseware/data/newWord.js

@@ -91,7 +91,7 @@ export function getNewWordProperty() {
     emotion: '', // 风格,情感
     speed_ratio: '', // 语速
     front_view: 'table', // 主视图
-    is_enable_score: switchOption[1].value, // 是否开启录音评分
+    is_enable_score: switchOption[0].value, // 是否开启录音评分
   };
 }
 

+ 123 - 8
src/views/book/courseware/preview/common/RecordScoreSingleDetail.vue

@@ -4,7 +4,6 @@
     v-dialogDrag
     custom-class="record-score-single-dialog"
     :visible="visible"
-    width="45vw"
     :close-on-click-modal="false"
     :modal="modal"
     :before-close="handleClose"
@@ -76,6 +75,34 @@
         </div>
       </div>
     </div>
+    <div class="voice-box">
+      <a
+        class="voice-item"
+        @click="
+          handleChangeTime(
+            recordScoreDetail.audio_url_standard,
+            recordScoreDetail.audio_url_standard_bg,
+            recordScoreDetail.audio_url_standard_ed,
+            'standard',
+          )
+        "
+      >
+        <SvgIcon
+          size="16"
+          :icon-class="stopAudioS && type === 'standard' ? 'pause-large-fill' : 'play-large-fill'"
+          :style="{ color: attrib?.topic_color }"
+        />
+        标准音
+      </a>
+      <a class="voice-item" @click="handleChangeTime(recordScoreDetail.audio_url_user, 0, 100000, 'user')">
+        <SvgIcon
+          size="16"
+          :icon-class="stopAudioS && type === 'user' ? 'pause-large-fill' : 'play-large-fill'"
+          :style="{ color: attrib?.topic_color }"
+        />
+        我的读音
+      </a>
+    </div>
     <h5>逐字评分</h5>
     <div class="word-score-box">
       <div
@@ -84,25 +111,46 @@
         :key="index"
         :style="wordScoreItem(item.score)"
       >
-        <span class="pinyin">{{ item.pinyin }}·{{ item.tone }}声</span>
         <p :style="textColor(item.score)">{{ item.hz }}</p>
-        <span :style="textColor(item.score)">{{ item.score }}</span>
+        <div class="char-item">
+          <span>{{ item.pinyin }}</span>
+          <b :style="textColor(item.score)">{{ item.score }}</b>
+        </div>
+        <div class="char-item" v-for="(items, indexs) in item.phoneme_list" :key="indexs">
+          <span>{{ items.char }}</span>
+          <b :style="textColor(items.score)">{{ items.score }}</b>
+        </div>
+        <div class="char-item">
+          <span>{{ item.tone_char }}</span>
+          <b :style="textColor(item.tone_score)">{{ item.tone_score }}</b>
+        </div>
       </div>
     </div>
     <div class="tips">
-      逐字得分:<span class="color-block" style="background-color: #e7f4e7"></span>≥ 80 标准<span
+      得分:<span class="color-block" style="background-color: #e7f4e7"></span>≥ 80<span
         class="color-block"
         style="background-color: #fdf1d6"
       ></span
-      >60–79 偏差 <span class="color-block" style="background-color: #fbe0e0"></span> < 60 需练习
+      >60–79<span class="color-block" style="background-color: #fbe0e0"></span> < 60
     </div>
+    <AudioLine
+      ref="audioLine"
+      audio-id="recordScoreSingle"
+      :mp3="mp3Url"
+      :get-cur-time="getCurTime"
+      :ed="ed"
+      type="audioLine"
+      @handleListenRead="handleListenRead"
+      style="height: 0; opacity: 0"
+    />
   </el-dialog>
 </template>
 
 <script>
+import AudioLine from '../components/voice_matrix/components/AudioLine.vue';
 export default {
   name: 'RecordScoreSingleDetail',
-  components: {},
+  components: { AudioLine },
   inject: {
     modal: {
       default: true,
@@ -118,9 +166,19 @@ export default {
       required: true,
       default: () => ({}),
     },
+    attrib: {
+      type: Object,
+      default: () => ({}),
+    },
   },
   data() {
-    return {};
+    return {
+      stopAudioS: false,
+      mp3Url: '',
+      ed: null,
+      type: '',
+      curTime: 0,
+    };
   },
   computed: {},
 
@@ -150,13 +208,32 @@ export default {
       };
       return style;
     },
+    handleListenRead(playFlag) {
+      this.stopAudioS = playFlag;
+    },
+    // 点击播放
+    handleChangeTime(mp3, time, edTime, type) {
+      this.mp3Url = mp3;
+      this.$nextTick(() => {
+        this.$refs.audioLine.onTimeupdateTime(time / 1000, true);
+        this.ed = edTime;
+        this.type = type;
+        this.stopAudioS = true;
+      });
+    },
+    emptyEd() {
+      this.ed = null;
+    },
+    getCurTime(curTime) {
+      this.curTime = curTime * 1000;
+    },
   },
 };
 </script>
 
 <style lang="scss">
 .record-score-single-dialog {
-  width: min(560px, 92vw);
+  width: min(620px, 92vw);
   padding: 22px 26px;
   background: #fff;
   border-radius: 14px;
@@ -250,6 +327,7 @@ export default {
     gap: 3px;
 
     .word-score-item {
+      min-width: 40px;
       padding: 4px 0 3px;
       color: #9aa5b5;
       text-align: center;
@@ -272,6 +350,25 @@ export default {
         font-size: 13px;
       }
     }
+
+    .char-item {
+      display: flex;
+      gap: 3px;
+      align-items: center;
+      padding: 0 2px;
+      color: #2b3544;
+
+      span {
+        min-width: 15px;
+        font-family: 'League';
+        text-align: left;
+      }
+
+      b {
+        flex: 1;
+        text-align: right;
+      }
+    }
   }
 
   .tips {
@@ -289,5 +386,23 @@ export default {
       margin: 0 3px 0 10px;
     }
   }
+
+  .voice-box {
+    display: flex;
+    gap: 6px;
+
+    .voice-item {
+      display: flex;
+      gap: 4px;
+      align-items: center;
+      padding: 3px 12px;
+      font-size: 14px;
+      color: #44515f;
+      cursor: pointer;
+      background: #f8fafc;
+      border: 1px solid #d7dee8;
+      border-radius: 14px;
+    }
+  }
 }
 </style>

+ 13 - 4
src/views/book/courseware/preview/components/article/Practicechs.vue

@@ -927,7 +927,7 @@
                 </div>
                 <el-button
                   type="text"
-                  v-if="curQue.property.is_enable_score && curQue.property.is_enable_score === 'true'"
+                  v-if="!(curQue.property.is_enable_score && curQue.property.is_enable_score === 'false')"
                   :class="['record-score-btn', wavblob ? 'record-score-btn-has' : '']"
                   @click="handleSingleScore(item, index)"
                   :loading="scoreLoading"
@@ -1081,6 +1081,7 @@
     </div>
     <RecordScoreSingleDetail
       v-if="visibleRecordSingle"
+      :attrib="attrib"
       :visible.sync="visibleRecordSingle"
       :recordScoreDetail="recordScoreDetail"
     />
@@ -1592,6 +1593,14 @@ export default {
         text: text,
         base64: this.wavblob,
         audio_paramter_type: this.wavblob.indexOf('data:audio/wav') > -1 ? 0 : 1,
+        standard:
+          this.curQue.mp3_list &&
+          this.curQue.mp3_list.length > 0 &&
+          this.curQue.mp3_list[0].url &&
+          this.curQue.wordTime &&
+          this.curQue.wordTime[index]
+            ? 'false'
+            : 'true',
       });
       this.scoreLoading = false;
       if (scoreObj) {
@@ -1605,9 +1614,9 @@ export default {
           this.curQue.wordTime &&
           this.curQue.wordTime[index]
         ) {
-          this.$set(scoreObj, 'audio_url_original', this.curQue.mp3_list[0].url);
-          this.$set(scoreObj, 'audio_url_original_bg', this.curQue.wordTime[index].bg);
-          this.$set(scoreObj, 'audio_url_original_ed', this.curQue.wordTime[index].ed);
+          this.$set(scoreObj, 'audio_url_standard', this.curQue.mp3_list[0].url);
+          this.$set(scoreObj, 'audio_url_standard_bg', this.curQue.wordTime[index].bg);
+          this.$set(scoreObj, 'audio_url_standard_ed', this.curQue.wordTime[index].ed);
         }
       }
       this.curQue.Bookanswer.practiceModel[this.sentIndex].scoreList[this.selectIndex] = scoreObj;