Merge branch 'main' of http://192.168.1.42/developOne/harmonyPool
Showing
4 changed files
with
143 additions
and
57 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 { ListHasNoMoreDataUI } from '../../reusable/ListHasNoMoreDataUI'; | @@ -7,6 +7,7 @@ import { ListHasNoMoreDataUI } from '../../reusable/ListHasNoMoreDataUI'; | ||
| 7 | import { FollowChildComponent } from '../follow/FollowChildComponent'; | 7 | import { FollowChildComponent } from '../follow/FollowChildComponent'; |
| 8 | import dataPreferences from '@ohos.data.preferences'; | 8 | import dataPreferences from '@ohos.data.preferences'; |
| 9 | import { EmptyComponent } from '../../view/EmptyComponent'; | 9 | import { EmptyComponent } from '../../view/EmptyComponent'; |
| 10 | +import { CustomPullToRefresh } from '../../reusable/CustomPullToRefresh'; | ||
| 10 | 11 | ||
| 11 | const TAG = "HomePageBottomFollowComponent" | 12 | const TAG = "HomePageBottomFollowComponent" |
| 12 | /** | 13 | /** |
| @@ -14,6 +15,7 @@ const TAG = "HomePageBottomFollowComponent" | @@ -14,6 +15,7 @@ const TAG = "HomePageBottomFollowComponent" | ||
| 14 | */ | 15 | */ |
| 15 | @Component | 16 | @Component |
| 16 | export struct HomePageBottomFollowComponent { | 17 | export struct HomePageBottomFollowComponent { |
| 18 | + private scroller: Scroller = new Scroller(); | ||
| 17 | @State data_follow: LazyDataSource<FollowListDetailItem> = new LazyDataSource(); | 19 | @State data_follow: LazyDataSource<FollowListDetailItem> = new LazyDataSource(); |
| 18 | @State isLoading: boolean = false | 20 | @State isLoading: boolean = false |
| 19 | @State hasMore: boolean = true | 21 | @State hasMore: boolean = true |
| @@ -104,8 +106,40 @@ export struct HomePageBottomFollowComponent { | @@ -104,8 +106,40 @@ export struct HomePageBottomFollowComponent { | ||
| 104 | }) | 106 | }) |
| 105 | }.layoutWeight(1) | 107 | }.layoutWeight(1) |
| 106 | } else { | 108 | } else { |
| 107 | - List({ space: 3 }) { | 109 | + CustomPullToRefresh({ |
| 110 | + alldata:this.data_follow, | ||
| 111 | + scroller:this.scroller, | ||
| 112 | + customList:()=>{ | ||
| 113 | + this.ListLayout() | ||
| 114 | + }, | ||
| 115 | + onRefresh:(resolve)=>{ | ||
| 116 | + this.curPageNum = 1; | ||
| 117 | + this.hasMore = true | ||
| 118 | + this.isGetRequest = false | ||
| 119 | + this.data_follow.clear() | ||
| 120 | + | ||
| 121 | + if (!this.isLoading){ | ||
| 122 | + this.getNewPageData() | ||
| 123 | + if(resolve) resolve('刷新成功') | ||
| 124 | + } | ||
| 125 | + }, | ||
| 126 | + onLoadMore:(resolve)=> { | ||
| 127 | + console.log(TAG, "触底了"); | ||
| 128 | + if (!this.isLoading) { | ||
| 129 | + this.isLoading = true | ||
| 130 | + //加载分页数据 | ||
| 131 | + this.getNewPageData() | ||
| 132 | + } | ||
| 133 | + } | ||
| 134 | + }) | ||
| 135 | + } | ||
| 136 | + }.layoutWeight(1) | ||
| 137 | + .justifyContent(FlexAlign.Start) | ||
| 138 | + .width('100%') | ||
| 139 | + } | ||
| 108 | 140 | ||
| 141 | + @Builder ListLayout(){ | ||
| 142 | + List({ space: 3 ,scroller:this.scroller}) { | ||
| 109 | ListItem() { | 143 | ListItem() { |
| 110 | Row() { | 144 | Row() { |
| 111 | Text("关注更多人民号") | 145 | Text("关注更多人民号") |
| @@ -136,7 +170,6 @@ export struct HomePageBottomFollowComponent { | @@ -136,7 +170,6 @@ export struct HomePageBottomFollowComponent { | ||
| 136 | FollowChildComponent({ data: item, type: 2 }) | 170 | FollowChildComponent({ data: item, type: 2 }) |
| 137 | } | 171 | } |
| 138 | }, (item: FollowListDetailItem, index: number) => index.toString()) | 172 | }, (item: FollowListDetailItem, index: number) => index.toString()) |
| 139 | - | ||
| 140 | //没有更多数据 显示提示 | 173 | //没有更多数据 显示提示 |
| 141 | if (!this.hasMore) { | 174 | if (!this.hasMore) { |
| 142 | ListItem() { | 175 | ListItem() { |
| @@ -153,18 +186,6 @@ export struct HomePageBottomFollowComponent { | @@ -153,18 +186,6 @@ export struct HomePageBottomFollowComponent { | ||
| 153 | scrollForward: NestedScrollMode.PARENT_FIRST, | 186 | scrollForward: NestedScrollMode.PARENT_FIRST, |
| 154 | scrollBackward: NestedScrollMode.SELF_FIRST | 187 | scrollBackward: NestedScrollMode.SELF_FIRST |
| 155 | }) | 188 | }) |
| 156 | - .onReachEnd(() => { | ||
| 157 | - console.log(TAG, "触底了"); | ||
| 158 | - if (!this.isLoading) { | ||
| 159 | - this.isLoading = true | ||
| 160 | - //加载分页数据 | ||
| 161 | - this.getNewPageData() | ||
| 162 | - } | ||
| 163 | - }) | ||
| 164 | - } | ||
| 165 | - }.layoutWeight(1) | ||
| 166 | - .justifyContent(FlexAlign.Start) | ||
| 167 | - .width('100%') | ||
| 168 | } | 189 | } |
| 169 | 190 | ||
| 170 | @Styles | 191 | @Styles |
| @@ -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 |
| @@ -4,6 +4,7 @@ import { WDRouterRule, WDRouterPage } from 'wdRouter'; | @@ -4,6 +4,7 @@ import { WDRouterRule, WDRouterPage } from 'wdRouter'; | ||
| 4 | import MinePageDatasModel from '../../../model/MinePageDatasModel'; | 4 | import MinePageDatasModel from '../../../model/MinePageDatasModel'; |
| 5 | import { FollowListDetailItem } from '../../../viewmodel/FollowListDetailItem'; | 5 | import { FollowListDetailItem } from '../../../viewmodel/FollowListDetailItem'; |
| 6 | import { UserFollowListRequestItem } from '../../../viewmodel/UserFollowListRequestItem'; | 6 | import { UserFollowListRequestItem } from '../../../viewmodel/UserFollowListRequestItem'; |
| 7 | +import { CustomPullToRefresh } from '../../reusable/CustomPullToRefresh'; | ||
| 7 | import { ListHasNoMoreDataUI } from '../../reusable/ListHasNoMoreDataUI'; | 8 | import { ListHasNoMoreDataUI } from '../../reusable/ListHasNoMoreDataUI'; |
| 8 | import { EmptyComponent } from '../../view/EmptyComponent'; | 9 | import { EmptyComponent } from '../../view/EmptyComponent'; |
| 9 | import { FollowChildComponent } from '../follow/FollowChildComponent'; | 10 | import { FollowChildComponent } from '../follow/FollowChildComponent'; |
| @@ -22,7 +23,7 @@ export struct OtherHomePageBottomFollowComponent{ | @@ -22,7 +23,7 @@ export struct OtherHomePageBottomFollowComponent{ | ||
| 22 | @State count:number = 0; | 23 | @State count:number = 0; |
| 23 | @Prop curUserId: string | 24 | @Prop curUserId: string |
| 24 | @State isGetRequest:boolean = false | 25 | @State isGetRequest:boolean = false |
| 25 | - | 26 | + private scroller: Scroller = new Scroller(); |
| 26 | 27 | ||
| 27 | aboutToAppear(){ | 28 | aboutToAppear(){ |
| 28 | this.getNewPageData() | 29 | this.getNewPageData() |
| @@ -66,8 +67,39 @@ export struct OtherHomePageBottomFollowComponent{ | @@ -66,8 +67,39 @@ export struct OtherHomePageBottomFollowComponent{ | ||
| 66 | }.layoutWeight(1) | 67 | }.layoutWeight(1) |
| 67 | .justifyContent(FlexAlign.Start) | 68 | .justifyContent(FlexAlign.Start) |
| 68 | }else{ | 69 | }else{ |
| 69 | - List({ space: 3 }) { | 70 | + CustomPullToRefresh({ |
| 71 | + alldata:this.data_follow, | ||
| 72 | + scroller:this.scroller, | ||
| 73 | + customList:()=>{ | ||
| 74 | + this.ListLayout() | ||
| 75 | + }, | ||
| 76 | + onRefresh:(resolve)=>{ | ||
| 77 | + this.curPageNum = 1; | ||
| 78 | + this.hasMore = true | ||
| 79 | + this.isGetRequest = false | ||
| 80 | + this.data_follow.clear() | ||
| 70 | 81 | ||
| 82 | + if (!this.isLoading){ | ||
| 83 | + this.getNewPageData() | ||
| 84 | + if(resolve) resolve('刷新成功') | ||
| 85 | + } | ||
| 86 | + }, | ||
| 87 | + onLoadMore:(resolve)=> { | ||
| 88 | + console.log(TAG, "触底了"); | ||
| 89 | + if (!this.isLoading) { | ||
| 90 | + this.isLoading = true | ||
| 91 | + //加载分页数据 | ||
| 92 | + this.getNewPageData() | ||
| 93 | + } | ||
| 94 | + } | ||
| 95 | + }) | ||
| 96 | + } | ||
| 97 | + } | ||
| 98 | + .width('100%') | ||
| 99 | + } | ||
| 100 | + | ||
| 101 | + @Builder ListLayout(){ | ||
| 102 | + List({ space: 3 ,scroller:this.scroller}) { | ||
| 71 | ListItem() { | 103 | ListItem() { |
| 72 | Row(){ | 104 | Row(){ |
| 73 | Text("关注更多人民号") | 105 | Text("关注更多人民号") |
| @@ -115,19 +147,7 @@ export struct OtherHomePageBottomFollowComponent{ | @@ -115,19 +147,7 @@ export struct OtherHomePageBottomFollowComponent{ | ||
| 115 | scrollForward: NestedScrollMode.PARENT_FIRST, | 147 | scrollForward: NestedScrollMode.PARENT_FIRST, |
| 116 | scrollBackward: NestedScrollMode.SELF_FIRST | 148 | scrollBackward: NestedScrollMode.SELF_FIRST |
| 117 | }) | 149 | }) |
| 118 | - .onReachEnd(()=>{ | ||
| 119 | - console.log(TAG,"触底了"); | ||
| 120 | - if(!this.isLoading){ | ||
| 121 | - this.isLoading = true | ||
| 122 | - //加载分页数据 | ||
| 123 | - this.getNewPageData() | ||
| 124 | } | 150 | } |
| 125 | - }) | ||
| 126 | - } | ||
| 127 | - } | ||
| 128 | - .width('100%') | ||
| 129 | - } | ||
| 130 | - | ||
| 131 | 151 | ||
| 132 | @Styles | 152 | @Styles |
| 133 | listStyle() { | 153 | listStyle() { |
-
Please register or login to post a comment