Commit 9e9ff746 by zhanghaozhe

study

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