Practicechs.vue 37 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156
  1. <!-- -->
  2. <template>
  3. <div v-if="curQue" class="NNPE-ArticleView">
  4. <!-- <a class="ArticleView-full" @click="fullScreen">全屏模式</a> -->
  5. <div
  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. class="aduioLine-box aduioLine-practice-npc"
  13. >
  14. <div class="aduioLine-content">
  15. <template v-if="curQue.mp3_list && curQue.mp3_list.length > 0 && curQue.mp3_list[0].url">
  16. <AudioLine
  17. ref="audioLine"
  18. audio-id="artPraAudio"
  19. :mp3="curQue.mp3_list[0].url"
  20. :get-cur-time="getCurTime"
  21. :stop-audio="stopAudio"
  22. :width="colLength == 2 ? 175 : 700"
  23. :mp3-source="curQue.mp3_list[0].source"
  24. :ed="ed"
  25. type="audioLine"
  26. @handleChangeStopAudio="handleChangeStopAudio"
  27. @emptyEd="emptyEd"
  28. :attrib="attrib"
  29. />
  30. </template>
  31. </div>
  32. <div class="aduioLine-right">
  33. <SvgIcon
  34. v-if="config.isHasPY"
  35. icon-class="repeat-1"
  36. size="16"
  37. :class="['Repeat-16', isRepeat ? '' : 'disabled']"
  38. :style="{ color: isRepeat ? (attrib ? attrib.topic_color : '') : '#DCDFE6', cursor: 'pointer' }"
  39. @click="changeRepeat"
  40. />
  41. <!-- <span
  42. :class="['pinyin-16', config.isShowPY ? '' : 'disabled']"
  43. @click="changePinyin"
  44. v-if="config.isHasPY"
  45. ></span>
  46. <span :class="['EN-16', config.isShowEN ? '' : 'disabled']" @click="changeEN" v-if="config.isHasEN"></span> -->
  47. <SvgIcon
  48. v-if="config.isHasPY"
  49. icon-class="pin-btn"
  50. size="16"
  51. :class="['pinyin-16', config.isShowPY ? '' : 'disabled']"
  52. :style="{ color: config.isShowPY ? (attrib ? attrib.topic_color : '') : '#DCDFE6' }"
  53. @click="changePinyin"
  54. />
  55. <!-- <span :class="['EN-16', config.isShowEN ? '' : 'disabled']" @click="changeEN" v-if="config.isHasEN"></span> -->
  56. <SvgIcon
  57. v-if="config.isHasEN"
  58. icon-class="en-btn"
  59. size="16"
  60. :class="['EN-16', config.isShowEN ? '' : 'disabled']"
  61. :style="{ color: config.isShowEN ? (attrib ? attrib.topic_color : '') : '#DCDFE6' }"
  62. @click="changeEN"
  63. />
  64. </div>
  65. </div>
  66. <template v-if="resObj">
  67. <!-- -->
  68. <div class="NPC-sentences-list">
  69. <div
  70. v-for="(item, index) in resObj.sentList"
  71. :key="'detail' + index"
  72. :class="['NNPE-detail-box', sentIndex == index ? 'active' : '']"
  73. >
  74. <div
  75. :class="['NNPE-detail']"
  76. @click="
  77. handleChangeTime(
  78. curQue.wordTime && curQue.wordTime[index] && curQue.wordTime[index].bg,
  79. index,
  80. curQue.wordTime && curQue.wordTime[index] && curQue.wordTime[index].ed,
  81. )
  82. "
  83. >
  84. <div
  85. v-if="item.enwords && config.isShowEN && curQue.enPosition && curQue.enPosition == 'top'"
  86. :class="['enwords', sentIndex == index ? 'wordBlank' : '']"
  87. >
  88. {{ item.enwords }}
  89. </div>
  90. <div style="overflow: hidden; clear: both"></div>
  91. <div
  92. v-for="(pItem, pIndex) in item.sentArr"
  93. :key="'wordsList' + pIndex"
  94. class="NNPE-words"
  95. :class="[
  96. pItem.chs != '“' && pItem.wordIndex == 0 ? 'textLeft' : 'textCenter',
  97. pItem.chs == '“' ? 'textRight' : '',
  98. ]"
  99. >
  100. <template v-if="!pItem.width">
  101. <template v-if="pItem.isShow">
  102. <template
  103. v-if="
  104. item.sentArr[pIndex + 1] &&
  105. item.sentArr[pIndex + 1].chs &&
  106. chsFhList.indexOf(item.sentArr[pIndex + 1].chs) > -1
  107. "
  108. >
  109. <span class="NNPE-words-box">
  110. <template v-if="curQue.property.pinyin_position == 'top'">
  111. <span
  112. v-if="config.isShowPY"
  113. class="NNPE-pinyin"
  114. :class="[
  115. pItem.className ? pItem.className : '',
  116. sentIndex == index ? 'wordBlank' : '',
  117. noFont.indexOf(pItem.pinyin) > -1 ? 'noFont' : '',
  118. ]"
  119. >{{ pItem.pinyin }}</span
  120. >
  121. </template>
  122. <span
  123. class="NNPE-chs"
  124. :class="[
  125. pItem.padding && config.isShowPY ? 'padding' : '',
  126. sentIndex == index ? 'wordBlank' : '',
  127. ]"
  128. >
  129. <template>
  130. <span
  131. v-for="(wItem, wIndex) in pItem.leg"
  132. :key="'ci' + wIndex + pIndex + index"
  133. :class="[
  134. pItem.timeList[wIndex] &&
  135. curTime >= pItem.timeList[wIndex].wordBg &&
  136. curTime <= curQue.wordTime[index].ed
  137. ? 'active'
  138. : '',
  139. sentIndex == index ? 'wordBlank' : '',
  140. ]"
  141. :style="{
  142. fontFamily: pItem.config.fontFamily,
  143. height: '28px',
  144. display: 'inline-block',
  145. width: pItem.chs[wIndex].trim() === '' ? '6px' : '',
  146. }"
  147. >{{ NumberList.indexOf(pItem.pinyin) == -1 ? pItem.chs[wIndex] : '' }}</span
  148. >
  149. </template>
  150. </span>
  151. <template v-if="curQue.property.pinyin_position == 'bottom'">
  152. <span
  153. v-if="config.isShowPY"
  154. class="NNPE-pinyin"
  155. :class="[
  156. pItem.className ? pItem.className : '',
  157. sentIndex == index ? 'wordBlank' : '',
  158. noFont.indexOf(pItem.pinyin) > -1 ? 'noFont' : '',
  159. ]"
  160. >{{ pItem.pinyin }}</span
  161. >
  162. </template>
  163. </span>
  164. <span class="NNPE-words-box">
  165. <template v-if="curQue.property.pinyin_position == 'top'">
  166. <span
  167. v-if="config.isShowPY"
  168. :class="[
  169. 'NNPE-pinyin',
  170. sentIndex == index ? 'wordBlank' : '',
  171. noFont.indexOf(item.sentArr[pIndex + 1].pinyin) > -1 ? 'noFont' : '',
  172. ]"
  173. style="text-align: left"
  174. >{{ item.sentArr[pIndex + 1].pinyin }}</span
  175. >
  176. </template>
  177. <span class="NNPE-chs" style="text-align: left" :class="[sentIndex == index ? 'wordBlank' : '']">
  178. <span
  179. :class="[
  180. pItem.timeList[pItem.leg - 1] &&
  181. curQue.wordTime &&
  182. curTime >= pItem.timeList[pItem.leg - 1].wordBg &&
  183. curTime <= curQue.wordTime[index].ed
  184. ? 'active'
  185. : '',
  186. sentIndex == index ? 'wordBlank' : '',
  187. ]"
  188. :style="{
  189. fontFamily: item.sentArr[pIndex + 1].config.fontFamily,
  190. height: '28px',
  191. display: 'inline-block',
  192. width: item.sentArr[pIndex + 1].chs.trim() === '' ? '6px' : '',
  193. }"
  194. >
  195. {{
  196. NumberList.indexOf(item.sentArr[pIndex + 1].pinyin) == -1
  197. ? item.sentArr[pIndex + 1].chs
  198. : ''
  199. }}</span
  200. >
  201. </span>
  202. <template v-if="curQue.property.pinyin_position == 'bottom'">
  203. <span
  204. v-if="config.isShowPY"
  205. :class="[
  206. 'NNPE-pinyin',
  207. sentIndex == index ? 'wordBlank' : '',
  208. noFont.indexOf(item.sentArr[pIndex + 1].pinyin) > -1 ? 'noFont' : '',
  209. ]"
  210. style="text-align: left"
  211. >{{ item.sentArr[pIndex + 1].pinyin }}</span
  212. >
  213. </template>
  214. </span>
  215. <span
  216. v-if="
  217. item.sentArr[pIndex + 2] &&
  218. item.sentArr[pIndex + 2].chs &&
  219. chsFhList.indexOf(item.sentArr[pIndex + 2].chs) > -1
  220. "
  221. class="NNPE-words-box"
  222. >
  223. <template v-if="curQue.property.pinyin_position == 'top'">
  224. <span
  225. v-if="config.isShowPY"
  226. :class="[
  227. 'NNPE-pinyin',
  228. sentIndex == index ? 'wordBlank' : '',
  229. noFont.indexOf(item.sentArr[pIndex + 2].pinyin) > -1 ? 'noFont' : '',
  230. ]"
  231. style="text-align: left"
  232. >{{ item.sentArr[pIndex + 2].pinyin }}</span
  233. >
  234. </template>
  235. <span class="NNPE-chs" style="text-align: left" :class="[sentIndex == index ? 'wordBlank' : '']">
  236. <span
  237. :class="[
  238. pItem.timeList[pItem.leg - 1] &&
  239. curQue.wordTime &&
  240. curTime >= pItem.timeList[pItem.leg - 1].wordBg &&
  241. curTime <= curQue.wordTime[index].ed
  242. ? 'active'
  243. : '',
  244. sentIndex == index ? 'wordBlank' : '',
  245. ]"
  246. :style="{
  247. fontFamily: item.sentArr[pIndex + 2].config.fontFamily,
  248. height: '28px',
  249. display: 'inline-block',
  250. width: item.sentArr[pIndex + 2].chs.trim() === '' ? '6px' : '',
  251. }"
  252. >
  253. {{
  254. NumberList.indexOf(item.sentArr[pIndex + 2].pinyin) == -1
  255. ? item.sentArr[pIndex + 2].chs
  256. : ''
  257. }}</span
  258. >
  259. </span>
  260. <template v-if="curQue.property.pinyin_position == 'bottom'">
  261. <span
  262. v-if="config.isShowPY"
  263. :class="[
  264. 'NNPE-pinyin',
  265. sentIndex == index ? 'wordBlank' : '',
  266. noFont.indexOf(item.sentArr[pIndex + 2].pinyin) > -1 ? 'noFont' : '',
  267. ]"
  268. style="text-align: left"
  269. >{{ item.sentArr[pIndex + 2].pinyin }}</span
  270. >
  271. </template>
  272. </span>
  273. </template>
  274. <template v-else>
  275. <template v-if="curQue.property.pinyin_position == 'top'">
  276. <span
  277. v-if="config.isShowPY"
  278. class="NNPE-pinyin"
  279. :class="[
  280. pItem.chs != '“' && pItem.padding ? 'padding' : '',
  281. pItem.className ? pItem.className : '',
  282. sentIndex == index ? 'wordBlank' : '',
  283. noFont.indexOf(pItem.pinyin) > -1 ? 'noFont' : '',
  284. ]"
  285. >{{ pItem.pinyin }}</span
  286. >
  287. </template>
  288. <span
  289. class="NNPE-chs"
  290. :class="[
  291. pItem.chs != '“' && pItem.padding && config.isShowPY ? 'padding' : '',
  292. sentIndex == index ? 'wordBlank' : '',
  293. ]"
  294. >
  295. <template>
  296. <span
  297. v-for="(wItem, wIndex) in pItem.leg"
  298. :key="'ci' + wIndex + pIndex + index"
  299. :class="[
  300. pItem.timeList[wIndex] &&
  301. curQue.wordTime &&
  302. curQue.wordTime[index] &&
  303. curTime >= pItem.timeList[wIndex].wordBg &&
  304. curTime <= curQue.wordTime[index].ed
  305. ? 'active'
  306. : '',
  307. sentIndex == index ? 'wordBlank' : '',
  308. ]"
  309. :style="{
  310. fontFamily: pItem.config.fontFamily,
  311. height: '28px',
  312. display: 'inline-block',
  313. width: pItem.chs[wIndex].trim() === '' ? '6px' : '',
  314. }"
  315. >{{ NumberList.indexOf(pItem.pinyin) == -1 ? pItem.chs[wIndex] : '' }}</span
  316. >
  317. </template>
  318. </span>
  319. <template v-if="curQue.property.pinyin_position == 'bottom'">
  320. <span
  321. v-if="config.isShowPY"
  322. class="NNPE-pinyin"
  323. :class="[
  324. pItem.chs != '“' && pItem.padding ? 'padding' : '',
  325. pItem.className ? pItem.className : '',
  326. sentIndex == index ? 'wordBlank' : '',
  327. noFont.indexOf(pItem.pinyin) > -1 ? 'noFont' : '',
  328. ]"
  329. >{{ pItem.pinyin }}</span
  330. >
  331. </template>
  332. </template>
  333. </template>
  334. </template>
  335. <template v-else>
  336. <span
  337. :style="{
  338. height: pItem.height + 'px',
  339. width: pItem.width + 'px',
  340. }"
  341. ></span>
  342. </template>
  343. </div>
  344. <div style="overflow: hidden; clear: both"></div>
  345. <div
  346. v-if="
  347. item.enwords &&
  348. config.isShowEN &&
  349. (!curQue.enPosition || (curQue.enPosition && curQue.enPosition == 'bottom'))
  350. "
  351. :class="['enwords', sentIndex == index ? 'wordBlank' : '']"
  352. >
  353. {{ item.enwords }}
  354. </div>
  355. </div>
  356. <div
  357. class="multilingual-para"
  358. :class="[item.isTitle ? 'multilingual-para-center' : '']"
  359. v-if="curQue.property.multilingual_position === 'para'"
  360. >
  361. {{
  362. multilingualTextList[multilingual] && multilingualTextList[multilingual][index]
  363. ? multilingualTextList[multilingual][index]
  364. : ''
  365. }}
  366. </div>
  367. <div
  368. v-show="
  369. (curQue.wordTime &&
  370. curQue.wordTime[index] &&
  371. curTime >= curQue.wordTime[index].bg &&
  372. curTime <= curQue.wordTime[index].ed) ||
  373. sentIndex == index
  374. "
  375. class="Soundrecord-content"
  376. >
  377. <div class="Soundrecord-content-inner">
  378. <Soundrecord
  379. type="promax"
  380. class="luyin-box"
  381. :TaskModel="TaskModel"
  382. v-if="refresh"
  383. :answer-record-list="
  384. curQue.Bookanswer.practiceModel[index] && curQue.Bookanswer.practiceModel[index].recordList
  385. "
  386. :tm-index="index"
  387. :sent-index="sentIndex"
  388. @getWavblob="getWavblob"
  389. @handleParentPlay="handleParentPlay"
  390. @sentPause="sentPause"
  391. @handleWav="handleWav"
  392. />
  393. <div v-if="curQue.mp3_list && curQue.mp3_list.length > 0" class="compare-box">
  394. <Audio-compare
  395. :theme-color="themeColor"
  396. :index="index"
  397. :sent-index="sentIndex"
  398. :url="curQue.mp3_list[0].id"
  399. :bg="curQue.wordTime[index].bg"
  400. :ed="curQue.wordTime[index].ed"
  401. :wavblob="wavblob"
  402. :get-cur-time="getCurTime"
  403. :sent-pause="sentPause"
  404. :is-record="isRecord"
  405. :handle-change-stop-audio="handleChangeStopAudio"
  406. :get-play-status="getPlayStatus"
  407. :attrib="attrib"
  408. />
  409. </div>
  410. </div>
  411. <span class="full-screen-icon" @click="fullScreen"> </span>
  412. </div>
  413. </div>
  414. <!-- <div class="multilingual" v-for="(items, indexs) in multilingualTextList" :key="indexs">
  415. {{ items }}
  416. </div> -->
  417. </div>
  418. </template>
  419. <div class="multilingual" v-for="(items, indexs) in curQue.detail" :key="indexs">
  420. <div
  421. class="multilingual-para"
  422. :class="[items.isTitle ? 'multilingual-para-center' : '']"
  423. v-if="curQue.property.multilingual_position === 'all'"
  424. >
  425. {{
  426. items.multilingualTextList && items.multilingualTextList[multilingual]
  427. ? items.multilingualTextList[multilingual].join(' ')
  428. : ''
  429. }}
  430. </div>
  431. </div>
  432. <div
  433. v-if="
  434. ((curQue.mp3_list && curQue.mp3_list.length > 0 && curQue.mp3_list[0].url) ||
  435. config.isHasPY ||
  436. config.isHasEN) &&
  437. curQue.property.mp3_position === 'bottom'
  438. "
  439. class="aduioLine-box aduioLine-practice-npc aduioLine-box-bottom"
  440. >
  441. <div class="aduioLine-content">
  442. <template v-if="curQue.mp3_list && curQue.mp3_list.length > 0 && curQue.mp3_list[0].url">
  443. <AudioLine
  444. ref="audioLine"
  445. audio-id="artPraAudio"
  446. :mp3="curQue.mp3_list[0].url"
  447. :get-cur-time="getCurTime"
  448. :stop-audio="stopAudio"
  449. :width="colLength == 2 ? 175 : 700"
  450. :mp3-source="curQue.mp3_list[0].source"
  451. :ed="ed"
  452. type="audioLine"
  453. @handleChangeStopAudio="handleChangeStopAudio"
  454. @emptyEd="emptyEd"
  455. :attrib="attrib"
  456. />
  457. </template>
  458. </div>
  459. <div class="aduioLine-right">
  460. <!-- <span :class="['Repeat-16', isRepeat ? '' : 'disabled']" @click="changeRepeat"></span>
  461. <span
  462. :class="['pinyin-16', config.isShowPY ? '' : 'disabled']"
  463. @click="changePinyin"
  464. v-if="config.isHasPY"
  465. ></span>
  466. <span :class="['EN-16', config.isShowEN ? '' : 'disabled']" @click="changeEN" v-if="config.isHasEN"></span> -->
  467. <SvgIcon
  468. v-if="config.isHasPY"
  469. icon-class="repeat-1"
  470. size="16"
  471. :class="['Repeat-16', isRepeat ? '' : 'disabled']"
  472. :style="{ color: isRepeat ? (attrib ? attrib.topic_color : '') : '#DCDFE6', cursor: 'pointer' }"
  473. @click="changeRepeat"
  474. />
  475. <!-- <span
  476. :class="['pinyin-16', config.isShowPY ? '' : 'disabled']"
  477. @click="changePinyin"
  478. v-if="config.isHasPY"
  479. ></span>
  480. <span :class="['EN-16', config.isShowEN ? '' : 'disabled']" @click="changeEN" v-if="config.isHasEN"></span> -->
  481. <SvgIcon
  482. v-if="config.isHasPY"
  483. icon-class="pin-btn"
  484. size="16"
  485. :class="['pinyin-16', config.isShowPY ? '' : 'disabled']"
  486. :style="{ color: config.isShowPY ? (attrib ? attrib.topic_color : '') : '#DCDFE6' }"
  487. @click="changePinyin"
  488. />
  489. <!-- <span :class="['EN-16', config.isShowEN ? '' : 'disabled']" @click="changeEN" v-if="config.isHasEN"></span> -->
  490. <SvgIcon
  491. v-if="config.isHasEN"
  492. icon-class="en-btn"
  493. size="16"
  494. :class="['EN-16', config.isShowEN ? '' : 'disabled']"
  495. :style="{ color: config.isShowEN ? (attrib ? attrib.topic_color : '') : '#DCDFE6' }"
  496. @click="changeEN"
  497. />
  498. </div>
  499. </div>
  500. <div :id="'screen-' + mathNum" class="voice-full-screen">
  501. <Voicefullscreen
  502. v-if="isFull && resObj"
  503. :theme-color="themeColor"
  504. :cur-que="curQue"
  505. :sent-list="resObj.sentList"
  506. :sent-index="sentIndex"
  507. :mp3="curQue.mp3_list && curQue.mp3_list[0] ? curQue.mp3_list[0].url : ''"
  508. :no-font="noFont"
  509. :NNPENewWordList="NNPENewWordList"
  510. :current-tree-i-d="currentTreeID"
  511. :config="config"
  512. :TaskModel="TaskModel"
  513. @handleWav="handleWav"
  514. @changePinyin="changePinyin"
  515. @changeEN="changeEN"
  516. @exitFullscreen="exitFullscreen"
  517. @changeIsFull="changeIsFull"
  518. :attrib="attrib"
  519. />
  520. </div>
  521. </div>
  522. </template>
  523. <script>
  524. import AudioLine from '../voice_matrix/components/AudioLine.vue';
  525. import Soundrecord from '../../common/SoundRecord.vue';
  526. import AudioCompare from './components/AudioCompare.vue';
  527. import Voicefullscreen from './Voicefullscreen.vue';
  528. export default {
  529. name: 'ArticleView',
  530. components: {
  531. AudioLine,
  532. Soundrecord,
  533. AudioCompare,
  534. Voicefullscreen,
  535. },
  536. props: [
  537. 'curQue',
  538. 'noFont',
  539. 'themeColor',
  540. 'NNPENewWordList',
  541. 'currentTreeID',
  542. 'config',
  543. 'TaskModel',
  544. 'colLength',
  545. 'isFull',
  546. 'multilingual',
  547. 'attrib',
  548. ],
  549. data() {
  550. return {
  551. resObj: null,
  552. curTime: 0, // 单位s
  553. chsFhList: [',', '。', '”', ':', '》', '?', '!', ';', '、'],
  554. enFhList: [',', '.', ';', '?', '!', ':', '>', '<'],
  555. NumberList: ['①', '②', '③', '④', '⑤', '⑥', '⑦', '⑧', '⑨', '⑩', '⑪', '⑫', '⑬', '⑭', '⑮', '⑯', '⑰', '⑱', '⑲', '⑳'],
  556. stopAudio: false,
  557. sentIndex: 0,
  558. isRepeat: false,
  559. currSent: null, // 当前句子的时间
  560. isRecord: false,
  561. wavblob: null,
  562. mathNum: Math.random().toString(36).substr(2),
  563. ed: undefined,
  564. refresh: true,
  565. multilingualTextList: {},
  566. };
  567. },
  568. computed: {
  569. isPlaying() {
  570. let playing = false;
  571. if (this.$refs.audioLine) {
  572. playing = this.$refs.audioLine.audio.isPlaying;
  573. }
  574. return playing;
  575. },
  576. },
  577. watch: {
  578. sentIndex: {
  579. handler(newVal, oldVal) {
  580. let _this = this;
  581. if (newVal != oldVal) {
  582. let Bookanswer = _this.curQue.Bookanswer;
  583. if (
  584. Bookanswer &&
  585. Bookanswer.practiceModel &&
  586. Bookanswer.practiceModel[newVal] &&
  587. Bookanswer.practiceModel[newVal].recordList &&
  588. Bookanswer.practiceModel[newVal].recordList.length > 0
  589. ) {
  590. _this.wavblob = Bookanswer.practiceModel[newVal].recordList[0].wavData;
  591. } else {
  592. _this.wavblob = '';
  593. }
  594. }
  595. },
  596. deep: true,
  597. },
  598. isFull: {
  599. handler(newVal, oldVal) {
  600. let _this = this;
  601. _this.refresh = false;
  602. if (!newVal) {
  603. _this.$nextTick(() => {
  604. // 重新渲染组件
  605. _this.refresh = true;
  606. });
  607. }
  608. },
  609. deep: true,
  610. },
  611. },
  612. // 生命周期 - 创建完成(可以访问当前this实例)
  613. created() {},
  614. // 生命周期 - 挂载完成(可以访问DOM元素)
  615. mounted() {
  616. if (this.curQue) {
  617. this.handleData();
  618. }
  619. },
  620. beforeCreate() {}, // 生命周期 - 创建之前
  621. beforeMount() {}, // 生命周期 - 挂载之前
  622. beforeUpdate() {}, // 生命周期 - 更新之前
  623. updated() {}, // 生命周期 - 更新之后
  624. beforeDestroy() {}, // 生命周期 - 销毁之前
  625. destroyed() {}, // 生命周期 - 销毁完成
  626. activated() {},
  627. // 方法集合
  628. methods: {
  629. getPlayStatus(val) {
  630. // this.isPlaying = val;
  631. },
  632. // 拼音的显示和隐藏
  633. changePinyin() {
  634. if (this.config.isHasPY) {
  635. this.$emit('changeConfig', 'isShowPY');
  636. }
  637. },
  638. // 英文的显示和隐藏
  639. changeEN() {
  640. if (this.config.isHasEN) {
  641. this.$emit('changeConfig', 'isShowEN');
  642. }
  643. },
  644. pauseAudio() {
  645. let audio = document.getElementsByTagName('audio');
  646. if (audio && audio.length > 0 && window.location.href.indexOf('GCLS-Learn') == -1 && audio.forEach) {
  647. audio.forEach((item) => {
  648. item.pause();
  649. });
  650. }
  651. },
  652. pauseVideo() {
  653. let video = document.getElementsByTagName('video');
  654. if (video && video.length > 0 && window.location.href.indexOf('GCLS-Learn') == -1 && video.forEach) {
  655. video.forEach((item) => {
  656. item.pause();
  657. });
  658. }
  659. },
  660. // 语音全屏
  661. fullScreen() {
  662. this.pauseAudio();
  663. this.pauseVideo();
  664. this.isFull = true;
  665. this.goFullscreen();
  666. },
  667. goFullscreen() {
  668. let id = `screen-${this.mathNum}`;
  669. let element = document.getElementById(id);
  670. if (element.requestFullscreen) {
  671. element.requestFullscreen();
  672. } else if (element.msRequestFullscreen) {
  673. element.msRequestFullscreen();
  674. } else if (element.mozRequestFullScreen) {
  675. element.mozRequestFullScreen();
  676. } else if (element.webkitRequestFullscreen) {
  677. element.webkitRequestFullscreen();
  678. }
  679. },
  680. exitFullscreen() {
  681. this.isFull = false;
  682. if (document.exitFullscreen) {
  683. document.exitFullscreen();
  684. } else if (document.msExitFullscreen) {
  685. document.msExitFullscreen();
  686. } else if (document.mozCancelFullScreen) {
  687. document.mozCancelFullScreen();
  688. } else if (document.webkitExitFullscreen) {
  689. document.webkitExitFullscreen();
  690. }
  691. },
  692. changeIsFull() {
  693. this.isFull = false;
  694. },
  695. getWavblob(wavblob) {
  696. this.wavblob = wavblob;
  697. },
  698. sentPause(isRecord) {
  699. this.isRecord = isRecord;
  700. },
  701. getCurTime(curTime) {
  702. let _this = this;
  703. if (_this.isRepeat) {
  704. let time = curTime * 1000;
  705. if (time >= _this.currSent.ed || time <= _this.currSent.bg) {
  706. _this.curTime = _this.currSent.bg;
  707. this.$refs.audioLine.onTimeupdateTime(_this.currSent.bg / 1000, true);
  708. } else {
  709. _this.curTime = curTime * 1000;
  710. }
  711. } else {
  712. _this.curTime = curTime * 1000;
  713. _this.getSentIndex(_this.curTime);
  714. }
  715. },
  716. getSentIndex(curTime) {
  717. for (let i = 0; i < this.curQue.wordTime.length; i++) {
  718. let bg = this.curQue.wordTime[i].bg;
  719. let ed = this.curQue.wordTime[i].ed;
  720. if (curTime >= bg && curTime <= ed) {
  721. this.sentIndex = i;
  722. break;
  723. }
  724. }
  725. },
  726. handleData() {
  727. this.curQue.multilingual.forEach((item) => {
  728. let trans_arr = item.translation.split('\n');
  729. this.$set(this.multilingualTextList, item.type, trans_arr);
  730. });
  731. let resArr = [];
  732. let sentArrTotal = [];
  733. let timeArr = [];
  734. let curQue = JSON.parse(JSON.stringify(this.curQue));
  735. let wordTimeList = curQue.wordTime;
  736. let dhaspinyin = false; // 每段是否有拼音
  737. let dhaspinyinArr = [];
  738. curQue.detail.forEach((dItem, dIndex) => {
  739. dhaspinyin = false;
  740. dItem.wordsList.forEach((sItem, sIndex) => {
  741. let sentArr = [];
  742. sItem.forEach((wItem, wIndex) => {
  743. let startIndex = wIndex == 0 ? 0 : sentArr[wIndex - 1].startIndex + sentArr[wIndex - 1].chs.length;
  744. let endIndex = wIndex == 0 ? wItem.chs.length : sentArr[wIndex - 1].endIndex + wItem.chs.length;
  745. // this.judgePad(sItem, wItem, wIndex);
  746. this.mergeWordSymbol(wItem);
  747. let obj = {
  748. paraIndex: dIndex, // 段落索引
  749. sentIndex: sIndex, // 在段落中句子索引
  750. wordIndex: wIndex, // 单词的索引
  751. pinyin:
  752. curQue.pinyin_type === 'pinyin'
  753. ? curQue.property.is_first_sentence_first_hz_pinyin_first_char_upper_case === 'true' && wIndex === 0
  754. ? wItem.pinyin_up
  755. : wItem.pinyin
  756. : wItem.pinyin_tone,
  757. chs: wItem.chs,
  758. padding: true,
  759. className: wItem.className,
  760. isShow: wItem.isShow,
  761. startIndex,
  762. endIndex,
  763. leg: wItem.chs.length,
  764. timeList: [],
  765. config: {
  766. fontFamily: wItem.fontFamily,
  767. },
  768. };
  769. sentArr.push(obj);
  770. if (wItem.pinyin) dhaspinyin = true;
  771. });
  772. let objs = {
  773. sentArr,
  774. enwords: dItem.sentencesEn && dItem.sentencesEn[sIndex] && dItem.sentencesEn[sIndex].replace(/\'/g, '’'),
  775. };
  776. sentArrTotal.push(sentArr);
  777. resArr.push(objs);
  778. });
  779. timeArr.push(dItem.timeList);
  780. dhaspinyinArr.push(dhaspinyin);
  781. });
  782. if (wordTimeList && wordTimeList.length > 0) {
  783. this.mergeWordTime(sentArrTotal, wordTimeList);
  784. }
  785. let timeList = [];
  786. timeArr.forEach((item) => {
  787. item.forEach((aItem) => {
  788. if (timeList.indexOf(aItem) < 0) {
  789. timeList.push(aItem);
  790. }
  791. });
  792. });
  793. this.resObj = {
  794. sentList: resArr,
  795. timeList,
  796. dhaspinyinArr,
  797. };
  798. },
  799. mergeWordTime(resArr, wordTimeList) {
  800. resArr.forEach((item, index) => {
  801. let wordsResultList = wordTimeList[index].wordsResultList;
  802. item.forEach((wItem) => {
  803. let startIndex = wItem.startIndex;
  804. let endIndex = wItem.endIndex;
  805. wItem.timeList = wordsResultList.slice(startIndex, endIndex);
  806. });
  807. });
  808. },
  809. // 词和标点合一起
  810. mergeWordSymbol(wItem) {
  811. if (this.chsFhList.indexOf(wItem.chs) > -1) {
  812. wItem.isShow = false;
  813. } else {
  814. wItem.isShow = true;
  815. }
  816. },
  817. // 判断是否有padding
  818. judgePad(sItem, wItem, curIndex) {
  819. let leg = sItem.length;
  820. if (curIndex < leg - 1) {
  821. let nextIndex = curIndex + 1;
  822. let chs = sItem[nextIndex].chs;
  823. if (this.chsFhList.indexOf(chs) > -1 || this.chsFhList.indexOf(wItem.chs) > -1) {
  824. wItem.padding = false;
  825. } else {
  826. wItem.padding = true;
  827. }
  828. if (this.enFhList.indexOf(wItem.pinyin) > -1) {
  829. wItem.className = 'textLeft';
  830. }
  831. }
  832. },
  833. // 转化时间
  834. handleTimeList(list) {
  835. let listRes = [];
  836. list.forEach((item) => {
  837. let res = timeStrToSen(item);
  838. listRes.push(res);
  839. });
  840. return listRes;
  841. },
  842. // 分:秒转秒
  843. timeStrToSen(time) {
  844. if (!time) {
  845. return -1;
  846. }
  847. let pos = time.indexOf(':');
  848. let min = 0;
  849. var sec = 0;
  850. if (pos > 0) {
  851. min = parseInt(time.substring(0, pos));
  852. sec = parseFloat(time.substring(pos + 1));
  853. }
  854. return min * 60 + sec;
  855. },
  856. // 计算总时间
  857. countWordTime(sentArr) {
  858. let total = 0;
  859. sentArr.forEach((item) => {
  860. total += item.endTime;
  861. });
  862. return total;
  863. },
  864. // 点击播放某个句子
  865. handleChangeTime(time, index, ed) {
  866. let _this = this;
  867. if (this.isRepeat) {
  868. _this.currSent = _this.curQue.wordTime[index];
  869. }
  870. _this.sentIndex = index;
  871. _this.ed = ed;
  872. if (time) {
  873. _this.curTime = time;
  874. _this.$refs.audioLine.onTimeupdateTime(time / 1000, true);
  875. }
  876. },
  877. emptyEd() {
  878. this.ed = undefined;
  879. },
  880. handleWav(list, tmIndex) {
  881. tmIndex = tmIndex || 0;
  882. this.curQue.Bookanswer.practiceModel[tmIndex] = {
  883. recordList: [],
  884. };
  885. this.$set(this.curQue.Bookanswer.practiceModel[tmIndex], 'recordList', list);
  886. },
  887. // 录音时暂停音频播放
  888. handleParentPlay() {
  889. this.stopAudio = true;
  890. },
  891. // 音频播放时改变布尔值
  892. handleChangeStopAudio() {
  893. this.stopAudio = false;
  894. },
  895. // 单句是否重复播放
  896. changeRepeat() {
  897. let _this = this;
  898. _this.isRepeat = !_this.isRepeat;
  899. this.currSent = _this.curQue.wordTime[_this.sentIndex];
  900. },
  901. }, // 如果页面有keep-alive缓存功能,这个函数会触发
  902. };
  903. </script>
  904. <style lang="scss" scoped>
  905. //@import url(); 引入公共css类
  906. .NNPE-ArticleView {
  907. position: relative;
  908. width: 100%;
  909. .ArticleView-full {
  910. position: absolute;
  911. top: -33px;
  912. left: 0;
  913. z-index: 99999;
  914. padding-left: 24px;
  915. font-size: 14px;
  916. font-weight: bold;
  917. line-height: 24px;
  918. color: #000;
  919. background: url('@/assets/full-screen-red.png') left center no-repeat;
  920. background-size: 16px 16px;
  921. }
  922. .NPC-sentences-list {
  923. padding: 16px 0;
  924. }
  925. .multilingual {
  926. padding: 6px 24px 12px;
  927. word-break: break-word;
  928. }
  929. .aduioLine-content {
  930. flex: 1;
  931. }
  932. .NNPE-detail-box {
  933. box-sizing: border-box;
  934. width: 100%;
  935. padding: 8px 24px;
  936. margin-bottom: 8px;
  937. &.active {
  938. background: rgba(222, 68, 68, 15%);
  939. }
  940. }
  941. .aduioLine-practice-npc {
  942. display: flex;
  943. align-items: center;
  944. justify-content: flex-start;
  945. .aduioLine-right {
  946. box-sizing: border-box;
  947. display: flex;
  948. align-items: center;
  949. justify-content: space-between;
  950. width: 92px;
  951. height: 40px;
  952. padding: 0 12px;
  953. border-left: 1px solid rgba(0, 0, 0, 10%);
  954. .svg-icon {
  955. width: 16px;
  956. height: 16px;
  957. cursor: pointer;
  958. }
  959. }
  960. }
  961. .NNPE-detail {
  962. overflow: hidden;
  963. clear: both;
  964. .NNPE-words {
  965. float: left;
  966. &-box {
  967. float: left;
  968. > span {
  969. display: block;
  970. &.NNPE-pinyin {
  971. height: 20px;
  972. font-family: 'League';
  973. font-size: 14px;
  974. font-weight: normal;
  975. line-height: 20px;
  976. color: rgba(0, 0, 0, 45%);
  977. &.noFont {
  978. font-family: initial;
  979. }
  980. &.textLeft {
  981. text-align: left;
  982. }
  983. &.wordBlank {
  984. color: rgba(0, 0, 0, 85%);
  985. }
  986. }
  987. &.NNPE-chs {
  988. display: flex;
  989. flex-flow: wrap;
  990. font-family: '楷体';
  991. font-size: 20px;
  992. line-height: 28px;
  993. color: rgba(0, 0, 0, 45%);
  994. .active {
  995. color: #de4444;
  996. }
  997. &.wordBlank {
  998. color: rgba(0, 0, 0, 85%);
  999. }
  1000. }
  1001. // &.padding {
  1002. // padding-right: 6px;
  1003. // }
  1004. }
  1005. }
  1006. &.textLeft {
  1007. text-align: left;
  1008. }
  1009. &.textCenter {
  1010. text-align: center;
  1011. .NNPE-chs {
  1012. justify-content: center;
  1013. }
  1014. }
  1015. &.textRight {
  1016. text-align: right;
  1017. }
  1018. > span {
  1019. display: block;
  1020. &.NNPE-pinyin {
  1021. height: 20px;
  1022. font-family: 'League';
  1023. font-size: 14px;
  1024. font-weight: normal;
  1025. line-height: 20px;
  1026. color: rgba(0, 0, 0, 45%);
  1027. &.noFont {
  1028. font-family: initial;
  1029. }
  1030. &.textLeft {
  1031. text-align: left;
  1032. }
  1033. &.wordBlank {
  1034. color: rgba(0, 0, 0, 85%);
  1035. }
  1036. }
  1037. &.NNPE-chs {
  1038. display: flex;
  1039. flex-flow: wrap;
  1040. font-family: '楷体';
  1041. font-size: 20px;
  1042. line-height: 28px;
  1043. color: rgba(0, 0, 0, 45%);
  1044. .active {
  1045. color: #de4444;
  1046. }
  1047. &.wordBlank {
  1048. color: rgba(0, 0, 0, 85%);
  1049. }
  1050. }
  1051. &.padding {
  1052. padding: 0 3px;
  1053. }
  1054. }
  1055. }
  1056. }
  1057. .Soundrecord-content {
  1058. display: flex;
  1059. align-items: center;
  1060. justify-content: space-between;
  1061. margin-top: 8px;
  1062. &-inner {
  1063. display: flex;
  1064. align-items: center;
  1065. justify-content: flex-start;
  1066. width: 304px;
  1067. padding: 4px 12px;
  1068. background: #fff;
  1069. border: 1px solid rgba(0, 0, 0, 10%);
  1070. border-radius: 8px;
  1071. .luyin-box {
  1072. width: 280px;
  1073. max-width: 280px;
  1074. }
  1075. .compare-box {
  1076. display: flex;
  1077. align-items: center;
  1078. justify-content: center;
  1079. height: 32px;
  1080. }
  1081. }
  1082. .full-screen-icon {
  1083. width: 16px;
  1084. height: 16px;
  1085. cursor: pointer;
  1086. background: url('@/assets/full-screen-red.png') no-repeat left top;
  1087. background-size: 100% 100%;
  1088. }
  1089. }
  1090. .enwords {
  1091. padding-left: 3px;
  1092. font-family: 'Helvetica';
  1093. font-size: 14px;
  1094. font-weight: normal;
  1095. line-height: 22px;
  1096. color: rgba(0, 0, 0, 45%);
  1097. word-break: break-word;
  1098. &.wordBlank {
  1099. color: rgba(0, 0, 0, 85%);
  1100. }
  1101. }
  1102. .multilingual-para {
  1103. word-break: break-word;
  1104. &-center {
  1105. text-align: center;
  1106. text-indent: 0;
  1107. }
  1108. }
  1109. }
  1110. </style>