guanchunjie 3 years ago
parent
commit
85e9d7a1ff

+ 0 - 1
src/components/Adult/preview/DialogueArticleViewChs/PhraseModelChs.vue

@@ -584,7 +584,6 @@ export default {
       _this.clientY = e.clientY;
       let left = e.clientX;
       let width = 642;
-      debugger;
       if (left - this.bodyLeft > this.contentWidth / 2) {
         _this.left = left - width + 10;
       } else {

+ 15 - 7
src/components/Adult/preview/NewWordShow.vue

@@ -3,8 +3,15 @@
   <div class="Big-Book-prev-Textdes NewWordShow" v-if="curQue">
     <h2 v-if="curQue.title">{{ curQue.title }}</h2>
     <div class="item-box">
-      <div class="item" v-for="(item, index) in curQue.option" :key="index" :style="{width:(curQue.numberList?100/curQue.numberList.con+'%' : 'auto')}">
-        <p v-if="item.pinyin||item.en ">
+      <div
+        class="item"
+        v-for="(item, index) in curQue.option"
+        :key="index"
+        :style="{
+          width: curQue.numberList ? 100 / curQue.numberList.con + '%' : 'auto',
+        }"
+      >
+        <p v-if="item.pinyin || item.en">
           <span>{{ item.pinyin }}</span>
           <span>{{ item.en }}</span>
         </p>
@@ -20,7 +27,9 @@
                 <Strockplayredline
                   :Book_text="conItem"
                   :playStorkes="true"
-                  :targetDiv="'bwcHanziIntp' + index + conItem + conindex + indexStr"
+                  :targetDiv="
+                    'bwcHanziIntp' + index + conItem + conindex + indexStr
+                  "
                 />
                 <div
                   class="bwc-line"
@@ -108,16 +117,16 @@ export default {
       const MethodName = "tool-ChineseSCConvert";
       const data = {
         text: words,
-        swap_mode: 'S-C'
+        swap_mode: "S-C",
       };
-      let TChinese = await getContentFile(MethodName,data)
+      let TChinese = await getContentFile(MethodName, data);
       this.curData = {
         stem: [
           {
             con: words ? words : "",
             pinyin: pinyin && pinyin ? pinyin : "",
             mp3_url: "",
-            TChinese: TChinese.text
+            TChinese: TChinese.text,
           },
         ],
       };
@@ -237,7 +246,6 @@ export default {
     width: 100%;
     height: 100vh;
     background: rgba(0, 0, 0, 0.19);
-    padding-top: 32px;
     box-sizing: border-box;
     overflow: hidden;
     overflow-y: auto;

+ 24 - 61
src/components/Adult/preview/WordPhrase.vue

@@ -105,17 +105,16 @@
         </ul>
       </div>
     </el-collapse-transition>
-    <div v-if="detailShow">
+    <div class="practiceBox" v-if="detailShow">
       <WordPhraseDetail
-        v-if="isSuccess"
         :data="data"
-        :curQue="curQue"
         :changeDetailIndex="changeDetailIndex"
         :closeWord="closeWordShow"
         :detailIndex="detailIndex"
-        :getWordLiju="getWordLiju"
         :optionRes="optionRes"
         :themeColor="themeColor"
+        :currentTreeID="currentTreeID"
+        type="newWordDetail"
       />
     </div>
   </div>
@@ -125,7 +124,7 @@
 //这里可以导入其它文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
 //例如:import 《组件名称》from ‘《组件路径》';
 import WordPhraseDetail from "./components/WordPhraseDetail.vue";
-import { getContent } from "@/api/ajax";
+import { getHZChineseInfo } from "@/api/ajax";
 export default {
   //import引入的组件需要注入到对象中才能使用
   components: {
@@ -146,6 +145,7 @@ export default {
       optionRes: [],
       mp3List: [],
       isSuccess: false,
+      loading: false,
     };
   },
   //计算属性 类似于data概念
@@ -202,73 +202,24 @@ export default {
     showDetail(item) {
       this.data = null;
       this.data = item;
-      console.log(this.data);
       this.detailShow = true;
       this.detailIndex = item.sIndex;
-      this.getWordLiju(item.new_word);
-    },
-    // 获取生词的例句
-    getWordLiju(val) {
-      this.isSuccess = false;
-      console.log(this.data);
-      this.data.list1 = [];
-      this.data.list2 = [];
-      this.data.list3 = [];
-      let Mname =
-        "book-courseware_manager-GetCoursewareWordExampleSentenceList";
-      // 获取本课的 本教材的 本套的 的例句
-      getContent(Mname, {
-        courseware_id: this.currentTreeID, // 课件id
-        word: val, //生词
-        search_scope: 2, //检索范围0 本课件  1本教材 2本套
-        is_contain_word_variants: false,
-      }).then((res) => {
-        this.data.list3 = res.sentence_list;
-        getContent(Mname, {
-          courseware_id: this.currentTreeID, // 课件id
-          word: val, //生词
-          search_scope: 1, //检索范围0 本课件  1本教材 2本套
-          is_contain_word_variants: false,
-        }).then((res) => {
-          this.data.list2 = res.sentence_list;
-          getContent(Mname, {
-            courseware_id: this.currentTreeID, // 课件id
-            word: val, //生词
-            search_scope: 0, //检索范围0 本课件  1本教材 2本套
-            is_contain_word_variants: false,
-          }).then((res) => {
-            this.$set(this.data, "list1", res.sentence_list);
-            this.isSuccess = true;
-          });
-        });
-      });
     },
+    
     // 关闭单词详情
     closeWordShow(val) {
       this.detailShow = val;
     },
-    // 上一个单词详情
-    lasspanetail(val) {
-      this.detailIndex = val;
-      this.data = null;
-      this.data = this.optionRes[this.detailIndex];
-      this.getWordLiju(this.data.new_word);
-    },
-    // 下一个单词详情
-    nexspanetail(val) {
-      this.detailIndex = val;
-      this.data = null;
-      this.data = this.optionRes[this.detailIndex];
-      this.getWordLiju(this.data.new_word);
-    },
     changeDetailIndex(val) {
+      let _this = this;
       if (val == "last") {
-        this.detailIndex--;
+        _this.detailIndex--;
       } else {
-        this.detailIndex++;
+        _this.detailIndex++;
       }
-      this.data = null;
-      this.data = this.optionRes[this.detailIndex];
+      _this.data = null;
+      _this.data = _this.optionRes[_this.detailIndex];
+      //_this.getWordLiju(_this.data.new_word);
     },
     playNewwords() {
       let _this = this;
@@ -387,6 +338,18 @@ export default {
 .NPC-zhedie {
   width: 780px;
   margin-bottom: 16px;
+  .practiceBox {
+    position: fixed;
+    left: 0;
+    top: 0;
+    z-index: 999;
+    width: 100%;
+    height: 100vh;
+    background: rgba(0, 0, 0, 0.19);
+    box-sizing: border-box;
+    overflow: hidden;
+    overflow-y: auto;
+  }
   .NPC-word-list {
     background: #f7f7f7;
   }

+ 30 - 37
src/components/Adult/preview/components/Intp.vue

@@ -349,6 +349,9 @@ export default {
     word: {
       handler: function (val, oldVal) {
         let _this = this;
+        if (_this.type == "newWordDetail") {
+          _this.getChineseInfo();
+        }
       },
       // 深度观察监听
       deep: true,
@@ -368,7 +371,7 @@ export default {
     getChineseInfo() {
       let _this = this;
       let data = {
-        query: this.word.new_word,
+        query: this.word.detail.new_word,
       };
       getHZChineseInfo(data).then((res) => {
         _this.dataDetail = res.data.result;
@@ -385,21 +388,22 @@ export default {
             items.attrs.forEach((itemss) => {
               if (itemss.key == "pronunciation") {
                 // 音频
-                _this.mp3Url = itemss.objects[0]["@value"]
+
+                _this.word.mp3Url = itemss.objects[0]["@value"]
                   ? itemss.objects[0]["@value"]
                   : "";
               } else if (itemss.key == "definition") {
                 // 释义
-                _this.paraphrase = itemss.objects;
+                _this.word.paraphrase = itemss.objects;
               } else if (itemss.key == "synonym") {
                 // 近义词
-                _this.synonymList = itemss.objects;
+                _this.word.synonymList = itemss.objects;
               } else if (itemss.key == "antonym") {
                 // 反义词
-                _this.antonymList = itemss.objects;
+                _this.word.antonymList = itemss.objects;
               } else if (itemss.key == "terms") {
                 // 组词
-                _this.termsList = itemss.objects;
+                _this.word.termsList = itemss.objects;
               }
             });
           });
@@ -412,23 +416,24 @@ export default {
   //生命周期 - 挂载完成(可以访问DOM元素)
   mounted() {
     let _this = this;
-    console.log(_this.word);
-    // _this.getChineseInfo();
-    // _this.handleChineseDetail();
-    if (_this.word) {
-      _this.mp3Url = _this.word.mp3Url ? _this.word.mp3Url : "";
-      _this.paraphrase = _this.word.paraphrase
-        ? JSON.parse(JSON.stringify(_this.word.paraphrase))
-        : [];
-      _this.synonymList = _this.word.synonymList
-        ? JSON.parse(JSON.stringify(_this.word.synonymList))
-        : [];
-      _this.antonymList = _this.word.antonymList
-        ? JSON.parse(JSON.stringify(_this.word.antonymList))
-        : [];
-      _this.termsList = _this.word.termsList
-        ? JSON.parse(JSON.stringify(_this.word.termsList))
-        : [];
+    if (_this.type == "newWordDetail") {
+      _this.getChineseInfo();
+    } else {
+      if (_this.word) {
+        _this.mp3Url = _this.word.mp3Url ? _this.word.mp3Url : "";
+        _this.paraphrase = _this.word.paraphrase
+          ? JSON.parse(JSON.stringify(_this.word.paraphrase))
+          : [];
+        _this.synonymList = _this.word.synonymList
+          ? JSON.parse(JSON.stringify(_this.word.synonymList))
+          : [];
+        _this.antonymList = _this.word.antonymList
+          ? JSON.parse(JSON.stringify(_this.word.antonymList))
+          : [];
+        _this.termsList = _this.word.termsList
+          ? JSON.parse(JSON.stringify(_this.word.termsList))
+          : [];
+      }
     }
   },
   beforeCreate() {}, //生命周期 - 创建之前
@@ -444,11 +449,12 @@ export default {
 //@import url(); 引入公共css类
 .wordIntp {
   width: 100%;
-  //   height: 100vh;
+  height: 2000px;
   overflow: hidden;
   overflow-y: auto;
   margin: 0 auto;
   position: relative;
+  margin-top: 16px !important;
   .bwc-intp {
     padding: 16px 0;
     h1 {
@@ -498,19 +504,6 @@ export default {
       }
     }
   }
-  .practiceBox {
-    position: fixed;
-    left: 0;
-    top: 0;
-    z-index: 999;
-    width: 100%;
-    height: 100vh;
-    background: rgba(0, 0, 0, 0.19);
-    padding-top: 32px;
-    box-sizing: border-box;
-    overflow: hidden;
-    overflow-y: auto;
-  }
   .closeBox {
     width: 100%;
     display: flex;

+ 83 - 47
src/components/Adult/preview/components/WordPhraseDetail.vue

@@ -1,7 +1,7 @@
 <template>
   <div
     v-if="height"
-    class="Module wordDetailChs"
+    class="wordDetailModule wordDetailChs"
     :style="{
       height: height,
       maxHeight: height,
@@ -55,9 +55,10 @@
               :key="'new_word_' + conindex"
             >
               <Strockplayredline
+                :key="conItem + detailIndex + conindex"
                 :Book_text="conItem"
                 :playStorkes="true"
-                :targetDiv="'bwcHanziIntp' + detailIndex + conindex"
+                :targetDiv="'bwcHanziIntp' + conItem + detailIndex + conindex"
                 :wordNum="data.new_word.length"
                 :themeColor="themeColor"
               />
@@ -92,7 +93,7 @@
           </div>
         </div>
         <div class="zhedie-white">
-          <div v-if="data.list1.length > 0">
+          <div v-if="list1 && list1.length > 0" v-loading="loading1">
             <div class="topTitle">
               <span>本课例句</span>
               <span @click="handleChangeTab('wordShow')"
@@ -107,7 +108,7 @@
             </div>
             <el-collapse-transition>
               <div class="liju" v-show="wordShow">
-                <div v-for="(item, i) in data.list1" :key="i">
+                <div v-for="(item, i) in list1" :key="i">
                   <div>{{ i + 1 }}.</div>
                   <div>
                     <p v-html="item.res"></p>
@@ -119,7 +120,7 @@
               </div>
             </el-collapse-transition>
           </div>
-          <div v-if="data.list2.length > 0">
+          <div v-if="list2 && list2.length > 0" v-loading="loading2">
             <div class="topTitle">
               <span>本书例句</span>
               <span @click="handleChangeTab('wordShow2')"
@@ -134,8 +135,8 @@
             </div>
             <el-collapse-transition>
               <div class="liju" v-show="wordShow2">
-                <div v-for="(item, i) in data.list2" :key="i">
-                  <div>{{ i + 1 }}.</div>
+                <div v-for="(item, i) in list2" :key="i">
+                  <div>{{ list1.length + i + 1 }}.</div>
                   <div>
                     <p v-html="item.res"></p>
                     <p class="p2">
@@ -146,7 +147,7 @@
               </div>
             </el-collapse-transition>
           </div>
-          <div v-if="data.list3.length > 0">
+          <div v-if="list3 && list3.length > 0" v-loading="loading3">
             <div class="topTitle">
               <span>本套教材例句</span>
               <span @click="handleChangeTab('wordShow3')"
@@ -160,8 +161,8 @@
             </div>
             <el-collapse-transition>
               <div class="liju" v-if="wordShow3">
-                <div v-for="(item, i) in data.list3" :key="i">
-                  <div>{{ data.list3.length + i + 1 }}.</div>
+                <div v-for="(item, i) in list3" :key="i">
+                  <div>{{ list1.length + list2.length + i + 1 }}.</div>
                   <div>
                     <p>{{ item.sentence }}</p>
                     <p class="p2">
@@ -217,9 +218,7 @@
           </div>
         </div>
       </div>
-      <div class="module-bottom">
-        <Intp :word="data" :themeColor="themeColor" />
-      </div>
+      <Intp :word="data" :themeColor="themeColor" :type="type" />
     </div>
   </div>
 </template>
@@ -228,6 +227,7 @@
 import Strockplayredline from "./Strockplayredline.vue";
 import Audio from "./AudioRed.vue";
 import Intp from "./Intp.vue";
+import { getContent } from "@/api/ajax";
 
 export default {
   //import引入的组件需要注入到对象中才能使用
@@ -238,7 +238,6 @@ export default {
   },
   props: [
     "data",
-    "curQue",
     "changeDetailIndex",
     "closeWord",
     "detailIndex",
@@ -246,6 +245,9 @@ export default {
     "getWordLiju",
     "optionRes",
     "themeColor",
+    "isSuccess",
+    "currentTreeID",
+    "type",
   ],
   data() {
     //这里存放数据
@@ -256,8 +258,13 @@ export default {
       wordShow2: true,
       wordShow3: true,
       list1: [],
+      list2: [],
+      list3: [],
       isShow: false,
       old_word: "",
+      loading1: false,
+      loading2: false,
+      loading3: false,
     };
   },
   //计算属性 类似于data概念
@@ -292,20 +299,63 @@ export default {
     },
     // 下一个单词详情
     nextDetail() {
-      if (this.detailIndex == this.optionRes.length - 1) {
+      let _this = this;
+      if (_this.detailIndex == _this.optionRes.length - 1) {
         this.$message.warning("当前已经是最后一个了 ");
         return;
       }
-      if (this.old_word != this.data.new_word) {
-        this.isShow = false;
-        setTimeout(() => {
-          this.changeDetailIndex("next");
-          this.getWordLiju();
-        }, 50);
-      }
+      _this.changeDetailIndex("next");
+    },
+    viewIntp() {
+      this.loading1 = true;
+      this.loading2 = true;
+      this.loading3 = true;
+      let Mname =
+        "book-courseware_manager-GetCoursewareWordExampleSentenceList";
+      // 获取本课的 本教材的 本套的 的例句
+      getContent(Mname, {
+        courseware_id: this.currentTreeID, // 课件id
+        word: this.data.new_word, //生词
+        search_scope: 0, //检索范围0 本课件  1本教材 2本套
+        is_contain_word_variants: false,
+      })
+        .then((res) => {
+          this.loading1 = false;
+          this.list1 = this.handleExample(res.sentence_list);
+          console.log(this.list1);
+          getContent(Mname, {
+            courseware_id: this.currentTreeID, // 课件id
+            word: this.data.new_word, //生词
+            search_scope: 1, //检索范围0 本课件  1本教材 2本套
+            is_contain_word_variants: false,
+          })
+            .then((res) => {
+              this.loading2 = false;
+              this.list2 = this.handleExample(res.sentence_list);
+              getContent(Mname, {
+                courseware_id: this.currentTreeID, // 课件id
+                word: this.data.new_word, //生词
+                search_scope: 2, //检索范围0 本课件  1本教材 2本套
+                is_contain_word_variants: false,
+              })
+                .then((res) => {
+                  this.loading3 = false;
+                  this.list3 = this.handleExample(res.sentence_list);
+                })
+                .catch((err) => {
+                  this.loading3 = false;
+                });
+            })
+            .catch((err) => {
+              this.loading2 = false;
+            });
+        })
+        .catch((err) => {
+          this.loading1 = false;
+        });
     },
     handleExample(list) {
-      list.map((item, index) => {
+      list = list.map((item, index) => {
         let b = item.begin_position;
         let e = item.end_position;
         let sent = item.sentence;
@@ -317,21 +367,12 @@ export default {
         item.res = res;
         return item;
       });
+      return list;
     },
+
     initData() {
-      // if (this.curQue) {
-      //   this.isShow = true;
-      if (this.data.list1 && this.data.list1.length > 0) {
-        this.handleExample(this.data.list1);
-      }
-      if (this.data.list2 && this.data.list2.length > 0) {
-        this.handleExample(this.data.list2);
-      }
-      if (this.data.list3 && this.data.list3.length > 0) {
-        this.handleExample(this.data.list3);
-      }
-      this.old_word = this.optionRes ? this.optionRes.new_word : "";
-      //}
+      console.log(this.data);
+      this.viewIntp();
       let Fathernode = document.getElementsByClassName(
         "NPC-Big-Book-preview"
       )[0];
@@ -369,22 +410,17 @@ export default {
 </script>
 <style lang="scss" scoped>
 /* @import url(); 引入css类 */
-.Module {
-  position: fixed;
+.wordDetailModule {
   width: 100%;
-  left: 0;
-  top: 0;
   z-index: 999;
   background: rgba(0, 0, 0, 0.33);
   overflow-y: scroll;
+
   .module-inner {
-    position: fixed;
-    top: 0%;
-    left: 50%;
-    margin-left: -394px;
+    padding: 30px 0;
     > div {
       width: 788px;
-      margin-left: 36px;
+      margin: 0 auto;
       background: #ffffff;
       box-shadow: 0px 2px 8px rgba(0, 0, 0, 0.15);
       border-radius: 8px;
@@ -486,8 +522,8 @@ export default {
             margin-right: 8px;
             word-break: normal;
           }
-          .content-voices{
-              width: 16px;
+          .content-voices {
+            width: 16px;
           }
         }
       }

+ 2 - 32
src/components/Adult/preview/components/Wordcard.vue

@@ -121,6 +121,7 @@
     </div>
     <div class="practiceBox" v-if="isIntpShow">
       <WordPhraseDetail
+        :currentTreeID="currentTreeID"
         :closeWord="changeIntpShow"
         :data="word.detail"
         :themeColor="themeColor"
@@ -193,38 +194,7 @@ export default {
       this.isPraShow = false;
     },
     viewIntp() {
-      this.isIntpShow = false;
-      this.word.detail.list1 = [];
-      this.word.detail.list2 = [];
-      this.word.detail.list3 = [];
-      let Mname =
-        "book-courseware_manager-GetCoursewareWordExampleSentenceList";
-      // 获取本课的 本教材的 本套的 的例句
-      getContent(Mname, {
-        courseware_id: this.currentTreeID, // 课件id
-        word: this.word.detail.new_word, //生词
-        search_scope: 2, //检索范围0 本课件  1本教材 2本套
-        is_contain_word_variants: false,
-      }).then((res) => {
-        this.$set(this.word.detail, "list3", res.sentence_list);
-        getContent(Mname, {
-          courseware_id: this.currentTreeID, // 课件id
-          word: this.word.detail.new_word, //生词
-          search_scope: 1, //检索范围0 本课件  1本教材 2本套
-          is_contain_word_variants: false,
-        }).then((res) => {
-          this.$set(this.word.detail, "list2", res.sentence_list);
-          getContent(Mname, {
-            courseware_id: this.currentTreeID, // 课件id
-            word: this.word.detail.new_word, //生词
-            search_scope: 0, //检索范围0 本课件  1本教材 2本套
-            is_contain_word_variants: false,
-          }).then((res) => {
-            this.$set(this.word.detail, "list1", res.sentence_list);
-            this.isIntpShow = true;
-          });
-        });
-      });
+      this.isIntpShow = true;
     },
     changeIntpShow() {
       this.isIntpShow = false;