Showing
1 changed file
with
48 additions
and
48 deletions
sight_harmony/features/wdComponent/src/main/ets/components/comment/view/QualityCommentsComponent.ets
| @@ -18,11 +18,10 @@ const TAG = 'QualityCommentsComponent'; | @@ -18,11 +18,10 @@ const TAG = 'QualityCommentsComponent'; | ||
| 18 | @Preview | 18 | @Preview |
| 19 | @Component | 19 | @Component |
| 20 | export struct QualityCommentsComponent { | 20 | export struct QualityCommentsComponent { |
| 21 | - | ||
| 22 | //刷新 | 21 | //刷新 |
| 23 | - @State viewType:number = ViewType.LOADING; | 22 | + @State viewType: number = ViewType.LOADING; |
| 24 | @State hasMore: boolean = true; | 23 | @State hasMore: boolean = true; |
| 25 | - @State currentPage: number = 1; | 24 | + @State currentPage: number = 1; |
| 26 | private scroller: Scroller = new Scroller(); | 25 | private scroller: Scroller = new Scroller(); |
| 27 | @State tileOpacity: number = 0; | 26 | @State tileOpacity: number = 0; |
| 28 | firstPositionY: number = 0; | 27 | firstPositionY: number = 0; |
| @@ -32,11 +31,9 @@ export struct QualityCommentsComponent { | @@ -32,11 +31,9 @@ export struct QualityCommentsComponent { | ||
| 32 | currentWindowColor: string = '#FF4202' | 31 | currentWindowColor: string = '#FF4202' |
| 33 | @State allDatas: LazyDataSource<commentItemModel> = new LazyDataSource(); | 32 | @State allDatas: LazyDataSource<commentItemModel> = new LazyDataSource(); |
| 34 | @State dialogController: CustomDialogController | null = null; | 33 | @State dialogController: CustomDialogController | null = null; |
| 35 | - | ||
| 36 | /*必传*/ | 34 | /*必传*/ |
| 37 | @State publishCommentModel: publishCommentModel = new publishCommentModel() | 35 | @State publishCommentModel: publishCommentModel = new publishCommentModel() |
| 38 | 36 | ||
| 39 | - | ||
| 40 | aboutToDisappear(): void { | 37 | aboutToDisappear(): void { |
| 41 | // windowClass.setWindowSystemBarProperties({ statusBarColor: '#000' }) | 38 | // windowClass.setWindowSystemBarProperties({ statusBarColor: '#000' }) |
| 42 | this.dialogController = null // 将dialogController置空 | 39 | this.dialogController = null // 将dialogController置空 |
| @@ -55,7 +52,7 @@ export struct QualityCommentsComponent { | @@ -55,7 +52,7 @@ export struct QualityCommentsComponent { | ||
| 55 | this.showAlert() | 52 | this.showAlert() |
| 56 | } | 53 | } |
| 57 | 54 | ||
| 58 | - showAlert(){ | 55 | + showAlert() { |
| 59 | this.dialogController = new CustomDialogController({ | 56 | this.dialogController = new CustomDialogController({ |
| 60 | builder: CommentCustomDialog({ | 57 | builder: CommentCustomDialog({ |
| 61 | confirm: (value: Record<string, string>) => { | 58 | confirm: (value: Record<string, string>) => { |
| @@ -74,9 +71,11 @@ export struct QualityCommentsComponent { | @@ -74,9 +71,11 @@ export struct QualityCommentsComponent { | ||
| 74 | }) | 71 | }) |
| 75 | } | 72 | } |
| 76 | 73 | ||
| 77 | - getData(resolve?: (value: string | PromiseLike<string>) => void){ | 74 | + getData(resolve?: (value: string | PromiseLike<string>) => void) { |
| 78 | commentViewModel.fetchQualityCommentList(this.currentPage + '').then((commentListModel) => { | 75 | commentViewModel.fetchQualityCommentList(this.currentPage + '').then((commentListModel) => { |
| 79 | - if(resolve) resolve('刷新成功') | 76 | + if (resolve) { |
| 77 | + resolve('刷新成功') | ||
| 78 | + } | ||
| 80 | 79 | ||
| 81 | if (commentListModel && commentListModel.list && commentListModel.list.length > 0) { | 80 | if (commentListModel && commentListModel.list && commentListModel.list.length > 0) { |
| 82 | if (this.currentPage === 1) { | 81 | if (this.currentPage === 1) { |
| @@ -143,6 +142,7 @@ export struct QualityCommentsComponent { | @@ -143,6 +142,7 @@ export struct QualityCommentsComponent { | ||
| 143 | .height(this.topSafeHeight + vp2px(44) + 'px') | 142 | .height(this.topSafeHeight + vp2px(44) + 'px') |
| 144 | .width('100%') | 143 | .width('100%') |
| 145 | .backgroundColor($r('app.color.color_transparent')) | 144 | .backgroundColor($r('app.color.color_transparent')) |
| 145 | + .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP]) | ||
| 146 | } | 146 | } |
| 147 | 147 | ||
| 148 | /*导航栏*/ | 148 | /*导航栏*/ |
| @@ -187,62 +187,66 @@ export struct QualityCommentsComponent { | @@ -187,62 +187,66 @@ export struct QualityCommentsComponent { | ||
| 187 | .height(this.topSafeHeight + vp2px(44) + 'px') | 187 | .height(this.topSafeHeight + vp2px(44) + 'px') |
| 188 | .width('100%') | 188 | .width('100%') |
| 189 | .backgroundColor($r('app.color.white')) | 189 | .backgroundColor($r('app.color.white')) |
| 190 | + .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP]) | ||
| 190 | } | 191 | } |
| 191 | 192 | ||
| 192 | build() { | 193 | build() { |
| 193 | - Column() { | ||
| 194 | - | ||
| 195 | - | ||
| 196 | - Stack({ alignContent: Alignment.Top }) { | ||
| 197 | - | ||
| 198 | - Scroll() { | ||
| 199 | - Column() { | ||
| 200 | - Stack() { | ||
| 201 | - this.titleHeader() | ||
| 202 | - | ||
| 203 | - if(this.viewType == ViewType.ERROR){ | ||
| 204 | - ErrorComponent() | ||
| 205 | - }else if(this.viewType == ViewType.EMPTY){ | ||
| 206 | - EmptyComponent({emptyType:WDViewDefaultType.WDViewDefaultType_NoComment}) | ||
| 207 | - }else { | 194 | + Stack({ alignContent: Alignment.Top }) { |
| 195 | + Scroll() { | ||
| 196 | + Column() { | ||
| 197 | + Stack() { | ||
| 198 | + this.titleHeader() | ||
| 199 | + | ||
| 200 | + if (this.viewType == ViewType.ERROR) { | ||
| 201 | + ErrorComponent() | ||
| 202 | + } else if (this.viewType == ViewType.EMPTY) { | ||
| 203 | + EmptyComponent({ emptyType: WDViewDefaultType.WDViewDefaultType_NoComment }) | ||
| 204 | + } else { | ||
| 208 | this.listLayout() | 205 | this.listLayout() |
| 209 | - } | 206 | + } |
| 210 | 207 | ||
| 211 | - }.alignContent(Alignment.Top) | ||
| 212 | - }.backgroundColor(this.currentWindowColor).width('100%') | 208 | + }.alignContent(Alignment.Top) |
| 213 | } | 209 | } |
| 214 | - .friction(0.6) | ||
| 215 | - .scrollBar(BarState.Off) | ||
| 216 | - .edgeEffect(EdgeEffect.None) | ||
| 217 | - .width('100%') | ||
| 218 | - .height('100%') | ||
| 219 | - | ||
| 220 | - this.TabbarTransparent() | ||
| 221 | - this.TabbarNormal() | ||
| 222 | - | 210 | + .backgroundColor(this.currentWindowColor).width('100%') |
| 223 | } | 211 | } |
| 212 | + .friction(0.6) | ||
| 213 | + .scrollBar(BarState.Off) | ||
| 214 | + .edgeEffect(EdgeEffect.None) | ||
| 215 | + .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM]) | ||
| 224 | 216 | ||
| 217 | + this.TabbarTransparent() | ||
| 218 | + this.TabbarNormal() | ||
| 225 | } | 219 | } |
| 220 | + .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM]) | ||
| 226 | 221 | ||
| 227 | } | 222 | } |
| 228 | 223 | ||
| 229 | @Builder | 224 | @Builder |
| 230 | - listLayout(){ | ||
| 231 | - List({ space: 12, scroller:this.scroller }) { | 225 | + listLayout() { |
| 226 | + List({ space: 12, scroller: this.scroller }) { | ||
| 232 | // ListItemGroup({ header: this.titleHeader() }) | 227 | // ListItemGroup({ header: this.titleHeader() }) |
| 233 | LazyForEach(this.allDatas, (item: commentItemModel, index: number) => { | 228 | LazyForEach(this.allDatas, (item: commentItemModel, index: number) => { |
| 234 | ListItem() { | 229 | ListItem() { |
| 235 | - QualityCommentItem({ item: item, index: index , dialogController:this.dialogController, publishCommentModel:this.publishCommentModel}).margin({ left: 12, right: 12 }) | 230 | + QualityCommentItem({ |
| 231 | + item: item, | ||
| 232 | + index: index, | ||
| 233 | + dialogController: this.dialogController, | ||
| 234 | + publishCommentModel: this.publishCommentModel | ||
| 235 | + }).margin({ left: 12, right: 12 }) | ||
| 236 | } | 236 | } |
| 237 | }) | 237 | }) |
| 238 | // 加载更多 | 238 | // 加载更多 |
| 239 | ListItem() { | 239 | ListItem() { |
| 240 | - if (this.hasMore === false) NoMoreLayout() | 240 | + if (this.hasMore === false) { |
| 241 | + NoMoreLayout() | ||
| 242 | + } | ||
| 241 | } | 243 | } |
| 244 | + | ||
| 242 | // ListItem() { | 245 | // ListItem() { |
| 243 | // | 246 | // |
| 244 | // }.height(`${this.bottomSafeHeight}` + 'px') | 247 | // }.height(`${this.bottomSafeHeight}` + 'px') |
| 245 | - }.onReachEnd(()=>{ | 248 | + } |
| 249 | + .onReachEnd(() => { | ||
| 246 | this.currentPage++ | 250 | this.currentPage++ |
| 247 | this.getData() | 251 | this.getData() |
| 248 | }) | 252 | }) |
| @@ -255,14 +259,9 @@ export struct QualityCommentsComponent { | @@ -255,14 +259,9 @@ export struct QualityCommentsComponent { | ||
| 255 | scrollBackward: NestedScrollMode.SELF_FIRST | 259 | scrollBackward: NestedScrollMode.SELF_FIRST |
| 256 | }) | 260 | }) |
| 257 | } | 261 | } |
| 258 | - | ||
| 259 | - | ||
| 260 | - | ||
| 261 | } | 262 | } |
| 262 | 263 | ||
| 263 | 264 | ||
| 264 | - | ||
| 265 | - | ||
| 266 | @Component | 265 | @Component |
| 267 | struct QualityCommentItem { | 266 | struct QualityCommentItem { |
| 268 | @ObjectLink publishCommentModel: publishCommentModel | 267 | @ObjectLink publishCommentModel: publishCommentModel |
| @@ -279,7 +278,8 @@ struct QualityCommentItem { | @@ -279,7 +278,8 @@ struct QualityCommentItem { | ||
| 279 | 278 | ||
| 280 | Image(this.item.fromUserHeader) | 279 | Image(this.item.fromUserHeader) |
| 281 | 280 | ||
| 282 | - .alt($r(commentViewModel.adjustUserType(this.item.fromUserType) ? 'app.media.WDAccountOwnerHedaerDefaultIcon' : 'app.media.WDAccountDefaultIcon')) | 281 | + .alt($r(commentViewModel.adjustUserType(this.item.fromUserType) ? |
| 282 | + 'app.media.WDAccountOwnerHedaerDefaultIcon' : 'app.media.WDAccountDefaultIcon')) | ||
| 283 | .width(50) | 283 | .width(50) |
| 284 | .height(50) | 284 | .height(50) |
| 285 | .borderRadius(25) | 285 | .borderRadius(25) |
| @@ -296,7 +296,7 @@ struct QualityCommentItem { | @@ -296,7 +296,7 @@ struct QualityCommentItem { | ||
| 296 | } | 296 | } |
| 297 | ) | 297 | ) |
| 298 | .onClick(() => { | 298 | .onClick(() => { |
| 299 | - this.jumpToAccountOwner() | 299 | + this.jumpToAccountOwner() |
| 300 | }) | 300 | }) |
| 301 | Text(this.item.fromUserName) | 301 | Text(this.item.fromUserName) |
| 302 | .fontSize(14) | 302 | .fontSize(14) |
| @@ -376,7 +376,7 @@ struct QualityCommentItem { | @@ -376,7 +376,7 @@ struct QualityCommentItem { | ||
| 376 | Row() { | 376 | Row() { |
| 377 | Image($r('app.media.comment_icon_pinglun')).width(16).height(16) | 377 | Image($r('app.media.comment_icon_pinglun')).width(16).height(16) |
| 378 | }.height('100%') | 378 | }.height('100%') |
| 379 | - .onClick(()=>{ | 379 | + .onClick(() => { |
| 380 | this.replyComment() | 380 | this.replyComment() |
| 381 | }) | 381 | }) |
| 382 | 382 |
-
Please register or login to post a comment