chenquansheng

fix |> 修复点击评论按钮进入稿件详情页滑动到指定评论区域

... ... @@ -189,7 +189,7 @@ export class ProcessUtils {
if (typeof type == "number") {
type = `${type}`
}
// console.log(TAG, 'objectType', `${JSON.stringify(content)}`);
// Logger.debug(TAG, `objectType, ${JSON.stringify(content)}`);
switch (type) {
case ContentConstants.TYPE_NONE:
// Logger.debug(TAG, "processPage, do nothing");
... ... @@ -432,7 +432,8 @@ export class ProcessUtils {
commentId: content?.commentInfo?.commentId,
title: content?.newsTitle
} as ExtraDTO,
targetLayout: content.customParamTargetLayout
targetLayout: content.customParamTargetLayout,
clickComment: content.clickComment
} as Params,
};
WDRouterRule.jumpWithAction(taskAction)
... ... @@ -454,7 +455,8 @@ export class ProcessUtils {
sourcePage: '5',
commentId: content?.commentInfo?.commentId
} as ExtraDTO,
targetLayout: content.customParamTargetLayout
targetLayout: content.customParamTargetLayout,
clickComment: content.clickComment
} as Params,
};
WDRouterRule.jumpWithAction(taskAction)
... ...
... ... @@ -144,6 +144,7 @@ export class ContentDTO implements BaseDTO {
isMourning?: boolean = false;
author: string = ""; ///撰稿人
clickComment:boolean = false;
static clone(old: ContentDTO): ContentDTO {
let content = new ContentDTO();
... ...
... ... @@ -24,6 +24,6 @@ export interface Params {
videoCoverUrl?: string;
pageId?: string;
backVisibility?: boolean; //展示顶部返回栏
clickComment?:boolean;//点击评论按钮进入稿件详情页定位到评论区
targetLayout?: string; // "comment" 表示进入对应页面后,跳转至评论区
}
... ...
... ... @@ -101,6 +101,7 @@ export struct CarderInteraction {
}
.justifyContent(FlexAlign.Center)
.onClick(() => {
this.contentDTO.clickComment = true
ProcessUtils.processPage(this.contentDTO);
})
}
... ...
... ... @@ -52,7 +52,7 @@ export struct ImageAndTextPageComponent {
@State recommendList: ContentDTO[] = []
@State newsStatusOfUser: batchLikeAndCollectResult | undefined = undefined // 点赞、收藏状态
@State interactData: InteractDataDTO = {} as InteractDataDTO
@State isPageEnd: boolean = false
// @State isPageEnd: boolean = false
@State publishTime: string = ''
@State publishCommentModel: publishCommentModel = new publishCommentModel()
// @State operationButtonList: string[] = ['comment', 'collect', 'share']
... ... @@ -77,6 +77,7 @@ export struct ImageAndTextPageComponent {
lastTimeoutId?: number
@State needAnimation: boolean = false;
@State @Watch("webPageIsPageEnd") isPageEnd: boolean = false
@Consume @Watch('pageShowForUpdateData') pageShow :number
@Consume @Watch('pageHideForUpdateData') pageHide :number
... ... @@ -92,6 +93,15 @@ export struct ImageAndTextPageComponent {
TrackingPageBrowse.trackCommonPageExposureEnd(TrackConstants.PageName.Customer_Personal,TrackConstants.PageName.Customer_Personal,duration)
}
webPageIsPageEnd() {
if (this.action.params?.clickComment) {
setTimeout(()=>{
this.pageScrollToCommonent()
},
900)
}
}
build() {
Stack({ alignContent: Alignment.Top }) {
Stack({ alignContent: Alignment.Bottom }) {
... ... @@ -198,8 +208,8 @@ export struct ImageAndTextPageComponent {
.onAreaChange((oldValue: Area, newValue: Area) => {
this.info = newValue
console.log(TAG, "总页面滑动偏移量", this.scroller.currentOffset().yOffset)
console.log(TAG, "总页面滑动偏移量111", newValue.globalPosition.y as number)
// console.log(TAG, "总页面滑动偏移量", this.scroller.currentOffset().yOffset)
// console.log(TAG, "总页面滑动偏移量111", newValue.globalPosition.y as number)
this.checkToScrollCommentArea()
})
// .onMeasureSize()
... ... @@ -245,30 +255,7 @@ export struct ImageAndTextPageComponent {
showMainText:this.showMainText,
styleType: 1,
onCommentIconClick: () => {
const info = componentUtils.getRectangleById('comment');
console.log(TAG, "点击滑动页面", JSON.stringify(info))
//评论区当前位置
let currentCommonentOffSetY = this.info?.globalPosition.y as number
let offSetY = 0
if (currentCommonentOffSetY >= (this.screenHeight-this.bottomHeight) ) {
offSetY = currentCommonentOffSetY-200
}
// if (!this.offsetY) {
// this.offsetY = componentUtils.getRectangleById('comment').windowOffset.y
// }
// 定位到评论区域
if (this.isScrollTop) {
this.scroller.scrollTo({
xOffset: 0,
yOffset: offSetY,
animation: { duration: 1000, curve: Curve.Ease }
})
} else {
this.scroller.scrollEdge(Edge.Top)
}
this.isScrollTop = !this.isScrollTop
this.pageScrollToCommonent()
}
})
}
... ... @@ -288,6 +275,7 @@ export struct ImageAndTextPageComponent {
Text(this.publishTime)
.fontColor($r('app.color.color_B0B0B0'))
.fontSize(13)
.height(20)
}
}
.width(CommonConstants.FULL_WIDTH)
... ... @@ -514,6 +502,29 @@ export struct ImageAndTextPageComponent {
}
}
private pageScrollToCommonent() {
const info = componentUtils.getRectangleById('comment');
console.log(TAG, "点击滑动页面", JSON.stringify(info))
//评论区当前位置
let currentCommonentOffSetY = this.info?.globalPosition.y as number
let offSetY = 0
if (currentCommonentOffSetY >= (this.screenHeight-this.bottomHeight) ) {
offSetY = currentCommonentOffSetY-200
}
// 定位到评论区域
if (this.isScrollTop) {
this.scroller.scrollTo({
xOffset: 0,
yOffset: offSetY,
animation: { duration: 1000, curve: Curve.Ease }
})
} else {
this.scroller.scrollEdge(Edge.Top)
}
this.isScrollTop = !this.isScrollTop
}
aboutToAppear() {
Logger.debug(TAG, '文章详情页 aboutToAppear,开始请求接口数据');
this.getDetail()
... ...