AnswerModel.vue 38 KB

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