Commit e1ad5fca by zhangleyuan

feat:处理助教重复翻页的问题

parent dc38ad1b
......@@ -49,7 +49,8 @@ class AddLiveClass extends React.Component {
this.getAssistantList();
}
componentWillReceiveProps(nextProps) {
if(nextProps.data.assistantStoreUserId.length > 0) {
if(nextProps.data.assistantStoreUserId.sort().toString() !== this.props.data.assistantStoreUserId.sort().toString()) {
console.log('我在改变')
// 获取助教老师列表
this.getAssistantList(1, nextProps.data.assistantStoreUserId);
}
......@@ -73,6 +74,9 @@ class AddLiveClass extends React.Component {
}
// 获取助教老师列表
getAssistantList = (current = 1, selectList) => {
console.log('zhujiao',current);
const { assistantQuery,assistantList} = this.state;
const { assistantStoreUserId } = this.props.data;
const idList = selectList ? selectList : assistantStoreUserId;
......@@ -87,6 +91,7 @@ class AddLiveClass extends React.Component {
const { records = [], total = 0, hasNext} = result;
const { teacherId } = this.props.data
let list = current > 1 ? assistantList.concat(records) : records;
console.log("hasNext",typeof(hasNext),hasNext)
this.setState({
assistantHasNext:hasNext,
assistantList: list,
......@@ -101,7 +106,11 @@ class AddLiveClass extends React.Component {
const scrollToBottom = container && container.scrollHeight <= container.clientHeight + container.scrollTop;
if (scrollToBottom && hasNext) {
const { teacherQuery } = this.state;
this.getTeacherList(teacherQuery.current + 1);
let _teacherQuery = teacherQuery;
_teacherQuery.current = _teacherQuery.current + 1
this.setState({
assistantQuery:{..._teacherQuery}
},()=>{this.getTeacherList(_teacherQuery.current)})
}
}
......@@ -112,7 +121,11 @@ class AddLiveClass extends React.Component {
const scrollToBottom = container && container.scrollHeight <= container.clientHeight + container.scrollTop;
if (scrollToBottom && assistantHasNext) {
const { assistantQuery } = this.state;
this.getAssistantList(assistantQuery.current + 1);
let _assistantQuery = assistantQuery;
_assistantQuery.current = _assistantQuery.current + 1
this.setState({
assistantQuery:{..._assistantQuery}
},()=>{this.getAssistantList(_assistantQuery.current)})
}
}
......@@ -318,9 +331,6 @@ class AddLiveClass extends React.Component {
this.getAssistantList()
})
}}
getPopupContainer={() =>
document.getElementById("assistant-teacher")
}
>
{_.map(assistantList, (item, index) => {
if(item.userId !== teacherId){
......
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