|
@@ -1,5 +1,6 @@
|
|
|
import React, { useState } from 'react'
|
|
|
-import { Steps } from 'tdesign-react'
|
|
|
+import { Steps, Button } from 'tdesign-react'
|
|
|
+import { useNavigate } from 'react-router-dom'
|
|
|
import MeasurementStep from '../../components/Steps/MeasurementStep'
|
|
|
import '../../assets/css/talking.css'
|
|
|
|
|
@@ -23,36 +24,56 @@ const problems = [
|
|
|
export default function Talking() {
|
|
|
const [count, setCount] = useState(0);
|
|
|
|
|
|
+ const navigate = useNavigate()
|
|
|
+
|
|
|
const changeProblems = (type) => {
|
|
|
- console.log(type);
|
|
|
- if (type == 'add') {
|
|
|
+ if (count < problems.length && type == 'add') {
|
|
|
setCount(count + 1)
|
|
|
- } else {
|
|
|
+ } else if (count > 0 && type == 'reduce') {
|
|
|
setCount(count - 1)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- return (
|
|
|
- <>
|
|
|
+ let pro = problems[count];
|
|
|
+
|
|
|
+ if (count == problems.length) { // 答完题了
|
|
|
+ return (
|
|
|
<div style={{ padding: '10px 20px' }}>
|
|
|
<MeasurementStep current={0} />
|
|
|
- <div className='question-box'>
|
|
|
- <p>Count: {count}</p>
|
|
|
- <h3>{problems[count] ? problems[count].ques : ''}?</h3>
|
|
|
- <div className='question-option'>
|
|
|
- 111
|
|
|
- {problems[0].options.map((tag, index) => (
|
|
|
- <span key={index} onClick={changeProblems('add')}>{tag}</span>
|
|
|
- ))}
|
|
|
- </div>
|
|
|
- </div>
|
|
|
|
|
|
- <div className='question-bar'>
|
|
|
- <span onClick={() => setCount(count - 1)}>上一题</span>
|
|
|
- <span>1/3</span>
|
|
|
- <span onClick={() => setCount(count + 1)}>下一题</span>
|
|
|
- </div>
|
|
|
+ <div className='question-box question-result'>这是测试结果</div>
|
|
|
+
|
|
|
+ <Button block variant="base" style={{ width: '30%', margin: '40px auto' }}
|
|
|
+ onClick={() => {
|
|
|
+ navigate('/diagnosis_m', {
|
|
|
+ replace: true
|
|
|
+ })
|
|
|
+ }}
|
|
|
+ > 下一步 </Button>
|
|
|
</div>
|
|
|
- </>
|
|
|
- )
|
|
|
+ )
|
|
|
+ } else {
|
|
|
+ return (
|
|
|
+ <>
|
|
|
+ <div style={{ padding: '10px 20px' }}>
|
|
|
+ <MeasurementStep current={0} />
|
|
|
+
|
|
|
+ <div className='question-box'>
|
|
|
+ <h3>{pro.ques}?</h3>
|
|
|
+ <div className='question-option'>
|
|
|
+ {problems[count].options.map((tag, index) => (
|
|
|
+ <span key={index} onClick={() => changeProblems('add')}>{tag}</span>
|
|
|
+ ))}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div className='question-bar'>
|
|
|
+ <span onClick={() => changeProblems('reduce')}>上一题</span>
|
|
|
+ <span>{count + 1}/{problems.length}</span>
|
|
|
+ <span></span>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </>
|
|
|
+ )
|
|
|
+ }
|
|
|
}
|