NormalModel.vue 13 KB

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