CommentDialogView.ets 1.47 KB
import { ContentDetailDTO, InteractDataDTO, PageInfoDTO } from 'wdBean/Index'

import { CommentListDialogView, publishCommentModel } from '../../../../Index'

@Component
export struct CommentDialogView {
  @Link @Watch('showCommentListChange') showCommentList: boolean
  @Link index: number
  @Link currentIndex: number
  @Link publishCommentModel: publishCommentModel
  @Consume contentDetailData: ContentDetailDTO
  @Link interactData: InteractDataDTO
  @State fakePageInfo: PageInfoDTO = {} as PageInfoDTO
  @State dialogOffsetY: number = 0 // (this.windowHeight - this.windowWidth * 9 / 16)

  @State @Watch("innerShowCommentChange") innerShowComment: boolean = false

  showCommentListChange(val: boolean) {
    if (this.showCommentList && this.index === this.currentIndex) {
      this.innerShowComment = true
    } else {
      this.innerShowComment = false
    }
  }

  innerShowCommentChange() {
    this.showCommentList = this.innerShowComment
  }

  build() {
    CommentListDialogView({
      showCommentList: this.innerShowComment,
      contentDetailData: this.contentDetailData,
      publishCommentModel: this.publishCommentModel,
      pageInfo: this.fakePageInfo,
      onClose: () => {
        this.showCommentList = false
        if (Number.parseInt(this.publishCommentModel.totalCommentNumer) > Number.parseInt(this.interactData.commentNum + "")) {
          this.interactData.commentNum = Number.parseInt(this.publishCommentModel.totalCommentNumer)
        }
      }
    })
  }
}