Commit cb5df2e7 authored by marsandheart's avatar marsandheart

fix issue 1,2

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