|
@@ -3,7 +3,11 @@
|
|
|
<div class="NNPE-Book-record">
|
|
|
<template v-if="(type && type == 'normal') || (type && type == 'mini')">
|
|
|
<div
|
|
|
- :class="['record', microphoneStatus ? 'active' : '', !TaskModel||TaskModel!='ANSWER'?'':'notAllow']"
|
|
|
+ :class="[
|
|
|
+ 'record',
|
|
|
+ microphoneStatus ? 'active' : '',
|
|
|
+ !TaskModel || TaskModel != 'ANSWER' ? '' : 'notAllow',
|
|
|
+ ]"
|
|
|
@click="microphone"
|
|
|
/>
|
|
|
<span
|
|
@@ -30,7 +34,11 @@
|
|
|
</template>
|
|
|
<template v-else-if="type && type == 'pro'">
|
|
|
<div
|
|
|
- :class="['record', microphoneStatus ? 'active' : '', !TaskModel||TaskModel!='ANSWER'?'':'notAllow']"
|
|
|
+ :class="[
|
|
|
+ 'record',
|
|
|
+ microphoneStatus ? 'active' : '',
|
|
|
+ !TaskModel || TaskModel != 'ANSWER' ? '' : 'notAllow',
|
|
|
+ ]"
|
|
|
@click="microphone"
|
|
|
/>
|
|
|
<el-select
|
|
@@ -41,7 +49,7 @@
|
|
|
>
|
|
|
<el-option
|
|
|
v-for="(item, index) in recordList"
|
|
|
- :key="'select'+item.id"
|
|
|
+ :key="'select' + item.id"
|
|
|
:label="item.name"
|
|
|
:value="index"
|
|
|
/>
|
|
@@ -57,13 +65,23 @@
|
|
|
"
|
|
|
/>
|
|
|
<a
|
|
|
- :class="['record-delete', hasMicro&&(!TaskModel||TaskModel!='ANSWER') ? 'record-delete-has' : '', !TaskModel||TaskModel!='ANSWER'?'':'notAllow']"
|
|
|
+ :class="[
|
|
|
+ 'record-delete',
|
|
|
+ hasMicro && (!TaskModel || TaskModel != 'ANSWER')
|
|
|
+ ? 'record-delete-has'
|
|
|
+ : '',
|
|
|
+ !TaskModel || TaskModel != 'ANSWER' ? '' : 'notAllow',
|
|
|
+ ]"
|
|
|
@click="handleDelete"
|
|
|
/>
|
|
|
</template>
|
|
|
<template v-else>
|
|
|
<div
|
|
|
- :class="['record', microphoneStatus ? 'active' : '', !TaskModel||TaskModel!='ANSWER'?'':'notAllow']"
|
|
|
+ :class="[
|
|
|
+ 'record',
|
|
|
+ microphoneStatus ? 'active' : '',
|
|
|
+ !TaskModel || TaskModel != 'ANSWER' ? '' : 'notAllow',
|
|
|
+ ]"
|
|
|
@click="microphone"
|
|
|
/>
|
|
|
<span
|
|
@@ -81,7 +99,7 @@
|
|
|
>
|
|
|
<el-option
|
|
|
v-for="(item, index) in recordList"
|
|
|
- :key="'selectbig' + item.id + index "
|
|
|
+ :key="'selectbig' + item.id + index"
|
|
|
:label="item.name"
|
|
|
:value="index"
|
|
|
/>
|
|
@@ -97,7 +115,13 @@
|
|
|
"
|
|
|
/>
|
|
|
<a
|
|
|
- :class="['record-delete', hasMicro&&(!TaskModel||TaskModel!='ANSWER') ? 'record-delete-has' : '', !TaskModel||TaskModel!='ANSWER'?'':'notAllow']"
|
|
|
+ :class="[
|
|
|
+ 'record-delete',
|
|
|
+ hasMicro && (!TaskModel || TaskModel != 'ANSWER')
|
|
|
+ ? 'record-delete-has'
|
|
|
+ : '',
|
|
|
+ !TaskModel || TaskModel != 'ANSWER' ? '' : 'notAllow',
|
|
|
+ ]"
|
|
|
@click="handleDelete"
|
|
|
/>
|
|
|
</template>
|
|
@@ -115,7 +139,7 @@ export default {
|
|
|
"selectData",
|
|
|
"tmIndex",
|
|
|
"answerRecordList",
|
|
|
- "TaskModel"
|
|
|
+ "TaskModel",
|
|
|
],
|
|
|
data() {
|
|
|
return {
|
|
@@ -154,9 +178,12 @@ export default {
|
|
|
// 生命周期 - 挂载完成(可以访问DOM元素)
|
|
|
mounted() {
|
|
|
let _this = this;
|
|
|
- _this.recordList = _this.answerRecordList ? JSON.parse(JSON.stringify(_this.answerRecordList)) : [];
|
|
|
+ _this.recordList = _this.answerRecordList
|
|
|
+ ? JSON.parse(JSON.stringify(_this.answerRecordList))
|
|
|
+ : [];
|
|
|
if (_this.recordList.length > 0) {
|
|
|
_this.selectIndex = 0;
|
|
|
+ _this.recordFile = _this.recordList.length + 1;
|
|
|
_this.handleChangeRecord(0);
|
|
|
}
|
|
|
_this.audio.addEventListener("play", function () {
|
|
@@ -183,65 +210,65 @@ export default {
|
|
|
// 开始录音
|
|
|
microphone() {
|
|
|
let _this = this;
|
|
|
- if(!this.TaskModel||this.TaskModel!='ANSWER'){
|
|
|
- if (!_this.microphoneStatus) {
|
|
|
- _this.hasMicro = "";
|
|
|
- _this.$root.isRecording = true;
|
|
|
- _this.$emit("getWavblob", null);
|
|
|
- this.$emit("getSelectData", { type: "" });
|
|
|
- // 开始录音
|
|
|
- this.recorder.start();
|
|
|
- this.microphoneStatus = true;
|
|
|
- this.recordtime = 0;
|
|
|
- this.isPlaying = false;
|
|
|
- clearInterval(_this.timer);
|
|
|
- _this.timer = setInterval(() => {
|
|
|
- _this.recordtime++;
|
|
|
- }, 1000);
|
|
|
- this.$emit("handleParentPlay");
|
|
|
- let obj = {
|
|
|
- name: _this.fileName
|
|
|
- ? _this.fileName + _this.recordFile
|
|
|
- : "新录音" + _this.recordFile,
|
|
|
- id: _this.recordFile + Math.round(Math.random() * 10),
|
|
|
- };
|
|
|
- if (this.selectData) obj.selectData = this.selectData;
|
|
|
- _this.recordList.push(obj);
|
|
|
+ if (!this.TaskModel || this.TaskModel != "ANSWER") {
|
|
|
+ if (!_this.microphoneStatus) {
|
|
|
+ _this.hasMicro = "";
|
|
|
+ _this.$root.isRecording = true;
|
|
|
+ _this.$emit("getWavblob", null);
|
|
|
+ this.$emit("getSelectData", { type: "" });
|
|
|
+ // 开始录音
|
|
|
+ this.recorder.start();
|
|
|
+ this.microphoneStatus = true;
|
|
|
+ this.recordtime = 0;
|
|
|
+ this.isPlaying = false;
|
|
|
+ clearInterval(_this.timer);
|
|
|
+ _this.timer = setInterval(() => {
|
|
|
+ _this.recordtime++;
|
|
|
+ }, 1000);
|
|
|
+ this.$emit("handleParentPlay");
|
|
|
+ let obj = {
|
|
|
+ name: _this.fileName
|
|
|
+ ? _this.fileName + _this.recordFile
|
|
|
+ : "新录音" + _this.recordFile,
|
|
|
+ id: _this.recordFile + Math.round(Math.random() * 10),
|
|
|
+ };
|
|
|
+ if (this.selectData) obj.selectData = this.selectData;
|
|
|
+ _this.recordList.push(obj);
|
|
|
|
|
|
- _this.recordFile++;
|
|
|
- _this.selectIndex = _this.recordList.length - 1;
|
|
|
- } else {
|
|
|
- this.hasMicro = "normal";
|
|
|
- this.recorder.stop();
|
|
|
- _this.$root.isRecording = false;
|
|
|
- clearInterval(_this.timer);
|
|
|
- let toltime = this.recorder.duration; // 录音总时长
|
|
|
- let fileSize = this.recorder.fileSize; // 录音总大小
|
|
|
- // 录音结束,获取取录音数据
|
|
|
- let PCMBlob = this.recorder.getPCMBlob(); // 获取 PCM 数据
|
|
|
- let wav = this.recorder.getWAVBlob(); // 获取 WAV 数据
|
|
|
- // this.wavblob = wav;
|
|
|
- this.microphoneStatus = false;
|
|
|
- let reader = new window.FileReader();
|
|
|
- reader.readAsDataURL(wav);
|
|
|
- reader.onloadend = () => {
|
|
|
- _this.recordList[_this.selectIndex].wavData = reader.result;
|
|
|
- _this.recordList[_this.selectIndex].toltime = Math.floor(toltime);
|
|
|
- _this.recordList[_this.selectIndex].fileSize = fileSize;
|
|
|
- _this.wavblob = _this.recordList[_this.selectIndex].wavData;
|
|
|
- _this.$emit("getWavblob", _this.wavblob);
|
|
|
- _this.$emit(
|
|
|
- "handleWav",
|
|
|
- JSON.parse(JSON.stringify(_this.recordList)),
|
|
|
- _this.tmIndex
|
|
|
- );
|
|
|
+ _this.recordFile++;
|
|
|
+ _this.selectIndex = _this.recordList.length - 1;
|
|
|
+ } else {
|
|
|
+ this.hasMicro = "normal";
|
|
|
+ this.recorder.stop();
|
|
|
+ _this.$root.isRecording = false;
|
|
|
+ clearInterval(_this.timer);
|
|
|
+ let toltime = this.recorder.duration; // 录音总时长
|
|
|
+ let fileSize = this.recorder.fileSize; // 录音总大小
|
|
|
+ // 录音结束,获取取录音数据
|
|
|
+ let PCMBlob = this.recorder.getPCMBlob(); // 获取 PCM 数据
|
|
|
+ let wav = this.recorder.getWAVBlob(); // 获取 WAV 数据
|
|
|
+ // this.wavblob = wav;
|
|
|
+ this.microphoneStatus = false;
|
|
|
+ let reader = new window.FileReader();
|
|
|
+ reader.readAsDataURL(wav);
|
|
|
+ reader.onloadend = () => {
|
|
|
+ _this.recordList[_this.selectIndex].wavData = reader.result;
|
|
|
+ _this.recordList[_this.selectIndex].toltime = Math.floor(toltime);
|
|
|
+ _this.recordList[_this.selectIndex].fileSize = fileSize;
|
|
|
+ _this.wavblob = _this.recordList[_this.selectIndex].wavData;
|
|
|
+ _this.$emit("getWavblob", _this.wavblob);
|
|
|
+ _this.$emit(
|
|
|
+ "handleWav",
|
|
|
+ JSON.parse(JSON.stringify(_this.recordList)),
|
|
|
+ _this.tmIndex
|
|
|
+ );
|
|
|
if (this.recordList[this.selectIndex].selectData)
|
|
|
- this.$emit(
|
|
|
+ this.$emit(
|
|
|
"getSelectData",
|
|
|
this.recordList[this.selectIndex].selectData
|
|
|
- );
|
|
|
+ );
|
|
|
// }
|
|
|
- };
|
|
|
+ };
|
|
|
}
|
|
|
}
|
|
|
},
|
|
@@ -253,11 +280,11 @@ export default {
|
|
|
let _this = this;
|
|
|
if (!this.audio.paused) {
|
|
|
this.audio.pause();
|
|
|
- this.hasMicro = 'normal'
|
|
|
+ this.hasMicro = "normal";
|
|
|
clearInterval(_this.timer);
|
|
|
} else if (this.audio.paused && _this.oldIndex == _this.selectIndex) {
|
|
|
_this.audio.play();
|
|
|
- this.hasMicro = 'active'
|
|
|
+ this.hasMicro = "active";
|
|
|
if (_this.recordtime == 0) {
|
|
|
_this.recordtime = totalTimes;
|
|
|
_this.playtime = 0;
|
|
@@ -271,7 +298,7 @@ export default {
|
|
|
}
|
|
|
}, 1000);
|
|
|
} else {
|
|
|
- _this.hasMicro = 'active'
|
|
|
+ _this.hasMicro = "active";
|
|
|
_this.audio.pause();
|
|
|
_this.audio.load();
|
|
|
_this.audio.src = _this.wavblob;
|
|
@@ -334,7 +361,7 @@ export default {
|
|
|
},
|
|
|
handleDelete() {
|
|
|
let _this = this;
|
|
|
- if (_this.hasMicro&&(!this.TaskModel||this.TaskModel!='ANSWER')) {
|
|
|
+ if (_this.hasMicro && (!this.TaskModel || this.TaskModel != "ANSWER")) {
|
|
|
if (_this.selectIndex || _this.selectIndex == 0) {
|
|
|
_this.recordList.splice(_this.selectIndex, 1);
|
|
|
_this.$emit(
|
|
@@ -421,11 +448,11 @@ export default {
|
|
|
no-repeat;
|
|
|
background-size: 100%;
|
|
|
}
|
|
|
- &.notAllow{
|
|
|
- cursor: not-allowed;
|
|
|
- background: url("../../../assets/newImage/common/luyin-notAllow.png") center
|
|
|
- no-repeat;
|
|
|
- background-size: 100%;
|
|
|
+ &.notAllow {
|
|
|
+ cursor: not-allowed;
|
|
|
+ background: url("../../../assets/newImage/common/luyin-notAllow.png")
|
|
|
+ center no-repeat;
|
|
|
+ background-size: 100%;
|
|
|
}
|
|
|
}
|
|
|
.record-time {
|
|
@@ -462,8 +489,8 @@ export default {
|
|
|
background-size: 100%;
|
|
|
}
|
|
|
}
|
|
|
- &.notAllow{
|
|
|
- cursor: not-allowed;
|
|
|
+ &.notAllow {
|
|
|
+ cursor: not-allowed;
|
|
|
}
|
|
|
}
|
|
|
}
|