Commit 06952d0d by zhanghaozhe

首页banner跳转

parent 925bc0f7
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;
......@@ -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 (
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>
</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,7 +242,7 @@ 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=""/>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment