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
......@@ -52,3 +53,8 @@ export const NOMORE_COURSE = 'NOMORE_COURSES'
export const nomoreCourse = () => ({
type: NOMORE_COURSE
})
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,8 +100,11 @@ class MyCourses extends PureComponent {
render() {
let list = this.props.courseList
if (list && list.length !== 0) {
return (
return <Loading isLoading={this.props.isLoading}>
{
list && list.length !== 0
?
<>
<div className="my-course-uid">
{`加群请备注您的学号:${this.props.user.data.uid}`}
......@@ -156,9 +164,7 @@ class MyCourses extends PureComponent {
: null
}
</>
)
} else {
return (
:
<div className="empty">
<p><i className='iconfont iconfish'/></p>
<p className='empty-prompt'>还是咸鱼一条,快去翻身~</p>
......@@ -166,8 +172,8 @@ class MyCourses extends PureComponent {
<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