PhraseModelChs.vue 40 KB

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