Commit cb5df2e7 authored by marsandheart's avatar marsandheart

fix issue 1,2

parent 5ddfb0f0
......@@ -385,13 +385,16 @@ export default function(props) {
const playQuestion = (questionId) => {
console.log('407');
const targetQuestion = currentStep.questions.find((q) => q.questionId === questionId);
if (!targetQuestion || targetQuestion.playStatus === '3') {
if (!targetQuestion || targetQuestion.playStatus === '3' || targetQuestion.playStatus === '2') {
// 找不到问题,已经读完的,已经暂停的问题 不操作
return;
} else if (!targetQuestion.needPlay) {
// 不需要读的问题,直接置为已读完
setPlayStatus(questionId, '3');
} else if(targetQuestion.playStatus !== '2'){
} else {
// 还未开始的问题状态为0的,置为1 开始读
setPlayStatus(questionId, '1');
voiceStart(targetQuestion.voice);
voiceStart(targetQuestion);
}
};
......@@ -474,8 +477,8 @@ export default function(props) {
if (targetQuestion.needCheck) {
// stop and wait check
setPlayStatus(questionId, '3');
// console.log('need you check');
setPlayStatus(questionId, '3');
return;
} else {
setPlayStatusAndChecked(questionId, '3', true);
......@@ -526,9 +529,9 @@ export default function(props) {
};
// 调用app的语音播报,监听语音结束,在刚进入页面时自动调用一次,每一个问题结束后判断是否自动调用
const voiceStart = (voiceContent) => {
const voiceStart = (targetQuestion) => {
setIsPlaying('Y');
console.log(`播放: ${voiceContent}`);
console.log(`播放: ${targetQuestion.voice}`);
// setTimeout(() => {
// console.log('finish one voice');
......@@ -539,11 +542,18 @@ export default function(props) {
alert('window.webkit 未定义');
return;
}
window.webkit.messageHandlers.aiaVoiceBroadCastContent.postMessage({ content: voiceContent });
window.webkit.messageHandlers.aiaVoiceBroadCastContent.postMessage({
content: targetQuestion.voice
});
window.aiaVoiceFinish = () => {
console.log('finish one step');
setIsPlaying('N');
// 如果当前问题需要手动勾选,则将isPlaying置为 N ,如果不需要手动勾选,则马上要读下一个问题,故不改变isPlaying
if (targetQuestion.needCheck) {
setIsPlaying('N');
}
finishOneVoice();
};
};
......@@ -642,8 +652,13 @@ export default function(props) {
const currentStepIdx = steps.findIndex((s) => s.id === stepId);
const lastStepId = steps[currentStepIdx - 1].id;
voicePause();
setPlayStatus(questionId, '2');
const currentQuestion = currentStep.questions.find((q) => q.questionId === questionId);
if (currentQuestion.playStatus === '1') {
// 1 正在读的-暂停; 2 已暂停的-不操作;3 已读完的-不操作
voicePause();
setPlayStatus(questionId, '2');
}
setStepId(lastStepId);
setQuestionId(findLastUnreadQuestion(lastStepId));
}
......@@ -715,7 +730,6 @@ export default function(props) {
question={q}
setPlayStatus={setPlayStatus}
setChecked={setCheckThenNextQuestion}
voiceStart={voiceStart}
voicePause={voicePause}
voiceContinue={voiceContinue}
/>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment