PhraseModelChs.vue 41 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340
  1. <!-- -->
  2. <template>
  3. <div class="NNPE-ArticleView" v-if="curQue">
  4. <div
  5. class="aduioLine-box aduioLine-practice-npc"
  6. v-if="
  7. (curQue.mp3_list &&
  8. curQue.mp3_list.length > 0 &&
  9. curQue.mp3_list[0].id) ||
  10. config.isHasPY ||
  11. config.isHasEN
  12. "
  13. >
  14. <div class="aduioLine-content">
  15. <template
  16. v-if="
  17. curQue.mp3_list &&
  18. curQue.mp3_list.length > 0 &&
  19. curQue.mp3_list[0].id
  20. "
  21. >
  22. <AudioLine
  23. audioId="diaPhraAudio"
  24. :mp3="curQue.mp3_list[0].id"
  25. :getCurTime="getCurTime"
  26. :mp3Source="curQue.mp3_list[0].source"
  27. :width="colLength == 2 ? 200 : 590"
  28. ref="audioLine"
  29. />
  30. </template>
  31. </div>
  32. <div class="aduioLine-right">
  33. <span
  34. :class="['pinyin-16', config.isShowPY ? '' : 'disabled']"
  35. @click="changePinyin"
  36. v-if="config.isHasPY"
  37. ></span>
  38. <span
  39. :class="['EN-16', config.isShowEN ? '' : 'disabled']"
  40. @click="changeEN"
  41. v-if="config.isHasEN"
  42. ></span>
  43. </div>
  44. </div>
  45. <template v-if="resArr.length > 0">
  46. <div class="NPC-sentences-list">
  47. <div class="NPC-article-empty">
  48. <div :class="['empty-left', isHasRemark ? 'hasRemark' : '']"></div>
  49. <div class="empty-right"></div>
  50. </div>
  51. <p
  52. :class="['notice', isHasRemark ? 'hasRemark' : '']"
  53. v-if="curQue.notice"
  54. >
  55. {{ curQue.notice }}
  56. </p>
  57. <div
  58. :class="['NNPE-detail', item.isTitle ? 'NNPE-detail-title' : '']"
  59. v-for="(item, index) in resArr"
  60. :key="'detail' + index"
  61. >
  62. <div :class="['article-content', isHasRemark ? 'hasRemark' : '']">
  63. <RoleChs :curRole="item.roleDetail" :type="1" />
  64. <div class="wordsList-box">
  65. <img
  66. :src="articleImg[index]"
  67. v-if="articleImg[0] && index == 0"
  68. />
  69. <div
  70. class="roleDetail"
  71. v-if="item.roleDetail.detail.wordsList.length > 0"
  72. >
  73. <span class="pinyin">{{
  74. item.roleDetail.detail.wordsList | handlePinyin
  75. }}</span>
  76. <span class="chs">{{
  77. item.roleDetail.detail.wordsList | handleChs
  78. }}</span>
  79. </div>
  80. <div
  81. class="para-con"
  82. :style="{ background: item.roleDetail.color.bg }"
  83. >
  84. <div
  85. v-if="
  86. config.isShowEN &&
  87. item.enwords &&
  88. curQue.enPosition &&
  89. curQue.enPosition == 'top'
  90. "
  91. class="enwords"
  92. >
  93. {{ item.enwords }}
  94. </div>
  95. <div style="clear: both; overflow: hidden"></div>
  96. <div
  97. class="NNPE-words"
  98. v-for="(pItem, pIndex) in item.wordsList"
  99. :key="'wordsList' + pIndex"
  100. :class="[
  101. pItem.chs != '“' && pItem.wordIndex == 0
  102. ? 'textLeft'
  103. : 'textCenter',
  104. pItem.chs == '“' ? 'textRight' : ''
  105. ]"
  106. @click="showWordDetail($event, pItem.chs, pItem.words)"
  107. >
  108. <template v-if="!pItem.width">
  109. <template v-if="pItem.isShow">
  110. <template
  111. v-if="
  112. item.wordsList[pIndex + 1] &&
  113. item.wordsList[pIndex + 1].chs &&
  114. (chsFhList.indexOf(item.wordsList[pIndex + 1].chs) >
  115. -1 ||
  116. NumberList.indexOf(
  117. item.wordsList[pIndex + 1].chs
  118. ) > -1)
  119. "
  120. >
  121. <span class="NNPE-words-box">
  122. <span
  123. v-if="
  124. curQue.pyPosition == 'top' &&
  125. config.isShowPY &&
  126. item.dhaspinyin
  127. "
  128. class="NNPE-pinyin"
  129. :class="[
  130. pItem.className ? pItem.className : '',
  131. noFont.indexOf(item.pinyin) > -1 ? 'noFont' : ''
  132. ]"
  133. @click.stop="viewNotes($event, pItem.pinyin)"
  134. >{{ pItem.pinyin }}</span
  135. >
  136. <span
  137. class="NNPE-chs"
  138. :class="[
  139. newWordList.indexOf(pItem.chs) > -1
  140. ? 'newActive'
  141. : '',
  142. pItem.words ? 'newActive' : ''
  143. ]"
  144. @click.stop="
  145. viewNotes(
  146. $event,
  147. pItem.words ? pItem.words : pItem.chs
  148. )
  149. "
  150. :style="{
  151. fontFamily: pItem.config.fontFamily,
  152. height: '28px',
  153. display: 'inline-block'
  154. }"
  155. >{{
  156. NumberList.indexOf(pItem.pinyin) == -1
  157. ? pItem.chs
  158. : ""
  159. }}</span
  160. >
  161. <span
  162. v-if="
  163. curQue.pyPosition == 'bottom' &&
  164. config.isShowPY &&
  165. item.dhaspinyin
  166. "
  167. class="NNPE-pinyin"
  168. :class="[
  169. pItem.className ? pItem.className : '',
  170. noFont.indexOf(item.pinyin) > -1 ? 'noFont' : ''
  171. ]"
  172. @click.stop="viewNotes($event, pItem.pinyin)"
  173. >{{ pItem.pinyin }}</span
  174. >
  175. </span>
  176. <span class="NNPE-words-box">
  177. <span
  178. v-if="
  179. curQue.pyPosition == 'top' &&
  180. config.isShowPY &&
  181. item.dhaspinyin
  182. "
  183. class="NNPE-pinyin"
  184. style="text-align: left"
  185. :class="[
  186. noFont.indexOf(
  187. item.wordsList[pIndex + 1].pinyin
  188. ) > -1
  189. ? 'noFont'
  190. : ''
  191. ]"
  192. @click.stop="
  193. viewNotes(
  194. $event,
  195. item.wordsList[pIndex + 1].pinyin
  196. )
  197. "
  198. >{{ item.wordsList[pIndex + 1].pinyin }}</span
  199. >
  200. <span
  201. class="NNPE-chs"
  202. style="text-align: left"
  203. @click.stop="
  204. viewNotes(
  205. $event,
  206. item.wordsList[pIndex + 1].words
  207. ? item.wordsList[pIndex + 1].words
  208. : item.wordsList[pIndex + 1].chs
  209. )
  210. "
  211. :style="{
  212. fontFamily:
  213. item.wordsList[pIndex + 1].config.fontFamily,
  214. height: '28px',
  215. display: 'inline-block'
  216. }"
  217. >{{
  218. NumberList.indexOf(
  219. item.wordsList[pIndex + 1].pinyin
  220. ) == -1
  221. ? item.wordsList[pIndex + 1].chs
  222. : ""
  223. }}</span
  224. >
  225. <span
  226. v-if="
  227. curQue.pyPosition == 'bottom' &&
  228. config.isShowPY &&
  229. item.dhaspinyin
  230. "
  231. class="NNPE-pinyin"
  232. :class="[
  233. noFont.indexOf(
  234. item.wordsList[pIndex + 1].pinyin
  235. ) > -1
  236. ? 'noFont'
  237. : ''
  238. ]"
  239. @click.stop="
  240. viewNotes(
  241. $event,
  242. item.wordsList[pIndex + 1].pinyin
  243. )
  244. "
  245. style="text-align: left"
  246. >{{ item.wordsList[pIndex + 1].pinyin }}</span
  247. >
  248. </span>
  249. <span
  250. class="NNPE-words-box"
  251. v-if="
  252. item.wordsList[pIndex + 2] &&
  253. item.wordsList[pIndex + 2].chs &&
  254. (chsFhList.indexOf(
  255. item.wordsList[pIndex + 2].chs
  256. ) > -1 ||
  257. NumberList.indexOf(
  258. item.wordsList[pIndex + 2].chs
  259. ) > -1)
  260. "
  261. >
  262. <span
  263. v-if="
  264. curQue.pyPosition == 'top' &&
  265. config.isShowPY &&
  266. item.dhaspinyin
  267. "
  268. :class="[
  269. 'NNPE-pinyin',
  270. noFont.indexOf(
  271. item.wordsList[pIndex + 2].pinyin
  272. ) > -1
  273. ? 'noFont'
  274. : ''
  275. ]"
  276. @click.stop="
  277. viewNotes(
  278. $event,
  279. item.wordsList[pIndex + 2].pinyin
  280. )
  281. "
  282. style="text-align: left"
  283. >{{ item.wordsList[pIndex + 2].pinyin }}</span
  284. >
  285. <span
  286. class="NNPE-chs"
  287. style="text-align: left"
  288. :class="[
  289. pItem.chstimeList &&
  290. pItem.chstimeList[pItem.leg - 1] &&
  291. curTime >=
  292. pItem.chstimeList[pItem.leg - 1].wordBg &&
  293. curQue.wordTime &&
  294. curTime <= item.timeList[pItem.sentIndex].ed
  295. ? 'wordActive'
  296. : ''
  297. ]"
  298. @click.stop="
  299. viewNotes(
  300. $event,
  301. item.wordsList[pIndex + 2].words
  302. ? item.wordsList[pIndex + 2].words
  303. : item.wordsList[pIndex + 2].chs
  304. )
  305. "
  306. :style="{
  307. fontFamily:
  308. item.wordsList[pIndex + 2].config.fontFamily,
  309. height: '28px',
  310. display: 'inline-block'
  311. }"
  312. >{{
  313. NumberList.indexOf(
  314. item.wordsList[pIndex + 2].pinyin
  315. ) == -1
  316. ? item.wordsList[pIndex + 2].chs
  317. : ""
  318. }}</span
  319. >
  320. <span
  321. v-if="
  322. curQue.pyPosition == 'bottom' &&
  323. config.isShowPY &&
  324. item.dhaspinyin
  325. "
  326. :class="[
  327. 'NNPE-pinyin',
  328. noFont.indexOf(
  329. item.wordsList[pIndex + 2].pinyin
  330. ) > -1
  331. ? 'noFont'
  332. : ''
  333. ]"
  334. @click.stop="
  335. viewNotes(
  336. $event,
  337. item.wordsList[pIndex + 2].pinyin
  338. )
  339. "
  340. style="text-align: left"
  341. >{{ item.wordsList[pIndex + 2].pinyin }}</span
  342. >
  343. </span>
  344. </template>
  345. <template v-else>
  346. <span
  347. v-if="
  348. curQue.pyPosition == 'top' &&
  349. config.isShowPY &&
  350. item.dhaspinyin
  351. "
  352. class="NNPE-pinyin"
  353. :class="[
  354. pItem.chs != '“' && pItem.padding ? 'padding' : '',
  355. pItem.className ? pItem.className : '',
  356. noFont.indexOf(pItem.pinyin) > -1 ? 'noFont' : ''
  357. ]"
  358. @click.stop="viewNotes($event, pItem.pinyin)"
  359. >{{ pItem.pinyin }}</span
  360. >
  361. <span
  362. v-if="pItem.chs != '#'"
  363. class="NNPE-chs"
  364. :class="[
  365. newWordList.indexOf(pItem.chs) > -1
  366. ? 'newActive'
  367. : '',
  368. pItem.chs != '“' && pItem.padding && config.isShowPY
  369. ? 'padding'
  370. : '',
  371. pItem.words ? 'newActive' : ''
  372. ]"
  373. @click.stop="
  374. viewNotes(
  375. $event,
  376. pItem.words ? pItem.words : pItem.chs
  377. )
  378. "
  379. :style="{
  380. fontFamily: pItem.config.fontFamily,
  381. height: '28px',
  382. display: 'inline-block'
  383. }"
  384. >{{
  385. NumberList.indexOf(pItem.pinyin) == -1
  386. ? pItem.chs
  387. : ""
  388. }}</span
  389. >
  390. <span
  391. v-if="
  392. curQue.pyPosition == 'bottom' &&
  393. config.isShowPY &&
  394. item.dhaspinyin
  395. "
  396. class="NNPE-pinyin"
  397. :class="[
  398. pItem.chs != '“' && pItem.padding ? 'padding' : '',
  399. pItem.className ? pItem.className : '',
  400. noFont.indexOf(pItem.pinyin) > -1 ? 'noFont' : ''
  401. ]"
  402. @click.stop="viewNotes($event, pItem.pinyin)"
  403. >{{ pItem.pinyin }}</span
  404. >
  405. </template>
  406. </template>
  407. </template>
  408. <template v-else>
  409. <span
  410. :style="{
  411. height: pItem.height + 'px',
  412. width: pItem.width + 'px'
  413. }"
  414. ></span>
  415. </template>
  416. </div>
  417. <div style="clear: both; overflow: hidden"></div>
  418. <div
  419. v-if="
  420. config.isShowEN &&
  421. item.enwords &&
  422. (!curQue.enPosition ||
  423. (curQue.enPosition && curQue.enPosition == 'bottom'))
  424. "
  425. class="enwords"
  426. >
  427. {{ item.enwords }}
  428. </div>
  429. </div>
  430. <img :src="articleImg[index + 1]" v-if="articleImg[index + 1]" />
  431. </div>
  432. </div>
  433. <div class="remarkBox remark-top">
  434. <RemarkChs
  435. :remarkDetail="item.remarkDetail"
  436. :marginTop="item.roleDetail.detail.wordsList.length > 0 ? 44 : 8"
  437. />
  438. </div>
  439. </div>
  440. <div class="NPC-article-empty NPC-article-empty-bottom">
  441. <div :class="['empty-left', isHasRemark ? 'hasRemark' : '']"></div>
  442. <div class="empty-right"></div>
  443. </div>
  444. <div class="dia-article-record" v-if="1 == 2">
  445. <Soundrecord @handleWav="handleWav" type="promax" class="luyin-box" />
  446. </div>
  447. </div>
  448. </template>
  449. <template v-if="isShow">
  450. <div
  451. ref="wordcard"
  452. class="NNPE-wordDetail"
  453. :style="{
  454. marginLeft:
  455. word.detail.new_word.length === 1
  456. ? '-152px'
  457. : windowWidth > word.detail.new_word.length * 126 + 48
  458. ? '-' + (word.detail.new_word.length * 63 + 24) + 'px'
  459. : '0px',
  460. left:
  461. windowWidth > word.detail.new_word.length * 126 + 48 ? '' : '0px'
  462. }"
  463. >
  464. <Wordcard
  465. :word="word"
  466. :changeWordCard="changeWordCard"
  467. :themeColor="themeColor"
  468. :currentTreeID="currentTreeID"
  469. :TaskModel="TaskModel"
  470. :writeList="curQue.Bookanswer.writeModel"
  471. @changeCurQue="changeCurQue"
  472. :mp3Url="wordPlayMp3"
  473. :bg="wordbgs"
  474. :ed="wordeds"
  475. />
  476. </div>
  477. </template>
  478. <template v-if="isNoteShow">
  479. <div
  480. ref="notecard"
  481. class="NNPE-wordDetail"
  482. :style="{
  483. marginLeft: windowWidth > 642 ? '-321px' : '0px',
  484. left: windowWidth > 642 ? '' : '0px'
  485. }"
  486. >
  487. <Notecard :item="curNoteCon" :changeCard="changeCard" />
  488. </div>
  489. </template>
  490. </div>
  491. </template>
  492. <script>
  493. import { timeStrToSen } from "../../../../utils/index";
  494. import AudioLine from "../AudioLine.vue";
  495. import Wordcard from "../components/Wordcard.vue"; // 卡片
  496. import Notecard from "../components/Notecard.vue"; // 注释
  497. import RoleChs from "./RoleChs.vue";
  498. import RemarkChs from "./RemarkChs.vue";
  499. import Soundrecord from "../Soundrecord.vue";
  500. export default {
  501. name: "PhraseModelChs",
  502. props: [
  503. "curQue",
  504. "bodyLeft",
  505. "NNPENewWordList",
  506. "NNPEAnnotationList",
  507. "colorBox",
  508. "themeColor",
  509. "noFont",
  510. "currentTreeID",
  511. "config",
  512. "TaskModel",
  513. "colLength",
  514. "NpcNewWordMp3"
  515. ],
  516. components: {
  517. AudioLine,
  518. Wordcard,
  519. RoleChs,
  520. RemarkChs,
  521. Soundrecord,
  522. Notecard
  523. },
  524. filters: {
  525. handlePinyin(wordsList) {
  526. let str = "";
  527. wordsList.forEach((item, index) => {
  528. if (index < wordsList.length - 1) {
  529. str += item.pinyin + " ";
  530. } else {
  531. str += item.pinyin;
  532. }
  533. });
  534. return str;
  535. },
  536. handleChs(wordsList) {
  537. let str = "";
  538. wordsList.forEach((item, index) => {
  539. if (index < wordsList.length - 1) {
  540. str += item.chs + " ";
  541. } else {
  542. str += item.chs;
  543. }
  544. });
  545. return str;
  546. }
  547. },
  548. data() {
  549. return {
  550. resArr: [],
  551. curTime: 0, //单位s
  552. chsFhList: [",", "。", "”", ":", "》", "?", "!", ";", "#", "、"],
  553. enFhList: [",", ".", ";", "?", "!", ":", ">", "<"],
  554. NumberList: [
  555. "①",
  556. "②",
  557. "③",
  558. "④",
  559. "⑤",
  560. "⑥",
  561. "⑦",
  562. "⑧",
  563. "⑨",
  564. "⑩",
  565. "⑪",
  566. "⑫",
  567. "⑬",
  568. "⑭",
  569. "⑮",
  570. "⑯",
  571. "⑰",
  572. "⑱",
  573. "⑲",
  574. "⑳"
  575. ],
  576. newWords: ["鱼", "辩礼义"],
  577. oldHz: "",
  578. hz: "",
  579. clientY: "",
  580. top: 0,
  581. left: 0,
  582. articleImg: {}, // 文章图片
  583. newWordList: [],
  584. word: null,
  585. isShow: false,
  586. screenHeight: 0,
  587. cardHeight: 0,
  588. isHasRemark: false,
  589. clickType: "",
  590. isNoteShow: false,
  591. noteNum: "",
  592. oldNoteNum: "",
  593. curNoteCon: null,
  594. contentWidth: 732,
  595. highWords: null,
  596. highWordsArr: [],
  597. highIndex: 0,
  598. wordbgs: 0,
  599. wordeds: 0,
  600. wordPlayMp3: "",
  601. windowWidth: window.innerWidth
  602. };
  603. },
  604. computed: {},
  605. watch: {
  606. hz: {
  607. handler: function(val, oldVal) {
  608. let _this = this;
  609. if (val) {
  610. _this.handleNewWords(val, _this.top, _this.left);
  611. }
  612. },
  613. // 深度观察监听
  614. deep: true
  615. },
  616. isShow: {
  617. handler: function(val, oldVal) {
  618. let _this = this;
  619. if (val) {
  620. setTimeout(() => {
  621. _this.cardHeight = _this.$refs.wordcard.offsetHeight;
  622. if (_this.screenHeight - _this.clientY > _this.cardHeight) {
  623. _this.top = _this.clientY + 20;
  624. } else {
  625. _this.top = _this.clientY - _this.cardHeight - 30;
  626. }
  627. }, 50);
  628. }
  629. },
  630. // 深度观察监听
  631. deep: true
  632. },
  633. noteNum: {
  634. handler: function(val, oldVal) {
  635. let _this = this;
  636. if (val) {
  637. _this.handleNote(val);
  638. }
  639. },
  640. // 深度观察监听
  641. deep: true
  642. },
  643. isNoteShow: {
  644. handler: function(val, oldVal) {
  645. let _this = this;
  646. if (val) {
  647. setTimeout(() => {
  648. _this.cardHeight = _this.$refs.notecard.offsetHeight;
  649. if (_this.screenHeight - _this.clientY > _this.cardHeight) {
  650. _this.top = _this.clientY + 20;
  651. } else {
  652. _this.top = _this.clientY - _this.cardHeight - 30;
  653. }
  654. }, 50);
  655. }
  656. },
  657. // 深度观察监听
  658. deep: true
  659. }
  660. },
  661. //方法集合
  662. methods: {
  663. //拼音的显示和隐藏
  664. changePinyin() {
  665. if (this.config.isHasPY) {
  666. this.$emit("changeConfig", "isShowPY");
  667. }
  668. },
  669. // 英文的显示和隐藏
  670. changeEN() {
  671. if (this.config.isHasEN) {
  672. this.$emit("changeConfig", "isShowEN");
  673. }
  674. },
  675. handleWav() {},
  676. getCurTime(curTime) {
  677. this.curTime = curTime;
  678. },
  679. handleData() {
  680. let resArr = [];
  681. let leg = this.curQue.detail.length;
  682. let curQue = JSON.parse(JSON.stringify(this.curQue));
  683. let dhaspinyin = false; // 每段是否有拼音
  684. curQue.detail.forEach((dItem, dIndex) => {
  685. dhaspinyin = false;
  686. let roleDetail = this.getRole(dItem);
  687. let remarkDetail = dItem.remark;
  688. if (
  689. remarkDetail &&
  690. (remarkDetail.chs ||
  691. remarkDetail.en ||
  692. (remarkDetail.img_list && remarkDetail.img_list.length > 0))
  693. ) {
  694. this.isHasRemark = true;
  695. }
  696. let paraArr = [];
  697. dItem.wordsList.forEach((sItem, sIndex) => {
  698. let sentence = dItem.sentences[sIndex];
  699. sItem.forEach((wItem, wIndex) => {
  700. //this.judgePad(sItem, wItem, wIndex);
  701. this.mergeWordSymbol(wItem);
  702. let words = "";
  703. if (this.newWordList.length > 0) {
  704. if (!this.highWords) {
  705. this.findLightWord(wItem, wIndex, sentence, sItem);
  706. words = this.highWords ? this.highWords.words : "";
  707. } else {
  708. if (wIndex > this.highWords.endIndex - 1) {
  709. this.highWords = null;
  710. this.findLightWord(wItem, wIndex, sentence, sItem);
  711. words = this.highWords ? this.highWords.words : "";
  712. } else {
  713. words = this.highWords ? this.highWords.words : "";
  714. }
  715. }
  716. }
  717. let obj = {
  718. paraIndex: dIndex, //段落索引
  719. sentIndex: sIndex, //在段落中句子索引
  720. wordIndex: wIndex, //单词的索引
  721. pinyin: wItem.pinyin,
  722. chs: wItem.chs,
  723. padding: true, //wItem.padding,
  724. className: wItem.className,
  725. isShow: wItem.isShow,
  726. words: words,
  727. isNewWord: this.newWords.indexOf(wItem.chs) > -1 ? true : false,
  728. config: {
  729. fontFamily: wItem.fontFamily
  730. }
  731. };
  732. paraArr.push(obj);
  733. if (wItem.pinyin) dhaspinyin = true;
  734. });
  735. });
  736. let enwords =
  737. dItem.sentencesEn && dItem.sentencesEn.length > 0
  738. ? dItem.sentencesEn.join(" ").replace(/\'/g, "’")
  739. : "";
  740. let paraObj = {
  741. wordsList: paraArr,
  742. enwords: enwords,
  743. roleDetail: roleDetail,
  744. remarkDetail: remarkDetail,
  745. dhaspinyin: dhaspinyin
  746. };
  747. resArr.push(paraObj);
  748. });
  749. this.resArr = resArr;
  750. // 循环文章图片
  751. if (curQue.img_list) {
  752. curQue.img_list.forEach(item => {
  753. this.articleImg[item.imgNumber] = item.id;
  754. });
  755. }
  756. },
  757. findLightWord(wItem, startIndex, sentence, sItem) {
  758. let words = "",
  759. endIndex = 0;
  760. this.newWordList.forEach(item => {
  761. if (item.length == 1) {
  762. if (item == wItem.chs && !wItem.banLight) {
  763. words = wItem.chs;
  764. endIndex = startIndex + 1;
  765. }
  766. } else {
  767. if (item[0] == wItem.chs && sentence.indexOf(item) > -1) {
  768. let index = null;
  769. let chsStr = "";
  770. for (let i = startIndex; i < sItem.length + 1; i++) {
  771. index = i;
  772. if (chsStr.length == item.length) {
  773. break;
  774. } else {
  775. chsStr += sItem[i] ? sItem[i].chs : "";
  776. }
  777. }
  778. if (chsStr == item && !wItem.banLight) {
  779. words = item;
  780. endIndex = index;
  781. }
  782. } else if (
  783. wItem.new_word &&
  784. wItem.new_word == item &&
  785. !wItem.banLight
  786. ) {
  787. words = item;
  788. endIndex = startIndex + 1;
  789. }
  790. }
  791. });
  792. if (words) {
  793. this.highWords = { words: words, endIndex: endIndex };
  794. } else {
  795. this.highWords = null;
  796. }
  797. },
  798. //词和标点合一起
  799. mergeWordSymbol(wItem) {
  800. if (
  801. this.chsFhList.indexOf(wItem.chs) > -1 ||
  802. this.NumberList.indexOf(wItem.chs) > -1
  803. ) {
  804. wItem.isShow = false;
  805. } else {
  806. wItem.isShow = true;
  807. }
  808. },
  809. //获取角色
  810. getRole(dItem) {
  811. let roleIndex = dItem.roleIndex;
  812. let resObj = null;
  813. let roleList = JSON.parse(JSON.stringify(this.curQue.roleList));
  814. for (let i = 0; i < roleList.length; i++) {
  815. let item = roleList[i];
  816. if (item.id == roleIndex) {
  817. resObj = item;
  818. resObj.color = this.colorBox[i];
  819. break;
  820. }
  821. }
  822. return resObj;
  823. },
  824. //判断是否有padding
  825. judgePad(sItem, wItem, curIndex) {
  826. let leg = sItem.length;
  827. if (curIndex < leg - 1) {
  828. let nextIndex = curIndex + 1;
  829. let chs = sItem[nextIndex].chs;
  830. if (
  831. this.chsFhList.indexOf(chs) > -1 ||
  832. this.chsFhList.indexOf(wItem.chs) > -1
  833. ) {
  834. wItem.padding = false;
  835. } else {
  836. wItem.padding = true;
  837. }
  838. if (this.enFhList.indexOf(wItem.pinyin) > -1) {
  839. wItem.className = "textLeft";
  840. }
  841. }
  842. },
  843. //转化时间
  844. handleTimeList(list) {
  845. let listRes = [];
  846. list.forEach(item => {
  847. let res = timeStrToSen(item);
  848. listRes.push(res);
  849. });
  850. return listRes;
  851. },
  852. //点击播放某个句子
  853. handleChangeTime(time) {
  854. this.curTime = time;
  855. this.$refs.audioLine.onTimeupdateTime(time);
  856. },
  857. handleNewword() {
  858. let NewWordList = [];
  859. this.NNPENewWordList.forEach(item => {
  860. item.forEach(wItem => {
  861. if (wItem.new_word) {
  862. NewWordList.push(wItem.new_word);
  863. } else if (wItem.detail && wItem.detail.sentence) {
  864. NewWordList.push(wItem.detail.sentence);
  865. }
  866. });
  867. });
  868. this.newWordList = JSON.parse(JSON.stringify(NewWordList));
  869. },
  870. showWordDetail(e, word, words) {
  871. let _this = this;
  872. _this.highIndex = 0;
  873. _this.highWordsArr = [];
  874. if (word && this.newWordList.indexOf(word) > -1) {
  875. this.highWordsArr.push(word);
  876. }
  877. if (words && word != words && this.newWordList.indexOf(words) > -1) {
  878. this.highWordsArr.push(words);
  879. }
  880. if (
  881. this.newWordList.indexOf(word) > -1 ||
  882. this.newWordList.indexOf(words) > -1
  883. ) {
  884. if (word && this.newWordList.indexOf(word) > -1) {
  885. if (_this.oldHz != word) {
  886. this.isShow = false;
  887. setTimeout(() => {
  888. _this.hz = word;
  889. }, 50);
  890. }
  891. } else if (words && this.newWordList.indexOf(words) > -1) {
  892. if (_this.oldHz != words) {
  893. this.isShow = false;
  894. setTimeout(() => {
  895. _this.hz = words;
  896. }, 50);
  897. }
  898. }
  899. _this.clientY = e.clientY;
  900. let left = e.clientX;
  901. let width = 0;
  902. if (word.length == 1 || word.length == 2) {
  903. width = 304;
  904. } else if (word.length == 3 || word.length == 4) {
  905. width = 432;
  906. } else if (word.length > 3) {
  907. width = 560;
  908. }
  909. if (left - this.bodyLeft > this.contentWidth / 2) {
  910. _this.left = left - width + 10;
  911. } else {
  912. _this.left = left;
  913. }
  914. }
  915. },
  916. hideWordDetail() {
  917. this.isShow = false;
  918. },
  919. changeWordCard(isShow) {
  920. this.isShow = isShow;
  921. this.oldHz = "";
  922. this.hz = "";
  923. },
  924. // 处理分词数据
  925. handleNewWords(val, top, left) {
  926. this.isShow = true;
  927. this.word = null;
  928. for (let i = 0; i < this.NNPENewWordList.length; i++) {
  929. let pItem = this.NNPENewWordList[i];
  930. for (let j = 0; j < pItem.length; j++) {
  931. let item = pItem[j];
  932. if (item.new_word.trim() == val.trim()) {
  933. let wordlist = val.split("");
  934. this.word = { list: wordlist, detail: item, top: top, left: left };
  935. break;
  936. }
  937. }
  938. }
  939. this.oldHz = val;
  940. },
  941. viewNotes(e, noteNum) {
  942. let _this = this;
  943. _this.clickType = "note";
  944. let noteIndex = "";
  945. _this.wordPlayMp3 = "";
  946. _this.NNPENewWordList.forEach(items => {
  947. items.forEach(itemn => {
  948. if (itemn.new_word === noteNum) {
  949. _this.wordbgs = itemn.bg;
  950. _this.wordeds = itemn.ed;
  951. _this.wordPlayMp3 = itemn.newWordMp3;
  952. }
  953. });
  954. });
  955. if (_this.NumberList.indexOf(noteNum) > -1) {
  956. for (let i = 0; i < _this.NumberList.length; i++) {
  957. if (_this.NumberList[i] == noteNum) {
  958. noteIndex = "" + i + "";
  959. break;
  960. }
  961. }
  962. this.showNoteDetail(e, noteIndex);
  963. } else {
  964. if (this.newWordList.indexOf(noteNum) > -1) {
  965. if (_this.oldHz != noteNum) {
  966. this.isShow = false;
  967. setTimeout(() => {
  968. _this.hz = noteNum;
  969. }, 50);
  970. }
  971. _this.clientY = e.clientY;
  972. let left = e.clientX;
  973. let width = 0;
  974. if (noteNum.length == 1 || noteNum.length == 2) {
  975. width = 304;
  976. } else if (noteNum.length == 3 || noteNum.length == 4) {
  977. width = 432;
  978. } else if (noteNum.length > 3) {
  979. width = 560;
  980. }
  981. if (left - this.bodyLeft > this.contentWidth / 2) {
  982. _this.left = left - width + 10;
  983. } else {
  984. _this.left = left;
  985. }
  986. }
  987. }
  988. },
  989. showNoteDetail(e, noteNum) {
  990. let _this = this;
  991. if (_this.oldNoteNum != noteNum) {
  992. this.isNoteShow = false;
  993. setTimeout(() => {
  994. _this.noteNum = noteNum;
  995. }, 50);
  996. }
  997. _this.clientY = e.clientY;
  998. let left = e.clientX;
  999. let width = 642;
  1000. if (left - this.bodyLeft > this.contentWidth / 2) {
  1001. _this.left = left - width + 10;
  1002. } else {
  1003. _this.left = left - 200;
  1004. }
  1005. },
  1006. // 处理注释数据
  1007. handleNote(val) {
  1008. let _this = this;
  1009. _this.isNoteShow = true;
  1010. _this.oldNoteNum = val;
  1011. let noteIndex = Number(val);
  1012. if (_this.NNPEAnnotationList && _this.NNPEAnnotationList.length > 0) {
  1013. _this.curNoteCon = _this.NNPEAnnotationList[noteIndex]
  1014. ? _this.NNPEAnnotationList[noteIndex]
  1015. : null;
  1016. }
  1017. },
  1018. changeCard(isShow) {
  1019. let _this = this;
  1020. _this.isNoteShow = isShow;
  1021. _this.oldNoteNum = "";
  1022. _this.noteNum = "";
  1023. },
  1024. getScreenHeight() {
  1025. this.screenHeight = window.innerHeight;
  1026. },
  1027. changeCurQue(answer) {
  1028. if (answer) {
  1029. let writeModel = this.curQue.Bookanswer.writeModel;
  1030. let hz = answer.hz;
  1031. if (writeModel.hasOwnProperty(hz)) {
  1032. writeModel[hz].push(answer);
  1033. } else {
  1034. writeModel[hz] = [answer];
  1035. }
  1036. }
  1037. }
  1038. },
  1039. //生命周期 - 创建完成(可以访问当前this实例)
  1040. created() {},
  1041. //生命周期 - 挂载完成(可以访问DOM元素)
  1042. mounted() {
  1043. if (this.NNPENewWordList && this.NNPENewWordList.length > 0) {
  1044. this.handleNewword();
  1045. }
  1046. if (this.curQue) {
  1047. this.handleData();
  1048. }
  1049. $(window).resize(() => {
  1050. this.getScreenHeight();
  1051. });
  1052. this.getScreenHeight();
  1053. },
  1054. beforeCreate() {}, //生命周期 - 创建之前
  1055. beforeMount() {}, //生命周期 - 挂载之前
  1056. beforeUpdate() {}, //生命周期 - 更新之前
  1057. updated() {}, //生命周期 - 更新之后
  1058. beforeDestroy() {}, //生命周期 - 销毁之前
  1059. destroyed() {}, //生命周期 - 销毁完成
  1060. activated() {} //如果页面有keep-alive缓存功能,这个函数会触发
  1061. };
  1062. </script>
  1063. <style lang="scss" scoped>
  1064. //@import url(); 引入公共css类
  1065. .NNPE-ArticleView {
  1066. width: 100%;
  1067. .aduioLine-practice-npc {
  1068. display: flex;
  1069. justify-content: flex-start;
  1070. align-items: center;
  1071. .aduioLine-content {
  1072. flex: 1;
  1073. }
  1074. .aduioLine-right {
  1075. display: flex;
  1076. justify-content: space-between;
  1077. align-items: center;
  1078. width: 69px;
  1079. height: 40px;
  1080. box-sizing: border-box;
  1081. padding: 0 12px;
  1082. border-left: 1px solid rgba(0, 0, 0, 0.1);
  1083. > span {
  1084. width: 16px;
  1085. height: 16px;
  1086. cursor: pointer;
  1087. }
  1088. }
  1089. }
  1090. .NPC-sentences-list {
  1091. .NPC-article-empty {
  1092. display: flex;
  1093. justify-content: flex-start;
  1094. align-items: flex-start;
  1095. > div {
  1096. height: 24px;
  1097. &.empty-left {
  1098. width: 100%;
  1099. box-sizing: border-box;
  1100. &.hasRemark {
  1101. width: 553px;
  1102. box-sizing: border-box;
  1103. border-right: 1px rgba(0, 0, 0, 0.1) solid;
  1104. }
  1105. }
  1106. &.empty-right {
  1107. flex: 1;
  1108. }
  1109. }
  1110. &-bottom {
  1111. > div {
  1112. height: 40px;
  1113. }
  1114. }
  1115. }
  1116. .dia-article-record {
  1117. width: 100%;
  1118. border-top: 1px solid rgba(0, 0, 0, 0.1);
  1119. .luyin-box {
  1120. justify-content: start;
  1121. padding: 8px 12px;
  1122. height: 40px;
  1123. width: 280px;
  1124. justify-content: flex-start;
  1125. }
  1126. }
  1127. }
  1128. .NNPE-detail {
  1129. clear: both;
  1130. // overflow: hidden; // 为了不遮挡备注内容
  1131. display: flex;
  1132. justify-content: flex-start;
  1133. align-items: flex-start;
  1134. &.active {
  1135. background: rgba(0, 0, 0, 0.06);
  1136. }
  1137. .article-content {
  1138. width: 100%;
  1139. box-sizing: border-box;
  1140. padding: 8px 24px 8px 24px;
  1141. display: flex;
  1142. justify-content: flex-start;
  1143. align-items: flex-start;
  1144. &.hasRemark {
  1145. width: 553px;
  1146. border-right: 1px rgba(0, 0, 0, 0.1) solid;
  1147. padding: 8px 0px 8px 23px;
  1148. }
  1149. &.paraLast {
  1150. padding-bottom: 24px;
  1151. }
  1152. }
  1153. .enwords {
  1154. font-family: Helvetica;
  1155. font-weight: normal;
  1156. font-size: 14px;
  1157. line-height: 22px;
  1158. color: rgba(0, 0, 0, 0.85);
  1159. padding-left: 3px;
  1160. word-break: break-word;
  1161. }
  1162. .NNPE-words {
  1163. float: left;
  1164. &-box {
  1165. float: left;
  1166. > span {
  1167. display: block;
  1168. &.NNPE-pinyin {
  1169. font-family: "GB-PINYINOK-B";
  1170. font-weight: normal;
  1171. font-size: 14px;
  1172. line-height: 22px;
  1173. color: #000000;
  1174. height: 22px;
  1175. &.noFont {
  1176. font-family: initial;
  1177. }
  1178. &.textLeft {
  1179. text-align: left;
  1180. }
  1181. }
  1182. &.NNPE-chs {
  1183. font-family: "FZJCGFKTK";
  1184. font-size: 20px;
  1185. line-height: 28px;
  1186. color: #000000;
  1187. &.active {
  1188. background: rgba(60, 200, 99, 0.2);
  1189. }
  1190. &.wordActive {
  1191. color: #de4444;
  1192. }
  1193. &.newActive {
  1194. color: #de4444;
  1195. }
  1196. }
  1197. &.padding {
  1198. padding: 0 3px;
  1199. }
  1200. }
  1201. }
  1202. &.textLeft {
  1203. text-align: left;
  1204. }
  1205. &.textCenter {
  1206. text-align: center;
  1207. }
  1208. &.textRight {
  1209. text-align: right;
  1210. }
  1211. > span {
  1212. display: block;
  1213. &.NNPE-pinyin {
  1214. font-family: "GB-PINYINOK-B";
  1215. font-weight: normal;
  1216. font-size: 14px;
  1217. line-height: 22px;
  1218. color: #000000;
  1219. height: 22px;
  1220. &.noFont {
  1221. font-family: initial;
  1222. }
  1223. &.textLeft {
  1224. text-align: left;
  1225. }
  1226. }
  1227. &.NNPE-chs {
  1228. font-family: "FZJCGFKTK";
  1229. font-size: 20px;
  1230. line-height: 28px;
  1231. color: #000000;
  1232. &.active {
  1233. background: rgba(60, 200, 99, 0.2);
  1234. }
  1235. &.wordActive {
  1236. color: #de4444;
  1237. }
  1238. &.newActive {
  1239. color: #de4444;
  1240. }
  1241. }
  1242. &.padding {
  1243. padding: 0 3px;
  1244. }
  1245. }
  1246. }
  1247. &.NNPE-detail-title {
  1248. .wordsList-box {
  1249. > div {
  1250. display: flex;
  1251. justify-content: center;
  1252. flex-flow: wrap;
  1253. }
  1254. }
  1255. }
  1256. .index {
  1257. width: 48px;
  1258. box-sizing: border-box;
  1259. padding: 8px;
  1260. text-align: right;
  1261. border-right: 1px solid rgba(0, 0, 0, 0.1);
  1262. b {
  1263. font-weight: 400;
  1264. color: #000000;
  1265. line-height: 1.5;
  1266. }
  1267. }
  1268. .wordsList-box {
  1269. width: 100%;
  1270. padding: 0px 24px 0px 8px;
  1271. clear: both;
  1272. overflow: hidden;
  1273. .roleDetail {
  1274. height: 36px;
  1275. display: flex;
  1276. justify-content: flex-start;
  1277. align-items: center;
  1278. .pinyin {
  1279. font-family: "GB-PINYINOK-B";
  1280. font-size: 14px;
  1281. line-height: 22px;
  1282. color: rgba(0, 0, 0, 0.85);
  1283. margin-right: 4px;
  1284. }
  1285. .chs {
  1286. font-family: "FZJCGFKTK";
  1287. font-size: 16px;
  1288. line-height: 24px;
  1289. color: rgba(0, 0, 0, 0.85);
  1290. }
  1291. }
  1292. > .para-con {
  1293. float: left;
  1294. border: 1px solid rgba(0, 0, 0, 0.1);
  1295. box-sizing: border-box;
  1296. padding: 8px 12px 8px 12px;
  1297. border-radius: 8px;
  1298. }
  1299. > img {
  1300. width: 100%;
  1301. display: block;
  1302. }
  1303. }
  1304. }
  1305. .remarkBox {
  1306. flex: 1;
  1307. display: flex;
  1308. align-items: center;
  1309. justify-content: center;
  1310. position: relative;
  1311. &.remark72 {
  1312. padding-top: 72px;
  1313. }
  1314. &.remark-top {
  1315. padding-top: 44px;
  1316. }
  1317. }
  1318. .NNPE-wordDetail {
  1319. position: fixed;
  1320. z-index: 9999;
  1321. top: 50%;
  1322. margin-top: -196px;
  1323. left: 50%;
  1324. max-width: 100%;
  1325. overflow: auto;
  1326. }
  1327. }
  1328. </style>