yangsunyue_wd

desc:评论相关

import { Logger, NumberFormatterUtils, DateTimeUtils } from 'wdKit';
import { Logger, NumberFormatterUtils, DateTimeUtils, EmitterUtils, EmitterEventId } from 'wdKit';
import {
Action,
ContentDetailDTO,
... ... @@ -126,6 +126,7 @@ export struct ImageAndTextPageComponent {
CommentComponent({
publishCommentModel: this.publishCommentModel
})
// .onMeasureSize()
}
}
}
... ... @@ -280,6 +281,15 @@ export struct ImageAndTextPageComponent {
aboutToAppear() {
this.getDetail()
//注册通知,来自别的组件的评论成功通知
EmitterUtils.receiveEvent(EmitterEventId.COMMENT_PUBLISH, (targetId?: string) => {
if (targetId) {
if (targetId == this.publishCommentModel.targetId) {
// 滚动到评论列表
}
}
})
}
aboutToDisappear() {
... ...
... ... @@ -25,6 +25,10 @@ export struct CommentComponent {
// @State private browSingModel: commentListModel = new commentListModel()
/*必传*/
@ObjectLink publishCommentModel: publishCommentModel
listScroller: ListScroller = new ListScroller(); // scroller控制器
historyOffset: number = 0; // 上次浏览到列表距离顶端的偏移量offset
isloading: boolean = false
@State allDatas: LazyDataSource<commentItemModel> = new LazyDataSource();
@State dialogController: CustomDialogController | null = null;
... ... @@ -69,11 +73,12 @@ export struct CommentComponent {
//
addCommentLocal() {
let model = commentViewModel.deepCopyCommentItemModel(this.publishCommentModel.lastCommentModel)
// let model = commentViewModel.deepCopyCommentItemModel(this.publishCommentModel.lastCommentModel)
let model = this.publishCommentModel.lastCommentModel
/*一级评论*/
// if (this.publishCommentModel.lastCommentModel)
if (this.publishCommentModel.lastCommentModel.parentId == '-1') {
this.allDatas.addFirstItem(model)
//TODO 跳转顶部
} else {
//二级评论
this.allDatas.getDataArray().forEach(element => {
... ... @@ -134,7 +139,7 @@ export struct CommentComponent {
build() {
Column() {
List() {
List({scroller:this.listScroller}) {
ListItemGroup({ header: this.titleHeader() })
LazyForEach(this.allDatas, (item: commentItemModel, index: number) => {
... ... @@ -176,7 +181,9 @@ export struct CommentComponent {
if (this.hasMore === false) NoMoreLayout()
}
}
// .onScrollFrameBegin((offset: number, state: ScrollState)=>{
//
// })
.onReachEnd(()=>{
if (this.hasMore) {
this.getData()
... ...
... ... @@ -27,7 +27,9 @@ export struct CommentCustomDialog {
this.publishCommentModel.commentType = '2'
commentViewModel.publishComment(this.publishCommentModel).then((model:commentItemModel) => {
this.publishCommentModel.commentContent = ''
this.publishCommentModel.lastCommentModel = model
//
this.publishCommentModel.lastCommentModel = commentViewModel.deepCopyCommentItemModel(model)
// this.commentText = ''
if (this.controller != null) {
this.controller.close()
... ...
... ... @@ -44,7 +44,10 @@ export struct CommentTabComponent {
}
}.width(151).height(30)
.onClick(() => {
this.publishCommentModel.rootCommentId = '-1';
this.publishCommentModel.parentId = '-1';
this.publishCommentModel.placeHolderText = "优质评论会获得最佳评论人的称号"
this.dialogController?.open();
})
}
... ...