Intp.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522
  1. <!-- -->
  2. <template>
  3. <div class="wordIntp" v-if="flag">
  4. <!-- Key678 数据来自百度汉语-->
  5. <p class="from">{{ $t("Key678") }}</p>
  6. <el-menu
  7. :default-active="activeIndex"
  8. class="el-menu-demo"
  9. mode="horizontal"
  10. @select="handleSelect"
  11. >
  12. <!--词典释义 近/反义词 组词 -->
  13. <el-menu-item index="1">{{ $t("Key679") }}</el-menu-item>
  14. <el-menu-item index="2">{{ $t("Key680") }}</el-menu-item>
  15. <el-menu-item index="3">{{ $t("Key681") }}</el-menu-item>
  16. </el-menu>
  17. <template v-if="activeIndex == '1'">
  18. <div class="bwc-intp">
  19. <!-- 基本释义 -->
  20. <h1>{{ $t("Key681") }}</h1>
  21. <span v-if="pinyin" class="pinyin">{{ pinyin }}</span>
  22. <template v-if="isHasValue2 == 'definitionWithSpell'">
  23. <div
  24. v-for="(itemss, indexss) in paraphrase"
  25. :key="indexss"
  26. class="paraphrase"
  27. >
  28. <div
  29. v-for="(vItems, key, vIndexs) in itemss['@definitionWithSpell']"
  30. :key="vIndexs"
  31. class="para"
  32. >
  33. <span class="para-key">{{
  34. key.replace("[", "").replace("]", "")
  35. }}</span>
  36. <ul
  37. v-for="(pItems, pIndexs) in vItems"
  38. :key="pIndexs"
  39. class="para-value"
  40. >
  41. <li>{{ pItems }}</li>
  42. </ul>
  43. </div>
  44. </div>
  45. </template>
  46. <template v-else-if="isHasValue2 == 'definitions'">
  47. <div
  48. v-for="(itemss, indexss) in paraphrase"
  49. :key="indexss"
  50. class="paraphrase"
  51. >
  52. <ul
  53. v-for="(vItems, key, vIndexs) in itemss['@definitions']"
  54. :key="vIndexs"
  55. class="para"
  56. >
  57. <li>{{ vItems }}</li>
  58. </ul>
  59. </div>
  60. </template>
  61. <template v-else>
  62. <ul
  63. v-for="(itemss, indexss) in paraphrase"
  64. :key="indexss"
  65. class="paraphrase"
  66. >
  67. <li>{{ itemss["@value"] }}</li>
  68. </ul>
  69. </template>
  70. <hr />
  71. </div>
  72. </template>
  73. <template v-if="activeIndex == '2'">
  74. <div class="bwc-intp">
  75. <!-- 近义词 -->
  76. <h1 v-if="synonymList.length > 0">{{$t("Key683")}}</h1>
  77. <ul class="synonym">
  78. <li
  79. v-for="(itemss, indexss) in synonymList"
  80. :key="indexss"
  81. class="paraphrase"
  82. >
  83. {{ itemss["@value"] }}
  84. </li>
  85. </ul>
  86. <!-- 反义词 -->
  87. <h1 v-if="antonymList.length > 0">{{$t("Key684")}}</h1>
  88. <ul class="synonym">
  89. <li
  90. v-for="(itemss, indexss) in antonymList"
  91. :key="indexss"
  92. class="paraphrase"
  93. >
  94. {{ itemss["@value"] }}
  95. </li>
  96. </ul>
  97. </div>
  98. </template>
  99. <template v-if="activeIndex == '3'">
  100. <div class="bwc-intp">
  101. <ul class="synonym">
  102. <li
  103. v-for="(itemss, indexss) in termsList"
  104. :key="indexss"
  105. class="paraphrase"
  106. >
  107. {{ itemss["@value"] }}
  108. </li>
  109. </ul>
  110. </div>
  111. </template>
  112. </div>
  113. </template>
  114. <script>
  115. import Audio from "./AudioRed.vue";
  116. import Strockplayredline from "./Strockplayredline.vue";
  117. export default {
  118. name: "WordIntp",
  119. components: {
  120. Strockplayredline,
  121. Audio,
  122. },
  123. props: ["dict", "themeColor", "show", "pinyin"],
  124. data() {
  125. return {
  126. isPraShow: false,
  127. curData: null,
  128. activeIndex: "1",
  129. mp3Url: "", // 音频
  130. paraphrase: [], // 释义
  131. synonymList: [], // 近义词
  132. antonymList: [], // 反义词
  133. termsList: [], // 组词
  134. dataDetail: [],
  135. isHasValue2: "", // 释义里是否含有value2
  136. };
  137. },
  138. computed: {
  139. flag() {
  140. let _this = this;
  141. let flag = false;
  142. if (_this.paraphrase && _this.paraphrase.length > 0) {
  143. flag = true;
  144. } else if (_this.synonymList && _this.synonymList.length > 0) {
  145. flag = true;
  146. } else if (_this.antonymList && _this.antonymList.length > 0) {
  147. flag = true;
  148. } else if (_this.termsList && _this.termsList.length > 0) {
  149. flag = true;
  150. }
  151. return flag;
  152. },
  153. },
  154. watch: {},
  155. //方法集合
  156. methods: {
  157. writeWord() {
  158. this.isPraShow = true;
  159. },
  160. changePraShow() {
  161. this.isPraShow = false;
  162. },
  163. handleSelect(val) {
  164. this.activeIndex = val;
  165. },
  166. // 处理数据
  167. handleChineseDetail() {
  168. let _this = this;
  169. _this.paraphrase = [];
  170. _this.synonymList = [];
  171. _this.antonymList = [];
  172. _this.termsList = [];
  173. _this.isHasValue2 = "";
  174. _this.dataDetail.forEach((item) => {
  175. if (item.request.queryType == "entity") {
  176. // 读音
  177. item.response.entity.forEach((items) => {
  178. items.attrs.forEach((itemss) => {
  179. if (itemss.key == "pronunciation") {
  180. // 音频
  181. _this.mp3Url = itemss.objects[0]["@value"]
  182. ? itemss.objects[0]["@value"]
  183. : "";
  184. } else if (itemss.key == "definition") {
  185. // 释义
  186. _this.paraphrase = itemss.objects;
  187. for (let i = 0; i < _this.paraphrase.length; i++) {
  188. if (_this.paraphrase[i]["@definitionWithSpell"]) {
  189. _this.isHasValue2 = "definitionWithSpell";
  190. return false;
  191. } else if (_this.paraphrase[i]["@definitions"]) {
  192. _this.isHasValue2 = "definitions";
  193. }
  194. }
  195. } else if (itemss.key == "synonym") {
  196. // 近义词
  197. _this.synonymList = itemss.objects;
  198. } else if (itemss.key == "antonym") {
  199. // 反义词
  200. _this.antonymList = itemss.objects;
  201. } else if (itemss.key == "terms") {
  202. // 组词
  203. _this.termsList = itemss.objects;
  204. }
  205. });
  206. });
  207. }
  208. });
  209. },
  210. },
  211. //生命周期 - 创建完成(可以访问当前this实例)
  212. created() {},
  213. //生命周期 - 挂载完成(可以访问DOM元素)
  214. mounted() {
  215. let _this = this;
  216. if (_this.dict) {
  217. let dict = JSON.parse(_this.dict);
  218. _this.dataDetail = dict.data.result;
  219. _this.handleChineseDetail();
  220. }
  221. },
  222. beforeCreate() {}, //生命周期 - 创建之前
  223. beforeMount() {}, //生命周期 - 挂载之前
  224. beforeUpdate() {}, //生命周期 - 更新之前
  225. updated() {}, //生命周期 - 更新之后
  226. beforeDestroy() {}, //生命周期 - 销毁之前
  227. destroyed() {}, //生命周期 - 销毁完成
  228. activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  229. };
  230. </script>
  231. <style lang='scss' scoped>
  232. //@import url(); 引入公共css类
  233. .wordIntp {
  234. width: 100%;
  235. height: 600px;
  236. overflow: hidden;
  237. overflow-y: auto;
  238. margin: 0 auto;
  239. position: relative;
  240. margin-top: 12px !important;
  241. .from {
  242. color: rgba(0, 0, 0, 0.85);
  243. opacity: 0.2;
  244. margin: 0;
  245. font-size: 12px;
  246. line-height: 20px;
  247. }
  248. .bwc-intp {
  249. padding: 16px 0;
  250. h1 {
  251. color: #000000;
  252. font-size: 20px;
  253. line-height: 150%;
  254. font-weight: normal;
  255. margin: 8px 0 8px 0;
  256. }
  257. .pinyin {
  258. color: #de4444;
  259. font-size: 24px;
  260. line-height: 36px;
  261. margin-bottom: 8px;
  262. font-family: "GB-PINYINOK-B";
  263. display: block;
  264. }
  265. .paraphrase {
  266. margin-bottom: 8px;
  267. margin-top: 0;
  268. > .para {
  269. font-weight: normal;
  270. font-size: 14px;
  271. line-height: 22px;
  272. color: #000000;
  273. margin-bottom: 8px;
  274. .para-key {
  275. font-family: "GB-PINYINOK-B";
  276. }
  277. }
  278. }
  279. hr {
  280. margin: 16px 0 0 0;
  281. background: rgba($color: #000000, $alpha: 0.15);
  282. height: 1px;
  283. border: none;
  284. }
  285. ul.synonym {
  286. display: flex;
  287. flex-flow: wrap;
  288. margin-left: -4px;
  289. padding: 4px 0;
  290. li {
  291. padding: 4px 8px;
  292. background: #ffffff;
  293. border: 1px solid rgba(0, 0, 0, 0.15);
  294. border-radius: 4px;
  295. margin: 4px;
  296. font-size: 16px;
  297. line-height: 150%;
  298. color: #000000;
  299. text-align: center;
  300. min-width: 127px;
  301. }
  302. }
  303. }
  304. .closeBox {
  305. width: 100%;
  306. display: flex;
  307. justify-content: space-between;
  308. position: absolute;
  309. left: 0;
  310. top: 0;
  311. padding: 12px;
  312. > i {
  313. font-size: 16px;
  314. color: #000000;
  315. cursor: pointer;
  316. }
  317. span {
  318. color: #000000;
  319. opacity: 0.2;
  320. font-size: 14px;
  321. line-height: 130%;
  322. }
  323. }
  324. min-width: 312px;
  325. min-height: 360px;
  326. // background: #ffffff;
  327. // box-shadow: 0px 2px 8px rgba(0, 0, 0, 0.15);
  328. border-radius: 8px;
  329. // padding: 52px 32px 32px;
  330. box-sizing: border-box;
  331. .bwc-top {
  332. margin-bottom: 16px;
  333. width: 100%;
  334. display: flex;
  335. justify-content: center;
  336. align-items: center;
  337. .content-voices {
  338. width: 24px;
  339. }
  340. > span {
  341. font-family: "GB-PINYINOK-B";
  342. color: #2c2c2c;
  343. font-size: 20px;
  344. line-height: 24px;
  345. margin-right: 4px;
  346. }
  347. }
  348. .bwc-Strockplay {
  349. display: flex;
  350. justify-content: center;
  351. align-items: center;
  352. min-width: 130px;
  353. height: 130px;
  354. margin: 0 auto;
  355. margin-bottom: 6px;
  356. border: 2px solid #de4444;
  357. border-radius: 8px;
  358. box-sizing: border-box;
  359. overflow: hidden;
  360. .strockplay {
  361. display: flex;
  362. justify-content: center;
  363. align-items: center;
  364. position: relative;
  365. .collect-icon {
  366. width: 16px;
  367. position: absolute;
  368. right: 4px;
  369. bottom: 4px;
  370. cursor: pointer;
  371. }
  372. }
  373. .bwc-line {
  374. width: 2px;
  375. height: 126px;
  376. background: #de4444;
  377. }
  378. }
  379. .bwc-tolength {
  380. color: #404040;
  381. font-size: 30px;
  382. line-height: 1.5;
  383. font-family: FZJCGFKTK;
  384. text-align: center;
  385. border: 2px solid #de4444;
  386. border-radius: 8px;
  387. padding: 40px 0;
  388. margin: 0 0 16px 0;
  389. }
  390. .bwc-word-en {
  391. font-style: normal;
  392. font-weight: 600;
  393. font-size: 20px;
  394. line-height: 150%;
  395. text-align: center;
  396. color: #2c2c2c;
  397. margin-bottom: 8px;
  398. }
  399. .bwc-more-intp {
  400. font-weight: normal;
  401. font-size: 14px;
  402. line-height: 20px;
  403. color: #2c2c2c;
  404. opacity: 0.5;
  405. text-align: center;
  406. margin-bottom: 24px;
  407. cursor: pointer;
  408. }
  409. .bwc-footer {
  410. width: 100%;
  411. display: flex;
  412. justify-content: space-between;
  413. align-items: center;
  414. > button {
  415. width: 128px;
  416. height: 40px;
  417. display: flex;
  418. justify-content: center;
  419. align-items: center;
  420. color: #ff5757;
  421. background: rgba(255, 87, 87, 0.1);
  422. border-radius: 4px;
  423. outline: 0;
  424. border: 0;
  425. cursor: pointer;
  426. > img {
  427. width: 24px;
  428. height: 24px;
  429. margin-right: 8px;
  430. }
  431. }
  432. }
  433. }
  434. .NPC-Big-Book-preview-green {
  435. .wordIntp {
  436. .bwc-intp {
  437. .pinyin {
  438. color: #24b99e;
  439. }
  440. }
  441. .bwc-Strockplay {
  442. border: 2px solid #24b99e;
  443. .bwc-line {
  444. background: #24b99e;
  445. }
  446. }
  447. .bwc-tolength {
  448. border: 2px solid #24b99e;
  449. }
  450. .bwc-footer {
  451. > button {
  452. color: #24b99e;
  453. }
  454. }
  455. }
  456. }
  457. .NPC-Big-Book-preview-brown {
  458. .wordIntp {
  459. .bwc-intp {
  460. .pinyin {
  461. color: #bd8865;
  462. }
  463. }
  464. .bwc-Strockplay {
  465. border: 2px solid #bd8865;
  466. .bwc-line {
  467. background: #bd8865;
  468. }
  469. }
  470. .bwc-tolength {
  471. border: 2px solid #bd8865;
  472. }
  473. .bwc-footer {
  474. > button {
  475. color: #bd8865;
  476. }
  477. }
  478. }
  479. }
  480. </style>
  481. <style lang="scss">
  482. .OrderManage {
  483. .wordIntp {
  484. .el-menu--horizontal > .el-menu-item {
  485. width: 33.33%;
  486. text-align: center;
  487. color: #000000;
  488. font-size: 18px;
  489. margin: 0;
  490. }
  491. .el-menu.el-menu--horizontal {
  492. border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  493. }
  494. .el-menu--horizontal > .el-menu-item.is-active {
  495. color: #de4444;
  496. font-weight: bold;
  497. border-bottom: 2px solid #de4444;
  498. }
  499. }
  500. .NPC-Big-Book-preview-green {
  501. .wordIntp {
  502. .el-menu--horizontal > .el-menu-item.is-active {
  503. color: #24b99e;
  504. border-bottom: 2px solid #24b99e;
  505. }
  506. }
  507. }
  508. .NPC-Big-Book-preview-brown {
  509. .wordIntp {
  510. .el-menu--horizontal > .el-menu-item.is-active {
  511. color: #bd8865;
  512. border-bottom: 2px solid #bd8865;
  513. }
  514. }
  515. }
  516. }
  517. </style>