Showing
4 changed files
with
427 additions
and
3 deletions
| 1 | +import { LazyDataSource, StringUtils } from 'wdKit'; | ||
| 2 | +import { CommentListItem } from '../../../viewmodel/CommentListItem'; | ||
| 3 | +import { OtherUserCommentListRequestItem } from '../../../viewmodel/OtherUserCommentListRequestItem'; | ||
| 4 | +import { ListHasNoMoreDataUI } from '../../reusable/ListHasNoMoreDataUI'; | ||
| 5 | + | ||
| 6 | +const TAG = "HomePageBottomComponent" | ||
| 7 | +@Component | ||
| 8 | +export struct OtherHomePageBottomCommentComponent{ | ||
| 9 | + @Prop curUserId: string | ||
| 10 | + @State data_comment: LazyDataSource<CommentListItem> = new LazyDataSource(); | ||
| 11 | + @State isLoading:boolean = false | ||
| 12 | + @State hasMore:boolean = true | ||
| 13 | + curPageNum:number = 1; | ||
| 14 | + @State count:number = 0; | ||
| 15 | + | ||
| 16 | + aboutToAppear(){ | ||
| 17 | + this.getNewPageData() | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + build(){ | ||
| 21 | + Column(){ | ||
| 22 | + Divider().width('100%') | ||
| 23 | + .height('2lpx') | ||
| 24 | + .strokeWidth('1lpx') | ||
| 25 | + .backgroundColor($r('app.color.color_EDEDED')) | ||
| 26 | + | ||
| 27 | + if(this.count === 0){ | ||
| 28 | + ListHasNoMoreDataUI({style:2}) | ||
| 29 | + .height('100%') | ||
| 30 | + }else{ | ||
| 31 | + List({ space: 3 }) { | ||
| 32 | + LazyForEach(this.data_comment, (item: CommentListItem, index: number = 0) => { | ||
| 33 | + ListItem() { | ||
| 34 | + ChildCommentComponent({data: item}) | ||
| 35 | + } | ||
| 36 | + .onClick(() => { | ||
| 37 | + }) | ||
| 38 | + }, (item: CommentListItem, index: number) => index.toString()) | ||
| 39 | + | ||
| 40 | + //没有更多数据 显示提示 | ||
| 41 | + if(!this.hasMore){ | ||
| 42 | + ListItem(){ | ||
| 43 | + ListHasNoMoreDataUI() | ||
| 44 | + } | ||
| 45 | + } | ||
| 46 | + }.cachedCount(15) | ||
| 47 | + .layoutWeight(1) | ||
| 48 | + .scrollBar(BarState.Off) | ||
| 49 | + .edgeEffect(EdgeEffect.None) | ||
| 50 | + // .nestedScroll({ | ||
| 51 | + // scrollForward: NestedScrollMode.PARENT_FIRST, | ||
| 52 | + // scrollBackward: NestedScrollMode.SELF_FIRST | ||
| 53 | + // }) | ||
| 54 | + .onReachEnd(()=>{ | ||
| 55 | + console.log(TAG,"触底了"); | ||
| 56 | + if(!this.isLoading){ | ||
| 57 | + this.isLoading = true | ||
| 58 | + //加载分页数据 | ||
| 59 | + this.getNewPageData() | ||
| 60 | + } | ||
| 61 | + }) | ||
| 62 | + } | ||
| 63 | + } | ||
| 64 | + .width('100%') | ||
| 65 | + } | ||
| 66 | + | ||
| 67 | + | ||
| 68 | + @Styles | ||
| 69 | + listStyle() { | ||
| 70 | + .backgroundColor(Color.White) | ||
| 71 | + .height(72) | ||
| 72 | + .width("100%") | ||
| 73 | + .borderRadius(12) | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + getNewPageData(){ | ||
| 77 | + this.isLoading = true | ||
| 78 | + if(this.hasMore){ | ||
| 79 | + | ||
| 80 | + let object = new OtherUserCommentListRequestItem("",20,this.curPageNum,"","1",this.curUserId) | ||
| 81 | + | ||
| 82 | + // MinePageDatasModel.getMineCommentListData(object,getContext(this)).then((value)=>{ | ||
| 83 | + // if (!this.data_comment || value.list.length == 0){ | ||
| 84 | + // this.hasMore = false | ||
| 85 | + // }else{ | ||
| 86 | + // value.list.forEach((value)=>{ | ||
| 87 | + // this.data_comment.push(new CommentListItem(value.fromUserHeader,value.fromUserName,value.targetTitle,value.createTime,value.commentContent)) | ||
| 88 | + // }) | ||
| 89 | + // this.data_comment.notifyDataReload() | ||
| 90 | + // this.count = this.data_comment.totalCount() | ||
| 91 | + // if (this.data_comment.totalCount() < value.totalCount) { | ||
| 92 | + // this.curPageNum++ | ||
| 93 | + // }else { | ||
| 94 | + // this.hasMore = false | ||
| 95 | + // } | ||
| 96 | + // } | ||
| 97 | + // this.isLoading = false | ||
| 98 | + // }).catch((err:Error)=>{ | ||
| 99 | + // console.log(TAG,"请求失败") | ||
| 100 | + // this.isLoading = false | ||
| 101 | + // }) | ||
| 102 | + } | ||
| 103 | + } | ||
| 104 | +} | ||
| 105 | + | ||
| 106 | +@Component | ||
| 107 | +struct ChildCommentComponent { | ||
| 108 | + @ObjectLink data: CommentListItem | ||
| 109 | + | ||
| 110 | + build() { | ||
| 111 | + Column(){ | ||
| 112 | + Row() { | ||
| 113 | + Image(StringUtils.isEmpty(this.data.fromUserHeader)?$r('app.media.default_head'):this.data.fromUserHeader) | ||
| 114 | + .objectFit(ImageFit.Auto) | ||
| 115 | + .width('69lpx') | ||
| 116 | + .height('69lpx') | ||
| 117 | + .margin({right:'15lpx'}) | ||
| 118 | + | ||
| 119 | + Column(){ | ||
| 120 | + Text(this.data.fromUserName) | ||
| 121 | + .fontSize('25lpx') | ||
| 122 | + .lineHeight('35lpx') | ||
| 123 | + .fontWeight('600lpx') | ||
| 124 | + .fontColor($r('app.color.color_222222')) | ||
| 125 | + .margin({bottom:'6lpx'}) | ||
| 126 | + .maxLines(1) | ||
| 127 | + Text(`${this.data.createTime}`) | ||
| 128 | + .fontColor($r('app.color.color_B0B0B0')) | ||
| 129 | + .fontSize('23lpx') | ||
| 130 | + .lineHeight('31lpx') | ||
| 131 | + .fontWeight('400lpx') | ||
| 132 | + .maxLines(1) | ||
| 133 | + }.layoutWeight(1) | ||
| 134 | + .alignItems(HorizontalAlign.Start) | ||
| 135 | + } | ||
| 136 | + .margin({bottom:'10lpx'}) | ||
| 137 | + .width('100%') | ||
| 138 | + .height('108lpx') | ||
| 139 | + .padding({left:'31lpx',right:'31lpx'}) | ||
| 140 | + | ||
| 141 | + Row(){ | ||
| 142 | + Text(this.data.commentContent) | ||
| 143 | + .maxLines(3) | ||
| 144 | + .textOverflow({ overflow: TextOverflow.Ellipsis }) | ||
| 145 | + .fontWeight('400lpx') | ||
| 146 | + .fontSize('31lpx') | ||
| 147 | + .lineHeight('46lpx') | ||
| 148 | + .fontColor($r('app.color.color_222222')) | ||
| 149 | + .margin({bottom:'10lpx'}) | ||
| 150 | + }.padding({left:'31lpx',right:'31lpx'}) | ||
| 151 | + .width('100%') | ||
| 152 | + | ||
| 153 | + Row(){ | ||
| 154 | + Text(this.data.targetTitle) | ||
| 155 | + .fontWeight('400lpx') | ||
| 156 | + .fontColor($r('app.color.color_222222')) | ||
| 157 | + .lineHeight('38lpx') | ||
| 158 | + .fontSize('27lpx') | ||
| 159 | + .textAlign(TextAlign.Center) | ||
| 160 | + .margin({right:'4lpx'}) | ||
| 161 | + .maxLines(3) | ||
| 162 | + .width('616lpx') | ||
| 163 | + Image($r('app.media.arrow_icon_right')) | ||
| 164 | + .objectFit(ImageFit.Auto) | ||
| 165 | + .width('27lpx') | ||
| 166 | + .height('27lpx') | ||
| 167 | + } | ||
| 168 | + .padding({top:'17lpx',bottom:'17lpx',left:'23lpx',right:'23lpx'}) | ||
| 169 | + .width('662lpx') | ||
| 170 | + .backgroundColor($r('app.color.color_F5F5F5')) | ||
| 171 | + .margin({top:'19lpx',bottom:'31lpx'}) | ||
| 172 | + | ||
| 173 | + Divider().width('100%') | ||
| 174 | + .height('12lpx') | ||
| 175 | + .strokeWidth('12lpx') | ||
| 176 | + .backgroundColor($r('app.color.color_F5F5F5')) | ||
| 177 | + | ||
| 178 | + } | ||
| 179 | + .justifyContent(FlexAlign.Center) | ||
| 180 | + } | ||
| 181 | +} |
| 1 | +import { Params } from 'wdBean'; | ||
| 2 | +import { LazyDataSource, StringUtils } from 'wdKit'; | ||
| 3 | +import { WDRouterRule, WDRouterPage } from 'wdRouter'; | ||
| 4 | +import MinePageDatasModel from '../../../model/MinePageDatasModel'; | ||
| 5 | +import { FollowListDetailItem } from '../../../viewmodel/FollowListDetailItem'; | ||
| 6 | +import { FollowListDetailRequestItem } from '../../../viewmodel/FollowListDetailRequestItem'; | ||
| 7 | +import { ListHasNoMoreDataUI } from '../../reusable/ListHasNoMoreDataUI'; | ||
| 8 | + | ||
| 9 | +const TAG = "HomePageBottomComponent" | ||
| 10 | +@Component | ||
| 11 | +export struct OtherHomePageBottomFollowComponent{ | ||
| 12 | + @State data_follow: LazyDataSource<FollowListDetailItem> = new LazyDataSource(); | ||
| 13 | + @State isLoading:boolean = false | ||
| 14 | + @State hasMore:boolean = true | ||
| 15 | + curPageNum:number = 1; | ||
| 16 | + @State count:number = 0; | ||
| 17 | + | ||
| 18 | + aboutToAppear(){ | ||
| 19 | + this.getNewPageData() | ||
| 20 | + } | ||
| 21 | + | ||
| 22 | + build(){ | ||
| 23 | + Column(){ | ||
| 24 | + Divider().width('100%') | ||
| 25 | + .height('2lpx') | ||
| 26 | + .strokeWidth('1lpx') | ||
| 27 | + .backgroundColor($r('app.color.color_EDEDED')) | ||
| 28 | + | ||
| 29 | + if(this.count === 0){ | ||
| 30 | + ListHasNoMoreDataUI({style:2}) | ||
| 31 | + .height('100%') | ||
| 32 | + }else{ | ||
| 33 | + List({ space: 3 }) { | ||
| 34 | + | ||
| 35 | + ListItem() { | ||
| 36 | + Row(){ | ||
| 37 | + Text("关注更多人民号") | ||
| 38 | + .fontWeight('400lpx') | ||
| 39 | + .fontColor($r('app.color.color_222222')) | ||
| 40 | + .lineHeight('38lpx') | ||
| 41 | + .fontSize('27lpx') | ||
| 42 | + .textAlign(TextAlign.Center) | ||
| 43 | + .margin({right:'4lpx'}) | ||
| 44 | + Image($r('app.media.arrow_icon_right')) | ||
| 45 | + .objectFit(ImageFit.Auto) | ||
| 46 | + .width('27lpx') | ||
| 47 | + .height('27lpx') | ||
| 48 | + }.height('69lpx') | ||
| 49 | + .width('659lpx') | ||
| 50 | + .alignItems(VerticalAlign.Center) | ||
| 51 | + .justifyContent(FlexAlign.Center) | ||
| 52 | + .backgroundColor($r('app.color.color_F5F5F5')) | ||
| 53 | + .margin({top:'31lpx',bottom:'4lpx'}) | ||
| 54 | + }.onClick(()=>{ | ||
| 55 | + let params: Params = { | ||
| 56 | + pageID: "1" | ||
| 57 | + } | ||
| 58 | + WDRouterRule.jumpWithPage(WDRouterPage.followListPage,params) | ||
| 59 | + }) | ||
| 60 | + | ||
| 61 | + LazyForEach(this.data_follow, (item: FollowListDetailItem, index: number = 0) => { | ||
| 62 | + ListItem() { | ||
| 63 | + ChildFollowComponent({data: item}) | ||
| 64 | + } | ||
| 65 | + .onClick(() => { | ||
| 66 | + }) | ||
| 67 | + }, (item: FollowListDetailItem, index: number) => index.toString()) | ||
| 68 | + | ||
| 69 | + //没有更多数据 显示提示 | ||
| 70 | + if(!this.hasMore){ | ||
| 71 | + ListItem(){ | ||
| 72 | + ListHasNoMoreDataUI() | ||
| 73 | + } | ||
| 74 | + } | ||
| 75 | + }.cachedCount(15) | ||
| 76 | + .padding({left:'31lpx',right:'31lpx'}) | ||
| 77 | + .layoutWeight(1) | ||
| 78 | + .scrollBar(BarState.Off) | ||
| 79 | + .edgeEffect(EdgeEffect.None) | ||
| 80 | + // .nestedScroll({ | ||
| 81 | + // scrollForward: NestedScrollMode.PARENT_FIRST, | ||
| 82 | + // scrollBackward: NestedScrollMode.SELF_FIRST | ||
| 83 | + // }) | ||
| 84 | + .onReachEnd(()=>{ | ||
| 85 | + console.log(TAG,"触底了"); | ||
| 86 | + if(!this.isLoading){ | ||
| 87 | + this.isLoading = true | ||
| 88 | + //加载分页数据 | ||
| 89 | + this.getNewPageData() | ||
| 90 | + } | ||
| 91 | + }) | ||
| 92 | + } | ||
| 93 | + } | ||
| 94 | + .width('100%') | ||
| 95 | + } | ||
| 96 | + | ||
| 97 | + | ||
| 98 | + @Styles | ||
| 99 | + listStyle() { | ||
| 100 | + .backgroundColor(Color.White) | ||
| 101 | + .height(72) | ||
| 102 | + .width("100%") | ||
| 103 | + .borderRadius(12) | ||
| 104 | + } | ||
| 105 | + | ||
| 106 | + getNewPageData(){ | ||
| 107 | + this.isLoading = true | ||
| 108 | + //我的关注列表 | ||
| 109 | + if(this.hasMore){ | ||
| 110 | + let object = new FollowListDetailRequestItem(20,this.curPageNum) | ||
| 111 | + | ||
| 112 | + MinePageDatasModel.getMineFollowListData(object,getContext(this)).then((value)=>{ | ||
| 113 | + if (!this.data_follow || value.list.length == 0){ | ||
| 114 | + this.hasMore = false | ||
| 115 | + }else{ | ||
| 116 | + value.list.forEach((value)=>{ | ||
| 117 | + this.data_follow.push(new FollowListDetailItem(value.attentionHeadPhotoUrl,value.attentionUserName,value.fansNum,value.introduction,value.attentionCreatorId,"1")) | ||
| 118 | + }) | ||
| 119 | + this.data_follow.notifyDataReload() | ||
| 120 | + this.count = this.data_follow.totalCount() | ||
| 121 | + if (this.data_follow.totalCount() < value.totalCount) { | ||
| 122 | + this.curPageNum++ | ||
| 123 | + }else { | ||
| 124 | + this.hasMore = false | ||
| 125 | + } | ||
| 126 | + } | ||
| 127 | + this.isLoading = false | ||
| 128 | + }).catch((err:Error)=>{ | ||
| 129 | + console.log(TAG,"请求失败") | ||
| 130 | + this.isLoading = false | ||
| 131 | + }) | ||
| 132 | + } | ||
| 133 | + } | ||
| 134 | +} | ||
| 135 | + | ||
| 136 | +@Component | ||
| 137 | +struct ChildFollowComponent { | ||
| 138 | + @ObjectLink data: FollowListDetailItem | ||
| 139 | + | ||
| 140 | + build() { | ||
| 141 | + Column(){ | ||
| 142 | + Blank().height('27lpx') | ||
| 143 | + | ||
| 144 | + Row() { | ||
| 145 | + Image(StringUtils.isEmpty(this.data.headPhotoUrl)?$r('app.media.default_head'):this.data.headPhotoUrl) | ||
| 146 | + .objectFit(ImageFit.Auto) | ||
| 147 | + .width('92lpx') | ||
| 148 | + .height('92lpx') | ||
| 149 | + .margin({right:'15lpx'}) | ||
| 150 | + | ||
| 151 | + Column(){ | ||
| 152 | + Text(this.data.cnUserName) | ||
| 153 | + .fontWeight('400lpx') | ||
| 154 | + .fontSize('31lpx') | ||
| 155 | + .lineHeight('38lpx') | ||
| 156 | + .fontColor($r('app.color.color_222222')) | ||
| 157 | + Text(`粉丝${this.data.cnFansNum}`) | ||
| 158 | + .fontColor($r('app.color.color_B0B0B0')) | ||
| 159 | + .fontSize('23lpx') | ||
| 160 | + .maxLines(1) | ||
| 161 | + Text(`${this.data.introduction}`) | ||
| 162 | + .fontColor($r('app.color.color_B0B0B0')) | ||
| 163 | + .fontSize('23lpx') | ||
| 164 | + .maxLines(2) | ||
| 165 | + .textOverflow({ overflow: TextOverflow.Ellipsis }) | ||
| 166 | + }.layoutWeight(1) | ||
| 167 | + .alignItems(HorizontalAlign.Start) | ||
| 168 | + | ||
| 169 | + if(this.data.status == "1"){ | ||
| 170 | + Row(){ | ||
| 171 | + Text(`已关注`) | ||
| 172 | + .fontColor($r('app.color.color_CCCCCC')) | ||
| 173 | + .fontSize('23lpx') | ||
| 174 | + .fontWeight('500lpx') | ||
| 175 | + .lineHeight('35lpx') | ||
| 176 | + }.backgroundColor($r('app.color.color_F5F5F5')) | ||
| 177 | + .borderRadius('6lpx') | ||
| 178 | + .borderColor($r('app.color.color_F5F5F5')) | ||
| 179 | + .borderWidth('2lpx') | ||
| 180 | + .justifyContent(FlexAlign.Center) | ||
| 181 | + .width('100lpx') | ||
| 182 | + .height('46lpx') | ||
| 183 | + .margin({left:'4lpx',top:'23lpx'}) | ||
| 184 | + .onClick(()=>{ | ||
| 185 | + this.data.status = "0" | ||
| 186 | + }) | ||
| 187 | + }else{ | ||
| 188 | + Row(){ | ||
| 189 | + Image($r('app.media.follow_icon')) | ||
| 190 | + .margin({right:'4lpx'}) | ||
| 191 | + .width('23lpx') | ||
| 192 | + .height('23lpx') | ||
| 193 | + Text(`关注`) | ||
| 194 | + .fontColor($r('app.color.color_ED2800')) | ||
| 195 | + .fontSize('23lpx') | ||
| 196 | + .fontWeight('500lpx') | ||
| 197 | + .lineHeight('35lpx') | ||
| 198 | + }.borderColor($r('app.color.color_1AED2800')) | ||
| 199 | + .borderRadius('6lpx') | ||
| 200 | + .borderWidth('2lpx') | ||
| 201 | + .justifyContent(FlexAlign.Center) | ||
| 202 | + .width('100lpx') | ||
| 203 | + .height('46lpx') | ||
| 204 | + .margin({left:'4lpx',top:'23lpx'}) | ||
| 205 | + .onClick(()=>{ | ||
| 206 | + this.data.status = "1" | ||
| 207 | + }) | ||
| 208 | + } | ||
| 209 | + }.alignItems(VerticalAlign.Top) | ||
| 210 | + .width('100%') | ||
| 211 | + .layoutWeight(1) | ||
| 212 | + | ||
| 213 | + Divider().width('100%') | ||
| 214 | + .height('2lpx') | ||
| 215 | + .strokeWidth('1lpx') | ||
| 216 | + .backgroundColor($r('app.color.color_EDEDED')) | ||
| 217 | + | ||
| 218 | + }.height('146lpx') | ||
| 219 | + .justifyContent(FlexAlign.Center) | ||
| 220 | + } | ||
| 221 | +} |
| 1 | import router from '@ohos.router' | 1 | import router from '@ohos.router' |
| 2 | import { Params } from 'wdBean'; | 2 | import { Params } from 'wdBean'; |
| 3 | import { StringUtils } from 'wdKit'; | 3 | import { StringUtils } from 'wdKit'; |
| 4 | -import { HomePageBottomComponent } from '../components/mine/home/HomePageBottomComponent'; | 4 | +import { OtherHomePageBottomCommentComponent } from '../components/mine/home/OtherHomePageBottomCommentComponent'; |
| 5 | +import { OtherHomePageBottomFollowComponent } from '../components/mine/home/OtherHomePageBottomFollowComponent'; | ||
| 5 | import MinePageDatasModel from '../model/MinePageDatasModel'; | 6 | import MinePageDatasModel from '../model/MinePageDatasModel'; |
| 6 | import { OtherUserDetailRequestItem } from '../viewmodel/OtherUserDetailRequestItem'; | 7 | import { OtherUserDetailRequestItem } from '../viewmodel/OtherUserDetailRequestItem'; |
| 7 | 8 | ||
| @@ -152,10 +153,10 @@ struct OtherNormalUserHomePage { | @@ -152,10 +153,10 @@ struct OtherNormalUserHomePage { | ||
| 152 | //tab 页面 | 153 | //tab 页面 |
| 153 | Tabs({controller: this.controller}) { | 154 | Tabs({controller: this.controller}) { |
| 154 | TabContent() { | 155 | TabContent() { |
| 155 | - HomePageBottomComponent({style:0}) | 156 | + OtherHomePageBottomCommentComponent({curUserId:this.curUserId}) |
| 156 | }.tabBar(this.TabBuilder(0,"评论")) | 157 | }.tabBar(this.TabBuilder(0,"评论")) |
| 157 | TabContent() { | 158 | TabContent() { |
| 158 | - HomePageBottomComponent({style:1}) | 159 | + OtherHomePageBottomFollowComponent() |
| 159 | }.tabBar(this.TabBuilder(1,"关注")) | 160 | }.tabBar(this.TabBuilder(1,"关注")) |
| 160 | } | 161 | } |
| 161 | .backgroundColor($r('app.color.white')) | 162 | .backgroundColor($r('app.color.white')) |
sight_harmony/features/wdComponent/src/main/ets/viewmodel/OtherUserCommentListRequestItem.ets
0 → 100644
| 1 | +export class OtherUserCommentListRequestItem { | ||
| 2 | + creatorId: string = "" | ||
| 3 | + pageSize: number = 20 | ||
| 4 | + pageNum: number = 1 | ||
| 5 | + time: string = "" | ||
| 6 | + userType: string = "1" | ||
| 7 | + userId: string = "" | ||
| 8 | + | ||
| 9 | + constructor(creatorId: string, pageSize: number, | ||
| 10 | + pageNum: number, | ||
| 11 | + time: string, | ||
| 12 | + userType: string, | ||
| 13 | + userId: string) { | ||
| 14 | + this.creatorId = creatorId | ||
| 15 | + this.pageSize = pageSize | ||
| 16 | + this.pageNum = pageNum | ||
| 17 | + this.time = time | ||
| 18 | + this.userType = userType | ||
| 19 | + this.userId = userId | ||
| 20 | + } | ||
| 21 | +} |
-
Please register or login to post a comment