Showing
2 changed files
with
74 additions
and
29 deletions
| @@ -7,6 +7,7 @@ import { EmptyComponent } from '../../view/EmptyComponent'; | @@ -7,6 +7,7 @@ import { EmptyComponent } from '../../view/EmptyComponent'; | ||
| 7 | import { ChildCommentComponent } from './ChildCommentComponent'; | 7 | import { ChildCommentComponent } from './ChildCommentComponent'; |
| 8 | import { MineCommentListDetailItem } from '../../../viewmodel/MineCommentListDetailItem'; | 8 | import { MineCommentListDetailItem } from '../../../viewmodel/MineCommentListDetailItem'; |
| 9 | import { OtherUserCommentLikeStatusRequestItem } from '../../../viewmodel/OtherUserCommentLikeStatusRequestItem'; | 9 | import { OtherUserCommentLikeStatusRequestItem } from '../../../viewmodel/OtherUserCommentLikeStatusRequestItem'; |
| 10 | +import { CustomPullToRefresh } from '../../reusable/CustomPullToRefresh'; | ||
| 10 | 11 | ||
| 11 | const TAG = "HomePageBottomCommentComponent" | 12 | const TAG = "HomePageBottomCommentComponent" |
| 12 | 13 | ||
| @@ -22,6 +23,7 @@ export struct HomePageBottomCommentComponent { | @@ -22,6 +23,7 @@ export struct HomePageBottomCommentComponent { | ||
| 22 | @State count: number = 0; | 23 | @State count: number = 0; |
| 23 | @Link commentNum: number | 24 | @Link commentNum: number |
| 24 | @State isGetRequest: boolean = false | 25 | @State isGetRequest: boolean = false |
| 26 | + private scroller: Scroller = new Scroller(); | ||
| 25 | 27 | ||
| 26 | aboutToAppear() { | 28 | aboutToAppear() { |
| 27 | this.getNewPageData() | 29 | this.getNewPageData() |
| @@ -42,7 +44,40 @@ export struct HomePageBottomCommentComponent { | @@ -42,7 +44,40 @@ export struct HomePageBottomCommentComponent { | ||
| 42 | .offset({ y: "-200lpx" }) | 44 | .offset({ y: "-200lpx" }) |
| 43 | } | 45 | } |
| 44 | } else { | 46 | } else { |
| 45 | - List({ space: 3 }) { | 47 | + CustomPullToRefresh({ |
| 48 | + alldata:this.data_comment, | ||
| 49 | + scroller:this.scroller, | ||
| 50 | + customList:()=>{ | ||
| 51 | + this.ListLayout() | ||
| 52 | + }, | ||
| 53 | + onRefresh:(resolve)=>{ | ||
| 54 | + this.curPageNum = 1; | ||
| 55 | + this.hasMore = true | ||
| 56 | + this.isGetRequest = false | ||
| 57 | + this.data_comment.clear() | ||
| 58 | + | ||
| 59 | + if (!this.isLoading){ | ||
| 60 | + this.getNewPageData() | ||
| 61 | + if(resolve) resolve('刷新成功') | ||
| 62 | + } | ||
| 63 | + }, | ||
| 64 | + onLoadMore:(resolve)=> { | ||
| 65 | + console.log(TAG, "触底了"); | ||
| 66 | + if (!this.isLoading) { | ||
| 67 | + this.isLoading = true | ||
| 68 | + //加载分页数据 | ||
| 69 | + this.getNewPageData() | ||
| 70 | + } | ||
| 71 | + } | ||
| 72 | + }) | ||
| 73 | + } | ||
| 74 | + }.layoutWeight(1) | ||
| 75 | + .justifyContent(FlexAlign.Start) | ||
| 76 | + .width('100%') | ||
| 77 | + } | ||
| 78 | + | ||
| 79 | + @Builder ListLayout(){ | ||
| 80 | + List({ space: 3,scroller: this.scroller }) { | ||
| 46 | LazyForEach(this.data_comment, (item: CommentListItem, index: number = 0) => { | 81 | LazyForEach(this.data_comment, (item: CommentListItem, index: number = 0) => { |
| 47 | ListItem() { | 82 | ListItem() { |
| 48 | ChildCommentComponent({ | 83 | ChildCommentComponent({ |
| @@ -68,18 +103,6 @@ export struct HomePageBottomCommentComponent { | @@ -68,18 +103,6 @@ export struct HomePageBottomCommentComponent { | ||
| 68 | scrollForward: NestedScrollMode.PARENT_FIRST, | 103 | scrollForward: NestedScrollMode.PARENT_FIRST, |
| 69 | scrollBackward: NestedScrollMode.SELF_FIRST | 104 | scrollBackward: NestedScrollMode.SELF_FIRST |
| 70 | }) | 105 | }) |
| 71 | - .onReachEnd(() => { | ||
| 72 | - console.log(TAG, "触底了"); | ||
| 73 | - if (!this.isLoading) { | ||
| 74 | - this.isLoading = true | ||
| 75 | - //加载分页数据 | ||
| 76 | - this.getNewPageData() | ||
| 77 | - } | ||
| 78 | - }) | ||
| 79 | - } | ||
| 80 | - }.layoutWeight(1) | ||
| 81 | - .justifyContent(FlexAlign.Start) | ||
| 82 | - .width('100%') | ||
| 83 | } | 106 | } |
| 84 | 107 | ||
| 85 | getNewPageData() { | 108 | getNewPageData() { |
| @@ -7,6 +7,7 @@ import { MineCommentListDetailItem } from '../../../viewmodel/MineCommentListDet | @@ -7,6 +7,7 @@ import { MineCommentListDetailItem } from '../../../viewmodel/MineCommentListDet | ||
| 7 | import { OtherUserCommentLikeStatusRequestItem } from '../../../viewmodel/OtherUserCommentLikeStatusRequestItem'; | 7 | import { OtherUserCommentLikeStatusRequestItem } from '../../../viewmodel/OtherUserCommentLikeStatusRequestItem'; |
| 8 | import { ChildCommentComponent } from './ChildCommentComponent'; | 8 | import { ChildCommentComponent } from './ChildCommentComponent'; |
| 9 | import { EmptyComponent } from '../../view/EmptyComponent'; | 9 | import { EmptyComponent } from '../../view/EmptyComponent'; |
| 10 | +import { CustomPullToRefresh } from '../../reusable/CustomPullToRefresh'; | ||
| 10 | 11 | ||
| 11 | const TAG = "HomePageBottomComponent" | 12 | const TAG = "HomePageBottomComponent" |
| 12 | /** | 13 | /** |
| @@ -23,6 +24,8 @@ export struct OtherHomePageBottomCommentComponent { | @@ -23,6 +24,8 @@ export struct OtherHomePageBottomCommentComponent { | ||
| 23 | @Prop levelHead: string | 24 | @Prop levelHead: string |
| 24 | @Link commentNum: number | 25 | @Link commentNum: number |
| 25 | @State isGetRequest: boolean = false | 26 | @State isGetRequest: boolean = false |
| 27 | + private scroller: Scroller = new Scroller(); | ||
| 28 | + | ||
| 26 | 29 | ||
| 27 | aboutToAppear() { | 30 | aboutToAppear() { |
| 28 | this.getNewPageData() | 31 | this.getNewPageData() |
| @@ -41,7 +44,41 @@ export struct OtherHomePageBottomCommentComponent { | @@ -41,7 +44,41 @@ export struct OtherHomePageBottomCommentComponent { | ||
| 41 | .layoutWeight(1) | 44 | .layoutWeight(1) |
| 42 | } | 45 | } |
| 43 | } else { | 46 | } else { |
| 44 | - List({ space: 3 }) { | 47 | + CustomPullToRefresh({ |
| 48 | + alldata:this.data_comment, | ||
| 49 | + scroller:this.scroller, | ||
| 50 | + customList:()=>{ | ||
| 51 | + this.ListLayout() | ||
| 52 | + }, | ||
| 53 | + onRefresh:(resolve)=>{ | ||
| 54 | + this.curPageNum = 1; | ||
| 55 | + this.hasMore = true | ||
| 56 | + this.isGetRequest = false | ||
| 57 | + this.data_comment.clear() | ||
| 58 | + | ||
| 59 | + if (!this.isLoading){ | ||
| 60 | + this.getNewPageData() | ||
| 61 | + if(resolve) resolve('刷新成功') | ||
| 62 | + } | ||
| 63 | + }, | ||
| 64 | + onLoadMore:(resolve)=> { | ||
| 65 | + console.log(TAG, "触底了"); | ||
| 66 | + if (!this.isLoading) { | ||
| 67 | + this.isLoading = true | ||
| 68 | + //加载分页数据 | ||
| 69 | + this.getNewPageData() | ||
| 70 | + } | ||
| 71 | + } | ||
| 72 | + }) | ||
| 73 | + } | ||
| 74 | + } | ||
| 75 | + .width('100%') | ||
| 76 | + .layoutWeight(1) | ||
| 77 | + .justifyContent(FlexAlign.Start) | ||
| 78 | + } | ||
| 79 | + | ||
| 80 | + @Builder ListLayout(){ | ||
| 81 | + List({ space: 3 ,scroller: this.scroller}) { | ||
| 45 | LazyForEach(this.data_comment, (item: CommentListItem, index: number = 0) => { | 82 | LazyForEach(this.data_comment, (item: CommentListItem, index: number = 0) => { |
| 46 | ListItem() { | 83 | ListItem() { |
| 47 | ChildCommentComponent({ | 84 | ChildCommentComponent({ |
| @@ -50,8 +87,6 @@ export struct OtherHomePageBottomCommentComponent { | @@ -50,8 +87,6 @@ export struct OtherHomePageBottomCommentComponent { | ||
| 50 | isLastItem: index === this.data_comment.totalCount() - 1 | 87 | isLastItem: index === this.data_comment.totalCount() - 1 |
| 51 | }) | 88 | }) |
| 52 | } | 89 | } |
| 53 | - .onClick(() => { | ||
| 54 | - }) | ||
| 55 | }, (item: CommentListItem, index: number) => index.toString()) | 90 | }, (item: CommentListItem, index: number) => index.toString()) |
| 56 | 91 | ||
| 57 | //没有更多数据 显示提示 | 92 | //没有更多数据 显示提示 |
| @@ -69,19 +104,6 @@ export struct OtherHomePageBottomCommentComponent { | @@ -69,19 +104,6 @@ export struct OtherHomePageBottomCommentComponent { | ||
| 69 | scrollForward: NestedScrollMode.PARENT_FIRST, | 104 | scrollForward: NestedScrollMode.PARENT_FIRST, |
| 70 | scrollBackward: NestedScrollMode.SELF_FIRST | 105 | scrollBackward: NestedScrollMode.SELF_FIRST |
| 71 | }) | 106 | }) |
| 72 | - .onReachEnd(() => { | ||
| 73 | - console.log(TAG, "触底了"); | ||
| 74 | - if (!this.isLoading) { | ||
| 75 | - this.isLoading = true | ||
| 76 | - //加载分页数据 | ||
| 77 | - this.getNewPageData() | ||
| 78 | - } | ||
| 79 | - }) | ||
| 80 | - } | ||
| 81 | - } | ||
| 82 | - .width('100%') | ||
| 83 | - .layoutWeight(1) | ||
| 84 | - .justifyContent(FlexAlign.Start) | ||
| 85 | } | 107 | } |
| 86 | 108 | ||
| 87 | @Styles | 109 | @Styles |
-
Please register or login to post a comment