Commit d5771090 by zhanghaozhe

myCourses

parent 1e1965e5
...@@ -26,11 +26,11 @@ export const getMyCourses = payload => dispatch => { ...@@ -26,11 +26,11 @@ export const getMyCourses = payload => dispatch => {
return http.get(`${API.home}/m/my_course/${payload.page}/${payload.num}`) return http.get(`${API.home}/m/my_course/${payload.page}/${payload.num}`)
.then(res => { .then(res => {
const {data, code, msg} = res.data const {data, code, msg} = res.data
if (data.length === 0) { if (code == 200 && data.length === 0) {
dispatch(nomoreCourse()) dispatch(nomoreCourse())
return return
} }
if (data.length % 10 !== 0) { if (code == 200 && data.length % 10 !== 0) {
dispatch(nomoreCourse()) dispatch(nomoreCourse())
} }
dispatch(receiveMyCourses({ dispatch(receiveMyCourses({
......
...@@ -99,15 +99,15 @@ class MyCourses extends PureComponent { ...@@ -99,15 +99,15 @@ class MyCourses extends PureComponent {
}, 200) }, 200)
render() { render() {
let list = this.props.courseList let {courseList, user} = this.props
return <Loading isLoading={this.props.isLoading}> return <Loading isLoading={this.props.isLoading}>
{ {
list && list.length !== 0 courseList && courseList.length !== 0
? ?
<> <>
<div className="my-course-uid"> <div className="my-course-uid">
{`加群请备注您的学号:${this.props.user.data.uid}`} {`加群请备注您的学号:${!user.hasError && this.props.user.data.uid}`}
</div> </div>
<InfiniteScroll <InfiniteScroll
pageStart={0} pageStart={0}
...@@ -117,7 +117,7 @@ class MyCourses extends PureComponent { ...@@ -117,7 +117,7 @@ class MyCourses extends PureComponent {
> >
<ul ref={el => this.list = el}> <ul ref={el => this.list = el}>
{ {
list.map((item, index) => { courseList.map((item, index) => {
const Info = ( const Info = (
<div className="info"> <div className="info">
...@@ -159,7 +159,7 @@ class MyCourses extends PureComponent { ...@@ -159,7 +159,7 @@ class MyCourses extends PureComponent {
</ul> </ul>
</InfiniteScroll> </InfiniteScroll>
{ {
list.length % 10 !== 0 ? courseList.length % 10 !== 0 ?
<AddCourse addCourseClick={this.addCourseClick}/> <AddCourse addCourseClick={this.addCourseClick}/>
: null : null
} }
......
...@@ -4,6 +4,7 @@ import { ...@@ -4,6 +4,7 @@ import {
NOMORE_COURSE, NOMORE_COURSE,
START_FETCHING_COURSES START_FETCHING_COURSES
} from './actions' } from './actions'
import { SET_CURRENT_USER } from '@/store/userAction'
const initialState = { const initialState = {
switchTab: false, switchTab: false,
...@@ -31,6 +32,8 @@ export default function myCourses(state = initialState, action) { ...@@ -31,6 +32,8 @@ export default function myCourses(state = initialState, action) {
return {...state, switchTab: action.payload} return {...state, switchTab: action.payload}
case NOMORE_COURSE: case NOMORE_COURSE:
return {...state, noMore: true} return {...state, noMore: true}
case SET_CURRENT_USER:
return action.payload.hasError ? initialState : {...state, page: 0}
default: default:
return state return state
} }
......
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