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
cee9c07a
Commit
cee9c07a
authored
Aug 19, 2019
by
FE
Browse files
Options
Browse Files
Download
Plain Diff
pull haozhe
parents
74b687a9
24451c4d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
26 deletions
+16
-26
src/components/study/myCourses/actions.js
+4
-15
src/components/study/myCourses/index.js
+8
-10
src/components/study/myCourses/reducers.js
+4
-1
No files found.
src/components/study/myCourses/actions.js
View file @
cee9c07a
...
@@ -22,28 +22,17 @@ export const fetchCoursesListIfNeeded = () => (dispatch, getState) => {
...
@@ -22,28 +22,17 @@ export const fetchCoursesListIfNeeded = () => (dispatch, getState) => {
}
}
}
}
// 首次加载,初始化noMore状态
export
const
initIsMore
=
()
=>
(
dispatch
)
=>
{
dispatch
(
nomoreCourse
({
noMore
:
false
}));
}
export
const
getMyCourses
=
payload
=>
dispatch
=>
{
export
const
getMyCourses
=
payload
=>
dispatch
=>
{
dispatch
(
startFetchingCourses
)
dispatch
(
startFetchingCourses
)
return
http
.
get
(
`
${
API
.
home
}
/m/my_course/
${
payload
.
page
}
/
${
payload
.
num
}
`
)
return
http
.
get
(
`
${
API
.
home
}
/m/my_course/
${
payload
.
page
}
/
${
payload
.
num
}
`
)
.
then
(
res
=>
{
.
then
(
res
=>
{
const
{
data
,
code
,
msg
}
=
res
.
data
const
{
data
,
code
,
msg
}
=
res
.
data
if
(
data
.
length
===
0
)
{
if
(
code
==
200
&&
data
.
length
===
0
)
{
dispatch
(
nomoreCourse
({
dispatch
(
nomoreCourse
())
noMore
:
true
}))
return
return
}
}
if
(
data
.
length
%
10
!==
0
)
{
if
(
code
==
200
&&
data
.
length
%
10
!==
0
)
{
dispatch
(
nomoreCourse
({
dispatch
(
nomoreCourse
())
noMore
:
true
}))
}
}
dispatch
(
receiveMyCourses
({
dispatch
(
receiveMyCourses
({
courseList
:
data
,
courseList
:
data
,
...
...
src/components/study/myCourses/index.js
View file @
cee9c07a
...
@@ -3,7 +3,7 @@ import VList from '@/common/v-list-base'
...
@@ -3,7 +3,7 @@ import VList from '@/common/v-list-base'
import
'./my-courses.scss'
import
'./my-courses.scss'
import
{
isToday
,
format
}
from
"date-fns"
import
{
isToday
,
format
}
from
"date-fns"
import
{
connect
}
from
"react-redux"
import
{
connect
}
from
"react-redux"
import
{
fetchCoursesListIfNeeded
,
switchTab
,
initIsMore
}
from
"./actions"
import
{
fetchCoursesListIfNeeded
,
switchTab
}
from
"./actions"
import
InfiniteScroll
from
'react-infinite-scroller'
import
InfiniteScroll
from
'react-infinite-scroller'
import
{
debounce
}
from
'lodash'
import
{
debounce
}
from
'lodash'
import
{
Link
}
from
'react-router-dom'
import
{
Link
}
from
'react-router-dom'
...
@@ -84,8 +84,6 @@ class MyCourses extends PureComponent {
...
@@ -84,8 +84,6 @@ class MyCourses extends PureComponent {
}
}
componentDidMount
()
{
componentDidMount
()
{
console
.
log
(
this
.
props
);
this
.
props
.
initIsMore
();
this
.
props
.
switchTab
(
false
)
this
.
props
.
switchTab
(
false
)
this
.
props
.
fetchCoursesListIfNeeded
()
this
.
props
.
fetchCoursesListIfNeeded
()
}
}
...
@@ -101,15 +99,15 @@ class MyCourses extends PureComponent {
...
@@ -101,15 +99,15 @@ class MyCourses extends PureComponent {
},
200
)
},
200
)
render
()
{
render
()
{
let
list
=
this
.
props
.
courseList
let
{
courseList
,
user
}
=
this
.
props
return
<
Loading
isLoading
=
{
this
.
props
.
isLoading
}
>
return
<
Loading
isLoading
=
{
this
.
props
.
isLoading
}
>
{
{
list
&&
l
ist
.
length
!==
0
courseList
&&
courseL
ist
.
length
!==
0
?
?
<>
<>
<
div
className
=
"my-course-uid"
>
<
div
className
=
"my-course-uid"
>
{
`加群请备注您的学号:
${
this
.
props
.
user
.
data
.
uid
}
`
}
{
`加群请备注您的学号:
${
!
user
.
hasError
&&
this
.
props
.
user
.
data
.
uid
}
`
}
<
/div
>
<
/div
>
<
InfiniteScroll
<
InfiniteScroll
pageStart
=
{
0
}
pageStart
=
{
0
}
...
@@ -119,7 +117,7 @@ class MyCourses extends PureComponent {
...
@@ -119,7 +117,7 @@ class MyCourses extends PureComponent {
>
>
<
ul
ref
=
{
el
=>
this
.
list
=
el
}
>
<
ul
ref
=
{
el
=>
this
.
list
=
el
}
>
{
{
l
ist
.
map
((
item
,
index
)
=>
{
courseL
ist
.
map
((
item
,
index
)
=>
{
const
Info
=
(
const
Info
=
(
<
div
className
=
"info"
>
<
div
className
=
"info"
>
...
@@ -161,7 +159,7 @@ class MyCourses extends PureComponent {
...
@@ -161,7 +159,7 @@ class MyCourses extends PureComponent {
<
/ul
>
<
/ul
>
<
/InfiniteScroll
>
<
/InfiniteScroll
>
{
{
l
ist
.
length
%
10
!==
0
?
courseL
ist
.
length
%
10
!==
0
?
<
AddCourse
addCourseClick
=
{
this
.
addCourseClick
}
/
>
<
AddCourse
addCourseClick
=
{
this
.
addCourseClick
}
/
>
:
null
:
null
}
}
...
@@ -188,6 +186,5 @@ export default connect(
...
@@ -188,6 +186,5 @@ export default connect(
}),
}),
{
{
fetchCoursesListIfNeeded
,
fetchCoursesListIfNeeded
,
switchTab
,
switchTab
initIsMore
})(
MyCourses
)
})(
MyCourses
)
\ No newline at end of file
src/components/study/myCourses/reducers.js
View file @
cee9c07a
...
@@ -4,6 +4,7 @@ import {
...
@@ -4,6 +4,7 @@ import {
NOMORE_COURSE
,
NOMORE_COURSE
,
START_FETCHING_COURSES
START_FETCHING_COURSES
}
from
'./actions'
}
from
'./actions'
import
{
SET_CURRENT_USER
}
from
'@/store/userAction'
const
initialState
=
{
const
initialState
=
{
switchTab
:
false
,
switchTab
:
false
,
...
@@ -31,7 +32,9 @@ export default function myCourses(state = initialState, action) {
...
@@ -31,7 +32,9 @@ export default function myCourses(state = initialState, action) {
case
SWITCH_TAB
:
case
SWITCH_TAB
:
return
{...
state
,
switchTab
:
payload
}
return
{...
state
,
switchTab
:
payload
}
case
NOMORE_COURSE
:
case
NOMORE_COURSE
:
return
Object
.
assign
({},
state
,
payload
);
return
{...
state
,
noMore
:
true
}
case
SET_CURRENT_USER
:
return
payload
.
hasError
?
initialState
:
{...
state
,
page
:
0
}
default
:
default
:
return
state
return
state
}
}
...
...
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