12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040 |
- <!-- -->
- <template>
- <div v-if="curQue" class="NNPE-ArticleView">
- <!-- <a class="ArticleView-full" @click="fullScreen">全屏模式</a> -->
- <div
- v-if="
- (curQue.mp3_list && curQue.mp3_list.length > 0 && curQue.mp3_list[0].url) || config.isHasPY || config.isHasEN
- "
- class="aduioLine-box aduioLine-practice-npc"
- >
- <div v-if="curQue.mp3_list && curQue.mp3_list.length > 0 && curQue.mp3_list[0].url" class="aduioLine-content">
- <AudioLine
- ref="audioLine"
- audio-id="artPraAudio"
- :mp3="curQue.mp3_list[0].url"
- :get-cur-time="getCurTime"
- :stop-audio="stopAudio"
- :width="colLength == 2 ? 175 : 700"
- :mp3-source="curQue.mp3_list[0].source"
- :ed="ed"
- type="audioLine"
- @handleChangeStopAudio="handleChangeStopAudio"
- @emptyEd="emptyEd"
- />
- </div>
- <div class="aduioLine-right">
- <!-- <span :class="['Repeat-16', isRepeat ? '' : 'disabled']" @click="changeRepeat"></span>
- <span
- :class="['pinyin-16', config.isShowPY ? '' : 'disabled']"
- @click="changePinyin"
- v-if="config.isHasPY"
- ></span>
- <span :class="['EN-16', config.isShowEN ? '' : 'disabled']" @click="changeEN" v-if="config.isHasEN"></span> -->
- <SvgIcon
- icon-class="repeat"
- size="16"
- :class="['Repeat-16', isRepeat ? '' : 'disabled']"
- :style="{ color: isRepeat ? themeColor : 'rgba(0,0,0,0.1)' }"
- @click="changeRepeat"
- />
- <SvgIcon
- v-if="config.isHasPY"
- icon-class="PinYin"
- size="16"
- :class="['pinyin-16', config.isShowPY ? '' : 'disabled']"
- :style="{ color: themeColor }"
- @click="changePinyin"
- />
- <SvgIcon
- v-if="config.isHasEN"
- icon-class="PinYin"
- size="16"
- :class="['EN-16', config.isShowEN ? '' : 'disabled']"
- :style="{ color: themeColor }"
- @click="changeEN"
- />
- </div>
- </div>
- <template v-if="resObj">
- <!-- -->
- <div class="NPC-sentences-list">
- <div
- v-for="(item, index) in resObj.sentList"
- :key="'detail' + index"
- :class="['NNPE-detail-box', sentIndex == index ? 'active' : '']"
- >
- <div
- :class="['NNPE-detail']"
- @click="
- handleChangeTime(
- curQue.wordTime && curQue.wordTime[index] && curQue.wordTime[index].bg,
- index,
- curQue.wordTime && curQue.wordTime[index] && curQue.wordTime[index].ed,
- )
- "
- >
- <div
- v-if="item.enwords && config.isShowEN && curQue.enPosition && curQue.enPosition == 'top'"
- :class="['enwords', sentIndex == index ? 'wordBlank' : '']"
- >
- {{ item.enwords }}
- </div>
- <div style="overflow: hidden; clear: both"></div>
- <div
- v-for="(pItem, pIndex) in item.sentArr"
- :key="'wordsList' + pIndex"
- class="NNPE-words"
- :class="[
- pItem.chs != '“' && pItem.wordIndex == 0 ? 'textLeft' : 'textCenter',
- pItem.chs == '“' ? 'textRight' : '',
- ]"
- >
- <template v-if="!pItem.width">
- <template v-if="pItem.isShow">
- <template
- v-if="
- item.sentArr[pIndex + 1] &&
- item.sentArr[pIndex + 1].chs &&
- chsFhList.indexOf(item.sentArr[pIndex + 1].chs) > -1
- "
- >
- <span class="NNPE-words-box">
- <template v-if="curQue.property.pinyin_position == 'top'">
- <span
- v-if="config.isShowPY"
- class="NNPE-pinyin"
- :class="[
- pItem.className ? pItem.className : '',
- sentIndex == index ? 'wordBlank' : '',
- noFont.indexOf(pItem.pinyin) > -1 ? 'noFont' : '',
- ]"
- >{{ pItem.pinyin }}</span
- >
- </template>
- <span
- class="NNPE-chs"
- :class="[
- pItem.padding && config.isShowPY ? 'padding' : '',
- sentIndex == index ? 'wordBlank' : '',
- ]"
- >
- <template>
- <span
- v-for="(wItem, wIndex) in pItem.leg"
- :key="'ci' + wIndex + pIndex + index"
- :class="[
- pItem.timeList[wIndex] &&
- curTime >= pItem.timeList[wIndex].wordBg &&
- curTime <= curQue.wordTime[index].ed
- ? 'active'
- : '',
- sentIndex == index ? 'wordBlank' : '',
- ]"
- :style="{
- fontFamily: pItem.config.fontFamily,
- height: '28px',
- display: 'inline-block',
- width: pItem.chs[wIndex].trim() === '' ? '6px' : '',
- }"
- >{{ NumberList.indexOf(pItem.pinyin) == -1 ? pItem.chs[wIndex] : '' }}</span
- >
- </template>
- </span>
- <template v-if="curQue.property.pinyin_position == 'bottom'">
- <span
- v-if="config.isShowPY"
- class="NNPE-pinyin"
- :class="[
- pItem.className ? pItem.className : '',
- sentIndex == index ? 'wordBlank' : '',
- noFont.indexOf(pItem.pinyin) > -1 ? 'noFont' : '',
- ]"
- >{{ pItem.pinyin }}</span
- >
- </template>
- </span>
- <span class="NNPE-words-box">
- <template v-if="curQue.property.pinyin_position == 'top'">
- <span
- v-if="config.isShowPY"
- :class="[
- 'NNPE-pinyin',
- sentIndex == index ? 'wordBlank' : '',
- noFont.indexOf(item.sentArr[pIndex + 1].pinyin) > -1 ? 'noFont' : '',
- ]"
- style="text-align: left"
- >{{ item.sentArr[pIndex + 1].pinyin }}</span
- >
- </template>
- <span class="NNPE-chs" style="text-align: left" :class="[sentIndex == index ? 'wordBlank' : '']">
- <span
- :class="[
- pItem.timeList[pItem.leg - 1] &&
- curQue.wordTime &&
- curTime >= pItem.timeList[pItem.leg - 1].wordBg &&
- curTime <= curQue.wordTime[index].ed
- ? 'active'
- : '',
- sentIndex == index ? 'wordBlank' : '',
- ]"
- :style="{
- fontFamily: item.sentArr[pIndex + 1].config.fontFamily,
- height: '28px',
- display: 'inline-block',
- width: item.sentArr[pIndex + 1].chs.trim() === '' ? '6px' : '',
- }"
- >
- {{
- NumberList.indexOf(item.sentArr[pIndex + 1].pinyin) == -1
- ? item.sentArr[pIndex + 1].chs
- : ''
- }}</span
- >
- </span>
- <template v-if="curQue.property.pinyin_position == 'bottom'">
- <span
- v-if="config.isShowPY"
- :class="[
- 'NNPE-pinyin',
- sentIndex == index ? 'wordBlank' : '',
- noFont.indexOf(item.sentArr[pIndex + 1].pinyin) > -1 ? 'noFont' : '',
- ]"
- style="text-align: left"
- >{{ item.sentArr[pIndex + 1].pinyin }}</span
- >
- </template>
- </span>
- <span
- v-if="
- item.sentArr[pIndex + 2] &&
- item.sentArr[pIndex + 2].chs &&
- chsFhList.indexOf(item.sentArr[pIndex + 2].chs) > -1
- "
- class="NNPE-words-box"
- >
- <template v-if="curQue.property.pinyin_position == 'top'">
- <span
- v-if="config.isShowPY"
- :class="[
- 'NNPE-pinyin',
- sentIndex == index ? 'wordBlank' : '',
- noFont.indexOf(item.sentArr[pIndex + 2].pinyin) > -1 ? 'noFont' : '',
- ]"
- style="text-align: left"
- >{{ item.sentArr[pIndex + 2].pinyin }}</span
- >
- </template>
- <span class="NNPE-chs" style="text-align: left" :class="[sentIndex == index ? 'wordBlank' : '']">
- <span
- :class="[
- pItem.timeList[pItem.leg - 1] &&
- curQue.wordTime &&
- curTime >= pItem.timeList[pItem.leg - 1].wordBg &&
- curTime <= curQue.wordTime[index].ed
- ? 'active'
- : '',
- sentIndex == index ? 'wordBlank' : '',
- ]"
- :style="{
- fontFamily: item.sentArr[pIndex + 2].config.fontFamily,
- height: '28px',
- display: 'inline-block',
- width: item.sentArr[pIndex + 2].chs.trim() === '' ? '6px' : '',
- }"
- >
- {{
- NumberList.indexOf(item.sentArr[pIndex + 2].pinyin) == -1
- ? item.sentArr[pIndex + 2].chs
- : ''
- }}</span
- >
- </span>
- <template v-if="curQue.property.pinyin_position == 'bottom'">
- <span
- v-if="config.isShowPY"
- :class="[
- 'NNPE-pinyin',
- sentIndex == index ? 'wordBlank' : '',
- noFont.indexOf(item.sentArr[pIndex + 2].pinyin) > -1 ? 'noFont' : '',
- ]"
- style="text-align: left"
- >{{ item.sentArr[pIndex + 2].pinyin }}</span
- >
- </template>
- </span>
- </template>
- <template v-else>
- <template v-if="curQue.property.pinyin_position == 'top'">
- <span
- v-if="config.isShowPY"
- class="NNPE-pinyin"
- :class="[
- pItem.chs != '“' && pItem.padding ? 'padding' : '',
- pItem.className ? pItem.className : '',
- sentIndex == index ? 'wordBlank' : '',
- noFont.indexOf(pItem.pinyin) > -1 ? 'noFont' : '',
- ]"
- >{{ pItem.pinyin }}</span
- >
- </template>
- <span
- class="NNPE-chs"
- :class="[
- pItem.chs != '“' && pItem.padding && config.isShowPY ? 'padding' : '',
- sentIndex == index ? 'wordBlank' : '',
- ]"
- >
- <template>
- <span
- v-for="(wItem, wIndex) in pItem.leg"
- :key="'ci' + wIndex + pIndex + index"
- :class="[
- pItem.timeList[wIndex] &&
- curQue.wordTime &&
- curQue.wordTime[index] &&
- curTime >= pItem.timeList[wIndex].wordBg &&
- curTime <= curQue.wordTime[index].ed
- ? 'active'
- : '',
- sentIndex == index ? 'wordBlank' : '',
- ]"
- :style="{
- fontFamily: pItem.config.fontFamily,
- height: '28px',
- display: 'inline-block',
- width: pItem.chs[wIndex].trim() === '' ? '6px' : '',
- }"
- >{{ NumberList.indexOf(pItem.pinyin) == -1 ? pItem.chs[wIndex] : '' }}</span
- >
- </template>
- </span>
- <template v-if="curQue.property.pinyin_position == 'bottom'">
- <span
- v-if="config.isShowPY"
- class="NNPE-pinyin"
- :class="[
- pItem.chs != '“' && pItem.padding ? 'padding' : '',
- pItem.className ? pItem.className : '',
- sentIndex == index ? 'wordBlank' : '',
- noFont.indexOf(pItem.pinyin) > -1 ? 'noFont' : '',
- ]"
- >{{ pItem.pinyin }}</span
- >
- </template>
- </template>
- </template>
- </template>
- <template v-else>
- <span
- :style="{
- height: pItem.height + 'px',
- width: pItem.width + 'px',
- }"
- ></span>
- </template>
- </div>
- <div style="overflow: hidden; clear: both"></div>
- <div
- v-if="
- item.enwords &&
- config.isShowEN &&
- (!curQue.enPosition || (curQue.enPosition && curQue.enPosition == 'bottom'))
- "
- :class="['enwords', sentIndex == index ? 'wordBlank' : '']"
- >
- {{ item.enwords }}
- </div>
- </div>
- <div
- v-show="
- (curQue.wordTime &&
- curQue.wordTime[index] &&
- curTime >= curQue.wordTime[index].bg &&
- curTime <= curQue.wordTime[index].ed) ||
- sentIndex == index
- "
- class="Soundrecord-content"
- >
- <div class="Soundrecord-content-inner">
- <Soundrecord
- type="promax"
- class="luyin-box"
- :TaskModel="TaskModel"
- v-if="refresh"
- :answer-record-list="
- curQue.Bookanswer.practiceModel[index] && curQue.Bookanswer.practiceModel[index].recordList
- "
- :tm-index="index"
- :sent-index="sentIndex"
- @getWavblob="getWavblob"
- @handleParentPlay="handleParentPlay"
- @sentPause="sentPause"
- @handleWav="handleWav"
- />
- <div v-if="curQue.mp3_list && curQue.mp3_list.length > 0" class="compare-box">
- <Audio-compare
- :theme-color="themeColor"
- :index="index"
- :sent-index="sentIndex"
- :url="curQue.mp3_list[0].id"
- :bg="curQue.wordTime[index].bg"
- :ed="curQue.wordTime[index].ed"
- :wavblob="wavblob"
- :get-cur-time="getCurTime"
- :sent-pause="sentPause"
- :is-record="isRecord"
- :handle-change-stop-audio="handleChangeStopAudio"
- :get-play-status="getPlayStatus"
- />
- </div>
- </div>
- <span class="full-screen-icon" @click="fullScreen"> </span>
- </div>
- </div>
- <div class="multilingual" v-for="(items, indexs) in multilingualTextList" :key="indexs">
- {{ items }}
- </div>
- </div>
- </template>
- <div :id="'screen-' + mathNum" class="voice-full-screen">
- <Voicefullscreen
- v-if="isFull && resObj"
- :theme-color="themeColor"
- :cur-que="curQue"
- :sent-list="resObj.sentList"
- :sent-index="sentIndex"
- :mp3="curQue.mp3_list && curQue.mp3_list[0] ? curQue.mp3_list[0].url : ''"
- :no-font="noFont"
- :NNPENewWordList="NNPENewWordList"
- :current-tree-i-d="currentTreeID"
- :config="config"
- :TaskModel="TaskModel"
- @handleWav="handleWav"
- @changePinyin="changePinyin"
- @changeEN="changeEN"
- @exitFullscreen="exitFullscreen"
- @changeIsFull="changeIsFull"
- />
- </div>
- </div>
- </template>
- <script>
- import AudioLine from '../voice_matrix/components/AudioLine.vue';
- import Soundrecord from '../../common/SoundRecord.vue';
- import AudioCompare from './components/AudioCompare.vue';
- import Voicefullscreen from './Voicefullscreen.vue';
- export default {
- name: 'ArticleView',
- components: {
- AudioLine,
- Soundrecord,
- AudioCompare,
- Voicefullscreen,
- },
- props: [
- 'curQue',
- 'noFont',
- 'themeColor',
- 'NNPENewWordList',
- 'currentTreeID',
- 'config',
- 'TaskModel',
- 'colLength',
- 'isFull',
- 'multilingualTextList',
- ],
- data() {
- return {
- resObj: null,
- curTime: 0, // 单位s
- chsFhList: [',', '。', '”', ':', '》', '?', '!', ';', '、'],
- enFhList: [',', '.', ';', '?', '!', ':', '>', '<'],
- NumberList: ['①', '②', '③', '④', '⑤', '⑥', '⑦', '⑧', '⑨', '⑩', '⑪', '⑫', '⑬', '⑭', '⑮', '⑯', '⑰', '⑱', '⑲', '⑳'],
- stopAudio: false,
- sentIndex: 0,
- isRepeat: false,
- currSent: null, // 当前句子的时间
- isRecord: false,
- wavblob: null,
- mathNum: Math.random().toString(36).substr(2),
- ed: undefined,
- refresh: true,
- };
- },
- computed: {
- isPlaying() {
- let playing = false;
- if (this.$refs.audioLine) {
- playing = this.$refs.audioLine.audio.isPlaying;
- }
- return playing;
- },
- },
- watch: {
- sentIndex: {
- handler(newVal, oldVal) {
- let _this = this;
- if (newVal != oldVal) {
- let Bookanswer = _this.curQue.Bookanswer;
- if (
- Bookanswer &&
- Bookanswer.practiceModel &&
- Bookanswer.practiceModel[newVal] &&
- Bookanswer.practiceModel[newVal].recordList &&
- Bookanswer.practiceModel[newVal].recordList.length > 0
- ) {
- _this.wavblob = Bookanswer.practiceModel[newVal].recordList[0].wavData;
- } else {
- _this.wavblob = '';
- }
- }
- },
- deep: true,
- },
- isFull: {
- handler(newVal, oldVal) {
- let _this = this;
- _this.refresh = false;
- if (!newVal) {
- _this.$nextTick(() => {
- // 重新渲染组件
- _this.refresh = true;
- });
- }
- },
- deep: true,
- },
- },
- // 生命周期 - 创建完成(可以访问当前this实例)
- created() {},
- // 生命周期 - 挂载完成(可以访问DOM元素)
- mounted() {
- if (this.curQue) {
- this.handleData();
- }
- },
- beforeCreate() {}, // 生命周期 - 创建之前
- beforeMount() {}, // 生命周期 - 挂载之前
- beforeUpdate() {}, // 生命周期 - 更新之前
- updated() {}, // 生命周期 - 更新之后
- beforeDestroy() {}, // 生命周期 - 销毁之前
- destroyed() {}, // 生命周期 - 销毁完成
- activated() {},
- // 方法集合
- methods: {
- getPlayStatus(val) {
- // this.isPlaying = val;
- },
- // 拼音的显示和隐藏
- changePinyin() {
- if (this.config.isHasPY) {
- this.$emit('changeConfig', 'isShowPY');
- }
- },
- // 英文的显示和隐藏
- changeEN() {
- if (this.config.isHasEN) {
- this.$emit('changeConfig', 'isShowEN');
- }
- },
- pauseAudio() {
- let audio = document.getElementsByTagName('audio');
- if (audio && audio.length > 0 && window.location.href.indexOf('GCLS-Learn') == -1 && audio.forEach) {
- audio.forEach((item) => {
- item.pause();
- });
- }
- },
- pauseVideo() {
- let video = document.getElementsByTagName('video');
- if (video && video.length > 0 && window.location.href.indexOf('GCLS-Learn') == -1 && video.forEach) {
- video.forEach((item) => {
- item.pause();
- });
- }
- },
- // 语音全屏
- fullScreen() {
- this.pauseAudio();
- this.pauseVideo();
- this.isFull = true;
- this.goFullscreen();
- },
- goFullscreen() {
- let id = `screen-${this.mathNum}`;
- let element = document.getElementById(id);
- if (element.requestFullscreen) {
- element.requestFullscreen();
- } else if (element.msRequestFullscreen) {
- element.msRequestFullscreen();
- } else if (element.mozRequestFullScreen) {
- element.mozRequestFullScreen();
- } else if (element.webkitRequestFullscreen) {
- element.webkitRequestFullscreen();
- }
- },
- exitFullscreen() {
- this.isFull = false;
- if (document.exitFullscreen) {
- document.exitFullscreen();
- } else if (document.msExitFullscreen) {
- document.msExitFullscreen();
- } else if (document.mozCancelFullScreen) {
- document.mozCancelFullScreen();
- } else if (document.webkitExitFullscreen) {
- document.webkitExitFullscreen();
- }
- },
- changeIsFull() {
- this.isFull = false;
- },
- getWavblob(wavblob) {
- this.wavblob = wavblob;
- },
- sentPause(isRecord) {
- this.isRecord = isRecord;
- },
- getCurTime(curTime) {
- let _this = this;
- if (_this.isRepeat) {
- let time = curTime * 1000;
- if (time >= _this.currSent.ed || time <= _this.currSent.bg) {
- _this.curTime = _this.currSent.bg;
- this.$refs.audioLine.onTimeupdateTime(_this.currSent.bg / 1000, true);
- } else {
- _this.curTime = curTime * 1000;
- }
- } else {
- _this.curTime = curTime * 1000;
- _this.getSentIndex(_this.curTime);
- }
- },
- getSentIndex(curTime) {
- for (let i = 0; i < this.curQue.wordTime.length; i++) {
- let bg = this.curQue.wordTime[i].bg;
- let ed = this.curQue.wordTime[i].ed;
- if (curTime >= bg && curTime <= ed) {
- this.sentIndex = i;
- break;
- }
- }
- },
- handleData() {
- let resArr = [];
- let sentArrTotal = [];
- let timeArr = [];
- let curQue = JSON.parse(JSON.stringify(this.curQue));
- let wordTimeList = curQue.wordTime;
- let dhaspinyin = false; // 每段是否有拼音
- let dhaspinyinArr = [];
- curQue.detail.forEach((dItem, dIndex) => {
- dhaspinyin = false;
- dItem.wordsList.forEach((sItem, sIndex) => {
- let sentArr = [];
- sItem.forEach((wItem, wIndex) => {
- let startIndex = wIndex == 0 ? 0 : sentArr[wIndex - 1].startIndex + sentArr[wIndex - 1].chs.length;
- let endIndex = wIndex == 0 ? wItem.chs.length : sentArr[wIndex - 1].endIndex + wItem.chs.length;
- // this.judgePad(sItem, wItem, wIndex);
- this.mergeWordSymbol(wItem);
- let obj = {
- paraIndex: dIndex, // 段落索引
- sentIndex: sIndex, // 在段落中句子索引
- wordIndex: wIndex, // 单词的索引
- pinyin:
- curQue.pinyin_type === 'pinyin'
- ? curQue.property.is_enable_sentence_case && wIndex === 0
- ? wItem.pinyin_up
- : wItem.pinyin
- : wItem.pinyin_tone,
- chs: wItem.chs,
- padding: true,
- className: wItem.className,
- isShow: wItem.isShow,
- startIndex,
- endIndex,
- leg: wItem.chs.length,
- timeList: [],
- config: {
- fontFamily: wItem.fontFamily,
- },
- };
- sentArr.push(obj);
- if (wItem.pinyin) dhaspinyin = true;
- });
- let objs = {
- sentArr,
- enwords: dItem.sentencesEn && dItem.sentencesEn[sIndex] && dItem.sentencesEn[sIndex].replace(/\'/g, '’'),
- };
- sentArrTotal.push(sentArr);
- resArr.push(objs);
- });
- timeArr.push(dItem.timeList);
- dhaspinyinArr.push(dhaspinyin);
- });
- if (wordTimeList && wordTimeList.length > 0) {
- this.mergeWordTime(sentArrTotal, wordTimeList);
- }
- let timeList = [];
- timeArr.forEach((item) => {
- item.forEach((aItem) => {
- if (timeList.indexOf(aItem) < 0) {
- timeList.push(aItem);
- }
- });
- });
- this.resObj = {
- sentList: resArr,
- timeList,
- dhaspinyinArr,
- };
- },
- mergeWordTime(resArr, wordTimeList) {
- resArr.forEach((item, index) => {
- let wordsResultList = wordTimeList[index].wordsResultList;
- item.forEach((wItem) => {
- let startIndex = wItem.startIndex;
- let endIndex = wItem.endIndex;
- wItem.timeList = wordsResultList.slice(startIndex, endIndex);
- });
- });
- },
- // 词和标点合一起
- mergeWordSymbol(wItem) {
- if (this.chsFhList.indexOf(wItem.chs) > -1) {
- wItem.isShow = false;
- } else {
- wItem.isShow = true;
- }
- },
- // 判断是否有padding
- judgePad(sItem, wItem, curIndex) {
- let leg = sItem.length;
- if (curIndex < leg - 1) {
- let nextIndex = curIndex + 1;
- let chs = sItem[nextIndex].chs;
- if (this.chsFhList.indexOf(chs) > -1 || this.chsFhList.indexOf(wItem.chs) > -1) {
- wItem.padding = false;
- } else {
- wItem.padding = true;
- }
- if (this.enFhList.indexOf(wItem.pinyin) > -1) {
- wItem.className = 'textLeft';
- }
- }
- },
- // 转化时间
- handleTimeList(list) {
- let listRes = [];
- list.forEach((item) => {
- let res = timeStrToSen(item);
- listRes.push(res);
- });
- return listRes;
- },
- // 分:秒转秒
- timeStrToSen(time) {
- if (!time) {
- return -1;
- }
- let pos = time.indexOf(':');
- let min = 0;
- var sec = 0;
- if (pos > 0) {
- min = parseInt(time.substring(0, pos));
- sec = parseFloat(time.substring(pos + 1));
- }
- return min * 60 + sec;
- },
- // 计算总时间
- countWordTime(sentArr) {
- let total = 0;
- sentArr.forEach((item) => {
- total += item.endTime;
- });
- return total;
- },
- // 点击播放某个句子
- handleChangeTime(time, index, ed) {
- let _this = this;
- if (this.isRepeat) {
- _this.currSent = _this.curQue.wordTime[index];
- }
- _this.sentIndex = index;
- _this.ed = ed;
- if (time) {
- _this.curTime = time;
- _this.$refs.audioLine.onTimeupdateTime(time / 1000, true);
- }
- },
- emptyEd() {
- this.ed = undefined;
- },
- handleWav(list, tmIndex) {
- tmIndex = tmIndex || 0;
- this.curQue.Bookanswer.practiceModel[tmIndex] = {
- recordList: [],
- };
- this.$set(this.curQue.Bookanswer.practiceModel[tmIndex], 'recordList', list);
- },
- // 录音时暂停音频播放
- handleParentPlay() {
- this.stopAudio = true;
- },
- // 音频播放时改变布尔值
- handleChangeStopAudio() {
- this.stopAudio = false;
- },
- // 单句是否重复播放
- changeRepeat() {
- let _this = this;
- _this.isRepeat = !_this.isRepeat;
- this.currSent = _this.curQue.wordTime[_this.sentIndex];
- },
- }, // 如果页面有keep-alive缓存功能,这个函数会触发
- };
- </script>
- <style lang="scss" scoped>
- //@import url(); 引入公共css类
- .NNPE-ArticleView {
- position: relative;
- width: 100%;
- .ArticleView-full {
- position: absolute;
- top: -33px;
- left: 0;
- z-index: 99999;
- padding-left: 24px;
- font-size: 14px;
- font-weight: bold;
- line-height: 24px;
- color: #000;
- background: url('@/assets/full-screen-red.png') left center no-repeat;
- background-size: 16px 16px;
- }
- .NPC-sentences-list {
- padding: 16px 0;
- }
- .multilingual {
- padding: 6px 24px 12px;
- word-break: break-word;
- }
- .aduioLine-content {
- flex: 1;
- }
- .NNPE-detail-box {
- box-sizing: border-box;
- width: 100%;
- padding: 8px 24px;
- margin-bottom: 8px;
- &.active {
- background: rgba(222, 68, 68, 15%);
- }
- }
- .aduioLine-practice-npc {
- display: flex;
- align-items: center;
- justify-content: flex-start;
- .aduioLine-right {
- box-sizing: border-box;
- display: flex;
- align-items: center;
- justify-content: space-between;
- width: 92px;
- height: 40px;
- padding: 0 12px;
- border-left: 1px solid rgba(0, 0, 0, 10%);
- .svg-icon {
- width: 16px;
- height: 16px;
- cursor: pointer;
- }
- }
- }
- .NNPE-detail {
- overflow: hidden;
- clear: both;
- .NNPE-words {
- float: left;
- &-box {
- float: left;
- > span {
- display: block;
- &.NNPE-pinyin {
- height: 20px;
- font-family: 'GB-PINYINOK-B';
- font-size: 14px;
- font-weight: normal;
- line-height: 20px;
- color: rgba(0, 0, 0, 45%);
- &.noFont {
- font-family: initial;
- }
- &.textLeft {
- text-align: left;
- }
- &.wordBlank {
- color: rgba(0, 0, 0, 85%);
- }
- }
- &.NNPE-chs {
- display: flex;
- flex-flow: wrap;
- font-family: '楷体';
- font-size: 20px;
- line-height: 28px;
- color: rgba(0, 0, 0, 45%);
- .active {
- color: #de4444;
- }
- &.wordBlank {
- color: rgba(0, 0, 0, 85%);
- }
- }
- // &.padding {
- // padding-right: 6px;
- // }
- }
- }
- &.textLeft {
- text-align: left;
- }
- &.textCenter {
- text-align: center;
- .NNPE-chs {
- justify-content: center;
- }
- }
- &.textRight {
- text-align: right;
- }
- > span {
- display: block;
- &.NNPE-pinyin {
- height: 20px;
- font-family: 'GB-PINYINOK-B';
- font-size: 14px;
- font-weight: normal;
- line-height: 20px;
- color: rgba(0, 0, 0, 45%);
- &.noFont {
- font-family: initial;
- }
- &.textLeft {
- text-align: left;
- }
- &.wordBlank {
- color: rgba(0, 0, 0, 85%);
- }
- }
- &.NNPE-chs {
- display: flex;
- flex-flow: wrap;
- font-family: '楷体';
- font-size: 20px;
- line-height: 28px;
- color: rgba(0, 0, 0, 45%);
- .active {
- color: #de4444;
- }
- &.wordBlank {
- color: rgba(0, 0, 0, 85%);
- }
- }
- &.padding {
- padding: 0 3px;
- }
- }
- }
- }
- .Soundrecord-content {
- display: flex;
- align-items: center;
- justify-content: space-between;
- margin-top: 8px;
- &-inner {
- display: flex;
- align-items: center;
- justify-content: flex-start;
- width: 304px;
- padding: 4px 12px;
- background: #fff;
- border: 1px solid rgba(0, 0, 0, 10%);
- border-radius: 8px;
- .luyin-box {
- width: 280px;
- max-width: 280px;
- }
- .compare-box {
- display: flex;
- align-items: center;
- justify-content: center;
- height: 32px;
- }
- }
- .full-screen-icon {
- width: 16px;
- height: 16px;
- cursor: pointer;
- background: url('@/assets/full-screen-red.png') no-repeat left top;
- background-size: 100% 100%;
- }
- }
- .enwords {
- padding-left: 3px;
- font-family: 'Helvetica';
- font-size: 14px;
- font-weight: normal;
- line-height: 22px;
- color: rgba(0, 0, 0, 45%);
- word-break: break-word;
- &.wordBlank {
- color: rgba(0, 0, 0, 85%);
- }
- }
- }
- </style>
|