Commit 426bfa05 by xuzhenghua

Merge branch 'master' of gitlab.julyedu.com:baiguangyao/mr-julyedu into detail

parents 5305b8d8 354acf13
{ {
"name": "my-julyedu", "name": "mr-julyedu",
"version": "0.1.0", "version": "0.1.0",
"private": true, "private": true,
"dependencies": { "dependencies": {
......
.course-base-item {
width: 47.8%;
margin-top: 15px;
margin-bottom: 5px;
position: relative;
img {
width: 100%;
height: 119px;
min-height: 119px;
}
.course-title {
font-size: 14px;
color: $color_333;
line-height: 19px;
margin-top: 9px;
}
}
import React from 'react'
import './course-base.scss'
const Course = (props) => {
return (
<li className={`course-base-item ${props.className}`} onClick={props.handleClick.bind(this, props.id)}>
{props.top}
<img src={props.img} alt=""/>
<p className="course-title">{props.title}</p>
{props.bottom}
</li>
);
};
export default Course;
import React from 'react';
import './index.scss'
const VList = (props) => {
return (
<li className='v-list-base-item' onClick={props.handleClick.bind(this, props.id)}>
<div className="content">
<div className="cover">
{props.status}
<img src={props.img} alt=""/>
</div>
{props.info}
</div>
{props.tab}
</li>
);
};
export default VList;
\ No newline at end of file
.v-list-base-item {
height: 127px;
padding: 10px 10px 0;
.content {
display: flex;
height: 100%;
padding-bottom: 10px;
border-bottom: 1px solid $sp_e7eaf1;
.cover {
flex: 0 0 auto;
margin-right: 16px;
position: relative;
img {
width: 150px;
height: 108px;
border-radius: 3px;
}
}
.course-status {
width: 100%;
height: 24px;
position: absolute;
bottom: -1px;
border-radius: 0 0 3px 3px;
text-align: center;
line-height: 24px;
color: $white;
font-size: 13px;
}
}
}
import React, { PureComponent } from 'react' import React, { PureComponent } from 'react'
import { Course, Tag } from '../../../common' import { Tag } from '../../../common'
import Course from '@/common/course-base'
import { http, api } from '@/utils' import { http, api } from '@/utils'
import { Toast } from "antd-mobile"; import { Toast } from "antd-mobile";
import classnames from 'classnames' import classnames from 'classnames'
import {isEmpty} from 'lodash'
import './free-courses.scss' import './free-courses.scss'
...@@ -25,8 +27,8 @@ class FreeCourse extends PureComponent { ...@@ -25,8 +27,8 @@ class FreeCourse extends PureComponent {
componentDidMount() { componentDidMount() {
this.getFreeCourses() this.getFreeCourses()
.then(res => { .then(res => {
if (res.data.code == 200) { let data = res.data
const data = res.data if (data.code == 200) {
this.setState({ this.setState({
courses: data.data, courses: data.data,
}) })
...@@ -36,16 +38,21 @@ class FreeCourse extends PureComponent { ...@@ -36,16 +38,21 @@ class FreeCourse extends PureComponent {
}) })
this.getFreeLive() this.getFreeLive()
.then(res => { .then(res => {
if (res.data.code == 200) { let data = res.data
if (data.code == 200) {
this.setState({ this.setState({
live: res.data.data live: isEmpty(data.data) ? [] : data.data
}) })
} else { } else {
Toast.info(res.data.msg) Toast.info(data.msg, 2, null, false)
} }
}) })
} }
handleClick = id => {
this.props.history.push(`/play?id=${id}`)
}
getFreeCourses = () => { getFreeCourses = () => {
return http.get(`${api.home}/m/free_course/${this.state.page}/${this.state.num}`) return http.get(`${api.home}/m/free_course/${this.state.page}/${this.state.num}`)
} }
...@@ -58,19 +65,6 @@ class FreeCourse extends PureComponent { ...@@ -58,19 +65,6 @@ class FreeCourse extends PureComponent {
return ( return (
<ul className='free-courses'> <ul className='free-courses'>
{ {
this.state.courses.map((item, index) => (
<Course
img={item.logo}
title={item['video_course_name']}
bottom={
<Bottom audience={item['play_times']} className={'tag-category'} text={item.category}/>
}
id={item['v_course_id']}
key={index}
/>
))
}
{
this.state.live.map((item, index) => { this.state.live.map((item, index) => {
const Bottom = ( const Bottom = (
<div className="bottom"> <div className="bottom">
...@@ -79,12 +73,12 @@ class FreeCourse extends PureComponent { ...@@ -79,12 +73,12 @@ class FreeCourse extends PureComponent {
return <i key={index} className={classnames('column', `column-${index + 1}`)}/> return <i key={index} className={classnames('column', `column-${index + 1}`)}/>
})} })}
</div> </div>
<div className="time">{`直播:${item['live_start_time']}`}</div> <div className="time">{`${item['live_start_time']}`}</div>
</div> </div>
) )
return ( return (
<Course <Course
img={item['live_img']} img={item['live_cover']}
title={item['live_title']} title={item['live_title']}
top={ top={
<Tag className={'tag-starting top'}>即将开始</Tag> <Tag className={'tag-starting top'}>即将开始</Tag>
...@@ -92,10 +86,26 @@ class FreeCourse extends PureComponent { ...@@ -92,10 +86,26 @@ class FreeCourse extends PureComponent {
bottom={Bottom} bottom={Bottom}
key={item['live_id']} key={item['live_id']}
className={'live'} className={'live'}
handleClick={this.handleClick}
id={index}
/> />
) )
}) })
} }
{
this.state.courses.map((item, index) => (
<Course
img={item.logo}
title={item['video_course_name']}
handleClick={this.handleClick}
bottom={
<Bottom audience={item['play_times']} className={'tag-category'} text={item.category}/>
}
id={item['v_course_id']}
key={index}
/>
))
}
</ul> </ul>
) )
} }
......
...@@ -7,6 +7,7 @@ import FreeCourses from './freeCourses' ...@@ -7,6 +7,7 @@ import FreeCourses from './freeCourses'
import WithTab from '@/HOCs/WithTab' import WithTab from '@/HOCs/WithTab'
import WithFullSize from '@/HOCs/WithFullSize' import WithFullSize from '@/HOCs/WithFullSize'
import { compose } from 'redux' import { compose } from 'redux'
import PrivateRoute from '@/router/privateRoute'
class Study extends Component { class Study extends Component {
...@@ -45,11 +46,11 @@ class Study extends Component { ...@@ -45,11 +46,11 @@ class Study extends Component {
<Switch> <Switch>
<Redirect exact from='/study' to='study/my-course'/> <Redirect exact from='/study' to='study/my-course'/>
<Route path={`${this.props.match.path}/my-course`} component={MyCourses}/> <Route path={`${this.props.match.path}/my-course`} component={MyCourses}/>
{/*<PrivateRoute path={`${this.props.match.path}/my-course`} component={MyCourses}/>*/}
<Route path={`${this.props.match.path}/free-course`} component={FreeCourses}/> <Route path={`${this.props.match.path}/free-course`} component={FreeCourses}/>
{/*<Route path={`${this.props.match.path}/my-course`} render={props => { {/*<Route path={`${this.props.match.path}/my-course`} render={props => {
<MyCourses storeScrollPosition={this.storeScrollPosition}/> <MyCourses storeScrollPosition={this.storeScrollPosition}/>
}}/>*/} }}/>*/}
<Route path={`${this.props.match.path}/free-course`} component={FreeCourses}/>
</Switch> </Switch>
</div> </div>
</section> </section>
......
import React, { PureComponent } from "react" import React, { PureComponent } from "react"
import { VList } from '@/common' 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"
...@@ -72,10 +72,10 @@ class MyCourses extends PureComponent { ...@@ -72,10 +72,10 @@ class MyCourses extends PureComponent {
list; list;
handleClick = id => { handleClick = id => {
this.props.history.push(`/detail?id=${id}`) this.props.history.push(`/play/video?id=${id}`)
} }
addCourseClick = () => { addCourseClick = () => {
console.log(2); this.props.history.push('/classify')
} }
componentDidMount() { componentDidMount() {
......
...@@ -22,7 +22,7 @@ class Video extends Component { ...@@ -22,7 +22,7 @@ class Video extends Component {
state = { state = {
title: '视频', title: '',
courseId: null, courseId: null,
video_catalog: [], video_catalog: [],
datum: [], datum: [],
...@@ -30,7 +30,8 @@ class Video extends Component { ...@@ -30,7 +30,8 @@ class Video extends Component {
activeIndex: 0, activeIndex: 0,
isAuth: true, isAuth: true,
course: null, course: null,
salePrice: null salePrice: null,
vCourseId: null
} }
...@@ -87,7 +88,9 @@ class Video extends Component { ...@@ -87,7 +88,9 @@ class Video extends Component {
video_catalog: data.data['lessons'], video_catalog: data.data['lessons'],
currentVideoSrc: data.data['lessons'][state.activeIndex]['play_url'], currentVideoSrc: data.data['lessons'][state.activeIndex]['play_url'],
course: data.data.course, course: data.data.course,
courseId: data.data.course['course_id'] courseId: data.data.course['course_id'],
vCourseId: data.data.course['v_course_id'],
title: data.data.course['course_title']
}), }),
() => { () => {
if (this.lessonAvailable()) { if (this.lessonAvailable()) {
...@@ -197,11 +200,11 @@ class Video extends Component { ...@@ -197,11 +200,11 @@ class Video extends Component {
render() { render() {
let {match} = this.props let {match, location} = this.props
const {video_catalog, activeIndex, isAuth, salePrice} = this.state const {video_catalog, activeIndex, isAuth, salePrice} = this.state
return ( return (
<div className='play'> <div className='play'>
<HeaderBar title={this.state.title}/> <HeaderBar title={this.state.title} arrow={true}/>
<div className="video"> <div className="video">
<video className={'video-js'} ref={el => this.video = el}> <video className={'video-js'} ref={el => this.video = el}>
<source src={'/'} type='application/x-mpegURL'/> <source src={'/'} type='application/x-mpegURL'/>
...@@ -235,7 +238,10 @@ class Video extends Component { ...@@ -235,7 +238,10 @@ class Video extends Component {
</div> </div>
</div> </div>
<Switch> <Switch>
<Redirect exact from={'/play'} to={'/play/video'}/> <Redirect exact from={'/play'} to={{
pathname: '/play/video',
search: location.search
}}/>
<Route path={`${match.path}/video`} render={props => { <Route path={`${match.path}/video`} render={props => {
return <VideoCatalog return <VideoCatalog
activeIndex={this.state.activeIndex} activeIndex={this.state.activeIndex}
...@@ -248,7 +254,7 @@ class Video extends Component { ...@@ -248,7 +254,7 @@ class Video extends Component {
}}/> }}/>
</Switch> </Switch>
<Route render={props => { <Route render={props => {
return this.state.courseId ? <Recommendation {...props} courseId={this.state.courseId}/> return this.state.vCourseId ? <Recommendation {...props} vCourseId={this.state.vCourseId}/>
: null : null
}}/> }}/>
</div> </div>
......
...@@ -2,7 +2,7 @@ import React, { PureComponent } from 'react'; ...@@ -2,7 +2,7 @@ import React, { PureComponent } from 'react';
import './recommendation.scss' import './recommendation.scss'
import { http, api } from '@/utils' import { http, api } from '@/utils'
import { Toast } from "antd-mobile"; import { Toast } from "antd-mobile";
import {VList} from '@/common'; import VList from '@/common/v-list-base';
...@@ -26,7 +26,11 @@ class Recommendation extends PureComponent { ...@@ -26,7 +26,11 @@ class Recommendation extends PureComponent {
componentDidMount() { componentDidMount() {
http.get(`${api.home}/m/play/recommend_course/${this.props.courseId}?num=${this.state.num}`) this.getRecommendation()
}
getRecommendation = () => {
http.get(`${api.home}/m/play/recommend_course/${this.props.vCourseId}?num=${this.state.num}`)
.then(res => { .then(res => {
const data = res.data const data = res.data
if(data.code === 200){ if(data.code === 200){
...@@ -43,7 +47,7 @@ class Recommendation extends PureComponent { ...@@ -43,7 +47,7 @@ class Recommendation extends PureComponent {
handleClick = id => { handleClick = id => {
console.log(id) this.props.history.push(`/detail?id=${id}`)
} }
render() { render() {
......
import React, { useEffect } from 'react'; import React, { useEffect, useState } from 'react';
import { withRouter } from "react-router-dom"; import { withRouter } from "react-router-dom";
import { compose } from "redux"; import { compose } from "redux";
import { connect } from "react-redux"; import { connect } from "react-redux";
import LoadingComponent from '@/common/Loading'
function Loading(props) { function Loading(props) {
const [isLoading, setLoadingState] = useState(true)
useEffect(() => { useEffect(() => {
let {user, location, history} = props let {user, location, history} = props
if (!user.isFetching) { if (!user.isFetching) {
if (user.hasError) { if (user.hasError) {
history.push('/passport', {from: location}) history.push('/passport', {from: location})
setLoadingState(false)
} else { } else {
if (Object.values(user.data).every(item => !!item).length !== 0) { if (Object.values(user.data).every(item => !!item).length !== 0) {
history.push(location.pathname) history.push(location.pathname)
setLoadingState(false)
} }
} }
} }
}) })
return ( return (
<div className={'loading'}> <div className={'loading-route'}>
loading... <LoadingComponent isLoading={isLoading}/>
</div> </div>
); );
} }
......
...@@ -19,7 +19,6 @@ import Passport from '@/components/passport'; ...@@ -19,7 +19,6 @@ import Passport from '@/components/passport';
import { Scholarship } from '@/components/scholarship/index'; import { Scholarship } from '@/components/scholarship/index';
import DrawDocument from '@/components/scholarship/DrawDocument/DrawDocument'; import DrawDocument from '@/components/scholarship/DrawDocument/DrawDocument';
import PayOrder from '@/components/order/payOrder/PayOrder' import PayOrder from '@/components/order/payOrder/PayOrder'
import Loading from '@/common/Loading'
const Coupons = loadable(() => import(/* webpackChunkName: 'coupons'*/ '@/components/coupons')) const Coupons = loadable(() => import(/* webpackChunkName: 'coupons'*/ '@/components/coupons'))
const Study = loadable(() => import(/* webpackChunkName: 'study'*/'@/components/study')) const Study = loadable(() => import(/* webpackChunkName: 'study'*/'@/components/study'))
...@@ -138,9 +137,4 @@ export default [ ...@@ -138,9 +137,4 @@ export default [
component: ToGroup, component: ToGroup,
isPrivate: true isPrivate: true
}, },
{
path: '/loading',
component: Loading,
},
] ]
\ No newline at end of file
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