Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
addInsured-AIA-POC
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liujianghai
addInsured-AIA-POC
Commits
5ddfb0f0
Commit
5ddfb0f0
authored
Mar 08, 2020
by
marsandheart
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改了切换上一步/下一步时候的继续播放问题
parent
b24b77ec
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
22 deletions
+62
-22
DoubleRecord.jsx
src/pages/DoubleRecord.jsx
+58
-22
InsuredInfo.jsx
src/pages/InsuredInfo.jsx
+4
-0
No files found.
src/pages/DoubleRecord.jsx
View file @
5ddfb0f0
...
...
@@ -13,20 +13,15 @@ import QuestionItem from './DoubleRecord.components/QuestionItem';
const
defaultPdfPath
=
'https://gitee.com/JYWan/JYWeiBo/raw/master/aia_doc-1.pdf'
;
// 调用app的展示PDF方法,合同展示节点使用
const
showPDF
=
(
pdfPath
,
pdfName
)
=>
{
if
(
!
window
.
webkit
)
{
alert
(
'window.webkit 未定义'
);
return
;
}
window
.
webkit
.
messageHandlers
.
aiaPDFPreView
.
postMessage
({
pdfPath
,
pdfName
});
// 为什么这个放在useState里面就不能生效,放在外面就可以生效?useState看来也不能用,后面还是用redux吧
let
isPlaying
=
'N'
;
const
setIsPlaying
=
(
val
)
=>
{
isPlaying
=
val
;
};
// question不一定都是问题,也可能是答案,其实分为需要读/不需要读 和 需要操作/不需要操作
const
defaultSteps
=
[
export
default
function
(
props
)
{
// question不一定都是问题,也可能是答案,其实分为需要读/不需要读 和 需要操作/不需要操作
const
defaultSteps
=
[
{
id
:
'1'
,
label
:
'节点一'
,
...
...
@@ -368,15 +363,14 @@ const defaultSteps = [
}
]
}
];
];
export
default
function
(
props
)
{
const
[
steps
,
updateSteps
]
=
useState
(
defaultSteps
);
const
[
imgSrc1
,
setImgSrc1
]
=
useState
(
''
);
const
[
imgSrc2
,
setImgSrc2
]
=
useState
(
''
);
const
[
stepId
,
setStepId
]
=
useState
(
'1'
);
const
[
questionId
,
setQuestionId
]
=
useState
(
'1'
);
// const [
signVisible, setSignVisible] = useState(false
);
// const [
isPlaying, setIsPlaying] = useState('N'
);
const
currentStep
=
steps
.
find
((
s
)
=>
s
.
id
===
stepId
);
...
...
@@ -395,7 +389,7 @@ export default function(props) {
return
;
}
else
if
(
!
targetQuestion
.
needPlay
)
{
setPlayStatus
(
questionId
,
'3'
);
}
else
{
}
else
if
(
targetQuestion
.
playStatus
!==
'2'
)
{
setPlayStatus
(
questionId
,
'1'
);
voiceStart
(
targetQuestion
.
voice
);
}
...
...
@@ -515,8 +509,25 @@ export default function(props) {
setQuestionId
(
nextQuestionId
);
// 设置完之后触发useEffect,由useEffect调用app的朗读
};
// 调用app的展示PDF方法,合同展示节点使用
const
showPDF
=
(
pdfPath
,
pdfName
)
=>
{
console
.
log
(
'show pdf'
);
if
(
isPlaying
===
'Y'
)
{
return
;
}
if
(
!
window
.
webkit
)
{
alert
(
'window.webkit 未定义'
);
return
;
}
window
.
webkit
.
messageHandlers
.
aiaPDFPreView
.
postMessage
({
pdfPath
,
pdfName
});
};
// 调用app的语音播报,监听语音结束,在刚进入页面时自动调用一次,每一个问题结束后判断是否自动调用
const
voiceStart
=
(
voiceContent
)
=>
{
setIsPlaying
(
'Y'
);
console
.
log
(
`播放:
${
voiceContent
}
`
);
// setTimeout(() => {
...
...
@@ -532,6 +543,7 @@ export default function(props) {
window
.
aiaVoiceFinish
=
()
=>
{
console
.
log
(
'finish one step'
);
setIsPlaying
(
'N'
);
finishOneVoice
();
};
};
...
...
@@ -559,6 +571,7 @@ export default function(props) {
// 调用app的语音停止,在跳转、翻页的时候调用,避免翻页后继续播放
const
voiceStop
=
()
=>
{
console
.
log
(
'停止播放'
);
setIsPlaying
(
'N'
);
if
(
!
window
.
webkit
)
{
alert
(
'window.webkit 未定义'
);
return
;
...
...
@@ -605,18 +618,34 @@ export default function(props) {
// );
};
// 查找最后一个未读的问题,用于跳转上一步、下一步之后回到刚才的问题。
const
findLastUnreadQuestion
=
(
sId
)
=>
{
const
questions
=
steps
.
find
((
s
)
=>
s
.
id
===
sId
).
questions
;
const
len
=
questions
.
length
;
let
questionId
=
''
;
for
(
let
i
=
0
;
i
<
len
;
i
++
)
{
questionId
=
questions
[
i
].
questionId
;
if
(
!
questions
[
i
].
checked
)
{
break
;
}
}
return
questionId
;
};
// 上一个节点,如果是第一节点则回到上一页
const
lastStep
=
()
=>
{
setPlayStatus
(
questionId
,
'3'
);
voiceStop
();
if
(
stepId
===
'1'
)
{
voiceStop
();
setPlayStatus
(
questionId
,
'3'
);
window
.
history
.
go
(
-
1
);
}
else
{
const
currentStepIdx
=
steps
.
findIndex
((
s
)
=>
s
.
id
===
stepId
);
const
lastStepId
=
steps
[
currentStepIdx
-
1
].
id
;
voicePause
();
setPlayStatus
(
questionId
,
'2'
);
setStepId
(
lastStepId
);
setQuestionId
(
'1'
);
setQuestionId
(
findLastUnreadQuestion
(
lastStepId
)
);
}
};
...
...
@@ -627,7 +656,7 @@ export default function(props) {
return
;
}
setPlayStatus
(
questionId
,
'3'
);
voiceStop
();
//
voiceStop();
if
(
stepId
===
7
)
{
// setSignVisible(true);
return
;
...
...
@@ -636,7 +665,7 @@ export default function(props) {
const
nextStepId
=
steps
[
currentStepIdx
+
1
].
id
;
setStepId
(
nextStepId
);
setQuestionId
(
'1'
);
setQuestionId
(
findLastUnreadQuestion
(
nextStepId
)
);
}
};
...
...
@@ -649,7 +678,14 @@ export default function(props) {
return
(
<
div
className=
{
styles
.
page
}
>
<
div
className=
{
styles
.
header
}
>
<
img
src=
{
Logo
}
alt=
"logo"
className=
{
styles
.
aiaLogo
}
></
img
>
<
img
src=
{
Logo
}
alt=
"logo"
className=
{
styles
.
aiaLogo
}
onClick=
{
()
=>
{
console
.
log
(
JSON
.
stringify
({
stepId
,
questionId
,
isPlaying
}));
}
}
></
img
>
<
div
>
双录指引
</
div
>
<
div
className=
{
styles
.
homeIcon
}
>
<
img
src=
{
IconHome
}
alt=
"logo"
></
img
>
...
...
src/pages/InsuredInfo.jsx
View file @
5ddfb0f0
...
...
@@ -98,6 +98,10 @@ const InsuredInfo = (props) => {
};
const
removeTableData
=
async
(
key
)
=>
{
if
(
key
===
'1'
)
{
return
;
}
showLoading
();
await
sleep
(
500
);
hideLoading
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment