Преглед на файлове

Merge branch 'master' into gcj

guanchunjie преди 3 години
родител
ревизия
f70f350ff8

+ 8 - 0
src/components/Adult/preview/AudioLine.vue

@@ -265,6 +265,14 @@ export default {
           }
         });
         this.$refs[audioId].play();
+      }else{
+            let audio = document.getElementsByTagName("audio");
+            audio.forEach((item) => {
+                if (item.id !== audioId) {
+                    item.pause();
+                }
+            });
+            this.$refs[audioId].pause();
       }
     },
     // 将整数转换成 时:分:秒的格式

+ 29 - 18
src/components/Adult/preview/DialogueArticleViewChs/AnswerModel.vue

@@ -73,7 +73,7 @@
                                 ? 'noFont'
                                 : '',
                             ]"
-                            >{{ pItem.pinyin }}</span
+                            >{{ pItem.pinyin | handlePY }}</span
                           >
                           <template v-if="!pItem.isHeng">
                             <span
@@ -106,10 +106,13 @@
                               pItem.className ? pItem.className : '',
                               noFont.indexOf(pItem.pinyin) > -1 ? 'noFont' : '',
                             ]"
-                            >{{ pItem.pinyin }}</span
+                            >{{ pItem.pinyin | handlePY }}</span
                           >
                         </span>
-                        <span class="NNPE-words-box" v-if="item.wordsList[pIndex + 1]">
+                        <span
+                          class="NNPE-words-box"
+                          v-if="item.wordsList[pIndex + 1]"
+                        >
                           <span
                             v-if="pyPosition == 'top'"
                             class="NNPE-pinyin"
@@ -121,7 +124,9 @@
                                 : '',
                             ]"
                             style="text-align: left"
-                            >{{ item.wordsList[pIndex + 1].pinyin }}</span
+                            >{{
+                              item.wordsList[pIndex + 1].pinyin | handlePY
+                            }}</span
                           >
 
                           <span
@@ -151,7 +156,9 @@
                                 : '',
                             ]"
                             style="text-align: left"
-                            >{{ item.wordsList[pIndex + 1].pinyin }}</span
+                            >{{
+                              item.wordsList[pIndex + 1].pinyin | handlePY
+                            }}</span
                           >
                         </span>
                       </template>
@@ -159,17 +166,14 @@
                       <!--下一个元素不是标点-->
                       <template v-else>
                         <span
-                          v-if="pyPosition == 'top'&&item.wordsList[pIndex + 1]"
+                          v-if="pyPosition == 'top'"
                           class="NNPE-pinyin"
                           :class="[
                             pItem.padding ? 'padding' : '',
                             pItem.className ? pItem.className : '',
-                            noFont.indexOf(item.wordsList[pIndex + 1].pinyin) >
-                            -1
-                              ? 'noFont'
-                              : '',
+                            noFont.indexOf(pItem.pinyin) > -1 ? 'noFont' : '',
                           ]"
-                          >{{ pItem.pinyin }}</span
+                          >{{ pItem.pinyin | handlePY }}</span
                         >
                         <template v-if="!pItem.isHeng">
                           <span
@@ -196,17 +200,14 @@
                           </div>
                         </template>
                         <span
-                          v-if="pyPosition == 'bottom'&&item.wordsList[pIndex + 1]"
+                          v-if="pyPosition == 'bottom'"
                           class="NNPE-pinyin"
                           :class="[
                             pItem.padding ? 'padding' : '',
                             pItem.className ? pItem.className : '',
-                            noFont.indexOf(item.wordsList[pIndex + 1].pinyin) >
-                            -1
-                              ? 'noFont'
-                              : '',
+                            noFont.indexOf(pItem.pinyin) > -1 ? 'noFont' : '',
                           ]"
-                          >{{ pItem.pinyin }}</span
+                          >{{ pItem.pinyin | handlePY }}</span
                         >
                       </template>
                     </template>
@@ -408,6 +409,16 @@ export default {
       });
       return str;
     },
+    handlePY(pinyin) {
+      let reg = /_{2,}/g;
+      let py = "";
+      if (reg.test(pinyin)) {
+        py = "";
+      } else {
+        py = pinyin;
+      }
+      return py;
+    },
   },
   data() {
     return {
@@ -416,7 +427,7 @@ export default {
       chsFhList: [",", "。", "“", ":", "》", "《", "?", "!", ";"],
       enFhList: [",", ".", ";", "?", "!", ":", ">", "<"],
       newWords: ["鱼", "辩礼义"],
-      noFont: ["~", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "/"],
+      noFont: ["~", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "/", "_"],
       oldHz: "",
       hz: "",
       top: 0,

+ 29 - 5
src/components/Adult/preview/SelectTone.vue

@@ -27,7 +27,7 @@
               ? 'active'
               : '',
           ]"
-          @click="handleChangeTime(curQue.wordTime[index].bg)"
+          @click="handleChangeTime(curQue.wordTime[index].bg,curQue.wordTime[index].ed)"
         ></a>
         <!-- <Audio
           :mp3="item.mp3_list.length > 0 ? item.mp3_list[0].url : ''"
@@ -67,6 +67,7 @@ export default {
       userSelect: [],
       curTime: "",
       stopAudio: false,
+      timer: null,
     };
   },
   computed: {},
@@ -84,28 +85,51 @@ export default {
     handleClick(index, indexs) {
       this.$set(this.userSelect, index, indexs);
     },
-    handleChangeTime(time) {
+    handleChangeTime(time,edTime) {
       let _this = this;
       _this.curTime = time;
+      _this.stopAudio = true
       _this.$refs.audioLine.onTimeupdateTime(time / 1000, true);
+      _this.timer = setInterval(() => {
+          if(_this.curTime >= edTime){
+              _this.stopAudio = false
+              _this.$refs.audioLine.onTimeupdateTime(_this.curTime / 1000, false);
+              clearInterval(_this.timer);
+          }
+      }, 200);
     },
     getCurTime(curTime) {
       this.curTime = curTime * 1000;
     },
     handleListenRead(playFlag) {
       this.stopAudio = playFlag;
+      if(this.timer){
+          clearInterval(this.timer);
+      }
     },
   },
   //生命周期 - 创建完成(可以访问当前this实例)
-  created() {},
+  created() {
+      if(this.timer){
+          clearInterval(this.timer);
+      }
+  },
   //生命周期 - 挂载完成(可以访问DOM元素)
   mounted() {},
   beforeCreate() {}, //生命周期 - 创建之前
   beforeMount() {}, //生命周期 - 挂载之前
   beforeUpdate() {}, //生命周期 - 更新之前
   updated() {}, //生命周期 - 更新之后
-  beforeDestroy() {}, //生命周期 - 销毁之前
-  destroyed() {}, //生命周期 - 销毁完成
+  beforeDestroy() {
+      if(this.timer){
+          clearInterval(this.timer);
+      }
+  }, //生命周期 - 销毁之前
+  destroyed() {
+      if(this.timer){
+          clearInterval(this.timer);
+      }
+  }, //生命周期 - 销毁完成
   activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
 };
 </script>