yangsunyue_wd

desc:评论相关,评论后自动定位评论区域

import { Logger, NumberFormatterUtils, DateTimeUtils, EmitterUtils, EmitterEventId, NetworkUtil } from 'wdKit';
import { Logger, NumberFormatterUtils, DateTimeUtils, EmitterUtils, EmitterEventId, NetworkUtil,
DisplayUtils } from 'wdKit';
import {
Action,
ContentDetailDTO,
... ... @@ -41,6 +42,7 @@ export struct ImageAndTextPageComponent {
@State publishCommentModel: publishCommentModel = new publishCommentModel()
@State operationButtonList: string[] = ['comment', 'collect', 'share']
@State isNetConnected: boolean = true
@State info: Area|null = null
build() {
Column() {
... ... @@ -131,8 +133,11 @@ export struct ImageAndTextPageComponent {
Divider().strokeWidth(6).color('#f5f5f5')
CommentComponent({
publishCommentModel: this.publishCommentModel
}).onAreaChange((oldValue: Area, newValue: Area) => {
this.info = newValue
})
// .onMeasureSize()
}
}
}
... ... @@ -144,7 +149,7 @@ export struct ImageAndTextPageComponent {
.scrollBar(BarState.Off)
.align(Alignment.Top)
if(!this.isNetConnected) {
if (!this.isNetConnected) {
EmptyComponent({
emptyType: 1,
emptyButton: true,
... ... @@ -152,7 +157,7 @@ export struct ImageAndTextPageComponent {
this.getDetail()
}
})
}else{
} else {
if (!this.isPageEnd) {
detailedSkeleton()
}
... ... @@ -308,7 +313,12 @@ export struct ImageAndTextPageComponent {
if (targetId) {
if (targetId == this.publishCommentModel.targetId) {
// 滚动到评论列表
if (this.info) {
// let height = DisplayUtils.getDeviceHeight() / 2
let offSetY = this.info?.globalPosition.y as number
//头部距离48
this.scroller.scrollTo({yOffset:offSetY - 100, xOffset:0, animation:{ duration: 1000, curve: Curve.Ease}})
}
}
}
})
... ...
... ... @@ -182,9 +182,6 @@ export struct CommentComponent {
if (this.hasMore === false) NoMoreLayout()
}
}
// .onScrollFrameBegin((offset: number, state: ScrollState)=>{
//
// })
.onReachEnd(()=>{
if (this.hasMore) {
this.getData()
... ...