Commit 831b3396 by zhanghaozhe

题库适配

parent 6da10838
...@@ -10,7 +10,7 @@ class Problems extends Component { ...@@ -10,7 +10,7 @@ class Problems extends Component {
state = { state = {
isShowAnswer: false, isShowAnswer: false,
isShowCaptcha: false, isShowCaptcha: true,
instance: null, instance: null,
problem: {}, problem: {},
} }
...@@ -19,12 +19,35 @@ class Problems extends Component { ...@@ -19,12 +19,35 @@ class Problems extends Component {
this.getProblem() this.getProblem()
} }
getInstance = () => { componentDidUpdate(prevProps, prevState) {
if (prevProps.match.params.id !== this.props.match.params.id) {
this.setState({
problem: {},
});
this.getProblem()
}
} }
switchProblem() {
onVerify = data => {
http.post(`${API.home}/m/safety`, data)
.then(res => {
const {code} = res.data
if (code === 200) {
this.setState({
isShowCaptcha: false,
})
this.getProblem()
} else {
this.state.instance && this.state.instance.reset()
}
})
}
getInstance = (instance) => {
this.setState({
instance,
});
} }
getProblem = () => { getProblem = () => {
...@@ -51,7 +74,7 @@ class Problems extends Component { ...@@ -51,7 +74,7 @@ class Problems extends Component {
render() { render() {
const {isShowAnswer, problem: {quesInfo, between}, isShowCaptcha} = this.state const {isShowAnswer, problem: {quesInfo, between}, isShowCaptcha} = this.state
return ( return (
<article id={'problems'}> quesInfo || isShowCaptcha ? <article id={'problems'}>
{ {
!isShowCaptcha ? !isShowCaptcha ?
<> <>
...@@ -90,10 +113,12 @@ class Problems extends Component { ...@@ -90,10 +113,12 @@ class Problems extends Component {
</footer> </footer>
</> </>
: <div className="captcha-container"> : <div className="captcha-container">
<CaptchaAli getInstance={this.getInstance}/> <div>亲,系统正忙,滑动一下马上回来</div>
<CaptchaAli getInstance={this.getInstance} onVerify={this.onVerify}/>
</div> </div>
} }
</article> </article> : null
); );
} }
} }
......
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
font-size: 16px; font-size: 16px;
color: #333; color: #333;
white-space: pre-wrap; white-space: pre-wrap;
word-break: break-all;
.title { .title {
margin-bottom: 5px; margin-bottom: 5px;
...@@ -95,8 +96,13 @@ ...@@ -95,8 +96,13 @@
.captcha-container{ .captcha-container{
width: 80%; width: 80%;
padding-top: 40%; padding-top: 50%;
margin: 0 auto; margin: 0 auto;
text-align: center;
font-size: 20px;
div:nth-child(1){
margin-bottom: 10px;
}
} }
} }
......
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