|
@@ -3,9 +3,9 @@
|
|
|
<div v-html="questionDetail.text"></div>
|
|
|
<!-- <div v-html="questionDetail.audio"></div> -->
|
|
|
<div v-for="({src, name}, index) in questionDetail.audio" :key="name" class="audio-div">
|
|
|
- <audio controls preload="auto" controlsList='nodownload' :name="name" :src="src" @play="($event) => played(index, $event)"></audio>
|
|
|
+ <audio controls preload="auto" controlsList='nodownload' :key="src" :name="name" :src="src" @play="($event) => played(index, $event)"></audio>
|
|
|
<span>(剩余播放次数:{{examQuestion.limitedPlayTimes -
|
|
|
- (audioPlayTimes.find(a => a.name === name) || { times: 0 }).times}})</span><br />
|
|
|
+ (allAudioPlayTimes.find(a => a.name === name) || { times: 0 }).times}})</span><br />
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
@@ -16,7 +16,7 @@
|
|
|
|
|
|
<script>
|
|
|
import { createNamespacedHelpers } from "vuex";
|
|
|
-const { mapMutations } = createNamespacedHelpers("examingHomeModule");
|
|
|
+const { mapState, mapMutations } = createNamespacedHelpers("examingHomeModule");
|
|
|
|
|
|
export default {
|
|
|
name: "QuestionBody",
|
|
@@ -37,7 +37,7 @@ export default {
|
|
|
// }
|
|
|
// },
|
|
|
methods: {
|
|
|
- ...mapMutations(["updateExamQuestion"]),
|
|
|
+ ...mapMutations(["updateExamQuestion", "updateQuestionAudioPlayTimes"]),
|
|
|
async parseQuestion() {
|
|
|
let question = {};
|
|
|
if (this.questionBody.includes("question-audio")) {
|
|
@@ -85,7 +85,7 @@ export default {
|
|
|
// console.log(`Found ${array1[0]}. Next starts at ${re.lastIndex}.`);
|
|
|
// console.log(array1[1]);
|
|
|
question.audio.push({ name: array1[1], src: array1[2] });
|
|
|
- console.log(question.audio);
|
|
|
+ // console.log(question.audio);
|
|
|
// expected output: "Found foo. Next starts at 9."
|
|
|
// expected output: "Found foo. Next starts at 19."
|
|
|
}
|
|
@@ -128,6 +128,7 @@ export default {
|
|
|
// });
|
|
|
// },
|
|
|
played(index, $event) {
|
|
|
+ // $event.target.pause();
|
|
|
const limitedPlayTimes = this.examQuestion.limitedPlayTimes;
|
|
|
let audioPlayTimes = this.audioPlayTimes;
|
|
|
console.log("开始播放");
|
|
@@ -141,17 +142,21 @@ export default {
|
|
|
$event.target.pause();
|
|
|
return;
|
|
|
}
|
|
|
+
|
|
|
+ // var audio = new Audio($event.target.src);
|
|
|
+ // audio.play();
|
|
|
+
|
|
|
if (theAudio) {
|
|
|
theAudio.times = playedTimes + 1;
|
|
|
} else {
|
|
|
this.audioPlayTimes.push({ name: name, times: 1 });
|
|
|
}
|
|
|
- this.updateExamQuestion({
|
|
|
- order: this.examQuestion.order,
|
|
|
- audioPlayTimes: JSON.stringify(this.audioPlayTimes)
|
|
|
- });
|
|
|
+ this.updateQuestionAudioPlayTimes(name);
|
|
|
}
|
|
|
},
|
|
|
+ computed: {
|
|
|
+ ...mapState(["allAudioPlayTimes"])
|
|
|
+ },
|
|
|
watch: {
|
|
|
questionBody() {
|
|
|
this.parseQuestion();
|