Commit c0fa737e by zhanghaozhe

Merge branch 'study'

parents 5a739f73 9e9ff746
...@@ -4,7 +4,8 @@ import cookie from 'js-cookie' ...@@ -4,7 +4,8 @@ import cookie from 'js-cookie'
import {api} from '@/utils' import {api} from '@/utils'
//拦截ajax请求,返回mock数据 //拦截ajax请求,返回mock数据
import mock from '@/utils/mock' /*import mock from '@/utils/mock'
mock()*/
// 默认样式 // 默认样式
...@@ -14,14 +15,12 @@ import './assets/css/index.scss'; ...@@ -14,14 +15,12 @@ import './assets/css/index.scss';
import './assets/font/iconfont.css'; import './assets/font/iconfont.css';
export default class App extends Component{ export default class App extends Component{
componentDidMount(){ componentDidMount(){
//平台信息 //平台信息
cookie.set('plat', '5') cookie.set('plat', '5')
//拦截ajax请求,返回mock数据
mock()
} }
render(){ render(){
return <Routes/> return <Routes/>
......
...@@ -78,20 +78,14 @@ class MyCourses extends PureComponent { ...@@ -78,20 +78,14 @@ class MyCourses extends PureComponent {
} }
componentDidMount() { componentDidMount() {
console.log('did mount')
this.props.switchTab(false) this.props.switchTab(false)
this.props.fetchCoursesListIfNeeded(); this.props.fetchCoursesListIfNeeded();
} }
componentWillUnmount(){ componentWillUnmount(){
console.log('will unmount')
this.props.switchTab(true); this.props.switchTab(true);
} }
componentDidUpdate() {
console.log('updated')
}
loadFunc = debounce(() => { loadFunc = debounce(() => {
if (this.props.courseList.length % 10 === 0) { if (this.props.courseList.length % 10 === 0) {
this.props.fetchCoursesListIfNeeded(); this.props.fetchCoursesListIfNeeded();
......
...@@ -18,10 +18,14 @@ export default function myCourses(state = initialState, action) { ...@@ -18,10 +18,14 @@ export default function myCourses(state = initialState, action) {
switch (action.type) { switch (action.type) {
case RECEIVE_MY_COURSES: case RECEIVE_MY_COURSES:
let {courseList, ...rest} = action.payload let {courseList, ...rest} = action.payload
return {...state, ...rest, courseList: state.courseList.concat(courseList)} return {
...state, ...rest,
courseList: Object.keys(courseList).length === 0 ? state.courseList : state.courseList.concat(courseList)
}
case SWITCH_TAB: case SWITCH_TAB:
return {...state, switchTab: action.payload} return {...state, switchTab: action.payload}
case NOMORE_COURSE: case NOMORE_COURSE:
return {...state, noMore: true}
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