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
dbfb701d
Commit
dbfb701d
authored
May 29, 2019
by
zhanghaozhe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
study redux
parent
437fc544
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
52 additions
and
73 deletions
+52
-73
src/components/study/myCourses/actions.js
+14
-1
src/components/study/myCourses/index.js
+13
-61
src/components/study/myCourses/my-courses.scss
+7
-7
src/components/study/myCourses/reducers.js
+17
-4
src/components/study/study.scss
+1
-0
No files found.
src/components/study/myCourses/actions.js
View file @
dbfb701d
import
{
api
}
from
'@/utils'
import
{
api
}
from
'@/utils'
export
const
RECEIVE_MY_COURSES
=
'RECEIVE_MY_COURSES'
export
const
RECEIVE_MY_COURSES
=
'RECEIVE_MY_COURSES'
export
const
receiveMyCourses
=
payload
=>
({
export
const
receiveMyCourses
=
payload
=>
({
type
:
RECEIVE_MY_COURSES
,
type
:
RECEIVE_MY_COURSES
,
...
@@ -14,6 +15,18 @@ export const getMyCourses = payload => dispatch => {
...
@@ -14,6 +15,18 @@ export const getMyCourses = payload => dispatch => {
})
})
}
}
const
fetchCoursesListIfNeeded
=
payload
=>
{
const
NUM_INTERVAL
=
10
export
const
fetchCoursesListIfNeeded
=
payload
=>
(
dispatch
,
getState
)
=>
{
const
{
shouldFetch
,
currentPage
,
currentNum
}
=
getState
().
myCourses
if
(
!
shouldFetch
){
dispatch
(
getMyCourses
)
}
}
}
export
const
INVALIDATE_COURSEDATA
=
'INVALIDATE_COURSEDATA'
export
const
invalidateCourseDate
=
()
=>
({
type
:
INVALIDATE_COURSEDATA
})
src/components/study/myCourses/index.js
View file @
dbfb701d
import
React
,
{
PureComponent
}
from
"react"
import
React
,
{
PureComponent
}
from
"react"
import
{
VList
}
from
'
../../..
/common'
import
{
VList
}
from
'
@
/common'
import
'./my-courses.scss'
import
'./my-courses.scss'
import
{
api
}
from
'@/utils'
import
{
isToday
,
format
}
from
"date-fns"
import
{
isToday
,
format
}
from
"date-fns"
import
{
connect
}
from
"react-redux"
import
{
connect
}
from
"react-redux"
import
{
getMyCourses
}
from
"./actions"
import
{
getMyCourses
}
from
"./actions"
const
mockData
=
[
{
title
:
'三月面试求职班'
,
imgUrl
:
'https://julyedu-img-public.oss-cn-beijing.aliyuncs.com/Public/Image/4c5ccac604.jpg'
,
contact
:
'QQ群:449141326'
,
time
:
'03月12日'
,
record
:
'学习到第2课2分33秒'
},
{
title
:
'三月面试求职班'
,
imgUrl
:
'https://julyedu-img-public.oss-cn-beijing.aliyuncs.com/Public/Image/4c5ccac604.jpg'
,
contact
:
'QQ群:449141326'
,
time
:
'03月12日'
,
record
:
'学习到第2课2分33秒'
},
{
title
:
'三月面试求职班'
,
imgUrl
:
'https://julyedu-img-public.oss-cn-beijing.aliyuncs.com/Public/Image/4c5ccac604.jpg'
,
contact
:
'QQ群:449141326'
,
time
:
'03月12日'
,
record
:
'学习到第2课2分33秒'
},
{
title
:
'三月面试求职班'
,
imgUrl
:
'https://julyedu-img-public.oss-cn-beijing.aliyuncs.com/Public/Image/4c5ccac604.jpg'
,
contact
:
'QQ群:449141326'
,
time
:
'03月12日'
,
record
:
'学习到第2课2分33秒'
},
{
title
:
'三月面试求职班'
,
imgUrl
:
'https://julyedu-img-public.oss-cn-beijing.aliyuncs.com/Public/Image/4c5ccac604.jpg'
,
contact
:
'QQ群:449141326'
,
time
:
'03月12日'
,
record
:
'学习到第2课2分33秒'
},
]
function
getStudyTime
(
seconds
)
{
function
getStudyTime
(
seconds
)
{
return
{
return
{
hour
:
Math
.
floor
(
seconds
/
(
60
*
60
)),
hour
:
Math
.
floor
(
seconds
/
(
60
*
60
)),
...
@@ -93,7 +52,7 @@ function Record({record: {seconds, lesson_name}}) {
...
@@ -93,7 +52,7 @@ function Record({record: {seconds, lesson_name}}) {
class
MyCourses
extends
PureComponent
{
class
MyCourses
extends
PureComponent
{
state
=
{
state
=
{
courseList
:
this
.
props
.
courseList
.
data
addVisible
:
false
}
}
handleClick
=
()
=>
{
handleClick
=
()
=>
{
...
@@ -104,23 +63,11 @@ class MyCourses extends PureComponent {
...
@@ -104,23 +63,11 @@ class MyCourses extends PureComponent {
}
}
componentDidMount
()
{
componentDidMount
()
{
console
.
log
(
this
.
props
.
courseList
)
/*api.get('/m/my_course/1/10')
.then(res => {
if (res.data.code == 200) {
this.setState({
courseList: res.data.data
});
} else {
console.log(res.data.msg)
}
})*/
this
.
props
.
getMyCourses
({
page
:
1
,
num
:
10
});
this
.
props
.
getMyCourses
({
page
:
1
,
num
:
10
});
}
}
render
()
{
render
()
{
let
{
data
}
=
this
.
props
.
courseList
let
{
data
}
=
this
.
props
.
courseData
console
.
log
(
data
)
if
(
data
&&
data
.
length
!==
0
)
{
if
(
data
&&
data
.
length
!==
0
)
{
return
(
return
(
<>
<>
...
@@ -144,19 +91,24 @@ class MyCourses extends PureComponent {
...
@@ -144,19 +91,24 @@ class MyCourses extends PureComponent {
return
(
return
(
<
VList
img
=
{
item
.
image_name
}
<
VList
img
=
{
item
.
image_name
}
handleClick
=
{
this
.
handleClick
}
handleClick
=
{
this
.
handleClick
}
{...
item
}
key
=
{
index
}
{...
item
}
key
=
{
index
}
info
=
{
Info
}
/
>
info
=
{
Info
}
/
>
)
)
})
})
}
}
<
/ul
>
<
/ul
>
{
this
.
state
.
addVisible
?
<
AddCourse
addCourseClick
=
{
this
.
addCourseClick
}
/
>
<
AddCourse
addCourseClick
=
{
this
.
addCourseClick
}
/
>
:
null
}
<
/
>
<
/
>
)
)
}
else
{
}
else
{
return
(
return
(
<
div
className
=
"empty"
>
<
div
className
=
"empty"
>
<
p
><
i
className
=
'iconfont iconfish'
><
/i
></
p
>
<
p
><
i
className
=
'iconfont iconfish'
/
><
/p
>
<
p
className
=
'empty-prompt'
>
还是咸鱼一条,快去翻身
~<
/p
>
<
p
className
=
'empty-prompt'
>
还是咸鱼一条,快去翻身
~<
/p
>
<
p
>
<
p
>
<
button
>
去选课
<
/button
>
<
button
>
去选课
<
/button
>
...
@@ -169,9 +121,9 @@ class MyCourses extends PureComponent {
...
@@ -169,9 +121,9 @@ class MyCourses extends PureComponent {
}
}
const
mapStateToProps
=
state
=>
({
const
mapStateToProps
=
state
=>
({
course
List
:
state
.
myCourses
.
courseList
course
Data
:
state
.
myCourses
.
courseData
})
})
const
mapDispatchToProps
=
{
getMyCourses
}
const
mapDispatchToProps
=
{
getMyCourses
}
export
default
connect
(
mapStateToProps
,
mapDispatchToProps
)(
MyCourses
)
export
default
connect
(
mapStateToProps
,
mapDispatchToProps
)(
MyCourses
)
\ No newline at end of file
\ No newline at end of file
src/components/study/myCourses/my-courses.scss
View file @
dbfb701d
.info
{
.info
{
display
:
flex
;
display
:
flex
;
//flex-flow: column wrap;
//justify-content: space-between;
flex-wrap
:
wrap
;
flex-wrap
:
wrap
;
width
:
55%
;
width
:
55%
;
...
@@ -56,6 +54,7 @@
...
@@ -56,6 +54,7 @@
align-items
:
center
;
align-items
:
center
;
padding-top
:
140px
;
padding-top
:
140px
;
background
:
$bg_f5f5f5
;
background
:
$bg_f5f5f5
;
.iconfish
{
.iconfish
{
width
:
20px
;
width
:
20px
;
height
:
20px
;
height
:
20px
;
...
@@ -67,11 +66,12 @@
...
@@ -67,11 +66,12 @@
font-size
:
$font_12
;
font-size
:
$font_12
;
color
:
$color_666
;
color
:
$color_666
;
}
}
button
{
width
:
131px
;
button
{
height
:
30px
;
width
:
131px
;
border
:
1px
solid
$active
;
height
:
30px
;
border-radius
:
15px
;
border
:
1px
solid
$active
;
border-radius
:
15px
;
background
:
transparent
;
background
:
transparent
;
color
:
$active
;
color
:
$active
;
font-size
:
$font_16
;
font-size
:
$font_16
;
...
...
src/components/study/myCourses/reducers.js
View file @
dbfb701d
import
{
RECEIVE_MY_COURSES
}
from
'./actions'
import
{
RECEIVE_MY_COURSES
,
INVALIDATE_COURSEDATA
}
from
'./actions'
const
initialState
=
{
const
initialState
=
{
isValid
:
false
,
shouldFetch
:
false
,
courseList
:
[]
courseData
:
{},
currentPage
:
1
,
currentNum
:
10
}
}
export
default
function
myCourses
(
state
=
initialState
,
action
)
{
export
default
function
myCourses
(
state
=
initialState
,
action
)
{
switch
(
action
.
type
)
{
switch
(
action
.
type
)
{
case
RECEIVE_MY_COURSES
:
case
RECEIVE_MY_COURSES
:
return
Object
.
assign
({},
state
,
{
courseList
:
action
.
payload
})
return
Object
.
assign
(
{},
state
,
{
courseData
:
action
.
payload
})
case
INVALIDATE_COURSEDATA
:
return
Object
.
assign
(
{},
state
,
{
shouldFetch
:
true
})
default
:
default
:
return
state
return
state
}
}
...
...
src/components/study/study.scss
View file @
dbfb701d
...
@@ -10,6 +10,7 @@ $tabFontSize: 15px;
...
@@ -10,6 +10,7 @@ $tabFontSize: 15px;
.tab
{
.tab
{
height
:
$tabHeight
;
height
:
$tabHeight
;
max-height
:
$tabHeight
;
line-height
:
$tabHeight
;
line-height
:
$tabHeight
;
text-align
:
center
;
text-align
:
center
;
background
:
#F7F9FC
;
background
:
#F7F9FC
;
...
...
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