Commit 96638577 by zhanghaozhe

tem

parent 5ec341f7
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
img { img {
width: 100%; width: 100%;
height: 119px; height: 119px;
min-height: 119px;
} }
.course-title { .course-title {
......
import React from 'react' import React, { PureComponent } from 'react'
import { Course, Tag } from '../../../common' import { Course, Tag } from '../../../common'
import { api } from '@/utils'
import './free-courses.scss' import './free-courses.scss'
const mockData = [
{
tagText: '机器学习',
tagType: 1,
title: '16年度最火课程TOP10',
src: 'https://julyedu-img-public.oss-cn-beijing.aliyuncs.com/Public/Image/4c5ccac604.jpg',
},
{
tagText: '机器学习',
tagType: 1,
title: '16年度最火课程TOP10',
src: 'https://julyedu-img-public.oss-cn-beijing.aliyuncs.com/Public/Image/4c5ccac604.jpg',
},
{
tagText: '机器学习',
tagType: 1,
title: '16年度最火课程TOP10',
src: 'https://julyedu-img-public.oss-cn-beijing.aliyuncs.com/Public/Image/4c5ccac604.jpg',
},
{
tagText: '机器学习',
tagType: 1,
title: '16年度最火课程TOP10',
src: 'https://julyedu-img-public.oss-cn-beijing.aliyuncs.com/Public/Image/4c5ccac604.jpg',
},
{
tagText: '机器学习',
tagType: 1,
title: '16年度最火课程TOP10',
src: 'https://julyedu-img-public.oss-cn-beijing.aliyuncs.com/Public/Image/4c5ccac604.jpg',
},
{
tagText: '机器学习',
tagType: 1,
title: '16年度最火课程TOP10',
src: 'https://julyedu-img-public.oss-cn-beijing.aliyuncs.com/Public/Image/4c5ccac604.jpg',
},
{
tagText: '机器学习',
tagType: 1,
title: '16年度最火课程TOP10',
src: 'https://julyedu-img-public.oss-cn-beijing.aliyuncs.com/Public/Image/4c5ccac604.jpg',
},
{
tagText: '机器学习',
tagType: 1,
title: '16年度最火课程TOP10',
src: 'https://julyedu-img-public.oss-cn-beijing.aliyuncs.com/Public/Image/4c5ccac604.jpg',
},
{
tagText: '机器学习',
tagType: 1,
title: '16年度最火课程TOP10',
src: 'https://julyedu-img-public.oss-cn-beijing.aliyuncs.com/Public/Image/4c5ccac604.jpg',
},
{
tagText: '机器学习',
tagType: 1,
title: '16年度最火课程TOP10',
src: 'https://julyedu-img-public.oss-cn-beijing.aliyuncs.com/Public/Image/4c5ccac604.jpg',
},
{
tagText: '机器学习',
tagType: 1,
title: '16年度最火课程TOP10',
src: 'https://julyedu-img-public.oss-cn-beijing.aliyuncs.com/Public/Image/4c5ccac604.jpg',
},
{
tagText: '机器学习',
tagType: 1,
title: '16年度最火课程TOP10',
src: 'https://julyedu-img-public.oss-cn-beijing.aliyuncs.com/Public/Image/4c5ccac604.jpg',
},
]
const Bottom = (props) => ( const Bottom = (props) => (
<div className='bottom'> <div className='bottom'>
<Tag className={props.className}>{props.tagText}</Tag> <Tag className={props.className}>{props.text}</Tag>
<span>{props.audience}人观看</span> <span>{props.audience}人观看</span>
</div> </div>
) )
class FreeCourse extends PureComponent {
state = {
courses: [],
live: [],
}
async componentDidMount() {
api.get('/m/free_course/1/10')
.then(res => {
if (res.data.code == 200) {
this.setState({
courses: res.data.data,
})
} else {
console.log(res.data.msg)
}
})
api.get('/m/live/free_list')
.then(res => {
if(res.data.code == 200){
this.setState({
live: res.data.data
})
}
})
}
const FreeCourse = (props) => { render() {
return ( return (
<ul className='free-courses'> <ul className='free-courses'>
{ {
mockData.map((item, index) => ( this.state.courses.map((item, index) => (
<Course <Course
data={item} data={{
src: item.logo,
title: item.video_course_name
}}
top={ top={
<Tag className={'tag-starting top'}>即将开始</Tag> <Tag className={'tag-starting top'}>即将开始</Tag>
} }
bottom={ bottom={
<Bottom audience={232} className={'tag-category'} tagText={item.tagText}></Bottom> <Bottom audience={item.lessons} className={'tag-category'} text={item.category}/>
} }
key={index} key={index}
> >
</Course> </Course>
)) ))
} }
{
/*this.state.live.map((item,index) => (
<Course
data={{
src: item.logo,
title: item.video_course_name
}}
top={
<Tag className={'tag-starting top'}>即将开始</Tag>
}
bottom={
<Bottom audience={item.lessons} className={'tag-category'} text={item.category}/>
}
key={index}
/>
))*/
}
</ul> </ul>
) )
}
} }
export default FreeCourse export default FreeCourse
\ No newline at end of file
...@@ -58,13 +58,6 @@ export default class MyCourses extends PureComponent { ...@@ -58,13 +58,6 @@ export default class MyCourses extends PureComponent {
console.log(2); console.log(2);
} }
componentDidMount() {
api.get('/m/free_course/1/10')
.then(res => {
console.log(res)
})
}
render() { render() {
if (mockData.length !== 0) { if (mockData.length !== 0) {
......
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