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
3a9818db
Commit
3a9818db
authored
May 29, 2020
by
zhanghaozhe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ml小程序
parent
68a1d7c8
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
79 additions
and
21 deletions
+79
-21
src/App.js
+3
-0
src/components/interactive-tutorial/index.js
+38
-13
src/components/interactive-tutorial/single-answer-question/index.js
+24
-8
src/components/interactive-tutorial/terminal/index.js
+1
-0
src/utils/index.js
+13
-0
No files found.
src/App.js
View file @
3a9818db
...
@@ -360,6 +360,9 @@ class App extends Component {
...
@@ -360,6 +360,9 @@ class App extends Component {
alt
=
""
/>
alt
=
""
/>
<
/div
>
<
/div
>
}
}
{
/*
//todo 删
*/
}
<
div
style
=
{{
backgroundColor
:
'#fff'
,
color
:
'#000'
,
position
:
'fixed'
,
bottom
:
'50px'
,
left
:
'0'
}}
>
<
div
style
=
{{
backgroundColor
:
'#fff'
,
color
:
'#000'
,
position
:
'fixed'
,
bottom
:
'50px'
,
left
:
'0'
}}
>
<
Link
to
=
{
'/interactive-tutorial?id=200'
}
>
编辑器
<
/Link
>
<
Link
to
=
{
'/interactive-tutorial?id=200'
}
>
编辑器
<
/Link
>
<
/div
>
<
/div
>
...
...
src/components/interactive-tutorial/index.js
View file @
3a9818db
...
@@ -4,7 +4,7 @@ import Container from './container'
...
@@ -4,7 +4,7 @@ import Container from './container'
import
SingleAnswerQuestion
from
"@components/interactive-tutorial/single-answer-question"
import
SingleAnswerQuestion
from
"@components/interactive-tutorial/single-answer-question"
import
Program
from
"@components/interactive-tutorial/program"
import
Program
from
"@components/interactive-tutorial/program"
import
Project
from
'./project'
import
Project
from
'./project'
import
{
getParam
,
http
,
getWXObject
}
from
"@/utils"
import
{
getParam
,
http
,
getWXObject
,
isValidHttpUrl
}
from
"@/utils"
import
{
Toast
}
from
'antd-mobile'
import
{
Toast
}
from
'antd-mobile'
import
{
questionType
,
status
}
from
'./consts'
import
{
questionType
,
status
}
from
'./consts'
import
Catalog
from
'./catalog'
import
Catalog
from
'./catalog'
...
@@ -65,6 +65,8 @@ class InteractiveStudy extends Component {
...
@@ -65,6 +65,8 @@ class InteractiveStudy extends Component {
resetProcessStatus
=
()
=>
{
resetProcessStatus
=
()
=>
{
this
.
setState
({
this
.
setState
({
processStatus
:
status
.
resumePractice
,
processStatus
:
status
.
resumePractice
,
},
()
=>
{
// console.log(this.state.processStatus)
})
})
}
}
...
@@ -99,7 +101,7 @@ class InteractiveStudy extends Component {
...
@@ -99,7 +101,7 @@ class InteractiveStudy extends Component {
cachedList
:
state
.
cachedList
.
reverse
().
concat
(
list
.
slice
(
progress
)).
reverse
(),
cachedList
:
state
.
cachedList
.
reverse
().
concat
(
list
.
slice
(
progress
)).
reverse
(),
page
:
state
.
page
+
1
,
page
:
state
.
page
+
1
,
pageData
:
data
,
pageData
:
data
,
progress
:
progress
,
progress
,
}
}
},
()
=>
{
},
()
=>
{
cb
&&
cb
()
cb
&&
cb
()
...
@@ -115,7 +117,7 @@ class InteractiveStudy extends Component {
...
@@ -115,7 +117,7 @@ class InteractiveStudy extends Component {
if
(
unitInfoId
)
{
if
(
unitInfoId
)
{
data
.
unit_info_id
=
unitInfoId
data
.
unit_info_id
=
unitInfoId
}
}
http
.
post
(
`/m/it/user/saveSchedule`
,
data
).
then
(
res
=>
{
http
.
post
(
`
${
API
.
home
}
/m/it/user/saveSchedule`
,
data
).
then
(
res
=>
{
const
{
code
,
msg
,
data
}
=
res
.
data
const
{
code
,
msg
,
data
}
=
res
.
data
if
(
code
===
200
)
{
if
(
code
===
200
)
{
...
@@ -125,9 +127,9 @@ class InteractiveStudy extends Component {
...
@@ -125,9 +127,9 @@ class InteractiveStudy extends Component {
})
})
}
}
savePractice
=
({
syllabus
I
d
,
type
,
answer
,
result
,
lines
})
=>
{
savePractice
=
({
syllabus
_i
d
,
type
,
answer
,
result
,
lines
})
=>
{
let
data
=
{
let
data
=
{
syllabus_id
:
syllabusId
,
syllabus_id
,
type
,
type
,
answer
,
answer
,
result
,
result
,
...
@@ -145,8 +147,10 @@ class InteractiveStudy extends Component {
...
@@ -145,8 +147,10 @@ class InteractiveStudy extends Component {
})
})
}
}
process
=
()
=>
{
process
=
()
=>
{
const
{
processStatus
}
=
this
.
state
const
{
processStatus
}
=
this
.
state
const
processContent
=
this
.
state
.
processContent
.
slice
()
if
(
processStatus
===
status
.
practicingProgram
||
processStatus
===
status
.
practicingSingle
)
{
if
(
processStatus
===
status
.
practicingProgram
||
processStatus
===
status
.
practicingSingle
)
{
this
.
showToast
(
'有其他正在进行的练习'
)
this
.
showToast
(
'有其他正在进行的练习'
)
return
return
...
@@ -156,11 +160,11 @@ class InteractiveStudy extends Component {
...
@@ -156,11 +160,11 @@ class InteractiveStudy extends Component {
return
return
}
}
this
.
setState
(
state
=>
{
this
.
setState
(
state
=>
{
let
nextQuestion
,
cachedList
=
state
.
cachedList
,
pageData
=
state
.
pageData
let
nextQuestion
,
cachedList
=
state
.
cachedList
,
pageData
=
state
.
pageData
,
processStatus
const
length
=
cachedList
.
length
const
length
=
cachedList
.
length
if
(
length
)
{
if
(
length
)
{
nextQuestion
=
[
cachedList
.
pop
()]
nextQuestion
=
cachedList
.
pop
()
if
(
length
<
6
)
{
if
(
length
<
3
)
{
this
.
getPageContent
(
state
.
videoId
)
this
.
getPageContent
(
state
.
videoId
)
}
}
}
}
...
@@ -169,23 +173,35 @@ class InteractiveStudy extends Component {
...
@@ -169,23 +173,35 @@ class InteractiveStudy extends Component {
processStatus
:
status
.
nextSection
,
processStatus
:
status
.
nextSection
,
}
}
}
}
let
processStatus
=
nextQuestion
[
0
]
.
type
===
questionType
.
singleAnswer
processStatus
=
nextQuestion
.
type
===
questionType
.
singleAnswer
?
status
.
practicingSingle
?
status
.
practicingSingle
:
nextQuestion
[
0
]
.
type
===
questionType
.
program
:
nextQuestion
.
type
===
questionType
.
program
?
status
.
practicingProgram
?
status
.
practicingProgram
:
status
.
resumePractice
:
status
.
resumePractice
if
(
!
nextQuestion
.
syllabus_id
)
{
nextQuestion
.
syllabus_id
=
state
.
processContent
[
state
.
processContent
.
length
-
1
].
syllabus_id
}
return
{
return
{
processContent
:
state
.
processContent
.
concat
(
nextQuestion
),
processContent
:
processContent
.
concat
([
nextQuestion
]
),
processStatus
,
processStatus
,
isProgramShowed
:
processStatus
===
status
.
practicingProgram
&&
(
state
.
isProgramShowed
+
1
),
isProgramShowed
:
processStatus
===
status
.
practicingProgram
&&
(
state
.
isProgramShowed
+
1
),
cachedList
,
cachedList
,
pageData
,
pageData
,
}
}
},
()
=>
{
},
()
=>
{
const
{
processContent
}
=
this
.
state
const
latestItem
=
processContent
[
processContent
.
length
-
1
]
this
.
saveSchedule
(
latestItem
.
syllabus_id
,
latestItem
.
info_id
)
this
.
updatePosition
()
this
.
updatePosition
()
})
})
}
}
addCache
=
(
ques
)
=>
{
this
.
setState
(
state
=>
({
cachedList
:
state
.
cachedList
.
concat
(
ques
),
}))
}
render
()
{
render
()
{
const
{
processStatus
,
processContent
,
avatar
,
isProgramShowed
}
=
this
.
state
const
{
processStatus
,
processContent
,
avatar
,
isProgramShowed
}
=
this
.
state
return
(
return
(
...
@@ -202,8 +218,10 @@ class InteractiveStudy extends Component {
...
@@ -202,8 +218,10 @@ class InteractiveStudy extends Component {
<
/Container
>
<
/Container
>
case
questionType
.
singleAnswer
:
case
questionType
.
singleAnswer
:
return
<
SingleAnswerQuestion
user
=
{
avatar
}
topic
=
{
item
.
content
}
question
=
{
item
}
return
<
SingleAnswerQuestion
user
=
{
avatar
}
topic
=
{
item
.
content
}
question
=
{
item
}
key
=
{
item
.
syllabus_id
}
updatePosition
=
{
this
.
updatePosition
}
key
=
{
item
.
syllabus_id
}
resetStatus
=
{
this
.
resetProcessStatus
}
/
>
updatePosition
=
{
this
.
updatePosition
}
resetStatus
=
{
this
.
resetProcessStatus
}
saveSchedule
=
{
this
.
saveSchedule
}
addCache
=
{
this
.
addCache
}
savePractice
=
{
this
.
savePractice
}
/
>
case
questionType
.
codeBlock
:
case
questionType
.
codeBlock
:
case
questionType
.
program
:
case
questionType
.
program
:
return
<
Program
question
=
{
item
}
key
=
{
item
.
syllabus_id
}
isProgramShowed
=
{
isProgramShowed
}
/
>
return
<
Program
question
=
{
item
}
key
=
{
item
.
syllabus_id
}
isProgramShowed
=
{
isProgramShowed
}
/
>
...
@@ -211,6 +229,13 @@ class InteractiveStudy extends Component {
...
@@ -211,6 +229,13 @@ class InteractiveStudy extends Component {
}
else
if
(
item
.
catalogue
===
2
)
{
}
else
if
(
item
.
catalogue
===
2
)
{
return
<
Catalog
title
=
{
item
.
content
}
key
=
{
item
.
syllabus_id
}
/
>
return
<
Catalog
title
=
{
item
.
content
}
key
=
{
item
.
syllabus_id
}
/
>
}
else
{
}
else
{
if
(
item
.
info_id
)
{
if
(
isValidHttpUrl
(
item
.
content
))
{
return
<
Container
key
=
{
item
.
info_id
}
><
img
src
=
{
item
.
content
}
alt
=
""
onLoad
=
{
this
.
updatePosition
}
/></
Container
>
}
return
<
Container
key
=
{
item
.
info_id
}
content
=
{
item
.
content
}
/
>
}
return
<
Container
key
=
{
item
.
syllabus_id
}
>
return
<
Container
key
=
{
item
.
syllabus_id
}
>
<
span
className
=
{
'subtitle'
}
>
{
item
.
content
}
<
/span
>
<
span
className
=
{
'subtitle'
}
>
{
item
.
content
}
<
/span
>
<
/Container
>
<
/Container
>
...
...
src/components/interactive-tutorial/single-answer-question/index.js
View file @
3a9818db
...
@@ -2,7 +2,7 @@ import React, { Component } from 'react';
...
@@ -2,7 +2,7 @@ import React, { Component } from 'react';
import
'./index.scss'
import
'./index.scss'
import
Container
from
'../container'
import
Container
from
'../container'
import
classnames
from
'classnames'
import
classnames
from
'classnames'
import
{
html
}
from
"@/utils"
import
{
html
,
isValidHttpUrl
}
from
"@/utils"
class
SingleAnswerQuestion
extends
Component
{
class
SingleAnswerQuestion
extends
Component
{
...
@@ -11,7 +11,7 @@ class SingleAnswerQuestion extends Component {
...
@@ -11,7 +11,7 @@ class SingleAnswerQuestion extends Component {
state
=
{
state
=
{
correct
:
''
,
correct
:
''
,
wrong
:
''
,
wrong
:
''
,
replies
:
[]
,
replies
:
''
,
selectable
:
false
,
selectable
:
false
,
}
}
...
@@ -20,16 +20,25 @@ class SingleAnswerQuestion extends Component {
...
@@ -20,16 +20,25 @@ class SingleAnswerQuestion extends Component {
return
return
}
}
const
{
question
:
{
unit_questions
},
updatePosition
,
resetStatus
}
=
this
.
props
const
{
question
:
{
unit_questions
,
type
,
syllabus_id
},
updatePosition
,
resetStatus
,
saveSchedule
,
addCache
,
savePractice
}
=
this
.
props
const
userSelect
=
unit_questions
[
index
]
const
userSelect
=
unit_questions
[
index
]
const
isCorrect
=
userSelect
.
is_ans
this
.
setState
({
this
.
setState
({
wrong
:
userSelect
.
is_ans
?
''
:
index
,
wrong
:
isCorrect
?
''
:
index
,
correct
:
userSelect
.
is_ans
?
index
:
''
,
correct
:
isCorrect
?
index
:
''
,
replies
:
info
,
replies
:
info
.
slice
(
0
,
1
)
,
selectable
:
false
,
selectable
:
false
,
},
()
=>
{
},
()
=>
{
updatePosition
()
updatePosition
()
resetStatus
()
resetStatus
()
addCache
(
info
.
slice
(
1
))
savePractice
({
type
:
1
,
syllabus_id
:
syllabus_id
,
answer
:
unit_questions
[
index
].
unit_id
,
result
:
isCorrect
,
})
saveSchedule
(
syllabus_id
,
info
[
0
].
info_id
)
})
})
}
}
...
@@ -55,7 +64,7 @@ class SingleAnswerQuestion extends Component {
...
@@ -55,7 +64,7 @@ class SingleAnswerQuestion extends Component {
render
()
{
render
()
{
const
{
correct
,
wrong
,
replies
}
=
this
.
state
const
{
correct
,
wrong
,
replies
}
=
this
.
state
const
{
user
,
topic
,
img
,
question
:
{
unit_questions
:
options
}}
=
this
.
props
const
{
user
,
topic
,
img
,
question
:
{
unit_questions
:
options
}
,
updatePosition
}
=
this
.
props
return
(
return
(
<>
<>
<
Container
<
Container
...
@@ -78,7 +87,14 @@ class SingleAnswerQuestion extends Component {
...
@@ -78,7 +87,14 @@ class SingleAnswerQuestion extends Component {
}
}
/
>
/
>
{
{
!!
replies
.
length
&&
replies
.
map
(
item
=>
<
Container
key
=
{
item
.
info_id
}
content
=
{
item
.
content
}
/>
)
!!
replies
.
length
&&
replies
.
map
(
item
=>
{
if
(
isValidHttpUrl
(
item
.
content
))
{
return
<
Container
key
=
{
item
.
info_id
}
>
<
img
src
=
{
item
.
content
}
alt
=
""
onLoad
=
{
updatePosition
}
/
>
<
/Container
>
}
return
<
Container
content
=
{
item
.
content
}
key
=
{
item
.
info_id
}
/
>
})
}
}
<
/
>
<
/
>
);
);
...
...
src/components/interactive-tutorial/terminal/index.js
View file @
3a9818db
...
@@ -45,6 +45,7 @@ class TerminalInterface extends Component {
...
@@ -45,6 +45,7 @@ class TerminalInterface extends Component {
}
}
getAuthenticationData
=
()
=>
{
getAuthenticationData
=
()
=>
{
// axios.post(`https://fwjizuub9f1tqlcb.julyedu.com`, {
axios
.
post
(
`http://47.93.119.175:8888/auth`
,
{
axios
.
post
(
`http://47.93.119.175:8888/auth`
,
{
username
:
'3guh394h3fhj0f4'
,
username
:
'3guh394h3fhj0f4'
,
password
:
'okqdw029j038hrv3890cv'
,
password
:
'okqdw029j038hrv3890cv'
,
...
...
src/utils/index.js
View file @
3a9818db
...
@@ -85,6 +85,18 @@ function validateEmail(email) {
...
@@ -85,6 +85,18 @@ function validateEmail(email) {
return
re
.
test
(
String
(
email
).
toLowerCase
());
return
re
.
test
(
String
(
email
).
toLowerCase
());
}
}
function
isValidHttpUrl
(
str
)
{
let
url
;
try
{
url
=
new
URL
(
str
);
}
catch
(
err
)
{
return
false
;
}
return
url
.
protocol
===
"http:"
||
url
.
protocol
===
"https:"
;
}
const
browser
=
(
function
()
{
const
browser
=
(
function
()
{
const
ua
=
navigator
.
userAgent
const
ua
=
navigator
.
userAgent
return
{
return
{
...
@@ -132,6 +144,7 @@ export {
...
@@ -132,6 +144,7 @@ export {
browser
,
browser
,
isLogin
,
isLogin
,
dateCountDown
,
dateCountDown
,
isValidHttpUrl
}
}
export
{
export
{
default
as
SendMessageToApp
,
default
as
SendMessageToApp
,
...
...
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