Commit 25943c4d by zhanghaozhe

temp

parent c61460e4
......@@ -17,6 +17,15 @@ class Loading extends Component {
isLoading: true
}
componentDidMount() {
if(!this.props.isLoading){
this.setState({
isLoading: false
})
}
}
componentDidUpdate(prevProps) {
let {isLoading, fake} = this.props
if (!isLoading) {
......
......@@ -62,7 +62,7 @@ class UseCoupon extends PureComponent {
if (this.state.showUseButton) {
this.setState({
couponList: [...state.couponList, coupon],
couponList: [...this.state.couponList, coupon],
redeemCode: ''
})
} else {
......
......@@ -22,6 +22,7 @@ export const fetchCoursesListIfNeeded = () => (dispatch, getState) => {
}
export const getMyCourses = payload => dispatch => {
dispatch(startFetchingCourses)
return http.get(`${api.home}/m/my_course/${payload.page}/${payload.num}`)
.then(res => {
const {data, code, msg} = res.data
......@@ -51,4 +52,9 @@ export const switchTab = payload => ({
export const NOMORE_COURSE = 'NOMORE_COURSES'
export const nomoreCourse = () => ({
type: NOMORE_COURSE
})
\ No newline at end of file
})
export const START_FETCHING_COURSES = 'START_FETCHING_COURSES'
export const startFetchingCourses = () => {
return {type: START_FETCHING_COURSES, payload: {isLoading: true}}
}
\ No newline at end of file
......@@ -7,6 +7,7 @@ import { fetchCoursesListIfNeeded, switchTab } from "./actions"
import InfiniteScroll from 'react-infinite-scroller'
import { debounce } from 'lodash'
import { Link } from 'react-router-dom'
import { Loading } from "@/common";
function getStudyTime(seconds) {
......@@ -69,7 +70,11 @@ const Bottom = React.memo(({item}) => {
class MyCourses extends PureComponent {
list;
list
state = {
isLoading: true
}
handleClick = id => {
this.props.history.push(`/play/video?id=${id}`)
......@@ -95,79 +100,80 @@ class MyCourses extends PureComponent {
render() {
let list = this.props.courseList
if (list && list.length !== 0) {
return (
<>
<div className="my-course-uid">
{`加群请备注您的学号:${this.props.user.data.uid}`}
</div>
<InfiniteScroll
pageStart={0}
hasMore={true}
loadMore={this.loadFunc}
useWindow={false}
>
<ul ref={el => this.list = el}>
{
list.map((item, index) => {
const Info = (
<div className="info">
<div className='title'>{item.course_title}</div>
{
item.is_aist
? <div className='contact'>助教微信:{item.assist_weixin}</div>
: <div className='contact'>QQ群:{item.course_qq}</div>
}
{
item.is_aist && item.aist_schedule &&
<div className="process-status">
<div className="process-wrapper">
<div className="process-bar"
style={{width: `${parseFloat(item.aist_schedule)}%`}}/>
return <Loading isLoading={this.props.isLoading}>
{
list && list.length !== 0
?
<>
<div className="my-course-uid">
{`加群请备注您的学号:${this.props.user.data.uid}`}
</div>
<InfiniteScroll
pageStart={0}
hasMore={true}
loadMore={this.loadFunc}
useWindow={false}
>
<ul ref={el => this.list = el}>
{
list.map((item, index) => {
const Info = (
<div className="info">
<div className='title'>{item.course_title}</div>
{
item.is_aist
? <div className='contact'>助教微信:{item.assist_weixin}</div>
: <div className='contact'>QQ群:{item.course_qq}</div>
}
{
item.is_aist && item.aist_schedule &&
<div className="process-status">
<div className="process-wrapper">
<div className="process-bar"
style={{width: `${parseFloat(item.aist_schedule)}%`}}/>
</div>
<div className="process-text">{item.aist_schedule}</div>
</div>
<div className="process-text">{item.aist_schedule}</div>
</div>
}
<Bottom item={item}/>
</div>
)
const status = (
item.is_aist && <span className='status'>返现</span>
)
return (
<VList img={item.image_name}
handleClick={this.handleClick}
{...item}
key={index}
info={Info}
status={status}
id={item['course_id']}
/>
)
})
}
</ul>
</InfiniteScroll>
{
list.length % 10 !== 0 ?
<AddCourse addCourseClick={this.addCourseClick}/>
: null
}
</>
)
} else {
return (
<div className="empty">
<p><i className='iconfont iconfish'/></p>
<p className='empty-prompt'>还是咸鱼一条,快去翻身~</p>
<p>
<Link className='select-course' to='/classify'>去选课</Link>
</p>
</div>
)
}
}
<Bottom item={item}/>
</div>
)
const status = (
item.is_aist && <span className='status'>返现</span>
)
return (
<VList img={item.image_name}
handleClick={this.handleClick}
{...item}
key={index}
info={Info}
status={status}
id={item['course_id']}
/>
)
})
}
</ul>
</InfiniteScroll>
{
list.length % 10 !== 0 ?
<AddCourse addCourseClick={this.addCourseClick}/>
: null
}
</>
:
<div className="empty">
<p><i className='iconfont iconfish'/></p>
<p className='empty-prompt'>还是咸鱼一条,快去翻身~</p>
<p>
<Link className='select-course' to='/classify'>去选课</Link>
</p>
</div>
}
</Loading>
}
}
......@@ -175,7 +181,8 @@ class MyCourses extends PureComponent {
export default connect(
state => ({
courseList: state.myCourses.courseList,
user: state.user
user: state.user,
isLoading: state.myCourses.isLoading
}),
{
fetchCoursesListIfNeeded,
......
import {
RECEIVE_MY_COURSES,
SWITCH_TAB,
NOMORE_COURSE
NOMORE_COURSE,
START_FETCHING_COURSES
} from './actions'
const initialState = {
......@@ -11,6 +12,7 @@ const initialState = {
statusCode: 0,
msg: '',
noMore: false,
isLoading: true
}
......@@ -20,8 +22,11 @@ export default function myCourses(state = initialState, action) {
let {courseList, ...rest} = action.payload
return {
...state, ...rest,
courseList: Object.keys(courseList).length === 0 ? state.courseList : state.courseList.concat(courseList)
courseList: Object.keys(courseList).length === 0 ? state.courseList : state.courseList.concat(courseList),
isLoading: false
}
case START_FETCHING_COURSES:
return {...state, ...action.payload}
case SWITCH_TAB:
return {...state, switchTab: action.payload}
case NOMORE_COURSE:
......
......@@ -101,7 +101,7 @@ class Video extends Component {
this.ws = new WebSocket('ws://process-test.julyedu.com:9502');
this.ws.addEventListener('error', () => {
this.ws = null
this.setupWS();
// this.setupWS();
})
this.ws.addEventListener('open', () => {
console.log('open');
......@@ -109,7 +109,7 @@ class Video extends Component {
this.ws.addEventListener('close', () => {
if(this.reconnect){
this.ws = null
this.setupWS()
// this.setupWS()
}
clearInterval(this.timer)
})
......@@ -332,7 +332,7 @@ class Video extends Component {
}
}
hasAuth = (index) => {
hasAuth = () => {
const {course, videoList, activeIndex} = this.state
let lesson = videoList[activeIndex]
if (!lesson['is_free']) {
......
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