guanchunjie 3 år sedan
förälder
incheckning
5b82c9f89a
1 ändrade filer med 19 tillägg och 12 borttagningar
  1. 19 12
      src/components/Adult/preview/WordPhrase.vue

+ 19 - 12
src/components/Adult/preview/WordPhrase.vue

@@ -50,13 +50,13 @@
                   <span
                     :class="[
                       'NPC-play-btn',
-                      mp3_index == index ? 'active' : '',
+                      mp3_index == sItem.sIndex ? 'active' : '',
                     ]"
-                    @click="palyAudio(item.new_word, index)"
+                    @click="palyAudio(sItem.new_word, sItem.sIndex)"
                   ></span>
                   <audio
                     :id="sItem.new_word"
-                    :src="sItem.mp3_list[0].url"
+                    :src="sItem.mp3_list[0].id"
                   ></audio>
                 </template>
                 <template v-else>
@@ -140,12 +140,12 @@ export default {
   //方法集合
   methods: {
     handleChange(val) {},
-    palyAudio(new_word, index) {
+    palyAudio(new_word, sIndex) {
       let _this = this;
       let node = document.getElementById(new_word);
       _this.playWord = node;
       if (node) {
-        this.mp3_index = index;
+        this.mp3_index = sIndex;
         node.play();
       }
       this.handleListenPlay();
@@ -238,16 +238,16 @@ export default {
       let _this = this;
       let mp3_index = 0;
       _this.mp3_index = mp3_index;
-      let leg = this.curQue.option.length;
-      let mp3 = this.curQue.option[mp3_index].mp3_list[0].url;
+      let leg = this.optionRes.length;
+      let mp3 = this.optionRes[mp3_index].mp3_list[0].id;
       _this.handlePlayVoice(mp3);
       _this.audio.addEventListener("ended", function () {
         if (mp3_index < leg - 1) {
           mp3_index = mp3_index + 1;
           _this.mp3_index = mp3_index;
           mp3 =
-            _this.curQue.option[mp3_index].mp3_list.length > 0 &&
-            _this.curQue.option[mp3_index].mp3_list[0].url;
+            _this.optionRes[mp3_index].mp3_list.length > 0 &&
+            _this.optionRes[mp3_index].mp3_list[0].id;
           if (mp3) {
             _this.handlePlayVoice(mp3);
           }
@@ -256,8 +256,14 @@ export default {
     },
     handlePlayVoice(mp3) {
       let _this = this;
+      let leg = this.optionRes.length;
       if (!mp3) {
-        return;
+        if (_this.mp3_index < leg - 1) {
+          _this.mp3_index = _this.mp3_index + 1;
+          mp3 = _this.optionRes[mp3_index].mp3_list[0].id;
+        } else {
+          return false;
+        }
       }
       if (!this.audio.paused) {
         this.audio.pause();
@@ -285,8 +291,7 @@ export default {
         optionRes = optionRes.concat(item);
         item.index = index + 1;
         item.forEach((sItem, sIndex) => {
-          sItem.sIndex =
-            index == 0 ? sIndex : sIndex + this.curQue.option[index - 1].length;
+          sItem.sIndex = index == 0 ? sIndex : sIndex + optionRes.length;
           sItem.def_str =
             sItem.definition_list.length > 0
               ? sItem.definition_list.join(";")
@@ -294,6 +299,8 @@ export default {
         });
       });
       this.optionRes = JSON.parse(JSON.stringify(optionRes));
+      console.log("======console.log(this.optionRes);");
+      console.log(this.optionRes);
     }
     console.log(this.curQue);
   },