Intp.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681
  1. <!-- -->
  2. <template>
  3. <div class="wordIntp" v-if="word">
  4. <el-menu
  5. :default-active="activeIndex"
  6. class="el-menu-demo"
  7. mode="horizontal"
  8. @select="handleSelect"
  9. >
  10. <el-menu-item index="1">释义</el-menu-item>
  11. <el-menu-item index="2">近/反义词</el-menu-item>
  12. <el-menu-item index="3">组词</el-menu-item>
  13. </el-menu>
  14. <template v-if="activeIndex == '1'">
  15. <div class="bwc-intp">
  16. <!-- 基本释义 -->
  17. <h1>基本释义</h1>
  18. <span v-if="word.pinyin" class="pinyin">{{ word.pinyin }}</span>
  19. <p
  20. v-for="(itemss, indexss) in paraphrase"
  21. :key="indexss"
  22. class="paraphrase"
  23. >
  24. {{ itemss["@value"] }}
  25. </p>
  26. <hr />
  27. </div>
  28. </template>
  29. <template v-if="activeIndex == '2'">
  30. <div class="bwc-intp">
  31. <h1 v-if="synonymList.length > 0">近义词</h1>
  32. <ul class="synonym">
  33. <li
  34. v-for="(itemss, indexss) in synonymList"
  35. :key="indexss"
  36. class="paraphrase"
  37. >
  38. {{ itemss["@value"] }}
  39. </li>
  40. </ul>
  41. <h1 v-if="antonymList.length > 0">反义词</h1>
  42. <ul class="synonym">
  43. <li
  44. v-for="(itemss, indexss) in antonymList"
  45. :key="indexss"
  46. class="paraphrase"
  47. >
  48. {{ itemss["@value"] }}
  49. </li>
  50. </ul>
  51. </div>
  52. </template>
  53. <template v-if="activeIndex == '3'">
  54. <div class="bwc-intp">
  55. <ul class="synonym">
  56. <li
  57. v-for="(itemss, indexss) in termsList"
  58. :key="indexss"
  59. class="paraphrase"
  60. >
  61. {{ itemss["@value"] }}
  62. </li>
  63. </ul>
  64. </div>
  65. </template>
  66. </div>
  67. </template>
  68. <script>
  69. import Audio from "./AudioRed.vue";
  70. import Strockplayredline from "./Strockplayredline.vue";
  71. import { getHZChineseInfo } from "@/api/ajax";
  72. export default {
  73. name: "WordIntp",
  74. components: {
  75. Strockplayredline,
  76. Audio,
  77. },
  78. props: ["word", "changeIntpShow", "themeColor", "show"],
  79. data() {
  80. return {
  81. isPraShow: false,
  82. curData: null,
  83. activeIndex: "1",
  84. mp3Url: "", // 音频
  85. paraphrase: [], // 释义
  86. synonymList: [], // 近义词
  87. antonymList: [], // 反义词
  88. termsList: [], // 组词
  89. dataDetail: [
  90. {
  91. request: {
  92. query: "生",
  93. queryType: "entity",
  94. },
  95. response: {
  96. voice:
  97. "这个字读: shēng,一(yi1)声,诗(shi1)鞥(eng1),生(sheng1),意思是:1、生育;出生。 2、生长。 ",
  98. sourceUrl:
  99. "https://hanyu.baidu.com/zici/s?wd=%E7%94%9F&query=%E7%94%9F&srcid=28532&from=kg2",
  100. answer: ["生"],
  101. sourceName: "百度汉语",
  102. title: "生",
  103. entity: [
  104. {
  105. "@type": ["word"],
  106. name: "生",
  107. attrs: [
  108. {
  109. objects: [
  110. {
  111. "@value":
  112. "http://t10.baidu.com/it/u=1615089267,1656681114&fm=58&s=6BAC3062C6E167A91D9015D70300A0A0",
  113. },
  114. ],
  115. label: "图片",
  116. type: "simple",
  117. key: "image",
  118. },
  119. {
  120. objects: [
  121. {
  122. "@value":
  123. "https://hanyu.baidu.com/zici/s?wd=%E7%94%9F&query=%E7%94%9F&srcid=28532&from=kg2",
  124. },
  125. ],
  126. label: "详情页",
  127. type: "simple",
  128. key: "url",
  129. },
  130. {
  131. objects: [
  132. {
  133. "@value": "熟",
  134. },
  135. {
  136. "@value": "死",
  137. },
  138. {
  139. "@value": "师",
  140. },
  141. {
  142. "@value": "卒",
  143. },
  144. ],
  145. label: "反义词",
  146. type: "simple",
  147. key: "antonym",
  148. },
  149. {
  150. objects: [
  151. {
  152. "@value":
  153. "1.生育;出生。 2.生长。 3.生存;活(跟“死”相对)。 4.生计。 5.生命。 6.生平。 7.具有生命力的;活的。 8.产生;发生。 9.使柴、煤等燃烧。 10.姓。11.果实没有成熟(跟“熟”相对,下12.—13.同)。 14.(食物)没有煮过或煮得不够的。 15.没有进一步加工或炼过的。 16.生疏。 17.生硬;勉强。 18.很(用在少数表示感情、感觉的词的前面)。 19.某些指人的名词后缀。 20.某些副词的后缀,如“好生、怎生”等。",
  154. },
  155. ],
  156. label: "释义",
  157. type: "simple",
  158. key: "definition",
  159. },
  160. {
  161. objects: [
  162. {
  163. "@value":
  164. "https://hanyu-word-pinyin-short.cdn.bcebos.com/sheng1.mp3",
  165. },
  166. ],
  167. label: "读音",
  168. type: "simple",
  169. key: "pronunciation",
  170. },
  171. {
  172. objects: [
  173. {
  174. "@value": "生",
  175. },
  176. ],
  177. label: "部首",
  178. type: "simple",
  179. key: "radicals",
  180. },
  181. {
  182. objects: [
  183. {
  184. "@value": "[shēng]",
  185. },
  186. ],
  187. label: "拼音",
  188. type: "simple",
  189. key: "spell",
  190. },
  191. {
  192. objects: [
  193. {
  194. "@value": "5",
  195. },
  196. ],
  197. label: "笔画",
  198. type: "simple",
  199. key: "stroke_count",
  200. },
  201. {
  202. objects: [
  203. {
  204. "@value": "撇、横、横、竖、横",
  205. },
  206. ],
  207. label: "笔顺",
  208. type: "simple",
  209. key: "stroke_order",
  210. },
  211. {
  212. objects: [
  213. {
  214. "@value":
  215. "http://appcdn.fanyi.baidu.com/zhdict/gif/b78128322d51c43cbaf2701d467822446.gif",
  216. },
  217. ],
  218. label: "笔顺动画",
  219. type: "simple",
  220. key: "stroke_order_gif",
  221. },
  222. {
  223. objects: [
  224. {
  225. "@value": "单一结构",
  226. },
  227. ],
  228. label: "字形结构",
  229. type: "simple",
  230. key: "struct_type",
  231. },
  232. {
  233. objects: [
  234. {
  235. "@value": "生命",
  236. },
  237. {
  238. "@value": "五行相生",
  239. },
  240. {
  241. "@value": "生活",
  242. },
  243. {
  244. "@value": "大学生",
  245. },
  246. {
  247. "@value": "诞生",
  248. },
  249. {
  250. "@value": "生肖",
  251. },
  252. {
  253. "@value": "油然而生",
  254. },
  255. {
  256. "@value": "舍生取义",
  257. },
  258. {
  259. "@value": "栩栩如生",
  260. },
  261. {
  262. "@value": "芸芸众生",
  263. },
  264. {
  265. "@value": "生意",
  266. },
  267. {
  268. "@value": "生机盎然",
  269. },
  270. {
  271. "@value": "生气",
  272. },
  273. {
  274. "@value": "妙笔生花",
  275. },
  276. {
  277. "@value": "浮生",
  278. },
  279. {
  280. "@value": "陌生",
  281. },
  282. {
  283. "@value": "衍生",
  284. },
  285. {
  286. "@value": "生机勃勃",
  287. },
  288. {
  289. "@value": "生意盎然",
  290. },
  291. {
  292. "@value": "终生",
  293. },
  294. ],
  295. label: "组词",
  296. type: "simple",
  297. key: "terms",
  298. },
  299. {
  300. objects: [
  301. {
  302. "@value": "TGD",
  303. },
  304. ],
  305. label: "五笔",
  306. type: "simple",
  307. key: "wubi",
  308. },
  309. ],
  310. },
  311. ],
  312. },
  313. },
  314. ],
  315. };
  316. },
  317. computed: {},
  318. watch: {
  319. word: {
  320. handler: function (val, oldVal) {
  321. let _this = this;
  322. },
  323. // 深度观察监听
  324. deep: true,
  325. },
  326. },
  327. //方法集合
  328. methods: {
  329. writeWord() {
  330. this.isPraShow = true;
  331. },
  332. changePraShow() {
  333. this.isPraShow = false;
  334. },
  335. handleSelect(val) {
  336. this.activeIndex = val;
  337. },
  338. getChineseInfo() {
  339. let _this = this;
  340. let data = {
  341. query: this.word.new_word,
  342. // query: "开心",
  343. };
  344. getHZChineseInfo(data).then((res) => {
  345. _this.dataDetail = res.data.result;
  346. _this.handleChineseDetail();
  347. });
  348. },
  349. // 处理数据
  350. handleChineseDetail() {
  351. let _this = this;
  352. _this.dataDetail.forEach((item) => {
  353. if (item.request.queryType == "entity") {
  354. // 读音
  355. item.response.entity.forEach((items) => {
  356. items.attrs.forEach((itemss) => {
  357. if (itemss.key == "pronunciation") {
  358. // 音频
  359. _this.mp3Url = itemss.objects[0]["@value"]
  360. ? itemss.objects[0]["@value"]
  361. : "";
  362. } else if (itemss.key == "definition") {
  363. // 释义
  364. _this.paraphrase = itemss.objects;
  365. } else if (itemss.key == "synonym") {
  366. // 近义词
  367. _this.synonymList = itemss.objects;
  368. } else if (itemss.key == "antonym") {
  369. // 反义词
  370. _this.antonymList = itemss.objects;
  371. } else if (itemss.key == "terms") {
  372. // 反义词
  373. _this.termsList = itemss.objects;
  374. }
  375. });
  376. });
  377. }
  378. });
  379. },
  380. },
  381. //生命周期 - 创建完成(可以访问当前this实例)
  382. created() {},
  383. //生命周期 - 挂载完成(可以访问DOM元素)
  384. mounted() {
  385. let _this = this;
  386. // this.getChineseInfo();
  387. _this.handleChineseDetail();
  388. },
  389. beforeCreate() {}, //生命周期 - 创建之前
  390. beforeMount() {}, //生命周期 - 挂载之前
  391. beforeUpdate() {}, //生命周期 - 更新之前
  392. updated() {}, //生命周期 - 更新之后
  393. beforeDestroy() {}, //生命周期 - 销毁之前
  394. destroyed() {}, //生命周期 - 销毁完成
  395. activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  396. };
  397. </script>
  398. <style lang='scss' scoped>
  399. //@import url(); 引入公共css类
  400. .wordIntp {
  401. width: 100%;
  402. // height: 100vh;
  403. overflow: hidden;
  404. overflow-y: auto;
  405. margin: 0 auto;
  406. position: relative;
  407. .bwc-intp {
  408. padding: 16px 0;
  409. h1 {
  410. color: #000000;
  411. font-size: 20px;
  412. line-height: 150%;
  413. font-weight: normal;
  414. margin: 8px 0 8px 0;
  415. }
  416. .pinyin {
  417. color: #de4444;
  418. font-size: 24px;
  419. line-height: 36px;
  420. margin-bottom: 8px;
  421. font-family: "GB-PINYINOK-B";
  422. display: block;
  423. }
  424. .paraphrase {
  425. margin-bottom: 8px;
  426. margin-top: 0;
  427. color: #000000;
  428. font-size: 16px;
  429. line-height: 150%;
  430. }
  431. hr {
  432. margin: 16px 0 0 0;
  433. background: rgba($color: #000000, $alpha: 0.15);
  434. height: 1px;
  435. border: none;
  436. }
  437. ul.synonym {
  438. display: flex;
  439. flex-flow: wrap;
  440. margin-left: -4px;
  441. padding: 4px 0;
  442. li {
  443. padding: 4px 8px;
  444. background: #ffffff;
  445. border: 1px solid rgba(0, 0, 0, 0.15);
  446. border-radius: 4px;
  447. margin: 4px;
  448. font-size: 16px;
  449. line-height: 150%;
  450. color: #000000;
  451. text-align: center;
  452. min-width: 127px;
  453. }
  454. }
  455. }
  456. .practiceBox {
  457. position: fixed;
  458. left: 0;
  459. top: 0;
  460. z-index: 999;
  461. width: 100%;
  462. height: 100vh;
  463. background: rgba(0, 0, 0, 0.19);
  464. padding-top: 32px;
  465. box-sizing: border-box;
  466. overflow: hidden;
  467. overflow-y: auto;
  468. }
  469. .closeBox {
  470. width: 100%;
  471. display: flex;
  472. justify-content: space-between;
  473. position: absolute;
  474. left: 0;
  475. top: 0;
  476. padding: 12px;
  477. > i {
  478. font-size: 16px;
  479. color: #000000;
  480. cursor: pointer;
  481. }
  482. span {
  483. color: #000000;
  484. opacity: 0.2;
  485. font-size: 14px;
  486. line-height: 130%;
  487. }
  488. }
  489. min-width: 312px;
  490. min-height: 360px;
  491. background: #ffffff;
  492. box-shadow: 0px 2px 8px rgba(0, 0, 0, 0.15);
  493. border-radius: 8px;
  494. padding: 52px 32px 32px;
  495. box-sizing: border-box;
  496. .bwc-top {
  497. margin-bottom: 16px;
  498. width: 100%;
  499. display: flex;
  500. justify-content: center;
  501. align-items: center;
  502. .content-voices {
  503. width: 24px;
  504. }
  505. > span {
  506. font-family: "GB-PINYINOK-B";
  507. color: #2c2c2c;
  508. font-size: 20px;
  509. line-height: 24px;
  510. margin-right: 4px;
  511. }
  512. }
  513. .bwc-Strockplay {
  514. display: flex;
  515. justify-content: center;
  516. align-items: center;
  517. min-width: 130px;
  518. height: 130px;
  519. margin: 0 auto;
  520. margin-bottom: 6px;
  521. border: 2px solid #de4444;
  522. border-radius: 8px;
  523. box-sizing: border-box;
  524. overflow: hidden;
  525. .strockplay {
  526. display: flex;
  527. justify-content: center;
  528. align-items: center;
  529. position: relative;
  530. .collect-icon {
  531. width: 16px;
  532. position: absolute;
  533. right: 4px;
  534. bottom: 4px;
  535. cursor: pointer;
  536. }
  537. }
  538. .bwc-line {
  539. width: 2px;
  540. height: 126px;
  541. background: #de4444;
  542. }
  543. }
  544. .bwc-tolength {
  545. color: #404040;
  546. font-size: 30px;
  547. line-height: 1.5;
  548. font-family: FZJCGFKTK;
  549. text-align: center;
  550. border: 2px solid #de4444;
  551. border-radius: 8px;
  552. padding: 40px 0;
  553. margin: 0 0 16px 0;
  554. }
  555. .bwc-word-en {
  556. font-style: normal;
  557. font-weight: 600;
  558. font-size: 20px;
  559. line-height: 150%;
  560. text-align: center;
  561. color: #2c2c2c;
  562. margin-bottom: 8px;
  563. }
  564. .bwc-more-intp {
  565. font-weight: normal;
  566. font-size: 14px;
  567. line-height: 20px;
  568. color: #2c2c2c;
  569. opacity: 0.5;
  570. text-align: center;
  571. margin-bottom: 24px;
  572. cursor: pointer;
  573. }
  574. .bwc-footer {
  575. width: 100%;
  576. display: flex;
  577. justify-content: space-between;
  578. align-items: center;
  579. > button {
  580. width: 128px;
  581. height: 40px;
  582. display: flex;
  583. justify-content: center;
  584. align-items: center;
  585. color: #ff5757;
  586. background: rgba(255, 87, 87, 0.1);
  587. border-radius: 4px;
  588. outline: 0;
  589. border: 0;
  590. cursor: pointer;
  591. > img {
  592. width: 24px;
  593. height: 24px;
  594. margin-right: 8px;
  595. }
  596. }
  597. }
  598. }
  599. .NNPE-Big-Book-preview-green {
  600. .wordIntp {
  601. .bwc-intp {
  602. .pinyin {
  603. color: #24b99e;
  604. }
  605. }
  606. .bwc-Strockplay {
  607. border: 2px solid #24b99e;
  608. .bwc-line {
  609. background: #24b99e;
  610. }
  611. }
  612. .bwc-tolength {
  613. border: 2px solid #24b99e;
  614. }
  615. .bwc-footer {
  616. > button {
  617. color: #24b99e;
  618. }
  619. }
  620. }
  621. }
  622. .NNPE-Big-Book-preview-brown {
  623. .wordIntp {
  624. .bwc-intp {
  625. .pinyin {
  626. color: #bd8865;
  627. }
  628. }
  629. .bwc-Strockplay {
  630. border: 2px solid #bd8865;
  631. .bwc-line {
  632. background: #bd8865;
  633. }
  634. }
  635. .bwc-tolength {
  636. border: 2px solid #bd8865;
  637. }
  638. .bwc-footer {
  639. > button {
  640. color: #bd8865;
  641. }
  642. }
  643. }
  644. }
  645. </style>
  646. <style lang="scss">
  647. .wordIntp {
  648. .el-menu--horizontal > .el-menu-item {
  649. width: 33.33%;
  650. text-align: center;
  651. color: #000000;
  652. font-size: 18px;
  653. }
  654. .el-menu.el-menu--horizontal {
  655. border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  656. }
  657. .el-menu--horizontal > .el-menu-item.is-active {
  658. color: #de4444;
  659. font-weight: bold;
  660. border-bottom: 2px solid #de4444;
  661. }
  662. }
  663. .NNPE-Big-Book-preview-green {
  664. .wordIntp {
  665. .el-menu--horizontal > .el-menu-item.is-active {
  666. color: #24b99e;
  667. border-bottom: 2px solid #24b99e;
  668. }
  669. }
  670. }
  671. .NNPE-Big-Book-preview-brown {
  672. .wordIntp {
  673. .el-menu--horizontal > .el-menu-item.is-active {
  674. color: #bd8865;
  675. border-bottom: 2px solid #bd8865;
  676. }
  677. }
  678. }
  679. </style>