ref |> 修复评论列表用户等级头像框和加V标签和最佳评论员头像相关逻辑
Signed-off-by: xugenyuan <xugenyuan@wondertek.com.cn>
Showing
3 changed files
with
102 additions
and
54 deletions
| @@ -114,7 +114,7 @@ export class commentItemModel { | @@ -114,7 +114,7 @@ export class commentItemModel { | ||
| 114 | /*评论点赞状态 0-未点赞 1-已点赞*/ | 114 | /*评论点赞状态 0-未点赞 1-已点赞*/ |
| 115 | api_status: boolean = false; | 115 | api_status: boolean = false; |
| 116 | api_level: string = ''; | 116 | api_level: string = ''; |
| 117 | - api_levelHead: string = 'http'; | 117 | + api_levelHead: string = ''; |
| 118 | api_userId: string = ''; | 118 | api_userId: string = ''; |
| 119 | api_creatorId: string = ''; | 119 | api_creatorId: string = ''; |
| 120 | api_userType: string = ''; | 120 | api_userType: string = ''; |
| 1 | -import { DateTimeUtils, EmitterEventId, EmitterUtils, LazyDataSource } from 'wdKit/Index'; | 1 | +import { DateTimeUtils, EmitterEventId, EmitterUtils, LazyDataSource, StringUtils } from 'wdKit/Index'; |
| 2 | import { commentItemModel, WDPublicUserType } from '../model/CommentModel'; | 2 | import { commentItemModel, WDPublicUserType } from '../model/CommentModel'; |
| 3 | import commentViewModel from '../viewmodel/CommentViewModel'; | 3 | import commentViewModel from '../viewmodel/CommentViewModel'; |
| 4 | import { CommentText } from './CommentText'; | 4 | import { CommentText } from './CommentText'; |
| @@ -303,34 +303,7 @@ struct ChildCommentItem { | @@ -303,34 +303,7 @@ struct ChildCommentItem { | ||
| 303 | Column() { | 303 | Column() { |
| 304 | Row() { | 304 | Row() { |
| 305 | //头像 | 305 | //头像 |
| 306 | - Stack() { | ||
| 307 | - Image(this.item.fromUserHeader) | ||
| 308 | - .alt($r('app.media.default_head')) | ||
| 309 | - .width('24') | ||
| 310 | - .height('24') | ||
| 311 | - .objectFit(ImageFit.Cover) | ||
| 312 | - .borderRadius(16) | ||
| 313 | - Image(this.item.api_levelHead) | ||
| 314 | - .width('36') | ||
| 315 | - .height('36') | ||
| 316 | - .objectFit(ImageFit.Cover) | ||
| 317 | - .borderRadius(24) | ||
| 318 | - } | ||
| 319 | - .width(48) | ||
| 320 | - .height(48) | ||
| 321 | - .margin({ left: 47 }) | ||
| 322 | - .alignContent(Alignment.Center) | ||
| 323 | - .onClick(() => { | ||
| 324 | - // TODO 跳转个人详情 | ||
| 325 | - // 跳转到号主页 | ||
| 326 | - if (this.contentDetailData.rmhInfo?.cnMainControl === 1) { | ||
| 327 | - const params: Params = { | ||
| 328 | - creatorId: this.contentDetailData.rmhInfo.rmhId, | ||
| 329 | - pageID: '' | ||
| 330 | - } | ||
| 331 | - WDRouterRule.jumpWithPage(WDRouterPage.peopleShipHomePage, params) | ||
| 332 | - } | ||
| 333 | - }) | 306 | + this.headerView() |
| 334 | 307 | ||
| 335 | //昵称 | 308 | //昵称 |
| 336 | Text() { | 309 | Text() { |
| @@ -354,7 +327,7 @@ struct ChildCommentItem { | @@ -354,7 +327,7 @@ struct ChildCommentItem { | ||
| 354 | /// 人民号>置顶>作者 | 327 | /// 人民号>置顶>作者 |
| 355 | 328 | ||
| 356 | //人民号 | 329 | //人民号 |
| 357 | - if (this.item.fromUserType === WDPublicUserType.WDPublicUserType_Matrix) { | 330 | + if (this.item.fromUserType !== 1) { |
| 358 | Image($r('app.media.comment_rmh_tag')).width(20).height(20).margin({ left: 5 }); | 331 | Image($r('app.media.comment_rmh_tag')).width(20).height(20).margin({ left: 5 }); |
| 359 | } | 332 | } |
| 360 | //置顶 | 333 | //置顶 |
| @@ -400,6 +373,53 @@ struct ChildCommentItem { | @@ -400,6 +373,53 @@ struct ChildCommentItem { | ||
| 400 | .width('100%') | 373 | .width('100%') |
| 401 | } | 374 | } |
| 402 | 375 | ||
| 376 | + @Builder headerView() { | ||
| 377 | + Stack() { | ||
| 378 | + Stack() { | ||
| 379 | + Image(this.item.fromUserHeader) | ||
| 380 | + .alt($r('app.media.default_head')) | ||
| 381 | + .width(24) | ||
| 382 | + .height(24) | ||
| 383 | + .objectFit(ImageFit.Cover) | ||
| 384 | + .borderRadius(16) | ||
| 385 | + | ||
| 386 | + if (this.item.api_authIcon && this.item.api_authIcon.length) { | ||
| 387 | + Image(this.item.api_authIcon) // 加v | ||
| 388 | + .width(14).height(14) | ||
| 389 | + .objectFit(ImageFit.Cover) | ||
| 390 | + } | ||
| 391 | + }.width(24).height(24) | ||
| 392 | + .alignContent(Alignment.BottomEnd) | ||
| 393 | + | ||
| 394 | + if ((!this.item.api_authIcon || this.item.api_authIcon.length == 0) | ||
| 395 | + && this.item.fromUserType === 1 | ||
| 396 | + && ((this.item.api_levelHead && this.item.api_levelHead.length > 0) | ||
| 397 | + || (this.item.avatarFrame && this.item.avatarFrame.length > 0))) { | ||
| 398 | + Image(this.customBorderIconURL()) | ||
| 399 | + .width('36') | ||
| 400 | + .height('36') | ||
| 401 | + .objectFit(ImageFit.Cover) | ||
| 402 | + .borderRadius(24) | ||
| 403 | + } | ||
| 404 | + } | ||
| 405 | + .width(48).height(48) | ||
| 406 | + .margin({ left: 47 }) | ||
| 407 | + .alignContent(Alignment.Center) | ||
| 408 | + .onClick(() => { | ||
| 409 | + commentViewModel.jumpToAccountPage(this.item) | ||
| 410 | + }) | ||
| 411 | + } | ||
| 412 | + | ||
| 413 | + customBorderIconURL() : string { | ||
| 414 | + if (this.item.avatarFrame.length > 0) { | ||
| 415 | + return this.item.avatarFrame | ||
| 416 | + } | ||
| 417 | + if (this.item.fromUserType === 1) { | ||
| 418 | + return this.item.api_levelHead | ||
| 419 | + } | ||
| 420 | + return "" | ||
| 421 | + } | ||
| 422 | + | ||
| 403 | replyComment() { | 423 | replyComment() { |
| 404 | if (this.item.id && this.item.checkStatus == '2') { // 审核通过的才显示回复 | 424 | if (this.item.id && this.item.checkStatus == '2') { // 审核通过的才显示回复 |
| 405 | this.publishCommentModel.rootCommentId = this.item.rootCommentId | 425 | this.publishCommentModel.rootCommentId = this.item.rootCommentId |
| @@ -498,26 +518,7 @@ struct commentHeaderView { | @@ -498,26 +518,7 @@ struct commentHeaderView { | ||
| 498 | Column() { | 518 | Column() { |
| 499 | Row() { | 519 | Row() { |
| 500 | //头像 | 520 | //头像 |
| 501 | - Stack() { | ||
| 502 | - Image(this.item.fromUserHeader) | ||
| 503 | - .alt($r('app.media.default_head')) | ||
| 504 | - .width('32') | ||
| 505 | - .height('32') | ||
| 506 | - .objectFit(ImageFit.Cover) | ||
| 507 | - .borderRadius(16) | ||
| 508 | - Image(this.item.api_levelHead) | ||
| 509 | - .width('48') | ||
| 510 | - .height('48') | ||
| 511 | - .objectFit(ImageFit.Cover) | ||
| 512 | - .borderRadius(24) | ||
| 513 | - } | ||
| 514 | - .width(48) | ||
| 515 | - .height(48) | ||
| 516 | - .margin({ left: 8 }) | ||
| 517 | - .alignContent(Alignment.Center) | ||
| 518 | - .onClick(() => { | ||
| 519 | - commentViewModel.jumpToAccountPage(this.item) | ||
| 520 | - }) | 521 | + this.headerView() |
| 521 | 522 | ||
| 522 | //昵称 | 523 | //昵称 |
| 523 | Text(this.item.fromUserName) | 524 | Text(this.item.fromUserName) |
| @@ -531,7 +532,7 @@ struct commentHeaderView { | @@ -531,7 +532,7 @@ struct commentHeaderView { | ||
| 531 | /// 人民号>置顶>作者 | 532 | /// 人民号>置顶>作者 |
| 532 | 533 | ||
| 533 | //人民号 | 534 | //人民号 |
| 534 | - if (this.item.fromUserType === WDPublicUserType.WDPublicUserType_Matrix) { | 535 | + if (this.item.fromUserType !== 1) { |
| 535 | Image($r('app.media.comment_rmh_tag')).width(20).height(20).margin({ left: 5 }); | 536 | Image($r('app.media.comment_rmh_tag')).width(20).height(20).margin({ left: 5 }); |
| 536 | } | 537 | } |
| 537 | //置顶 | 538 | //置顶 |
| @@ -573,6 +574,53 @@ struct commentHeaderView { | @@ -573,6 +574,53 @@ struct commentHeaderView { | ||
| 573 | .padding({bottom: 8}) | 574 | .padding({bottom: 8}) |
| 574 | } | 575 | } |
| 575 | 576 | ||
| 577 | + @Builder headerView() { | ||
| 578 | + Stack() { | ||
| 579 | + Stack() { | ||
| 580 | + Image(this.item.fromUserHeader) | ||
| 581 | + .alt($r('app.media.default_head')) | ||
| 582 | + .width(32) | ||
| 583 | + .height(32) | ||
| 584 | + .objectFit(ImageFit.Cover) | ||
| 585 | + .borderRadius(16) | ||
| 586 | + | ||
| 587 | + if (this.item.api_authIcon && this.item.api_authIcon.length > 0) { | ||
| 588 | + Image(this.item.api_authIcon) // 加v | ||
| 589 | + .width(14).height(14) | ||
| 590 | + .objectFit(ImageFit.Cover) | ||
| 591 | + } | ||
| 592 | + }.width(32).height(32) | ||
| 593 | + .alignContent(Alignment.BottomEnd) | ||
| 594 | + | ||
| 595 | + if ((!this.item.api_authIcon || this.item.api_authIcon.length == 0) | ||
| 596 | + && this.item.fromUserType === 1 | ||
| 597 | + && ((this.item.api_levelHead && this.item.api_levelHead.length > 0) | ||
| 598 | + || (this.item.avatarFrame && this.item.avatarFrame.length > 0))) { | ||
| 599 | + Image(this.customBorderIconURL()) | ||
| 600 | + .width(48) | ||
| 601 | + .height(48) | ||
| 602 | + .objectFit(ImageFit.Cover) | ||
| 603 | + .borderRadius(24) | ||
| 604 | + } | ||
| 605 | + } | ||
| 606 | + .width(48).height(48) | ||
| 607 | + .margin({ left: 8 }) | ||
| 608 | + .alignContent(Alignment.Center) | ||
| 609 | + .onClick(() => { | ||
| 610 | + commentViewModel.jumpToAccountPage(this.item) | ||
| 611 | + }) | ||
| 612 | + } | ||
| 613 | + | ||
| 614 | + customBorderIconURL() : string { | ||
| 615 | + if (this.item.avatarFrame.length > 0) { | ||
| 616 | + return this.item.avatarFrame | ||
| 617 | + } | ||
| 618 | + if (this.item.fromUserType === 1) { | ||
| 619 | + return this.item.api_levelHead | ||
| 620 | + } | ||
| 621 | + return "" | ||
| 622 | + } | ||
| 623 | + | ||
| 576 | replyComment() { | 624 | replyComment() { |
| 577 | if (this.item.id && this.item.checkStatus == '2') { // 审核通过的才显示回复 | 625 | if (this.item.id && this.item.checkStatus == '2') { // 审核通过的才显示回复 |
| 578 | this.publishCommentModel.rootCommentId = this.item.rootCommentId | 626 | this.publishCommentModel.rootCommentId = this.item.rootCommentId |
| @@ -419,7 +419,7 @@ class CommentViewModel { | @@ -419,7 +419,7 @@ class CommentViewModel { | ||
| 419 | newModel.fromUserHeader = model.fromUserHeader | 419 | newModel.fromUserHeader = model.fromUserHeader |
| 420 | newModel.fromUserId = model.fromUserId | 420 | newModel.fromUserId = model.fromUserId |
| 421 | newModel.fromUserName = model.fromUserName | 421 | newModel.fromUserName = model.fromUserName |
| 422 | - if (model.toUserType != null) { | 422 | + if (model.fromUserType) { |
| 423 | newModel.fromUserType = model.fromUserType | 423 | newModel.fromUserType = model.fromUserType |
| 424 | } | 424 | } |
| 425 | newModel.id = model.id | 425 | newModel.id = model.id |
| @@ -443,7 +443,7 @@ class CommentViewModel { | @@ -443,7 +443,7 @@ class CommentViewModel { | ||
| 443 | // newModel.isLoading = model.isLoading | 443 | // newModel.isLoading = model.isLoading |
| 444 | 444 | ||
| 445 | 445 | ||
| 446 | - if (model.toUserType != null) { | 446 | + if (model.toUserType) { |
| 447 | newModel.toUserType = model.toUserType.toString() | 447 | newModel.toUserType = model.toUserType.toString() |
| 448 | } | 448 | } |
| 449 | newModel.topFlag = model.topFlag | 449 | newModel.topFlag = model.topFlag |
-
Please register or login to post a comment