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
5e29c1a8
Commit
5e29c1a8
authored
Sep 06, 2019
by
zhanghaozhe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
公开课
parent
6b68cf90
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
8 deletions
+41
-8
src/components/Index/index.js
+2
-3
src/components/study/freeCourses/index.js
+39
-4
src/components/study/myCourses/actions.js
+0
-1
No files found.
src/components/Index/index.js
View file @
5e29c1a8
...
...
@@ -10,7 +10,6 @@ import LiveRoom from './liveRoom'
import
{
Link
}
from
"react-router-dom"
import
{
Toast
}
from
'antd-mobile'
import
{
connect
}
from
"react-redux"
;
import
{
getCourses
}
from
'./../detail/actions'
;
const
animateTypes
=
Swiper
.
animateTypes
...
...
@@ -148,10 +147,10 @@ class Index extends Component {
this
.
state
.
tabdata
.
map
((
item
,
index
)
=>
{
return
(
<
li
key
=
{
index
}
>
<
a
href
=
{
item
.
href
}
>
<
Link
to
=
{
item
.
href
}
>
<
img
src
=
{
item
.
src
}
alt
=
""
/>
<
span
>
{
item
.
name
}
<
/span
>
<
/
a
>
<
/
Link
>
<
/li
>
)
})
...
...
src/components/study/freeCourses/index.js
View file @
5e29c1a8
...
...
@@ -5,6 +5,8 @@ import { http } from '@/utils'
import
{
Toast
}
from
"antd-mobile"
;
import
classnames
from
'classnames'
import
{
isEmpty
}
from
'lodash'
import
InfiniteScroll
from
"react-infinite-scroller"
;
import
{
HashLoader
}
from
'react-spinners'
import
'./free-courses.scss'
...
...
@@ -17,11 +19,14 @@ const Bottom = (props) => (
)
class
FreeCourse
extends
PureComponent
{
page
=
1
num
=
10
state
=
{
courses
:
[],
live
:
[],
page
:
1
,
num
:
10
hasMore
:
false
}
componentDidMount
()
{
...
...
@@ -31,6 +36,7 @@ class FreeCourse extends PureComponent {
if
(
data
.
code
==
200
)
{
this
.
setState
({
courses
:
data
.
data
,
hasMore
:
true
})
}
else
{
Toast
.
info
(
data
.
msg
)
...
...
@@ -54,7 +60,7 @@ class FreeCourse extends PureComponent {
}
getFreeCourses
=
()
=>
{
return
http
.
get
(
`
${
API
.
home
}
/m/free_course/
${
this
.
state
.
page
}
/
${
this
.
state
.
num
}
`
)
return
http
.
get
(
`
${
API
.
home
}
/m/free_course/
${
this
.
page
++
}
/
${
this
.
num
}
`
)
}
getFreeLive
=
()
=>
{
...
...
@@ -70,9 +76,38 @@ class FreeCourse extends PureComponent {
}
}
loadFunc
=
()
=>
{
if
(
this
.
state
.
hasMore
)
{
this
.
setState
({
hasMore
:
this
.
state
.
courses
.
length
%
10
===
0
},
()
=>
{
this
.
getFreeCourses
()
.
then
(
res
=>
{
let
data
=
res
.
data
if
(
data
.
code
==
200
)
{
Array
.
isArray
(
data
.
data
)
&&
this
.
setState
({
courses
:
this
.
state
.
courses
.
concat
(
data
.
data
),
hasMore
:
data
.
data
.
length
%
10
===
0
})
}
else
{
Toast
.
info
(
data
.
msg
)
}
})
})
}
}
render
()
{
return
(
<
ul
className
=
'free-courses'
>
<
InfiniteScroll
pageStart
=
{
0
}
loadMore
=
{
this
.
loadFunc
}
useWindow
=
{
false
}
className
=
{
'free-courses'
}
element
=
{
'ul'
}
hasMore
=
{
this
.
state
.
hasMore
}
threshold
=
{
250
}
>
{
this
.
state
.
live
.
map
((
item
,
index
)
=>
{
const
Bottom
=
(
...
...
@@ -119,7 +154,7 @@ class FreeCourse extends PureComponent {
/
>
))
}
<
/
u
l
>
<
/
InfiniteScrol
l
>
)
}
}
...
...
src/components/study/myCourses/actions.js
View file @
5e29c1a8
...
...
@@ -12,7 +12,6 @@ const PAGE_INTERVAL = 1
export
const
NUM_INTERVAL
=
10
export
const
fetchCoursesListIfNeeded
=
()
=>
(
dispatch
,
getState
)
=>
{
const
myCourses
=
getState
().
myCourses
console
.
log
(
myCourses
);
const
{
switchTab
,
page
,
noMore
}
=
myCourses
if
(
!
switchTab
&&
!
noMore
)
{
dispatch
(
getMyCourses
({
...
...
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