WordPhraseDetailEn.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741
  1. <template>
  2. <div class="Module">
  3. <div class="module-inner">
  4. <div class="top" v-if="detail">
  5. <div class="operation">
  6. <div>
  7. <!-- <img
  8. style="margin-right: 8px"
  9. src="../../assets/Left-16-normal-Black.png"
  10. alt=""
  11. @click="lastDetail"
  12. v-if="!notshowNext"
  13. />
  14. <img
  15. src="../../assets/Right-16-normal-Black.png"
  16. alt=""
  17. @click="nextDetail"
  18. v-if="!notshowNext"
  19. /> -->
  20. <img
  21. @click="closeWordShow"
  22. src="../../assets/Cross-16-normal-Black.png"
  23. alt=""
  24. />
  25. </div>
  26. </div>
  27. <div class="wordDetail">
  28. <p class="word">{{ detail.new_word.new_word }}</p>
  29. <div class="yinpin" v-if="detail.new_word.pinyin">
  30. <span> /{{ detail.new_word.pinyin }}/</span>
  31. <img
  32. @click="palyAudio('deafult')"
  33. :src="playBtn == 'deafult' ? voicePlaySrc : voicePauseSrc"
  34. alt=""
  35. v-if="
  36. detail.new_word.mp3_list &&
  37. detail.new_word.mp3_list.length > 0 &&
  38. playWord == 'deafult' &&
  39. voiceSrc
  40. "
  41. />
  42. <img
  43. @click="palyAudio('deafult')"
  44. :src="voicePauseSrc"
  45. alt=""
  46. v-else-if="
  47. detail.new_word.mp3_list && detail.new_word.mp3_list.length > 0
  48. "
  49. />
  50. <audio
  51. v-if="
  52. detail.new_word.mp3_list && detail.new_word.mp3_list.length > 0
  53. "
  54. id="deafult"
  55. :src="detail.new_word.mp3_list[0].id"
  56. ></audio>
  57. </div>
  58. <p
  59. class="jieshu"
  60. v-for="(fy, i) in detail.new_word.definition_list"
  61. :key="i"
  62. >
  63. <template v-if="fy.indexOf('. ') > -1">
  64. <i>{{ fy.substring(0, fy.indexOf(". ") + 2) }}</i>
  65. <span
  66. >{{ fy.substring(fy.indexOf(". ") + 2, fy.length)
  67. }}{{
  68. i == detail.new_word.definition_list.length - 1 ? "" : ";"
  69. }}</span
  70. >
  71. </template>
  72. <template v-else>
  73. <span>{{
  74. i == detail.new_word.definition_list.length - 1 ? fy : fy + ";"
  75. }}</span>
  76. </template>
  77. </p>
  78. </div>
  79. <div class="zhedie">
  80. <div v-if="list1 && list1.length > 0">
  81. <div class="topTitle">
  82. <!-- 本课例句 -->
  83. <span>{{ $t("Key668") }}({{ list1.length }})</span>
  84. <span @click="handleChangeTab('wordShow')"
  85. >{{ wordShow ? $t("Key531") : $t("Key530") }}
  86. <img v-if="wordShow" src="../../assets/down-black.png" alt="" />
  87. <img
  88. v-else
  89. class="rotate"
  90. src="../../assets/up-black.png"
  91. alt=""
  92. />
  93. </span>
  94. </div>
  95. <el-collapse-transition>
  96. <div class="liju" v-if="wordShow">
  97. <div v-for="(item, i) in list1" :key="i">
  98. <div>{{ i + 1 }}.</div>
  99. <div style="flex: 1">
  100. <p v-html="item.res"></p>
  101. <p class="p2">
  102. {{ $t("Key666") }}:{{ item.source_courseware_name_path }}
  103. </p>
  104. </div>
  105. </div>
  106. </div>
  107. </el-collapse-transition>
  108. </div>
  109. <div v-if="list2 && list2.length > 0">
  110. <div class="topTitle">
  111. <!-- 本书例句 -->
  112. <span>{{ $t("Key669") }}({{ list2.length }})</span>
  113. <span @click="handleChangeTab('wordShow2')"
  114. >{{ wordShow2 ? $t("Key531") : $t("Key530") }}
  115. <img
  116. v-if="wordShow2"
  117. src="../../assets/down-black.png"
  118. alt=""
  119. />
  120. <img
  121. v-else
  122. class="rotate"
  123. src="../../assets/up-black.png"
  124. alt=""
  125. />
  126. </span>
  127. </div>
  128. <el-collapse-transition>
  129. <div class="liju" v-if="wordShow2">
  130. <div v-for="(item, i) in list2" :key="i">
  131. <div>{{ i + 1 }}.</div>
  132. <div style="flex: 1">
  133. <p v-html="item.res"></p>
  134. <p class="p2">
  135. {{ $t("Key666") }}:{{ item.source_courseware_name_path }}
  136. </p>
  137. </div>
  138. </div>
  139. </div>
  140. </el-collapse-transition>
  141. </div>
  142. <div v-if="list3 && list3.length > 0">
  143. <div class="topTitle">
  144. <!-- Key667 本套教材例句 -->
  145. <span>{{ $t("Key667") }}({{ list3.length }})</span>
  146. <span @click="handleChangeTab('wordShow3')"
  147. >{{ wordShow3 ? $t("Key531") : $t("Key530") }}
  148. <img
  149. v-if="wordShow3"
  150. src="../../assets/down-black.png"
  151. alt=""
  152. />
  153. <img
  154. v-else
  155. class="rotate"
  156. src="../../assets/up-black.png"
  157. alt=""
  158. />
  159. </span>
  160. </div>
  161. <el-collapse-transition>
  162. <div class="liju" v-if="wordShow3">
  163. <div v-for="(item, i) in list3" :key="i">
  164. <div>{{ list3.length + i + 1 }}.</div>
  165. <div style="flex: 1">
  166. <p v-html="item.res"></p>
  167. <p class="p2">
  168. {{ $t("Key666") }}:{{ item.source_courseware_name_path }}
  169. </p>
  170. </div>
  171. </div>
  172. </div>
  173. </el-collapse-transition>
  174. </div>
  175. </div>
  176. </div>
  177. <div class="bottom" v-if="dictDetail">
  178. <div class="from">
  179. <!-- Key670 来自网易有道-->
  180. {{ $t("Key670")
  181. }}<img
  182. @click="closeWordShow"
  183. src="../../assets/Cross-16-normal-Black.png"
  184. alt=""
  185. v-if="!dictDetail"
  186. />
  187. </div>
  188. <div class="wordDetail">
  189. <p class="word">
  190. {{ dictDetail["query"] }}
  191. </p>
  192. <div class="yinpin">
  193. <div class="yinpin-box">
  194. <!-- 英 -->
  195. <span>{{ $t("Key671") }}</span>
  196. <span v-if="dictDetail['uk-phonetic']">
  197. /{{ dictDetail["uk-phonetic"] }}/</span
  198. >
  199. <img
  200. @click="palyAudio('Y')"
  201. :src="playBtn == 'Y' ? voicePlaySrc : voicePauseSrc"
  202. alt=""
  203. v-if="
  204. dictDetail &&
  205. dictDetail['uk-sound'] &&
  206. playWord == 'Y' &&
  207. voiceSrc
  208. "
  209. />
  210. <img
  211. @click="palyAudio('Y')"
  212. :src="voicePauseSrc"
  213. alt=""
  214. v-else-if="dictDetail"
  215. />
  216. <audio id="Y" :src="dictDetail['uk-sound']"></audio>
  217. </div>
  218. <div>
  219. <!-- 美 -->
  220. <span>{{ $t("Key672") }}</span>
  221. <span v-if="dictDetail['us-phonetic']">
  222. /{{ dictDetail["us-phonetic"] }}/</span
  223. >
  224. <img
  225. @click="palyAudio('M')"
  226. :src="playBtn == 'M' ? voicePlaySrc : voicePauseSrc"
  227. alt=""
  228. v-if="
  229. dictDetail &&
  230. dictDetail['us-sound'] &&
  231. playWord == 'M' &&
  232. voiceSrc
  233. "
  234. />
  235. <img
  236. @click="palyAudio('M')"
  237. :src="voicePauseSrc"
  238. alt=""
  239. v-else-if="dictDetail && dictDetail['us-sound']"
  240. />
  241. <audio id="M" :src="dictDetail['us-sound']"></audio>
  242. </div>
  243. </div>
  244. <div class="jieshu" v-for="(fy, i) in dictDetail.part" :key="i">
  245. <i>
  246. {{ fy.part }}
  247. </i>
  248. <div>
  249. {{ fy.exp }}
  250. </div>
  251. </div>
  252. </div>
  253. </div>
  254. </div>
  255. </div>
  256. </template>
  257. <script>
  258. //这里可以导入其它文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  259. //例如:import 《组件名称》from ‘《组件路径》';
  260. import { getBookWebContent, getLearnWebContent } from "@/api/ajax";
  261. export default {
  262. //import引入的组件需要注入到对象中才能使用
  263. components: {},
  264. props: ["closeWord", "collId", "currentTreeID"],
  265. data() {
  266. //这里存放数据
  267. return {
  268. height: "",
  269. margintop: "",
  270. wordShow: true,
  271. wordShow2: false,
  272. wordShow3: false,
  273. list1: [],
  274. list2: [],
  275. list3: [],
  276. playWord: "",
  277. playBtn: "",
  278. voiceSrc: require("../../assets/play-red.png"),
  279. voicePauseSrc: require("../../assets/play-red.png"),
  280. voicePlaySrc: require("../../assets/icon-voice-play-red.png"),
  281. collFlag: false,
  282. loading: false,
  283. detail: null,
  284. dictDetail: null,
  285. };
  286. },
  287. // 计算属性 类似于data概念
  288. computed: {},
  289. // 监控data中数据变化
  290. watch: {},
  291. // 方法集合
  292. methods: {
  293. palyAudio(new_word) {
  294. let node = document.getElementById(new_word);
  295. this.playWord = new_word;
  296. if (node) {
  297. node.play();
  298. this.voiceSrc = this.voicePlaySrc;
  299. this.playBtn = new_word;
  300. }
  301. this.handleListenPlay();
  302. },
  303. handleListenPlay() {
  304. let _this = this;
  305. if (_this.playWord) {
  306. let node = document.getElementById(_this.playWord);
  307. node.addEventListener("play", function () {});
  308. node.addEventListener("pause", function () {
  309. _this.playBtn = "";
  310. });
  311. node.addEventListener("ended", function () {
  312. _this.playBtn = "";
  313. });
  314. }
  315. },
  316. // 关闭单词详情
  317. closeWordShow() {
  318. this.closeWord(false);
  319. },
  320. // 上一个单词详情
  321. lastDetail() {
  322. if (this.detailIndex == 0) {
  323. // this.$message.warning("当前已经是第一个");
  324. this.$message.warning(this.$t("Key665"));
  325. return;
  326. }
  327. this.changeDetailIndex("last");
  328. },
  329. // 下一个单词详情
  330. nextDetail() {
  331. if (this.detailIndex == this.curQue.option.length - 1) {
  332. // this.$message.warning("当前已经是最后一个了 ");
  333. this.$message.warning(this.$t("Key664"));
  334. return;
  335. }
  336. this.changeDetailIndex("next");
  337. },
  338. handleChangeTab(flag) {
  339. this[flag] = !this[flag];
  340. },
  341. viewIntp() {
  342. this.loading1 = true;
  343. this.loading2 = true;
  344. this.loading3 = true;
  345. let Mname =
  346. "book-courseware_manager-GetCoursewareWordExampleSentenceList";
  347. // 获取本课的 本教材的 本套的 的例句
  348. getBookWebContent(Mname, {
  349. courseware_id: this.currentTreeID, // 课件id
  350. word: this.detail.new_word.new_word, //生词
  351. search_scope: 0, //检索范围0 本课件 1本教材 2本套
  352. is_contain_word_variants: false,
  353. })
  354. .then((res) => {
  355. this.loading1 = false;
  356. this.list1 = this.handleExample(res.sentence_list);
  357. getBookWebContent(Mname, {
  358. courseware_id: this.currentTreeID, // 课件id
  359. word: this.detail.new_word.new_word, //生词
  360. search_scope: 1, //检索范围0 本课件 1本教材 2本套
  361. is_contain_word_variants: false,
  362. })
  363. .then((res) => {
  364. this.loading2 = false;
  365. this.list2 = this.handleExample(res.sentence_list);
  366. getBookWebContent(Mname, {
  367. courseware_id: this.currentTreeID, // 课件id
  368. word: this.detail.new_word.new_word, //生词
  369. search_scope: 2, //检索范围0 本课件 1本教材 2本套
  370. is_contain_word_variants: false,
  371. })
  372. .then((res) => {
  373. this.loading3 = false;
  374. this.list3 = this.handleExample(res.sentence_list);
  375. })
  376. .catch((err) => {
  377. this.loading3 = false;
  378. });
  379. })
  380. .catch((err) => {
  381. this.loading2 = false;
  382. });
  383. })
  384. .catch((err) => {
  385. this.loading1 = false;
  386. });
  387. },
  388. // 处理例句高亮数据
  389. handleExample(list) {
  390. let _this = this;
  391. // let list1Ora = JSON.parse(JSON.stringify(_this.data.list1))
  392. list = list.map((item, index) => {
  393. let position_str = [];
  394. let sentence = JSON.parse(JSON.stringify(item.sentence));
  395. let res = "";
  396. for (let i = 0; i < item.position_list.length; i++) {
  397. let part1 = "";
  398. let part2 = "";
  399. let part3 = "";
  400. if (item.position_list.length > 1) {
  401. if (i == 0) {
  402. part1 = sentence.substring(0, item.position_list[i].begin);
  403. part2 = sentence.substring(
  404. item.position_list[i].begin,
  405. item.position_list[i].end
  406. );
  407. part3 = sentence.substring(
  408. item.position_list[i].end,
  409. item.position_list[i + 1].begin
  410. );
  411. } else if (i == item.position_list.length - 1) {
  412. part1 = "";
  413. part2 = sentence.substring(
  414. item.position_list[i].begin,
  415. item.position_list[i].end
  416. );
  417. part3 = sentence.substring(item.position_list[i].end);
  418. } else {
  419. part1 = "";
  420. part2 = sentence.substring(
  421. item.position_list[i].begin,
  422. item.position_list[i].end
  423. );
  424. part3 = sentence.substring(
  425. item.position_list[i].end,
  426. item.position_list[i + 1].begin
  427. );
  428. }
  429. } else {
  430. part1 = sentence.substring(0, item.position_list[i].begin);
  431. part2 = sentence.substring(
  432. item.position_list[i].begin,
  433. item.position_list[i].end
  434. );
  435. part3 = sentence.substring(item.position_list[i].end);
  436. }
  437. res +=
  438. part1 + '<span style="color:#DE4444;">' + part2 + "</span>" + part3;
  439. }
  440. item.res = res;
  441. return item;
  442. });
  443. return list;
  444. },
  445. getMyCollection() {
  446. this.loading = true;
  447. let Mname = "order-collection_manager-GetMyCollection";
  448. let data = {
  449. id: this.collId,
  450. };
  451. getLearnWebContent(Mname, data).then((res) => {
  452. this.loading = false;
  453. this.detail = res;
  454. if (res.new_word.definition_dictionary_json) {
  455. let dictDetail = JSON.parse(res.new_word.definition_dictionary_json);
  456. this.dictDetail = dictDetail.data;
  457. console.log(this.dictDetail);
  458. }
  459. this.viewIntp();
  460. });
  461. },
  462. },
  463. //生命周期 - 创建完成(可以访问当前this实例)
  464. created() {
  465. this.getMyCollection();
  466. },
  467. //生命周期 - 挂载完成(可以访问DOM元素)
  468. mounted() {
  469. let Fathernode = document.getElementsByClassName(
  470. "NNPE-Big-Book-preview"
  471. )[0];
  472. if (Fathernode) {
  473. // this.height = Fathernode.clientHeight + "px";
  474. this.height = Fathernode.clientHeight + "px";
  475. // this.margintop = "-" + window.innerHeight / 2 + "px";
  476. }
  477. },
  478. //生命周期-创建之前
  479. beforeCreated() {},
  480. //生命周期-挂载之前
  481. beforeMount() {},
  482. //生命周期-更新之前
  483. beforUpdate() {},
  484. //生命周期-更新之后
  485. updated() {},
  486. //生命周期-销毁之前
  487. beforeDestory() {},
  488. //生命周期-销毁完成
  489. destoryed() {},
  490. //如果页面有keep-alive缓存功能,这个函数会触发
  491. activated() {},
  492. };
  493. </script>
  494. <style lang="scss" scoped>
  495. /* @import url(); 引入css类 */
  496. .Module {
  497. .module-inner {
  498. // position: fixed;
  499. // top: 0%;
  500. // left: 50%;
  501. // margin-left: -394px;
  502. width: 788px;
  503. margin: 0 auto;
  504. > div {
  505. width: 788px;
  506. margin-left: 36px;
  507. background: #ffffff;
  508. box-shadow: 0px 4px 24px rgba(0, 0, 0, 0.25);
  509. border-radius: 8px;
  510. padding-top: 16px;
  511. .operation {
  512. height: 24px;
  513. div {
  514. float: right;
  515. margin-right: 16px;
  516. > :nth-child(1) {
  517. margin-right: 16px;
  518. }
  519. > :nth-child(2) {
  520. margin-right: 8px;
  521. }
  522. > :nth-child(3) {
  523. margin-right: 16px;
  524. }
  525. > :last-child {
  526. margin-right: 0;
  527. }
  528. }
  529. img {
  530. width: 16px;
  531. height: 16px;
  532. cursor: pointer;
  533. }
  534. }
  535. }
  536. }
  537. .top {
  538. margin-top: 33px;
  539. padding-bottom: 42px;
  540. .wordDetail {
  541. width: 538px;
  542. margin-left: 40px;
  543. padding-bottom: 23px;
  544. p {
  545. margin: 0;
  546. }
  547. .word {
  548. font-weight: bold;
  549. font-size: 24px;
  550. line-height: 28px;
  551. color: #7b61ff;
  552. }
  553. .yinpin {
  554. font-size: 16px;
  555. line-height: 150%;
  556. color: #000000;
  557. margin-top: 16px;
  558. display: flex;
  559. align-items: center;
  560. justify-content: flex-start;
  561. > div {
  562. height: 16px;
  563. display: flex;
  564. align-items: center;
  565. }
  566. }
  567. img {
  568. margin-left: 10px;
  569. width: 16px;
  570. height: 16px;
  571. cursor: pointer;
  572. }
  573. .jieshu {
  574. margin-top: 16px;
  575. font-size: 16px;
  576. line-height: 150%;
  577. color: #000000;
  578. }
  579. }
  580. .zhedie {
  581. width: 708px;
  582. margin: 0 auto;
  583. > div {
  584. margin-bottom: 16px;
  585. }
  586. .topTitle {
  587. width: 100%;
  588. display: flex;
  589. justify-content: space-between;
  590. padding: 0 12px;
  591. align-items: center;
  592. background: #fff !important;
  593. height: 40px;
  594. background: #fff !important;
  595. border: 1px solid rgba(0, 0, 0, 0.1);
  596. -webkit-box-sizing: border-box;
  597. box-sizing: border-box;
  598. border-radius: 8px 8px 0px 0px;
  599. > :nth-child(1) {
  600. font-weight: 500;
  601. font-size: 16px;
  602. line-height: 150%;
  603. color: rgba(0, 0, 0, 0.85);
  604. }
  605. > :nth-child(2) {
  606. display: flex;
  607. align-items: center;
  608. font-weight: normal;
  609. font-size: 14px;
  610. line-height: 22px;
  611. color: rgba(0, 0, 0, 0.85);
  612. cursor: pointer;
  613. }
  614. img {
  615. width: 16px;
  616. height: 16px;
  617. margin-left: 4px;
  618. }
  619. .rotate {
  620. animation-name: firstrotate;
  621. animation-direction: 2s;
  622. animation-fill-mode: both;
  623. animation-timing-function: linear;
  624. }
  625. }
  626. .liju {
  627. padding-bottom: 16px;
  628. padding-right: 24px;
  629. background: #f7f7f7;
  630. border: 1px solid rgba(0, 0, 0, 0.1);
  631. border-top: none;
  632. border-radius: 0 0 4px 4px;
  633. > div {
  634. padding-top: 16px;
  635. margin-left: 8px;
  636. display: flex;
  637. > :nth-child(1) {
  638. margin-right: 6px;
  639. line-height: 24px;
  640. }
  641. p {
  642. margin: 0;
  643. line-height: 24px;
  644. font-size: 16px;
  645. color: rgba(0, 0, 0, 0.85);
  646. word-break: break-word;
  647. }
  648. .p2 {
  649. font-size: 12px;
  650. line-height: 20px;
  651. color: rgba(0, 0, 0, 0.85);
  652. opacity: 0.3;
  653. }
  654. }
  655. }
  656. }
  657. }
  658. .bottom {
  659. margin-top: 16px;
  660. padding-bottom: 23px;
  661. .from {
  662. // text-align: right;
  663. margin-right: 16px;
  664. font-size: 14px;
  665. line-height: 16px;
  666. color: #000000;
  667. opacity: 0.2;
  668. display: flex;
  669. justify-content: flex-end;
  670. align-items: center;
  671. img {
  672. width: 16px;
  673. margin-left: 16px;
  674. cursor: pointer;
  675. }
  676. }
  677. .wordDetail {
  678. width: 708px;
  679. margin-left: 40px;
  680. padding-bottom: 23px;
  681. border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  682. p {
  683. margin: 0;
  684. }
  685. .word {
  686. font-weight: bold;
  687. font-size: 24px;
  688. line-height: 28px;
  689. color: #7b61ff;
  690. }
  691. .yinpin {
  692. font-size: 16px;
  693. line-height: 150%;
  694. color: #000000;
  695. margin-top: 16px;
  696. display: flex;
  697. justify-content: flex-start;
  698. align-items: center;
  699. > div {
  700. height: 24px;
  701. display: flex;
  702. align-items: center;
  703. > :nth-child(1) {
  704. margin-right: 5px;
  705. }
  706. }
  707. > :nth-child(2) {
  708. margin-left: 27px;
  709. }
  710. img {
  711. margin-left: 10px;
  712. width: 16px;
  713. height: 16px;
  714. cursor: pointer;
  715. }
  716. }
  717. .jieshu {
  718. margin-top: 16px;
  719. font-size: 16px;
  720. line-height: 150%;
  721. color: #000000;
  722. display: flex;
  723. > :nth-child(1) {
  724. // width: 30px;
  725. // text-align: right;
  726. margin-right: 5px;
  727. }
  728. :nth-child(2) {
  729. max-width: 524px;
  730. }
  731. }
  732. }
  733. }
  734. }
  735. </style>