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

import { CommentListDialogView, publishCommentModel } from 'wdComponent/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)
  onHeightDidChange?: Callback<number>

  @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() {
    if(this.innerShowComment){
      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)
          }
        },
        onHeightDidChange: this.onHeightDidChange
      })
    }
  }
}