NormalModel.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  1. <!-- -->
  2. <template>
  3. <div class="NNPE-ArticleView" v-if="articleInfo">
  4. <template v-if="resArr[0]&&resArr[0].wordsList[0]&&resArr[0].wordsList[0].hasOwnProperty('pno')&&resArr[0].wordsList[0].pno===0">
  5. <h2 @click="
  6. handleChangeTime(
  7. resArr[0].timeList &&
  8. resArr[0].timeList[0] &&
  9. resArr[0].timeList[0].s
  10. )
  11. "
  12. @mouseover="handleMouseover(resArr[0])"
  13. @mouseleave="handleMouseleave"
  14. :class="[
  15. 'NNPE-words',
  16. isPlaying &&
  17. resArr[0].timeList &&
  18. resArr[0].timeList[0] &&
  19. curTime >= resArr[0].timeList[0].s &&
  20. curTime <= resArr[0].timeList[0].e
  21. ? 'sentActive'
  22. : '',
  23. resArr[0].wordsList[0].pno == paraIndex && resArr[0].wordsList[0].sno == sentIndex
  24. ? 'overActive'
  25. : '',
  26. ]">
  27. <span v-for="(itemR,indexR) in resArr[0].wordsList" :key="indexR" :style="{color:colorObj.titleColor,fontSize:(wordFontsize+30)+'px',lineHeight:(wordFontsize+38)+'px',marginRight:'10px',fontWeight:'700',cursor:'pointer'}"
  28. :class="[
  29. isPlaying &&
  30. resArr[0].timeList &&
  31. resArr[0].timeList[0] &&
  32. curTime >=
  33. resArr[0].timeList[0].tokens[indexR].s &&
  34. curTime <= resArr[0].timeList[0].e
  35. ? 'wordActive'
  36. : '',
  37. itemR.tokens[9]===' '?'marginRight':'',itemR.marginRight?'marginSingleRight':''
  38. ]">
  39. <template v-if="itemR.isShow">
  40. <span
  41. class="NNPE-chs"
  42. :class="[
  43. itemR.type,itemR.tokens[9]===' '?'marginRight':'',itemR.highIndex?'fontWeight':'',itemR.marginRight?'marginSingleRight':''
  44. ]"
  45. >{{ itemR.tokens[2] }}</span
  46. >
  47. <span
  48. class="NNPE-chs NNPE-chs-both"
  49. v-if="resArr[0].wordsList[indexR + 1] &&
  50. resArr[0].wordsList[indexR + 1].tokens[2] &&
  51. enFhList.indexOf(resArr[0].wordsList[indexR + 1].tokens[2]) > -1"
  52. :class="[
  53. resArr[0].wordsList[indexR + 1].type,resArr[0].wordsList[indexR + 1].tokens[9]===' '?'marginRight':'',resArr[0].wordsList[indexR + 1].highIndex?'fontWeight':'',resArr[0].wordsList[indexR + 1].marginRight?'marginSingleRight':''
  54. ]"
  55. >{{ resArr[0].wordsList[indexR + 1].tokens[2] }}</span
  56. >
  57. </template>
  58. <!-- {{itemR.tokens[2]}} -->
  59. </span>
  60. </h2>
  61. </template>
  62. <h6 class="nnpe-article-author" :style="{color:colorObj.sourceColor,fontSize:(wordFontsize-4)+'px',lineHeight:(wordFontsize+4)+'px',fontWeight:'400'}">
  63. {{articleInfo.art_author+' · '+articleInfo.study_phase_name+'版 · 第 '+articleInfo.iss_no+' 期 · '+articleInfo.release_date+' · '+articleInfo.chn_item+(articleInfo.page_no_in_pub?' · P'+articleInfo.page_no_in_pub:'')}}
  64. </h6>
  65. <div class="audio-box">
  66. <div
  67. class="aduioLine-content aduioLine-box"
  68. v-if="
  69. articleInfo.art_sound_url
  70. " :style="{background:colorObj.audiobg,borderColor:colorObj.audioBorder}"
  71. >
  72. <AudioLine
  73. audioId="artNormalAudio"
  74. :mp3="articleInfo.art_sound_url"
  75. :getCurTime="getCurTime"
  76. ref="audioLine"
  77. :mp3Source="'mp3'"
  78. />
  79. <svg-icon icon-class="icon-wrapper" class="wrapper"></svg-icon>
  80. </div>
  81. </div>
  82. <template v-if="resArr.length > 0">
  83. <div class="table-box">
  84. <div
  85. :class="['NNPE-detail']"
  86. v-for="(item, index) in resArr"
  87. :key="'detail' + index"
  88. >
  89. <div class="wordsList-box">
  90. <div class="nnpe-sentence-box">
  91. <div v-for="(pItem, pIndex) in item.wordsList" :key="'wordsList' + pIndex">
  92. <template v-if="pItem.pno!==0">
  93. <template v-if="pItem.isShow">
  94. <div
  95. :class="[
  96. 'NNPE-words',
  97. isPlaying &&
  98. item.timeList &&
  99. item.timeList[pItem.sno] &&
  100. curTime >= item.timeList[pItem.sno].s &&
  101. curTime <= item.timeList[pItem.sno].e
  102. ? 'sentActive'
  103. : '',
  104. pItem.pno == paraIndex && pItem.sno == sentIndex
  105. ? 'overActive'
  106. : '',
  107. ]"
  108. @click="
  109. handleChangeTime(
  110. item.timeList &&
  111. item.timeList[pItem.sno] &&
  112. item.timeList[pItem.sno].s
  113. )
  114. "
  115. @mouseover="handleMouseover(pItem)"
  116. @mouseleave="handleMouseleave"
  117. >
  118. <span
  119. class="NNPE-chs"
  120. :class="[
  121. isPlaying &&
  122. item.timeList &&
  123. item.timeList[pItem.sno] &&
  124. item.timeList[pItem.sno].e &&
  125. item.timeList[pItem.sno].tokens &&
  126. item.timeList[pItem.sno].tokens[pItem.wIndex]&&
  127. curTime >=
  128. item.timeList[pItem.sno].tokens[pItem.wIndex].s &&
  129. curTime <= item.timeList[pItem.sno].e
  130. ? 'wordActive'
  131. : '',
  132. pItem.tokens[9]===' '?'marginRight':'',pItem.marginRight?'marginSingleRight':''
  133. ]"
  134. :style="{fontSize:wordFontsize + 'px',color: isPlaying &&
  135. item.timeList &&
  136. item.timeList[pItem.sno] &&
  137. item.timeList[pItem.sno].tokens[pItem.wIndex]&&
  138. curTime >=
  139. item.timeList[pItem.sno].tokens[pItem.wIndex].s &&
  140. curTime <= item.timeList[pItem.sno].tokens[pItem.wIndex].e?colorObj.statisticValue:colorObj.contentColor}"
  141. >{{ pItem.tokens[2] }}</span
  142. >
  143. <span
  144. class="NNPE-chs NNPE-chs-both"
  145. v-if="item.wordsList[pIndex + 1] &&
  146. item.wordsList[pIndex + 1].tokens[2] &&
  147. enFhList.indexOf(item.wordsList[pIndex + 1].tokens[2]) > -1"
  148. :class="[
  149. isPlaying &&
  150. item.timeList &&
  151. item.timeList[pItem.sno] &&
  152. item.timeList[pItem.sno].tokens[pItem.wIndex]&&
  153. curTime >=
  154. item.timeList[pItem.sno].tokens[pItem.wIndex].s &&
  155. curTime <= item.timeList[pItem.sno].e
  156. ? 'wordActive'
  157. : '',
  158. item.wordsList[pIndex + 1].tokens[9]===' '?'marginRight':'',item.wordsList[pIndex + 1].marginRight?'marginSingleRight':''
  159. ]"
  160. :style="{fontSize:wordFontsize + 'px',color: isPlaying &&
  161. item.timeList &&
  162. item.timeList[pItem.sno] &&
  163. item.timeList[pItem.sno].tokens[pItem.wIndex]&&
  164. curTime >=
  165. item.timeList[pItem.sno].tokens[pItem.wIndex].s &&
  166. curTime <= item.timeList[pItem.sno].tokens[pItem.wIndex].e?colorObj.statisticValue:colorObj.contentColor}"
  167. >{{ item.wordsList[pIndex + 1].tokens[2] }}</span
  168. >
  169. </div>
  170. </template>
  171. </template>
  172. </div>
  173. </div>
  174. </div>
  175. </div>
  176. </div>
  177. </template>
  178. <!-- <img src="../../../assets/article-img.png" style="max-width:100%;margin:24px 0;" /> -->
  179. </div>
  180. </template>
  181. <script>
  182. import AudioLine from "@/components/common/AudioLine.vue"
  183. import MagazineVideo from "./MagazineVideo.vue"
  184. export default {
  185. name: "ArticleView",
  186. props: [ "titleFontsize", "wordFontsize", "colorObj","articleType","articleInfo"],
  187. components: {
  188. AudioLine,
  189. MagazineVideo
  190. },
  191. data() {
  192. return {
  193. resArr: [],
  194. curTime: 0, //单位s
  195. enFhList: [
  196. ",",
  197. ".",
  198. ";",
  199. "?",
  200. "!",
  201. ":",
  202. ">",
  203. "<",
  204. "'",
  205. "’",
  206. "n't",
  207. "n’t",
  208. "n’ts",
  209. "n‘t",
  210. "'t",
  211. "’t",
  212. "‘t",
  213. "'s",
  214. "’s",
  215. "‘s",
  216. "'m",
  217. "’m",
  218. "‘m",
  219. "'re",
  220. "’re",
  221. "‘re",
  222. "'d",
  223. "’d",
  224. "‘d",
  225. "'ve",
  226. "’ve",
  227. "‘ve",
  228. ")",
  229. "'ll",
  230. "’ll",
  231. "‘ll",
  232. "”",
  233. ],
  234. articleImg: {}, // 文章图片
  235. paraIndex: -1, //段落索引
  236. sentIndex: -1, // 句子索引
  237. };
  238. },
  239. computed: {
  240. isPlaying: function () {
  241. let playing = false;
  242. if (this.$refs.audioLine) {
  243. playing = this.$refs.audioLine.audio.isPlaying;
  244. }
  245. return playing;
  246. },
  247. },
  248. watch: {},
  249. //方法集合
  250. methods: {
  251. getCurTime(curTime) {
  252. this.curTime = curTime * 1000;
  253. },
  254. handleData() {
  255. let resArr = [];
  256. let articleInfo = JSON.parse(JSON.stringify(this.articleInfo));
  257. let leg = articleInfo.art_corpus_data.sentList[articleInfo.art_corpus_data.sentList.length-1].pno
  258. for(let i=0;i<leg+1;i++){
  259. let obj = {
  260. wordsList: [],
  261. timeList: [],
  262. }
  263. resArr.push(obj)
  264. }
  265. articleInfo.art_corpus_data.sentList.forEach((item,index) => {
  266. item.tokens.forEach((items,indexs)=>{
  267. let obj = {
  268. sent_id:item.id,
  269. sno: item.sno-1,
  270. pno: item.pno,
  271. text: item.text,
  272. tokens: items,
  273. wIndex: indexs,
  274. isShow: this.enFhList.indexOf(items[2])==-1,
  275. marginRight: indexs===item.tokens.length-1
  276. }
  277. resArr[item.pno].wordsList.push(obj)
  278. })
  279. resArr[item.pno].timeList.push(articleInfo.art_sound_srt_data.sents[index])
  280. });
  281. this.resArr = resArr;
  282. },
  283. handleChangeTime(time) {
  284. if (time>=0) {
  285. this.curTime = time;
  286. this.$refs.audioLine.onTimeupdateTime(time / 1000, true);
  287. }
  288. },
  289. //经过每个词,高亮句子
  290. handleMouseover(pItem) {
  291. this.paraIndex = pItem.pno;
  292. this.sentIndex = pItem.sno;
  293. },
  294. handleMouseleave() {
  295. this.paraIndex = -1;
  296. this.sentIndex = -1;
  297. },
  298. },
  299. //生命周期 - 创建完成(可以访问当前this实例)
  300. created() {},
  301. //生命周期 - 挂载完成(可以访问DOM元素)
  302. mounted() {
  303. if (this.articleInfo) {
  304. this.handleData();
  305. }
  306. },
  307. beforeCreate() {}, //生命周期 - 创建之前
  308. beforeMount() {}, //生命周期 - 挂载之前
  309. beforeUpdate() {}, //生命周期 - 更新之前
  310. updated() {}, //生命周期 - 更新之后
  311. beforeDestroy() {}, //生命周期 - 销毁之前
  312. destroyed() {}, //生命周期 - 销毁完成
  313. activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  314. };
  315. </script>
  316. <style lang='scss' scoped>
  317. //@import url(); 引入公共css类
  318. .NNPE-ArticleView {
  319. width: 100%;
  320. .nnpe-article-author{
  321. margin: 24px 0;
  322. }
  323. h2{
  324. display: flex;
  325. flex-flow: wrap;
  326. &.sentActive {
  327. background: rgba(24, 144, 255, 0.1);
  328. }
  329. &.overActive {
  330. background: rgba(0, 0, 0, 0.06);
  331. }
  332. .wordActive {
  333. color: #175DFF !important;
  334. }
  335. }
  336. .table-box {
  337. // background: #f7f7f7;
  338. // border-top: 1px solid rgba(0, 0, 0, 0.1);
  339. :last-child {
  340. :last-child.wordsList-box {
  341. padding-bottom: 40px;
  342. }
  343. }
  344. .wordsList-box {
  345. flex: 1;
  346. padding: 6px 0 12px 0;
  347. .nnpe-sentence-box {
  348. display: flex;
  349. flex-flow: wrap;
  350. }
  351. > img {
  352. max-width: 50%;
  353. display: block;
  354. padding: 16px 0;
  355. margin: 0 auto;
  356. }
  357. }
  358. }
  359. .NNPE-detail {
  360. clear: both;
  361. overflow: hidden;
  362. display: flex;
  363. .NNPE-words {
  364. float: left;
  365. padding: 0;
  366. &.noPadding{
  367. padding:0;
  368. }
  369. &.sentActive {
  370. background: rgba(24, 144, 255, 0.1);
  371. }
  372. &.overActive {
  373. background: rgba(0, 0, 0, 0.06);
  374. }
  375. &.textLeft {
  376. text-align: left;
  377. }
  378. &.textCenter {
  379. text-align: center;
  380. }
  381. > span {
  382. float: left;
  383. cursor: pointer;
  384. &.NNPE-chs {
  385. // font-size: 24px;
  386. font-family: 'Smartisan';
  387. line-height: 150%;
  388. color: #000000;
  389. &.wordActive {
  390. color: #175DFF !important;
  391. }
  392. &.marginRight{
  393. padding: 0 3px;
  394. }
  395. &.marginSingleRight{
  396. padding: 0 3px 0 0;
  397. }
  398. }
  399. &.padding {
  400. padding: 0 3px;
  401. cursor: pointer;
  402. }
  403. }
  404. }
  405. }
  406. }
  407. .audio-box{
  408. display: flex;
  409. align-items: center;
  410. justify-content: space-between;
  411. }
  412. .aduioLine-box{
  413. width: 516px;
  414. height: 48px;
  415. background: #FFFFFF;
  416. border: 1px solid #EBEBEB;
  417. border-radius: 30px;
  418. display: flex;
  419. align-items: center;
  420. padding: 8px 24px;
  421. .wrapper{
  422. width: 24px;
  423. height: 24px;
  424. flex-shrink: 0;
  425. color: #175DFF;
  426. margin-left: 8px;
  427. }
  428. .Audio{
  429. width: 430px;
  430. }
  431. }
  432. </style>