Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mr-julyedu
Overview
Overview
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
baiguangyao
mr-julyedu
Commits
02a8e5d8
Commit
02a8e5d8
authored
Jun 10, 2020
by
zhanghaozhe
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'ai-test' into dev
parents
ed16e36e
1299fa3c
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
12 deletions
+32
-12
src/components/ai-test/assist/index.js
+30
-10
src/components/ai-test/assist/index.scss
+2
-2
No files found.
src/components/ai-test/assist/index.js
View file @
02a8e5d8
...
...
@@ -2,26 +2,32 @@ import React, { Component } from 'react';
import
'./index.scss'
import
{
HeaderBar
}
from
"@common/index"
import
Question
from
"@components/ai-test/common/question"
import
{
html
,
http
}
from
"@/utils"
import
{
html
,
http
,
browser
}
from
"@/utils"
import
{
Toast
}
from
"antd-mobile"
;
import
{
Link
}
from
"react-router-dom"
;
import
{
connect
}
from
"react-redux"
;
import
Recommends
from
"@components/ai-test/common/recommends"
import
classnames
from
'classnames'
import
storage
from
'store2'
class
Assist
extends
Component
{
store
=
storage
.
namespace
(
'aiTestAssist'
)
state
=
{
question
:
null
,
answer
:
{}
,
question
:
this
.
store
.
session
.
get
(
'question'
)
,
answer
:
this
.
store
.
session
.
get
(
'answer'
)
,
result
:
null
,
rightAnswer
:
''
,
userAnswer
:
''
,
}
componentDidMount
()
{
if
(
!
this
.
store
.
session
.
get
(
'question'
))
{
this
.
getData
()
}
}
getData
=
()
=>
{
http
.
get
(
`
${
API
.
home
}
/sys/aitest/assist`
)
...
...
@@ -29,8 +35,10 @@ class Assist extends Component {
const
{
code
,
msg
,
data
}
=
res
.
data
if
(
code
===
200
)
{
const
answer
=
{
[
data
.
id
]:
undefined
,
[
data
.
id
]:
0
,
}
this
.
store
.
session
.
set
(
'question'
,
data
)
this
.
store
.
session
.
set
(
'answer'
,
answer
)
this
.
setState
({
question
:
data
,
answer
,
...
...
@@ -52,7 +60,11 @@ class Assist extends Component {
submit
=
()
=>
{
const
{
history
,
user
}
=
this
.
props
if
(
user
.
hasError
)
{
if
(
browser
.
isWeixin
)
{
window
.
location
.
href
=
`https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx23dac6775ac82877&redirect_uri=
${
encodeURIComponent
(
`
${
window
.
location
.
origin
}${
location
.
pathname
}
?aa=bb`
)}
&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect`
}
else
{
history
.
push
(
'/passport'
)
}
return
}
const
{
question
,
answer
}
=
this
.
state
...
...
@@ -66,11 +78,17 @@ class Assist extends Component {
answer_id
:
answer
[
question
.
id
],
}).
then
(
res
=>
{
const
{
code
,
msg
,
data
}
=
res
.
data
if
(
answer
[
question
.
id
]
===
data
.
correct_answer
)
{
Toast
.
info
(
'回答正确'
,
2
,
null
,
false
)
}
else
{
Toast
.
info
(
'回答错误'
,
2
,
null
,
false
)
}
this
.
setAnswer
(
data
.
correct_answer
)
if
(
code
===
200
)
{
this
.
setState
({
result
:
data
,
});
this
.
store
.
session
.
clearAll
()
}
else
{
Toast
.
fail
(
msg
,
2
,
null
,
false
)
}
...
...
@@ -127,24 +145,26 @@ class Assist extends Component {
{
result
&&
question
.
commend_course
&&
question
.
commend_course
.
length
&&
<>
<
Recommends
recommends
=
{
question
.
commend_course
}
/
>
<
div
className
=
{
classnames
([
'status'
,
{
<
/
>
}
<
div
className
=
"btns"
>
{
result
&&
<
div
className
=
{
classnames
([
'status'
,
{
end
:
result
.
status
===
6
,
success
:
result
.
status
===
1
,
error
:
result
.
status
===
2
||
result
.
status
===
3
||
result
.
status
===
4
||
result
.
status
===
5
,
}])}
>
{
result
.
desc
}
<
/div
>
<
/
>
}
<
div
className
=
"btns"
>
{
!
result
&&
<
button
className
=
{
'submit'
}
onClick
=
{
this
.
submit
}
>
提交
<
/button
>
}
{
result
&&
(
result
.
status
===
6
?
<
Link
to
=
{
'/'
}
class
=
{
'home'
}
>
返回首页
<
/Link
>
:
<
Link
to
=
{
'/ai-test/scores'
}
class
=
{
'test'
}
>
我也要测试
<
/Link>
)
?
<
Link
to
=
{
'/'
}
class
Name
=
{
'home'
}
>
返回首页
<
/Link
>
:
<
Link
to
=
{
'/ai-test/scores'
}
class
Name
=
{
'test'
}
>
我也要测试
<
/Link>
)
}
<
/div
>
<
/div
>
...
...
src/components/ai-test/assist/index.scss
View file @
02a8e5d8
...
...
@@ -16,7 +16,7 @@
bottom
:
0
;
left
:
0
;
width
:
100%
;
height
:
60px
;
//
height: 60px;
padding
:
10px
;
background-color
:
#fff
;
box-shadow
:
0
0
5px
0
rgba
(
0
,
0
,
0
,
0
.05
);
...
...
@@ -26,7 +26,7 @@
color
:
#fff
;
font-size
:
18px
;
width
:
100%
;
height
:
100%
;
height
:
40px
;
border
:
0
;
outline
:
0
;
-webkit-appearance
:
none
;
...
...
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