WordPhraseDetail.vue 20 KB

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