PracticeModel.vue 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074
  1. <!-- -->
  2. <template>
  3. <div class="NNPE-ArticleView" v-if="articleInfo">
  4. <template v-if="resArr&&resArr.wordsList&&resArr.wordsList[0]&&resArr.wordsList[0][0]&&resArr.wordsList[0][0].hasOwnProperty('pno')&&resArr.wordsList[0][0].pno===0">
  5. <h2 :class="['NNPE-words',]">
  6. <span v-for="(itemR,indexR) in resArr.wordsList[0]" :key="indexR" :style="{color:colorObj.titleColor,fontSize:titleFontsize+'px',lineHeight:(titleFontsize+8)+'px',marginRight:'10px',fontWeight:'700'}"
  7. :class="[
  8. itemR.tokens[9]===''?'marginRight':'',itemR.marginRight?'marginSingleRight':''
  9. ]">
  10. <template v-if="itemR.isShow">
  11. <span
  12. class="NNPE-chs"
  13. :class="[
  14. itemR.type,itemR.tokens[9]===''?'marginRight':'',itemR.highIndex?'fontWeight':'',itemR.marginRight?'marginSingleRight':''
  15. ]"
  16. >{{ itemR.tokens[2] }}</span
  17. >
  18. <span
  19. class="NNPE-chs NNPE-chs-both"
  20. v-if="resArr.wordsList[0][indexR + 1] &&
  21. resArr.wordsList[0][indexR + 1].tokens[2] &&
  22. enFhList.indexOf(resArr.wordsList[0][indexR + 1].tokens[2]) > -1"
  23. :class="[
  24. resArr.wordsList[0][indexR + 1].type,resArr.wordsList[0][indexR + 1].tokens[8]===''?'marginLeft':'',resArr.wordsList[0][indexR + 1].highIndex?'fontWeight':'',resArr.wordsList[0][indexR + 1].marginRight?'marginSingleRight':''
  25. ]"
  26. >{{ resArr.wordsList[0][indexR + 1].tokens[2] }}</span
  27. >
  28. </template>
  29. <!-- {{itemR.tokens[2]}} -->
  30. </span>
  31. </h2>
  32. </template>
  33. <h6 class="nnpe-article-author" :style="{color:colorObj.sourceColor,fontSize:'14px',lineHeight:'22px',fontWeight:'400'}">
  34. {{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:'')}}
  35. </h6>
  36. <div class="audio-box">
  37. <div
  38. class="aduioLine-content aduioLine-box"
  39. v-if="
  40. articleInfo.art_sound_url
  41. " :style="{background:colorObj.audiobg,borderColor:colorObj.audioBorder}"
  42. >
  43. <AudioLine
  44. audioId="artNormalAudio"
  45. :mp3="articleInfo.art_sound_url"
  46. :getCurTime="getCurTime"
  47. ref="audioLine"
  48. :mp3Source="'mp3'"
  49. type="audioLine"
  50. :ed="ed"
  51. :showEd="showEd"
  52. @emptyEd="emptyEd"
  53. :colorObj="colorObj"
  54. />
  55. <svg-icon icon-class="icon-wrapper" class="wrapper" @click="fullScreen" :style="{color: colorObj.audioBtnColor}"></svg-icon>
  56. </div>
  57. </div>
  58. <template v-if="resArr.wordsList&&resArr.wordsList.length > 0">
  59. <div class="table-box" :class="['table-box-'+colorObj.type]">
  60. <div
  61. :class="['NNPE-detail']"
  62. v-for="(item, index) in resArr.wordsList"
  63. :key="'detail' + index"
  64. >
  65. <a class="history-btn" v-if="resArr.timeList[index] && resArr.timeList[index] && curTime >= resArr.timeList[index].s && curTime <= resArr.timeList[index].e" @click="lookHistory(index)">历史记录</a>
  66. <b class="para-index" :style="{fontSize:wordFontsize + 'px',color:resArr.timeList[index] && resArr.timeList[index] && curTime >= resArr.timeList[index].s && curTime <= resArr.timeList[index].e ? colorObj.type==='white'?'#2F3742':colorObj.type==='darkGreen'?'#299772':colorObj.type==='armyGreen'?'#30A47D':'#5373E7':colorObj.type==='white'?'#D0D3D9':colorObj.type==='darkGreen'?'#7A8983':colorObj.type==='armyGreen'?'#6B7C74':'#737781'}">{{index+1}}</b>
  67. <div class="wordsList-box">
  68. <div class="nnpe-sentence-box">
  69. <div v-for="(pItem, pIndex) in item" :key="'wordsList' + pIndex">
  70. <template v-if="pItem.isShow">
  71. <div
  72. :class="[
  73. 'NNPE-words',
  74. isPlaying &&
  75. resArr.timeList[index] &&
  76. resArr.timeList[index] &&
  77. curTime >= resArr.timeList[index].s &&
  78. curTime <= resArr.timeList[index].e
  79. ? 'sentActive'
  80. : '',
  81. pItem.pno == paraIndex && pItem.sno == sentIndex
  82. ? 'overActive'
  83. : '',
  84. ]"
  85. @click="
  86. handleChangeTime(
  87. resArr.timeList[index] &&
  88. resArr.timeList[index] &&
  89. resArr.timeList[index].s
  90. )
  91. "
  92. @mouseover="handleMouseover(pItem)"
  93. @mouseleave="handleMouseleave"
  94. >
  95. <span
  96. class="NNPE-chs"
  97. :class="[
  98. isPlaying &&
  99. resArr.timeList[index] &&
  100. resArr.timeList[index] &&
  101. resArr.timeList[index].e &&
  102. resArr.timeList[index].tokens &&
  103. resArr.timeList[index].tokens[pItem.wIndex]&&
  104. curTime >=
  105. resArr.timeList[index].tokens[pItem.wIndex].s &&
  106. curTime <= resArr.timeList[index].e
  107. ? 'wordActive'
  108. : '',
  109. pItem.tokens[9]===''?'marginRight':'',pItem.marginRight?'marginSingleRight':''
  110. ]"
  111. :style="{fontSize:wordFontsize + 'px',color: isPlaying &&
  112. resArr.timeList[index] &&
  113. resArr.timeList[index] &&
  114. resArr.timeList[index].tokens[pItem.wIndex]&&
  115. curTime >=
  116. resArr.timeList[index].tokens[pItem.wIndex].s &&
  117. curTime <= resArr.timeList[index].tokens[pItem.wIndex].e?colorObj.statisticValue:
  118. resArr.timeList[index] &&
  119. resArr.timeList[index] &&
  120. curTime >= resArr.timeList[index].s &&
  121. curTime <= resArr.timeList[index].e?colorObj.contentColor:colorObj.type==='white'?'#D0D3D9':colorObj.type==='darkGreen'?'#7A8983':colorObj.type==='darkBlue'?'#737781':'#6B7C74'}"
  122. >{{ pItem.tokens[2] }}</span
  123. >
  124. <span
  125. class="NNPE-chs NNPE-chs-both"
  126. v-if="item[pIndex + 1] &&
  127. item[pIndex + 1].tokens[2] &&
  128. enFhList.indexOf(item[pIndex + 1].tokens[2]) > -1"
  129. :class="[
  130. isPlaying &&
  131. resArr.timeList[index] &&
  132. resArr.timeList[index] &&
  133. resArr.timeList[index].tokens[pItem.wIndex]&&
  134. curTime >=
  135. resArr.timeList[index].tokens[pItem.wIndex].s &&
  136. curTime <= resArr.timeList[index].e
  137. ? 'wordActive'
  138. : '',
  139. item[pIndex + 1].tokens[8]===''?'marginLeft':'',item[pIndex + 1].marginRight?'marginSingleRight':''
  140. ]"
  141. :style="{fontSize:wordFontsize + 'px',color: isPlaying &&
  142. resArr.timeList[index] &&
  143. resArr.timeList[index] &&
  144. resArr.timeList[index].tokens[pItem.wIndex]&&
  145. curTime >=
  146. resArr.timeList[index].tokens[pItem.wIndex].s &&
  147. curTime <= resArr.timeList[index].tokens[pItem.wIndex].e?colorObj.statisticValue:resArr.timeList[index] &&
  148. resArr.timeList[index] &&
  149. curTime >= resArr.timeList[index].s &&
  150. curTime <= resArr.timeList[index].e?colorObj.contentColor:colorObj.type==='white'?'#D0D3D9':colorObj.type==='darkGreen'?'#7A8983':colorObj.type==='darkBlue'?'#737781':'#6B7C74'}"
  151. >{{ item[pIndex + 1].tokens[2] }}</span
  152. >
  153. </div>
  154. </template>
  155. </div>
  156. </div>
  157. </div>
  158. </div>
  159. <div class="operate-box" :style="{background:colorObj.contentBg}">
  160. <div class="operate-box-inner" :style="{background:colorObj.contentInnerBg}">
  161. <div class="operate-box-inner-content">
  162. <div class="operate-item" @click="changePlaySent('-')">
  163. <svg-icon icon-class="Go-start" :style="{color:colorObj.type==='white'||colorObj.type==='darkGreen'?'#000':'#fff'}"></svg-icon>
  164. <span :style="{color:colorObj.type==='armyGreen'?'#7C8983':''}">上一句</span>
  165. </div>
  166. <div class="operate-item" @click="compare">
  167. <svg-icon icon-class="Type-drive" :style="{color:colorObj.type==='white'||colorObj.type==='darkGreen'?'#000':'#fff'}"></svg-icon>
  168. <span :style="{color:colorObj.type==='armyGreen'?'#7C8983':''}">听对比</span>
  169. </div>
  170. <div class="operate-item">
  171. <b class="luyin-btn" v-if="!microphoneStatus" @click="microphone">
  172. <svg-icon icon-class="Voice-luyin" :style="{color:'#fff'}"></svg-icon>
  173. </b>
  174. <img class="luyin-gif" @click="microphone" v-else src="../../../assets/voice-gif.png" />
  175. <span v-if="microphoneStatus" class="record-time" :style="{color:'#F2555A',fontWeight: '600'}">{{
  176. handleDateTime(recordtime)
  177. }}</span>
  178. </div>
  179. <div class="operate-item" @click="playmicrophone(selectIndex || selectIndex == 0 ? recordList[selectIndex].toltime : '')">
  180. <svg-icon icon-class="Headphone-sound" :style="{color:colorObj.type==='white'||colorObj.type==='darkGreen'?'#000':'#fff'}"></svg-icon>
  181. <span :style="{color:colorObj.type==='armyGreen'?'#7C8983':''}">我读的</span>
  182. </div>
  183. <div class="operate-item" @click="changePlaySent('+')">
  184. <svg-icon icon-class="Go-end" :style="{color:colorObj.type==='white'||colorObj.type==='darkGreen'?'#000':'#fff'}"></svg-icon>
  185. <span :style="{color:colorObj.type==='armyGreen'?'#7C8983':''}">下一句</span>
  186. </div>
  187. </div>
  188. </div>
  189. </div>
  190. </div>
  191. </template>
  192. <!-- <img src="../../../assets/article-img.png" style="max-width:100%;margin:24px 0;" /> -->
  193. <div class="clear-box">
  194. <h5>词汇标记设置</h5>
  195. <div class="item">
  196. <span>跟读</span>
  197. <el-switch
  198. v-model="repeatAfter"
  199. active-color="#175DFF"
  200. inactive-color="#D0D3D9"
  201. key="sent-repeatAfter">
  202. </el-switch>
  203. </div>
  204. <div class="item">
  205. <span>单句模式</span>
  206. <el-switch
  207. v-model="singleModel"
  208. active-color="#175DFF"
  209. inactive-color="#D0D3D9"
  210. key="sent-singleModel"
  211. @change="mutualExclusive('singleModel','autoNextSent')">
  212. </el-switch>
  213. </div>
  214. <div class="item">
  215. <span>自动下一句</span>
  216. <el-switch
  217. v-model="autoNextSent"
  218. active-color="#175DFF"
  219. inactive-color="#D0D3D9"
  220. key="sent-autoNextSent"
  221. @change="mutualExclusive('autoNextSent','singleModel')">
  222. </el-switch>
  223. </div>
  224. </div>
  225. <el-dialog
  226. :visible.sync="historyFlag"
  227. :show-close="false"
  228. :close-on-click-modal="false"
  229. width="680px"
  230. :modal="false"
  231. class="login-dialog"
  232. v-if="historyFlag">
  233. <history-record-list :list="historySentRecordList" :sentData="resArr.wordsList[playSentIndex]" :timeData="resArr.timeList[playSentIndex]" :mp3Url="articleInfo.art_sound_url" @closeHistory="closeHistory" :colorObj="colorObj" :wordFontsize="wordFontsize" @handleChangeTime="handleChangeTime" @returnCurrentTime="returnCurrentTime" :parentCurtimt="curTime" :parentPlay="Playing" v-loading="historyLoading"></history-record-list>
  234. </el-dialog>
  235. <div class="voice-full-screen" :id="'screen-' + mathNum">
  236. <Voicefullscreen
  237. v-if="isFull"
  238. :curQue="articleInfo"
  239. :likeWord="likeWord"
  240. :sentIndex="playSentIndex===-1?0:playSentIndex"
  241. :mp3="articleInfo.art_sound_url"
  242. :likeSentencelist="likeSentencelist"
  243. @exitFullscreen="exitFullscreen"
  244. @changeIsFull="changeIsFull"
  245. />
  246. </div>
  247. </div>
  248. </template>
  249. <script>
  250. import AudioLine from "@/components/common/AudioLine.vue"
  251. import HistoryRecordList from "./HistoryRecordList.vue"
  252. import Recorder from "js-audio-recorder"; // 录音插件
  253. import { getLogin } from "@/api/ajax";
  254. import Voicefullscreen from './Voicefullscreen.vue';
  255. export default {
  256. name: "ArticleView",
  257. props: [ "titleFontsize", "wordFontsize", "colorObj","articleType","articleInfo","likeSentencelist","likeWord"],
  258. components: {
  259. AudioLine,
  260. HistoryRecordList,
  261. Voicefullscreen
  262. },
  263. data() {
  264. return {
  265. resArr: [],
  266. curTime: 0, //单位s
  267. enFhList: [
  268. ",",
  269. ".",
  270. ";",
  271. "?",
  272. "!",
  273. ":",
  274. ">",
  275. "<",
  276. "'",
  277. "’",
  278. "n't",
  279. "n’t",
  280. "n’ts",
  281. "n‘t",
  282. "'t",
  283. "’t",
  284. "‘t",
  285. "'s",
  286. "’s",
  287. "‘s",
  288. "'m",
  289. "’m",
  290. "‘m",
  291. "'re",
  292. "’re",
  293. "‘re",
  294. "'d",
  295. "’d",
  296. "‘d",
  297. "'ve",
  298. "’ve",
  299. "‘ve",
  300. ")",
  301. "'ll",
  302. "’ll",
  303. "‘ll",
  304. "”",
  305. ],
  306. articleImg: {}, // 文章图片
  307. paraIndex: -1, //段落索引
  308. sentIndex: -1, // 句子索引
  309. repeatAfter: false,
  310. singleModel: false,
  311. autoNextSent: false,
  312. recorder: new Recorder({
  313. sampleBits: 16, // 采样位数,支持 8 或 16,默认是16
  314. sampleRate: 16000, // 采样率,支持 11025、16000、22050、24000、44100、48000,根据浏览器默认值,我的chrome是48000
  315. numChannels: 1, // 声道,支持 1 或 2, 默认是1
  316. }),
  317. microphoneStatus: false,
  318. hasMicro: "", // 录音后的样式class
  319. wavblob: null,
  320. audio: new window.Audio(),
  321. audioc: new window.Audio(), // 对比
  322. recordList: [], // 录音文件数组
  323. recordtime: 0, // 录音时长
  324. timer: null, // 计时器
  325. recordFile: 1, // 录音文件名
  326. selectIndex: null, // 选中的录音索引
  327. oldIndex: null, // 存储播放录音索引
  328. playtime: 0, // 播放时间
  329. isPlayings: false,
  330. playSentIndex: -1, // 播放的句子索引
  331. historyFlag: false, // 历史记录弹窗
  332. historySentRecordList: [], // 单句历史录音list
  333. ed: undefined,
  334. showEd: false, //是否看ed的值
  335. historyLoading: false,
  336. timeC: null,
  337. isCompare: false,
  338. isFull: false,
  339. mathNum: Math.random().toString(36).substr(2),
  340. };
  341. },
  342. computed: {
  343. isPlaying: function () {
  344. let playing = false;
  345. if (this.$refs.audioLine) {
  346. playing = this.$refs.audioLine.audio.isPlaying;
  347. }
  348. return playing;
  349. },
  350. Playing: function () {
  351. let playing = false;
  352. if (this.$refs.audioLine) {
  353. playing = this.$refs.audioLine.audio.playing;
  354. }
  355. return playing;
  356. },
  357. },
  358. watch: {},
  359. //方法集合
  360. methods: {
  361. changePlaySent(type){
  362. this.audio.pause();
  363. this.audioc.pause();
  364. if(type==='-'){
  365. if(this.playSentIndex>0){
  366. this.playSentIndex--
  367. }else{
  368. this.playSentIndex=0
  369. }
  370. }else{
  371. if(this.playSentIndex<this.resArr.wordsList.length-1){
  372. this.playSentIndex++
  373. }else{
  374. this.playSentIndex=0
  375. }
  376. }
  377. this.handleChangeTime(this.resArr.timeList[this.playSentIndex].s)
  378. },
  379. getCurTime(curTime) {
  380. if(this.isCompare){
  381. let time = curTime * 1000;
  382. if (time >= this.resArr.timeList[this.playSentIndex].e || time <= this.resArr.timeList[this.playSentIndex].s) {
  383. // this.curTime = this.resArr.timeList[this.playSentIndex].s;
  384. // this.$refs.audioLine.onTimeupdateTime(_this.currSent.bg / 1000, true);
  385. } else {
  386. this.curTime = curTime * 1000;
  387. }
  388. } else if(this.singleModel&&this.playSentIndex>-1&&!this.repeatAfter){
  389. let time = curTime * 1000;
  390. if (time >= this.resArr.timeList[this.playSentIndex].e || time <= this.resArr.timeList[this.playSentIndex].s) {
  391. this.curTime = this.resArr.timeList[this.playSentIndex].s;
  392. this.$refs.audioLine.onTimeupdateTime(this.resArr.timeList[this.playSentIndex].s / 1000, true);
  393. } else {
  394. this.curTime = curTime * 1000;
  395. }
  396. } else if((this.singleModel||this.autoNextSent)&&this.playSentIndex>-1&&this.repeatAfter){
  397. let time = curTime * 1000;
  398. this.curTime = curTime * 1000;
  399. // for(let i=0; i<this.resArr.timeList.length;i++){
  400. // if(this.curTime>this.resArr.timeList[i].s&&this.curTime<=this.resArr.timeList[i].e){
  401. // this.playSentIndex = i
  402. // break
  403. // }
  404. // }
  405. // if (time >= this.resArr.timeList[this.playSentIndex].s || time <= this.resArr.timeList[this.playSentIndex].e) {
  406. // this.curTime = this.resArr.timeList[this.playSentIndex].s;
  407. if(this.playSentIndex===0) this.ed = this.resArr.timeList[this.playSentIndex].e;
  408. this.showEd = true
  409. // this.$refs.audioLine.onTimeupdateTime(this.resArr.timeList[this.playSentIndex].s / 1000, true);
  410. // }
  411. }else{
  412. this.curTime = curTime * 1000;
  413. for(let i=0; i<this.resArr.timeList.length;i++){
  414. if(this.curTime>=this.resArr.timeList[i].s&&this.curTime<this.resArr.timeList[i].e){
  415. this.playSentIndex = i
  416. break
  417. }
  418. }
  419. }
  420. },
  421. returnCurrentTime(){
  422. return this.curTime
  423. },
  424. handleData() {
  425. let resArr = {
  426. wordsList: [],
  427. timeList: [],
  428. };
  429. let articleInfo = JSON.parse(JSON.stringify(this.articleInfo));
  430. articleInfo.art_corpus_data.sentList.forEach((item,index) => {
  431. let wordlist = []
  432. item.tokens.forEach((items,indexs)=>{
  433. let obj = {
  434. sent_id:item.id,
  435. sno: item.sno-1,
  436. pno: item.pno,
  437. text: item.text,
  438. tokens: items,
  439. wIndex: indexs,
  440. isShow: this.enFhList.indexOf(items[2])==-1,
  441. marginRight: indexs===item.tokens.length-1
  442. }
  443. wordlist.push(obj)
  444. })
  445. resArr.wordsList.push(wordlist)
  446. resArr.timeList.push(articleInfo.art_sound_srt_data.sents[index])
  447. });
  448. this.resArr = resArr;
  449. console.log(this.resArr)
  450. },
  451. handleChangeTime(time,ed,flag,type) {
  452. this.audio.pause();
  453. this.audioc.pause();
  454. if(flag){
  455. this.$refs.audioLine.PlayAudio()
  456. }else{
  457. if (time>=0) {
  458. this.curTime = time;
  459. for(let i=0; i<this.resArr.timeList.length;i++){
  460. if(this.curTime>=this.resArr.timeList[i].s&&this.curTime<this.resArr.timeList[i].e){
  461. this.playSentIndex = i
  462. break
  463. }
  464. }
  465. if(ed){
  466. this.ed = ed;
  467. }else if((this.singleModel||this.autoNextSent)&&this.playSentIndex>-1&&this.repeatAfter){
  468. this.ed = this.resArr.timeList[this.playSentIndex].e;
  469. }else{
  470. this.ed = undefined
  471. }
  472. this.$refs.audioLine.onTimeupdateTime(time / 1000, true);
  473. }
  474. }
  475. },
  476. emptyEd(flag) {
  477. this.ed = undefined;
  478. if(flag){
  479. this.showEd = false
  480. if(!this.microphoneStatus){
  481. this.microphone()
  482. }
  483. }
  484. },
  485. //经过每个词,高亮句子
  486. handleMouseover(pItem) {
  487. this.paraIndex = pItem.pno;
  488. this.sentIndex = pItem.sno;
  489. },
  490. handleMouseleave() {
  491. this.paraIndex = -1;
  492. this.sentIndex = -1;
  493. },
  494. mutualExclusive(val,val1){
  495. if(this[val]){
  496. this[val1] = false
  497. }
  498. },
  499. // 开始录音
  500. microphone() {
  501. let _this = this;
  502. this.audio.pause();
  503. this.audioc.pause();
  504. if(_this.$refs.audioLine.audio.playing){
  505. _this.$refs.audioLine.PlayAudio()
  506. }
  507. if (!this.microphoneStatus) {
  508. _this.hasMicro = "";
  509. // _this.$emit("getWavblob", null);
  510. // this.$emit("getSelectData", { type: "" });
  511. // 开始录音
  512. this.recorder.start();
  513. this.microphoneStatus = true;
  514. this.recordtime = 0;
  515. this.isPlayings = false;
  516. clearInterval(_this.timer);
  517. _this.timer = setInterval(() => {
  518. _this.recordtime++;
  519. }, 1000);
  520. this.$emit("handleParentPlay");
  521. let obj = {
  522. name: _this.fileName
  523. ? _this.fileName + _this.recordFile
  524. : "Recording " + _this.recordFile,
  525. id: _this.recordFile + Math.round(Math.random() * 10),
  526. };
  527. if (this.selectData) obj.selectData = this.selectData;
  528. _this.recordList.push(obj);
  529. _this.recordFile++;
  530. _this.selectIndex = _this.recordList.length - 1;
  531. } else {
  532. this.hasMicro = "normal";
  533. this.recorder.stop();
  534. clearInterval(_this.timer);
  535. let toltime = this.recorder.duration; // 录音总时长
  536. let fileSize = this.recorder.fileSize; // 录音总大小
  537. // 录音结束,获取取录音数据
  538. let wav = this.recorder.getWAVBlob(); // 获取 WAV 数据
  539. // this.wavblob = wav;
  540. this.microphoneStatus = false;
  541. let reader = new window.FileReader();
  542. reader.readAsDataURL(wav);
  543. reader.onloadend = () => {
  544. _this.recordList[_this.selectIndex].wavData = reader.result;
  545. _this.recordList[_this.selectIndex].toltime = Math.floor(toltime);
  546. _this.recordList[_this.selectIndex].fileSize = fileSize;
  547. _this.wavblob = _this.recordList[_this.selectIndex].wavData;
  548. _this.$emit("getWavblob", _this.wavblob);
  549. _this.$emit(
  550. "handleWav",
  551. JSON.parse(JSON.stringify(_this.recordList)),
  552. _this.tmIndex
  553. );
  554. if (this.recordList[this.selectIndex].selectData) {
  555. this.$emit(
  556. "getSelectData",
  557. this.recordList[this.selectIndex].selectData
  558. );
  559. }
  560. this.addRecord(reader.result)
  561. };
  562. }
  563. _this.$emit(
  564. "getRerordStatus",
  565. !_this.microphoneStatus && _this.recordList.length > 0
  566. );
  567. _this.$emit("getMicrophoneStatus", _this.microphoneStatus);
  568. },
  569. playmicrophone(totalTimes) {
  570. this.audioc.pause();
  571. if (this.hasMicro) {
  572. this.isPlayings = true;
  573. if (this.selectIndex || this.selectIndex == 0) {
  574. let totalTime = totalTimes;
  575. let _this = this;
  576. if (!this.audio.paused) {
  577. this.audio.pause();
  578. clearInterval(_this.timer);
  579. } else if (this.audio.paused && _this.oldIndex == _this.selectIndex) {
  580. _this.audio.play();
  581. if (_this.recordtime == 0) {
  582. _this.recordtime = totalTimes;
  583. _this.playtime = 0;
  584. }
  585. _this.timer = setInterval(() => {
  586. if (_this.playtime < totalTime) {
  587. _this.playtime++;
  588. _this.recordtime = totalTime - _this.playtime;
  589. } else {
  590. clearInterval(_this.timer);
  591. }
  592. }, 1000);
  593. } else {
  594. _this.audio.pause();
  595. _this.audio.load();
  596. _this.audio.src = _this.wavblob;
  597. _this.oldIndex = _this.selectIndex;
  598. _this.audio.play();
  599. _this.playtime = 0;
  600. _this.recordtime = totalTime;
  601. clearInterval(_this.timer);
  602. _this.timer = setInterval(() => {
  603. if (_this.playtime < totalTime) {
  604. _this.playtime++;
  605. _this.recordtime = totalTime - _this.playtime;
  606. } else {
  607. clearInterval(_this.timer);
  608. }
  609. }, 1000);
  610. }
  611. }
  612. }
  613. },
  614. // 格式化录音时长
  615. handleDateTime(time) {
  616. if (parseInt(time / 60) < 10) {
  617. time =
  618. ("0" + parseInt(time / 60)).substring(
  619. ("0" + parseInt(time / 60)).length - 2
  620. ) +
  621. ":" +
  622. ("0" + (time % 60)).substring(("0" + (time % 60)).length - 2);
  623. } else {
  624. time =
  625. parseInt(time / 60) +
  626. ":" +
  627. ("0" + (time % 60)).substring(("0" + (time % 60)).length - 2);
  628. }
  629. return time;
  630. },
  631. // 点击历史记录按钮
  632. lookHistory(index){
  633. this.historyFlag = true
  634. this.historyLoading = true
  635. this.audio.pause();
  636. this.audioc.pause();
  637. if(this.microphoneStatus){
  638. this.microphone()
  639. }
  640. if(this.$refs.audioLine.audio.playing){
  641. this.$refs.audioLine.PlayAudio()
  642. }
  643. this.playSentIndex = index
  644. let MethodName = "/PaperServer/Client/UserSentRec/RecListInUserSent";
  645. let data = {
  646. sent_id: this.articleInfo.art_corpus_data.sentList[index].id,
  647. got_rec_data_flag: false
  648. }
  649. getLogin(MethodName, data)
  650. .then((res) => {
  651. if(res.status===1){
  652. this.historySentRecordList = res.data.all
  653. this.historyLoading = false
  654. }
  655. }).catch(()=>{
  656. this.historyLoading = false
  657. })
  658. },
  659. closeHistory(){
  660. this.historyFlag = false
  661. },
  662. // 保存录音
  663. addRecord(wav){
  664. if(this.playSentIndex===-1){
  665. return
  666. }
  667. let MethodName = "/PaperServer/Client/UserSentRec/AddUserSentRec";
  668. let data = {
  669. sent_id: this.articleInfo.art_corpus_data.sentList[this.playSentIndex].id,
  670. rec_sound_data: wav
  671. }
  672. getLogin(MethodName, data)
  673. .then((res) => {
  674. if(this.repeatAfter){
  675. if(this.autoNextSent&&this.resArr.timeList[this.playSentIndex+1]){
  676. // this.playSentIndex = this.playSentIndex+1
  677. this.ed = this.resArr.timeList[this.playSentIndex+1].e
  678. this.handleChangeTime(this.resArr.timeList[this.playSentIndex+1].s)
  679. }
  680. }
  681. })
  682. },
  683. // 对比
  684. compare(){
  685. let _this = this;
  686. _this.isCompare = true
  687. // let curTime = _this.resArr.timeList[_this.playSentIndex].s
  688. // for(let i=0; i<this.resArr.timeList.length;i++){
  689. // if(curTime>this.resArr.timeList[i].s&&curTime<=this.resArr.timeList[i].e){
  690. // this.playSentIndex = i
  691. // break
  692. // }
  693. // }
  694. let playSentIndex = JSON.parse(JSON.stringify(_this.playSentIndex))
  695. if(playSentIndex===-1){
  696. this.$message.warning('请先选择要对比的句子')
  697. return
  698. }
  699. if(!this.wavblob){
  700. this.$message.warning('请先录音')
  701. return
  702. }
  703. this.audio.pause()
  704. if (!this.audioc.paused) {
  705. this.audioc.pause();
  706. } else {
  707. _this.audioc.pause();
  708. _this.audioc.load();
  709. _this.handleChangeTime(_this.resArr.timeList[playSentIndex].s,_this.resArr.timeList[playSentIndex].e)
  710. _this.timeC = setInterval(() => {
  711. if(_this.curTime>=_this.resArr.timeList[playSentIndex].e - 250){
  712. _this.curTime = _this.resArr.timeList[playSentIndex].s
  713. clearInterval(_this.timeC)
  714. _this.playWavdata()
  715. }
  716. }, 500);
  717. }
  718. },
  719. playWavdata(){
  720. let _this = this;
  721. _this.audioc.src = _this.wavblob;
  722. _this.audioc.play();
  723. _this.audioc.addEventListener("ended", function () {
  724. _this.isCompare = false
  725. });
  726. },
  727. pauseAudio() {
  728. let audio = document.getElementsByTagName("audio");
  729. audio.forEach((item) => {
  730. item.pause();
  731. });
  732. },
  733. pauseVideo() {
  734. let video = document.getElementsByTagName("video");
  735. video.forEach((item) => {
  736. item.pause();
  737. });
  738. },
  739. //语音全屏
  740. fullScreen() {
  741. this.pauseAudio();
  742. this.pauseVideo();
  743. this.isFull = true;
  744. this.goFullscreen();
  745. },
  746. goFullscreen() {
  747. let id = "screen-" + this.mathNum;
  748. var element = document.getElementById(id);
  749. if (element.requestFullscreen) {
  750. element.requestFullscreen();
  751. } else if (element.msRequestFullscreen) {
  752. element.msRequestFullscreen();
  753. } else if (element.mozRequestFullScreen) {
  754. element.mozRequestFullScreen();
  755. } else if (element.webkitRequestFullscreen) {
  756. element.webkitRequestFullscreen();
  757. }
  758. },
  759. exitFullscreen() {
  760. this.isFull = false;
  761. if (document.exitFullscreen) {
  762. document.exitFullscreen();
  763. } else if (document.msExitFullscreen) {
  764. document.msExitFullscreen();
  765. } else if (document.mozCancelFullScreen) {
  766. document.mozCancelFullScreen();
  767. } else if (document.webkitExitFullscreen) {
  768. document.webkitExitFullscreen();
  769. }
  770. },
  771. changeIsFull() {
  772. this.isFull = false;
  773. },
  774. },
  775. //生命周期 - 创建完成(可以访问当前this实例)
  776. created() {},
  777. //生命周期 - 挂载完成(可以访问DOM元素)
  778. mounted() {
  779. if (this.articleInfo) {
  780. this.handleData();
  781. }
  782. },
  783. beforeCreate() {}, //生命周期 - 创建之前
  784. beforeMount() {}, //生命周期 - 挂载之前
  785. beforeUpdate() {}, //生命周期 - 更新之前
  786. updated() {}, //生命周期 - 更新之后
  787. beforeDestroy() {
  788. clearInterval(this.timeC)
  789. }, //生命周期 - 销毁之前
  790. destroyed() {}, //生命周期 - 销毁完成
  791. activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  792. };
  793. </script>
  794. <style lang='scss' scoped>
  795. //@import url(); 引入公共css类
  796. .NNPE-ArticleView {
  797. width: 100%;
  798. .nnpe-article-author{
  799. margin: 24px 0;
  800. }
  801. h2{
  802. display: flex;
  803. flex-flow: wrap;
  804. &.sentActive {
  805. background: rgba(24, 144, 255, 0.1);
  806. }
  807. &.overActive {
  808. background: rgba(0, 0, 0, 0.06);
  809. }
  810. .wordActive {
  811. color: #175DFF;
  812. }
  813. }
  814. .table-box {
  815. padding-top: 20px;
  816. padding-bottom: 64px;
  817. // background: #f7f7f7;
  818. // border-top: 1px solid rgba(0, 0, 0, 0.1);
  819. :last-child {
  820. :last-child.wordsList-box {
  821. padding-bottom: 40px;
  822. }
  823. }
  824. .wordsList-box {
  825. flex: 1;
  826. padding: 20px 0;
  827. .nnpe-sentence-box {
  828. display: flex;
  829. flex-flow: wrap;
  830. }
  831. > img {
  832. max-width: 50%;
  833. display: block;
  834. padding: 16px 0;
  835. margin: 0 auto;
  836. }
  837. }
  838. }
  839. .NNPE-detail {
  840. clear: both;
  841. // overflow: hidden;
  842. display: flex;
  843. position: relative;
  844. .history-btn{
  845. position: absolute;
  846. left: -110px;
  847. top: 50%;
  848. margin-top: -16px;
  849. z-index: 1;
  850. padding: 5px 16px;
  851. border-radius: 2px;
  852. background: #F2F3F5;
  853. color:#4E5969;
  854. font-size: 14px;
  855. line-height: 22px;
  856. cursor: pointer;
  857. }
  858. .para-index{
  859. color:#D0D3D9;
  860. font-size: 18px;
  861. font-weight: 700;
  862. line-height: 26px;
  863. padding-top: 20px;
  864. width: 40px;
  865. flex-shrink: 0;
  866. &-active{
  867. color: #2F3742;
  868. }
  869. }
  870. .NNPE-words {
  871. float: left;
  872. padding: 0;
  873. &.noPadding{
  874. padding:0;
  875. }
  876. &.sentActive {
  877. background: rgba(24, 144, 255, 0.1);
  878. }
  879. &.overActive {
  880. background: rgba(0, 0, 0, 0.06);
  881. }
  882. &.textLeft {
  883. text-align: left;
  884. }
  885. &.textCenter {
  886. text-align: center;
  887. }
  888. > span {
  889. float: left;
  890. cursor: pointer;
  891. &.NNPE-chs {
  892. // font-size: 24px;
  893. font-family: 'Smartisan';
  894. line-height: 150%;
  895. color: #000000;
  896. padding: 0 3px;
  897. &.wordActive {
  898. color: #175DFF;
  899. }
  900. &.marginRight{
  901. padding-right: 0;
  902. }
  903. &.marginLeft{
  904. padding-left: 0;
  905. }
  906. &.marginSingleRight{
  907. padding-right: 3px;
  908. }
  909. }
  910. &.padding {
  911. padding: 0 3px;
  912. cursor: pointer;
  913. }
  914. }
  915. }
  916. }
  917. .operate-box{
  918. position: fixed;
  919. border-top: 1px solid #EBEBEB;
  920. height: 192px;
  921. width: 1000px;
  922. background: #F2F3F5;
  923. left: 50%;
  924. bottom: 0;
  925. margin-left: -500px;
  926. padding-bottom: 24px;
  927. z-index: 1;
  928. &-inner{
  929. padding-top: 40px;
  930. height: 144px;
  931. &-content{
  932. width: 680px;
  933. margin: 0 auto;
  934. display: flex;
  935. justify-content: space-between;
  936. }
  937. .operate-item{
  938. text-align: center;
  939. cursor: pointer;
  940. .luyin-btn{
  941. display: block;
  942. width: 64px;
  943. height: 64px;
  944. padding: 10px;
  945. border-radius: 60px;
  946. background: #F2555A;
  947. box-shadow: 0px 8px 10px -5px rgba(0, 0, 0, 0.08), 0px 16px 24px 2px rgba(0, 0, 0, 0.04), 0px 6px 30px 5px rgba(0, 0, 0, 0.05);
  948. }
  949. .luyin-gif{
  950. display: block;
  951. width: 64px;
  952. height: 64px;
  953. border-radius: 60px;
  954. box-shadow: 0px 8px 10px -5px rgba(0, 0, 0, 0.08), 0px 16px 24px 2px rgba(0, 0, 0, 0.04), 0px 6px 30px 5px rgba(0, 0, 0, 0.05);
  955. }
  956. .svg-icon{
  957. display: block;
  958. width: 44px;
  959. height: 44px;
  960. margin: 0 auto;
  961. padding: 6px;
  962. }
  963. span{
  964. color: #929CA8;
  965. font-size: 12px;
  966. font-weight: 400;
  967. line-height: 20px;
  968. }
  969. }
  970. }
  971. }
  972. .table-box-white{
  973. .wordActive {
  974. color: #3459D2 !important;
  975. }
  976. .sentActive {
  977. background: #D9E2FC !important;
  978. }
  979. }
  980. .table-box-darkGreen{
  981. .wordActive {
  982. color: #299772 !important;
  983. }
  984. .sentActive {
  985. background: #ECEFED !important;
  986. }
  987. }
  988. .table-box-darkBlue{
  989. .wordActive {
  990. color: #5373E7 !important;
  991. }
  992. .sentActive {
  993. background:#1C2129 !important;
  994. }
  995. }
  996. .table-box-armyGreen{
  997. .wordActive {
  998. color: #30A47D !important;
  999. }
  1000. .sentActive {
  1001. background: #2A2F2C !important;
  1002. }
  1003. }
  1004. }
  1005. .audio-box{
  1006. display: flex;
  1007. align-items: center;
  1008. justify-content: space-between;
  1009. }
  1010. .aduioLine-box{
  1011. width: 516px;
  1012. height: 48px;
  1013. background: #FFFFFF;
  1014. border: 1px solid #EBEBEB;
  1015. border-radius: 30px;
  1016. display: flex;
  1017. align-items: center;
  1018. padding: 8px 24px;
  1019. .wrapper{
  1020. width: 24px;
  1021. height: 24px;
  1022. flex-shrink: 0;
  1023. color: #175DFF;
  1024. margin-left: 8px;
  1025. }
  1026. .Audio{
  1027. width: 430px;
  1028. }
  1029. }
  1030. .clear-box{
  1031. right: calc((100% - 1000px)/2 - 172px);
  1032. position: fixed;
  1033. top: 510px;
  1034. overflow: auto;
  1035. width: 152px;
  1036. padding: 8px;
  1037. border-radius: 8px;
  1038. border: 1px solid #EBEBEB;
  1039. background: #FFF;
  1040. box-shadow: 0px 5px 5px -3px rgba(0, 0, 0, 0.10), 0px 4px 6px 1px rgba(0, 0, 0, 0.06), 0px 3px 6px 2px rgba(0, 0, 0, 0.05);
  1041. margin-top: 24px;
  1042. h5{
  1043. margin: 0;
  1044. color: rgba(0, 0, 0, 0.40);
  1045. font-size: 14px;
  1046. font-weight: 400;
  1047. line-height: 22px;
  1048. }
  1049. .item{
  1050. display: flex;
  1051. align-items: center;
  1052. justify-content: space-between;
  1053. margin-top: 4px;
  1054. border-radius: 4px;
  1055. background:#F2F3F5;
  1056. padding: 4px 8px;
  1057. color: #2F3742;
  1058. font-size: 14px;
  1059. font-weight: 400;
  1060. line-height: 22px;
  1061. cursor: pointer;
  1062. &.red-item{
  1063. color: #F53F3F;
  1064. }
  1065. }
  1066. }
  1067. </style>