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
06952d0d
Commit
06952d0d
authored
Aug 21, 2019
by
zhanghaozhe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
首页banner跳转
parent
925bc0f7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
23 deletions
+27
-23
src/components/Index/index.js
+27
-23
No files found.
src/components/Index/index.js
View file @
06952d0d
import
React
,
{
Component
}
from
'react'
import
{
Course
,
CallApp
}
from
'../../common'
import
React
,
{
Component
}
from
'react'
import
{
Course
,
CallApp
}
from
'../../common'
import
'./index.scss'
import
{
WithTab
}
from
'@/HOCs'
import
{
WithTab
}
from
'@/HOCs'
import
Swiper
from
'react-mobile-swiper'
import
createStyle
from
'./createStyle'
import
LazyLoad
from
'react-lazy-load'
import
{
http
}
from
'@/utils'
import
{
http
}
from
'@/utils'
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'
;
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
...
...
@@ -66,11 +66,11 @@ class Index extends Component {
getIndexData
=
()
=>
{
http
.
get
(
`
${
API
.
home
}
/m/home`
).
then
((
res
)
=>
{
if
(
res
.
data
.
code
===
200
)
{
const
{
data
}
=
res
.
data
||
{}
const
{
data
}
=
res
.
data
||
{}
this
.
setState
({
banner
:
data
.
banner
,
lives
:
data
.
lives
,
modules
:
typeof
data
.
modules
===
'object'
&&
data
.
modules
.
length
>
0
?
data
.
modules
:
[]
modules
:
typeof
data
.
modules
===
'object'
&&
data
.
modules
.
length
>
0
?
data
.
modules
:
[]
})
}
else
{
Toast
.
info
(
res
.
data
.
msg
,
2
)
...
...
@@ -109,7 +109,7 @@ class Index extends Component {
}
toCourseDetail
=
(
id
)
=>
{
const
{
dispatch
,
history
}
=
this
.
props
;
const
{
dispatch
,
history
}
=
this
.
props
;
dispatch
(
getCourses
(
id
,
()
=>
{
history
.
push
(
`/detail?id=
${
id
}
`
);
return
false
;
...
...
@@ -156,10 +156,10 @@ class Index extends Component {
{
(
this
.
state
.
lives
&&
this
.
state
.
lives
.
length
>
0
)
?
<
div
className
=
'lives'
>
<
h2
className
=
"title"
>
近期直播
<
/h2
>
<
ScrollBox
livesList
=
{
this
.
state
.
lives
}
liveCourse
=
{
this
.
liveCourse
}
/
>
<
/div> : nul
l
<
div
className
=
'lives'
>
<
h2
className
=
"title"
>
近期直播
<
/h2
>
<
ScrollBox
livesList
=
{
this
.
state
.
lives
}
liveCourse
=
{
this
.
liveCourse
}
/
>
<
/div> : nul
l
}
{
...
...
@@ -200,11 +200,15 @@ function TopSwiper({bannerList}) {
<
Swiper
type
=
{
animateTypes
.
CARD
}
loop
=
{
true
}
height
=
{
168
}
autoPlay
=
{
true
}
typePro
createStyle
=
{
createStyle
}
>
{
bannerList
&&
bannerList
.
length
>
0
&&
bannerList
.
map
((
item
,
index
)
=>
{
return
(
<
a
href
=
{
item
.
jump_url
}
key
=
{
index
}
>
{
/* <Link to={item.jump_url} key={index}> */
}
<
img
className
=
"item"
src
=
{
item
.
name
}
alt
=
""
/>
{
/* </Link> */
}
<
/a
>
Number
.
isNaN
(
parseInt
(
item
.
jump_url
))
?
<
a
href
=
{
item
.
jump_url
}
key
=
{
index
}
>
{
/* <Link to={item.jump_url} key={index}> */
}
<
img
className
=
"item"
src
=
{
item
.
name
}
alt
=
""
/>
{
/* </Link> */
}
<
/a>
:
<
Link
to
=
{{
pathname
:
'/detail'
,
search
:
`?id=
${
item
.
jump_url
}
`
}}
>
<
img
className
=
"item"
src
=
{
item
.
name
}
alt
=
""
/>
<
/Link
>
)
})
}
...
...
@@ -219,7 +223,7 @@ function CourseList({modules, toDetail}) {
// 数量为奇数时,第一个课程显示大图(如后台未上传,前台显示小图),课程数量为偶数时,均显示小图
let
filterList
=
''
if
(
isOdd
)
{
if
(
isOdd
)
{
filterList
=
modules
.
list
}
else
{
filterList
=
modules
.
list
[
0
].
course_img
===
modules
.
list
[
0
].
course_img_small
?
modules
.
list
:
modules
.
list
.
slice
(
1
)
...
...
@@ -238,10 +242,10 @@ function CourseList({modules, toDetail}) {
<
LazyLoad
offset
=
{
50
}
>
<
ul
className
=
'index-course-detail'
>
{
!
isOdd
&&
modules
.
list
[
0
].
course_img
!==
modules
.
list
[
0
].
course_img_small
&&
!
isOdd
&&
modules
.
list
[
0
].
course_img
!==
modules
.
list
[
0
].
course_img_small
&&
<
div
className
=
"category-vip"
onClick
=
{()
=>
toDetail
(
modules
.
list
[
0
].
course_id
)}
>
{
/* <Link to={`/detail?id=${modules.list[0].course_id}`}> */
}
<
img
src
=
{
modules
.
list
[
0
].
course_img
}
alt
=
""
/>
<
img
src
=
{
modules
.
list
[
0
].
course_img
}
alt
=
""
/>
{
/* </Link> */
}
<
/div
>
}
...
...
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