分页逻辑

master
pan 5 years ago
parent 80b54263b8
commit 8ec775a21a
  1. 8
      src/my/MyFriend.tsx
  2. 2
      src/my/MyHelp.tsx
  3. 2
      src/my/MyLeaveWord.tsx
  4. 2
      src/my/SeekHelp.tsx
  5. 2
      src/public.tsx
  6. 7
      src/sub/IndexMenu.tsx
  7. 5
      src/sub/Volunteer.tsx

@ -109,7 +109,7 @@ export class MyFriend extends React.Component<
/** /**
* *
*/ */
queryUser(name:string){ queryUser(name:string,page:number){
if(!name){ if(!name){
this.setState({ this.setState({
@ -122,7 +122,9 @@ export class MyFriend extends React.Component<
switch (res.customResult) { switch (res.customResult) {
case PageDataMessage.ok: case PageDataMessage.ok:
that.setState({ that.setState({
userList: res.dataList userList: page===1?res.dataList||[]:(that.state.userList||[]).concat(res.dataList||[]),
page: res.page,
scrollTip: page > 1 ? '成功加载第' + page + '页数据' : null,
}) })
break break
} }
@ -187,7 +189,7 @@ export class MyFriend extends React.Component<
this.setState({ this.setState({
queryUser:e.target.value queryUser:e.target.value
}) })
this.queryUser(e.target.value) this.queryUser(e.target.value,1)
}}/> }}/>
</ListGroup.Item> </ListGroup.Item>

@ -137,7 +137,7 @@ export class MyHelp extends React.Component<{
switch (res.customResult) { switch (res.customResult) {
case PageDataMessage.ok: case PageDataMessage.ok:
that.setState({ that.setState({
data: (that.state.data||[]).concat(res.dataList||[]), data: page===1?res.dataList||[]:(that.state.data||[]).concat(res.dataList||[]),
page: res.page, page: res.page,
scrollTip: page > 1 ? '成功加载第' + page + '页数据' : null, scrollTip: page > 1 ? '成功加载第' + page + '页数据' : null,
}) })

@ -64,7 +64,7 @@ export class MyLeaveWord extends React.Component<
switch (res.customResult) { switch (res.customResult) {
case PageDataMessage.ok: case PageDataMessage.ok:
that.setState({ that.setState({
data: (that.state.data||[]).concat(res.dataList||[]), data: page===1?res.dataList||[]:(that.state.data||[]).concat(res.dataList||[]),
page: res.page, page: res.page,
scrollTip: page > 1 ? '成功加载第' + page + '页数据' : null, scrollTip: page > 1 ? '成功加载第' + page + '页数据' : null,
}) })

@ -75,7 +75,7 @@ export class SeekHelp extends React.Component<{ user:string },
switch (res.customResult) { switch (res.customResult) {
case PageDataMessage.ok: case PageDataMessage.ok:
that.setState({ that.setState({
data: (that.state.data||[]).concat(res.dataList||[]), data: page===1?res.dataList||[]:(that.state.data||[]).concat(res.dataList||[]),
page: res.page, page: res.page,
scrollTip: page > 1 ? '成功加载第' + page + '页数据' : null, scrollTip: page > 1 ? '成功加载第' + page + '页数据' : null,
}) })

@ -89,7 +89,7 @@ export function loadMyFriend(name:string,that:React.Component<any,any>,page:numb
switch (res.customResult) { switch (res.customResult) {
case PageDataMessage.ok: case PageDataMessage.ok:
that.setState({ that.setState({
friendList: (that.state.friendList||[]).concat(res.dataList||[]), friendList: page===1?res.dataList||[]:(that.state.friendList||[]).concat(res.dataList||[]),
page: res.page, page: res.page,
scrollTip: page > 1 ? '成功加载第' + page + '页数据' : null, scrollTip: page > 1 ? '成功加载第' + page + '页数据' : null,
}) })

@ -68,9 +68,10 @@ export class IndexMenu extends React.Component<{ cookies:Cookies },
});break; });break;
case PageDataMessage.ok: case PageDataMessage.ok:
that.setState({ that.setState({
activityList:res.dataList, activityList: page===1?res.dataList||[]:(that.state.activityList||[]).concat(res.dataList||[]),
page:res.page page: res.page,
});break })
break
case PageDataMessage.empty: case PageDataMessage.empty:
that.setState({ that.setState({
activityList:[], activityList:[],

@ -54,9 +54,10 @@ export class Volunteer extends React.Component<{ undefined?:undefined },
},new FindUserTransform(),function(res:FindUserRes){ },new FindUserTransform(),function(res:FindUserRes){
switch (res.customResult) { switch (res.customResult) {
case PageDataMessage.ok: case PageDataMessage.ok:
that.setState({ that.setState({
volunteerList:res.dataList, volunteerList: page===1?res.dataList||[]:(that.state.volunteerList||[]).concat(res.dataList||[]),
page:res.page, page: res.page,
form:{ form:{
keyword:that.state.form.keyword, keyword:that.state.form.keyword,
serviceAddress:that.state.form.serviceAddress serviceAddress:that.state.form.serviceAddress

Loading…
Cancel
Save