Browse Source

对话课文

natasha 2 months ago
parent
commit
f2649fe97b

+ 16 - 0
src/utils/transform.js

@@ -55,3 +55,19 @@ export function audioTimeToMMSS(currentTime) {
   const milliseconds = String(totalMilliseconds % 1000).padStart(3, '0');
   return `${minutes}:${seconds}:${milliseconds}`;
 }
+
+
+//分:秒转秒
+export function timeStrToSen(time) {
+    if (!time) {
+        return -1;
+    }
+    var pos = time.indexOf(':');
+    var min = 0,
+        sec = 0;;
+    if (pos > 0) {
+        min = parseInt(time.substring(0, pos));
+        sec = parseFloat(time.substring(pos + 1))
+    }
+    return min * 60 + sec;
+}

+ 2 - 1
src/views/book/courseware/create/components/question/dialogue_article/Article.vue

@@ -261,7 +261,8 @@ import NewWord from '../article/NewWord.vue';
 import Notes from '../article/Notes.vue';
 
 import { getArticleData } from '@/views/book/courseware/data/dialogueArticle';
-import { segSentences, BatchSegContent, getWordTime, prepareTranscribe, fileUpload, fileToBase64Text } from '@/api/app';
+import { fileUpload } from '@/api/app';
+import { segSentences, BatchSegContent, getWordTime, prepareTranscribe, fileToBase64Text } from '@/api/article';
 const Base64 = require('js-base64').Base64;
 import cnchar from 'cnchar';
 

+ 61 - 61
src/views/book/courseware/preview/components/article/PhraseModelChs.vue

@@ -721,16 +721,16 @@ export default {
     if (this.curQue) {
       this.handleData();
     }
-    $(window).resize(() => {
-      this.getScreenHeight();
-    });
+    window.addEventListener('resize', this.getScreenHeight);
     this.getScreenHeight();
   },
   beforeCreate() {}, // 生命周期 - 创建之前
   beforeMount() {}, // 生命周期 - 挂载之前
   beforeUpdate() {}, // 生命周期 - 更新之前
   updated() {}, // 生命周期 - 更新之后
-  beforeDestroy() {}, // 生命周期 - 销毁之前
+  beforeDestroy() {
+    window.removeEventListener('resize', this.getScreenHeight);
+  }, // 生命周期 - 销毁之前
   destroyed() {}, // 生命周期 - 销毁完成
   activated() {},
   // 方法集合
@@ -786,12 +786,12 @@ export default {
                 this.findLightWord(wItem, wIndex, sentence, sItem);
                 words = this.highWords ? this.highWords.words : '';
               } else if (wIndex > this.highWords.endIndex - 1) {
-                  this.highWords = null;
-                  this.findLightWord(wItem, wIndex, sentence, sItem);
-                  words = this.highWords ? this.highWords.words : '';
-                } else {
-                  words = this.highWords ? this.highWords.words : '';
-                }
+                this.highWords = null;
+                this.findLightWord(wItem, wIndex, sentence, sItem);
+                words = this.highWords ? this.highWords.words : '';
+              } else {
+                words = this.highWords ? this.highWords.words : '';
+              }
             }
             let obj = {
               paraIndex: dIndex, // 段落索引
@@ -834,8 +834,8 @@ export default {
         });
       }
       let resArrs = [];
-        let sentArrTotal = [];
-        let timeArr = [];
+      let sentArrTotal = [];
+      let timeArr = [];
       let wordTimeList = curQue.wordTime;
       curQue.detail.forEach((dItem, dIndex) => {
         dItem.wordsList.forEach((sItem, sIndex) => {
@@ -902,24 +902,24 @@ export default {
             endIndex = startIndex + 1;
           }
         } else if (item[0] == wItem.chs && sentence.indexOf(item) > -1) {
-            let index = null;
-            let chsStr = '';
-            for (let i = startIndex; i < sItem.length + 1; i++) {
-              index = i;
-              if (chsStr.length == item.length) {
-                break;
-              } else {
-                chsStr += sItem[i] ? sItem[i].chs : '';
-              }
-            }
-            if (chsStr == item && !wItem.banLight) {
-              words = item;
-              endIndex = index;
+          let index = null;
+          let chsStr = '';
+          for (let i = startIndex; i < sItem.length + 1; i++) {
+            index = i;
+            if (chsStr.length == item.length) {
+              break;
+            } else {
+              chsStr += sItem[i] ? sItem[i].chs : '';
             }
-          } else if (wItem.new_word && wItem.new_word == item && !wItem.banLight) {
+          }
+          if (chsStr == item && !wItem.banLight) {
             words = item;
-            endIndex = startIndex + 1;
+            endIndex = index;
           }
+        } else if (wItem.new_word && wItem.new_word == item && !wItem.banLight) {
+          words = item;
+          endIndex = startIndex + 1;
+        }
       });
       if (words) {
         this.highWords = { words, endIndex };
@@ -998,7 +998,7 @@ export default {
       }
       let pos = time.indexOf(':');
       let min = 0;
-        var sec = 0;
+      var sec = 0;
       if (pos > 0) {
         min = parseInt(time.substring(0, pos));
         sec = parseFloat(time.substring(pos + 1));
@@ -1123,37 +1123,37 @@ export default {
         }
         this.showNoteDetail(e, noteIndex);
       } else if (this.newWordList.indexOf(noteNum) > -1) {
-          if (_this.oldHz != noteNum) {
-            this.isShow = false;
-            _this.NNPENewWordList.forEach((items) => {
-              // item.forEach((items) => {
-              if (items.new_word === noteNum) {
-                this.activeWord = items;
-              }
-              // });
-            });
-            setTimeout(() => {
-              _this.hz = noteNum;
-            }, 50);
-          }
-          _this.clientY = e.clientY;
-          let left = e.clientX;
-          let width = 0;
-
-          if (noteNum.length == 1 || noteNum.length == 2) {
-            width = 304;
-          } else if (noteNum.length == 3 || noteNum.length == 4) {
-            width = 432;
-          } else if (noteNum.length > 3) {
-            width = 560;
-          }
+        if (_this.oldHz != noteNum) {
+          this.isShow = false;
+          _this.NNPENewWordList.forEach((items) => {
+            // item.forEach((items) => {
+            if (items.new_word === noteNum) {
+              this.activeWord = items;
+            }
+            // });
+          });
+          setTimeout(() => {
+            _this.hz = noteNum;
+          }, 50);
+        }
+        _this.clientY = e.clientY;
+        let left = e.clientX;
+        let width = 0;
 
-          if (left - this.bodyLeft > this.contentWidth / 2) {
-            _this.left = left - width + 10;
-          } else {
-            _this.left = left;
-          }
+        if (noteNum.length == 1 || noteNum.length == 2) {
+          width = 304;
+        } else if (noteNum.length == 3 || noteNum.length == 4) {
+          width = 432;
+        } else if (noteNum.length > 3) {
+          width = 560;
+        }
+
+        if (left - this.bodyLeft > this.contentWidth / 2) {
+          _this.left = left - width + 10;
+        } else {
+          _this.left = left;
         }
+      }
     },
     showNoteDetail(e, noteNum) {
       let _this = this;
@@ -1169,10 +1169,10 @@ export default {
       if (left - this.bodyLeft > this.contentWidth / 2) {
         _this.left = left - width + 10;
       } else if (left - 200 > 500) {
-          _this.left = 500;
-        } else {
-          _this.left = left - 200;
-        }
+        _this.left = 500;
+      } else {
+        _this.left = left - 200;
+      }
     },
     // 处理注释数据
     handleNote(val) {

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

@@ -732,9 +732,7 @@ export default {
   // 生命周期 - 挂载完成(可以访问DOM元素)
   mounted() {
     let _this = this;
-    $(window).resize(() => {
-      _this.getScreenHeight();
-    });
+    window.addEventListener('resize', this.getScreenHeight);
     _this.getScreenHeight();
     document.addEventListener('keyup', function (e) {
       if (_this.isKeyboard) {
@@ -818,7 +816,9 @@ export default {
   beforeMount() {}, // 生命周期 - 挂载之前
   beforeUpdate() {}, // 生命周期 - 更新之前
   updated() {}, // 生命周期 - 更新之后
-  beforeDestroy() {}, // 生命周期 - 销毁之前
+  beforeDestroy() {
+    window.removeEventListener('resize', this.getScreenHeight);
+  }, // 生命周期 - 销毁之前
   destroyed() {}, // 生命周期 - 销毁完成
   activated() {},
   // 方法集合

+ 5 - 6
src/views/book/courseware/preview/components/article/WordModelChs.vue

@@ -639,9 +639,7 @@ export default {
     if (this.curQue) {
       this.handleData();
     }
-    $(window).resize(() => {
-      this.getScreenHeight();
-    });
+    window.addEventListener('resize', this.getScreenHeight);
     this.getScreenHeight();
   },
   beforeCreate() {}, // 生命周期 - 创建之前
@@ -650,6 +648,7 @@ export default {
   updated() {}, // 生命周期 - 更新之后
   beforeDestroy() {
     this.isShow = false;
+    window.removeEventListener('resize', this.getScreenHeight);
   }, // 生命周期 - 销毁之前
   destroyed() {}, // 生命周期 - 销毁完成
   activated() {},
@@ -755,8 +754,8 @@ export default {
         });
       }
       let resArrs = [];
-        let sentArrTotal = [];
-        let timeArr = [];
+      let sentArrTotal = [];
+      let timeArr = [];
       let wordTimeList = curQue.wordTime;
       curQue.detail.forEach((dItem, dIndex) => {
         dItem.wordsList.forEach((sItem, sIndex) => {
@@ -870,7 +869,7 @@ export default {
       }
       let pos = time.indexOf(':');
       let min = 0;
-        var sec = 0;
+      var sec = 0;
       if (pos > 0) {
         min = parseInt(time.substring(0, pos));
         sec = parseFloat(time.substring(pos + 1));

File diff suppressed because it is too large
+ 205 - 581
src/views/book/courseware/preview/components/dialogue_article/NormalModelChs.vue


File diff suppressed because it is too large
+ 216 - 530
src/views/book/courseware/preview/components/dialogue_article/PhraseModelChs.vue


File diff suppressed because it is too large
+ 476 - 361
src/views/book/courseware/preview/components/dialogue_article/Practicechs.vue


File diff suppressed because it is too large
+ 312 - 492
src/views/book/courseware/preview/components/dialogue_article/WordModelChs.vue


+ 35 - 26
src/views/book/courseware/preview/components/dialogue_article/index.vue

@@ -60,7 +60,7 @@
             </template>
           </div>
         </div>
-        <!-- <div class="ArticleView-body" ref="ArticleViewbody">
+        <div class="ArticleView-body" ref="ArticleViewbody">
           <NormalModelChs
             :curQue="data"
             :titleFontsize="titleFontsize"
@@ -82,7 +82,6 @@
             :NNPENewWordList="NNPENewWordList"
             :themeColor="bookInfo.theme_color"
             :noFont="noFont"
-            :currentTreeID="courseware_id"
             :bodyLeft="bodyLeft"
             v-if="showPhrases"
             :config="config"
@@ -99,7 +98,6 @@
             :themeColor="bookInfo.theme_color"
             :noFont="noFont"
             :NNPENewWordList="NNPENewWordList"
-            :currentTreeID="courseware_id"
             v-if="showPractice"
             :config="config"
             @changeConfig="changeConfig"
@@ -117,7 +115,6 @@
             :NNPENewWordList="NNPENewWordList"
             :themeColor="bookInfo.theme_color"
             :noFont="noFont"
-            :currentTreeID="courseware_id"
             v-if="showWord"
             :config="config"
             @changeConfig="changeConfig"
@@ -135,7 +132,6 @@
             :mp3="data.mp3_list && data.mp3_list[0] ? data.mp3_list[0].url : ''"
             :noFont="noFont"
             :NNPENewWordList="NNPENewWordList"
-            :currentTreeID="courseware_id"
             :isFull="isFull"
             :config="config"
             :TaskModel="isJudgingRightWrong ? 'ANSWER' : ''"
@@ -146,10 +142,16 @@
             @changeIsFull="changeIsFull"
             :NpcNewWordMp3="NpcNewWordMp3"
           />
-        </div> -->
+        </div>
       </div>
-      <template v-if="data.new_word_list.option.length > 0">
-        <!-- <NewWordPreview :newData="data.new_word_list"></NewWordPreview> -->
+      <template v-if="data.new_word_list.new_word_list.length > 0">
+        <NewWordPreview :newData="data.new_word_list"></NewWordPreview>
+      </template>
+      <template v-if="data.other_word_list.new_word_list.length > 0">
+        <NewWordPreview :newData="data.other_word_list"></NewWordPreview>
+      </template>
+      <template v-if="data.notes_list.option.length > 0">
+        <NotesPreview :notesData="data.notes_list"></NotesPreview>
       </template>
     </div>
   </div>
@@ -160,37 +162,39 @@ import { getArticleData } from '@/views/book/courseware/data/dialogueArticle';
 
 import PreviewMixin from '../common/PreviewMixin';
 
-// import PhraseModel from './PhraseModelChs.vue';
-// import NormalModelChs from './NormalModelChs.vue';
-// import Practice from './Practicechs.vue'; // 语音练习模式
-// import WordModel from './WordModelChs.vue'; // 语音练习模式
-// import Voicefullscreen from './Voicefullscreen.vue';
+import PhraseModel from './PhraseModelChs.vue';
+import NormalModelChs from './NormalModelChs.vue';
+import Practice from './Practicechs.vue'; // 语音练习模式
+import WordModel from './WordModelChs.vue'; // 语音练习模式
+import Voicefullscreen from '../article/Voicefullscreen.vue';
 import { getToken } from '@/utils/auth';
 import { analysSubmit, GetFileURLMap } from '@/api/app';
-// import NewWordPreview from '../new_word/NewWordPreview.vue';
+import NewWordPreview from '../new_word/NewWordPreview.vue';
+import NotesPreview from '../notes/NotesPreview.vue';
 
 export default {
   name: 'DialogueArticlePreview',
   components: {
-    // NormalModelChs,
-    // Practice,
-    // WordModel,
-    // PhraseModel,
-    // Voicefullscreen,
-    // NewWordPreview,
+    NormalModelChs,
+    Practice,
+    WordModel,
+    PhraseModel,
+    Voicefullscreen,
+    NewWordPreview,
+    NotesPreview,
   },
   mixins: [PreviewMixin],
   inject: ['bookInfo'],
   watch: {
-    'data.content': {
+    'data.detail.length': {
       handler(val) {
         if (val) {
           this.handleData();
           let _this = this;
-          if (!this.isJudgingRightWrong) {
-            let userAnswer = JSON.parse(JSON.stringify(_this.userAnswer));
-            _this.$set(this.data, 'Bookanswer', userAnswer);
-          }
+          // if (!this.isJudgingRightWrong) {
+          // let userAnswer = JSON.parse(JSON.stringify(_this.userAnswer));
+          // _this.$set(this.data, 'Bookanswer', userAnswer);
+          // }
           _this.$nextTick(() => {
             _this.bodyLeft = _this.$refs.ArticleViewbody.getBoundingClientRect().left;
           });
@@ -374,12 +378,17 @@ export default {
       }
     },
     handleData() {
+      console.log(this.data);
+      let userAnswer = JSON.parse(JSON.stringify(this.userAnswer));
+      this.$set(this.data, 'Bookanswer', userAnswer);
       if (this.data.mp3_list && this.data.mp3_list.length > 0) {
         GetFileURLMap({ file_id_list: [this.data.mp3_list[0].file_id] }).then(({ url_map }) => {
           this.data.mp3_list[0].url = url_map[this.data.mp3_list[0].file_id];
         });
       }
-      this.NNPENewWordList = this.data.new_word_list.option.concat(this.data.other_word_list.option);
+      this.NNPENewWordList = this.data.new_word_list_other_component_input
+        .concat(this.data.new_word_list.new_word_list)
+        .concat(this.data.other_word_list.new_word_list);
       this.NNPEAnnotationList = this.data.notes_list.option;
       let resArr = [],
         sentArrTotal = [],

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

@@ -638,7 +638,7 @@ export default {
     width: 1007px;
 
     // width: 780px;
-    margin-bottom: 24px;
+    // margin-bottom: 24px;
 
     .aduioLine-box {
       margin-bottom: 8px;

+ 1 - 1
src/views/book/courseware/preview/components/notes/NotesPreview.vue

@@ -81,7 +81,7 @@ export default {
   @include preview-base;
 
   .NPC-zhedie {
-    margin-bottom: 24px;
+    // margin-bottom: 24px;
 
     .topTitle {
       display: flex;

Some files were not shown because too many files changed in this diff