xugenyuan

ref |> 解决从精选评论、我的评论进入对应文章稿件详情时,自动跳转至稿件详情评论区问题

@@ -163,7 +163,8 @@ export class ProcessUtils { @@ -163,7 +163,8 @@ export class ProcessUtils {
163 extra: { 163 extra: {
164 relType: content?.relType, 164 relType: content?.relType,
165 relId: content?.relId, 165 relId: content?.relId,
166 - } as ExtraDTO 166 + } as ExtraDTO,
  167 + targetLayout: content.customParamTargetLayout
167 } as Params, 168 } as Params,
168 }; 169 };
169 WDRouterRule.jumpWithAction(taskAction) 170 WDRouterRule.jumpWithAction(taskAction)
@@ -232,7 +233,8 @@ export class ProcessUtils { @@ -232,7 +233,8 @@ export class ProcessUtils {
232 relId: content?.relId, 233 relId: content?.relId,
233 channelId: content?.channelId, 234 channelId: content?.channelId,
234 pageId: content?.pageId 235 pageId: content?.pageId
235 - } as ExtraDTO 236 + } as ExtraDTO,
  237 + targetLayout: content.customParamTargetLayout
236 } as Params, 238 } as Params,
237 }; 239 };
238 WDRouterRule.jumpWithAction(taskAction) 240 WDRouterRule.jumpWithAction(taskAction)
@@ -300,7 +302,8 @@ export class ProcessUtils { @@ -300,7 +302,8 @@ export class ProcessUtils {
300 channelId: content?.channelId, 302 channelId: content?.channelId,
301 sourcePage: '5', 303 sourcePage: '5',
302 commentId: content?.commentInfo?.commentId 304 commentId: content?.commentInfo?.commentId
303 - } as ExtraDTO 305 + } as ExtraDTO,
  306 + targetLayout: content.customParamTargetLayout
304 } as Params, 307 } as Params,
305 }; 308 };
306 WDRouterRule.jumpWithAction(taskAction) 309 WDRouterRule.jumpWithAction(taskAction)
@@ -316,7 +319,8 @@ export class ProcessUtils { @@ -316,7 +319,8 @@ export class ProcessUtils {
316 extra: { 319 extra: {
317 relType: content?.relType, 320 relType: content?.relType,
318 relId: content?.relId, 321 relId: content?.relId,
319 - } as ExtraDTO 322 + } as ExtraDTO,
  323 + targetLayout: content.customParamTargetLayout
320 } as Params, 324 } as Params,
321 }; 325 };
322 WDRouterRule.jumpWithAction(taskAction) 326 WDRouterRule.jumpWithAction(taskAction)
@@ -352,7 +356,8 @@ export class ProcessUtils { @@ -352,7 +356,8 @@ export class ProcessUtils {
352 extra: { 356 extra: {
353 relType: content?.relType, 357 relType: content?.relType,
354 relId: content?.relId, 358 relId: content?.relId,
355 - } as ExtraDTO 359 + } as ExtraDTO,
  360 + targetLayout: content.customParamTargetLayout
356 } as Params, 361 } as Params,
357 }; 362 };
358 WDRouterRule.jumpWithAction(taskAction) 363 WDRouterRule.jumpWithAction(taskAction)
@@ -394,7 +399,8 @@ export class ProcessUtils { @@ -394,7 +399,8 @@ export class ProcessUtils {
394 extra: { 399 extra: {
395 relType: content?.relType, 400 relType: content?.relType,
396 relId: content?.relId, 401 relId: content?.relId,
397 - } as ExtraDTO 402 + } as ExtraDTO,
  403 + targetLayout: content.customParamTargetLayout
398 } as Params, 404 } as Params,
399 }; 405 };
400 WDRouterRule.jumpWithAction(taskAction) 406 WDRouterRule.jumpWithAction(taskAction)
@@ -116,6 +116,9 @@ export class ContentDTO implements BaseDTO { @@ -116,6 +116,9 @@ export class ContentDTO implements BaseDTO {
116 timeBlurred:number = 0 116 timeBlurred:number = 0
117 top:number = 0 117 top:number = 0
118 118
  119 + // 自定义参数,用于跳转对应页面时 传递targetLayout参数用
  120 + customParamTargetLayout?: string
  121 +
119 static clone(old: ContentDTO): ContentDTO { 122 static clone(old: ContentDTO): ContentDTO {
120 let content = new ContentDTO(); 123 let content = new ContentDTO();
121 content.liveType = old.liveType; 124 content.liveType = old.liveType;
@@ -24,4 +24,6 @@ export interface Params { @@ -24,4 +24,6 @@ export interface Params {
24 videoCoverUrl?: string; 24 videoCoverUrl?: string;
25 pageId?: string; 25 pageId?: string;
26 backVisibility?: boolean; //展示顶部返回栏 26 backVisibility?: boolean; //展示顶部返回栏
  27 +
  28 + targetLayout?: string; // "comment" 表示进入对应页面后,跳转至评论区
27 } 29 }
@@ -66,6 +66,7 @@ export struct ImageAndTextPageComponent { @@ -66,6 +66,7 @@ export struct ImageAndTextPageComponent {
66 @State offsetY: number = 0 66 @State offsetY: number = 0
67 pageShowTime:number = 0; 67 pageShowTime:number = 0;
68 pageHideTime:number = 0; 68 pageHideTime:number = 0;
  69 + lastTimeoutId?: number
69 70
70 onPageShow() { 71 onPageShow() {
71 this.pageShowTime = DateTimeUtils.getTimeStamp() 72 this.pageShowTime = DateTimeUtils.getTimeStamp()
@@ -152,6 +153,8 @@ export struct ImageAndTextPageComponent { @@ -152,6 +153,8 @@ export struct ImageAndTextPageComponent {
152 153
153 .onAreaChange((oldValue: Area, newValue: Area) => { 154 .onAreaChange((oldValue: Area, newValue: Area) => {
154 this.info = newValue 155 this.info = newValue
  156 +
  157 + this.checkToScrollCommentArea()
155 }) 158 })
156 // .onMeasureSize() 159 // .onMeasureSize()
157 160
@@ -413,6 +416,7 @@ export struct ImageAndTextPageComponent { @@ -413,6 +416,7 @@ export struct ImageAndTextPageComponent {
413 if (this.info) { 416 if (this.info) {
414 // let height = DisplayUtils.getDeviceHeight() / 2 417 // let height = DisplayUtils.getDeviceHeight() / 2
415 let offSetY = this.info?.globalPosition.y as number 418 let offSetY = this.info?.globalPosition.y as number
  419 + Logger.debug(TAG, "滚动至yOffset: " + (offSetY - 100))
416 //头部距离48 420 //头部距离48
417 this.scroller.scrollTo({ 421 this.scroller.scrollTo({
418 yOffset: offSetY - 100, 422 yOffset: offSetY - 100,
@@ -427,4 +431,27 @@ export struct ImageAndTextPageComponent { @@ -427,4 +431,27 @@ export struct ImageAndTextPageComponent {
427 431
428 aboutToDisappear() { 432 aboutToDisappear() {
429 } 433 }
  434 +
  435 + checkToScrollCommentArea() {
  436 + if (!this.info) {
  437 + // 需要评论区位置,调用前 请确保它有值
  438 + return
  439 + }
  440 + if (this.action.params?.targetLayout && this.action.params.targetLayout == "comment") {
  441 + if (this.lastTimeoutId) {
  442 + clearTimeout(this.lastTimeoutId)
  443 + }
  444 + this.lastTimeoutId = setTimeout(() => {
  445 + let offSetY = this.info?.globalPosition.y as number
  446 + Logger.debug(TAG, "即将滚动至yOffset: " + (offSetY - 100))
  447 + //头部距离48
  448 + this.scroller.scrollTo({
  449 + yOffset: offSetY - 100,
  450 + xOffset: 0,
  451 + animation: { duration: 1000, curve: Curve.Ease }
  452 + })
  453 + this.action.params!.targetLayout = undefined
  454 + }, 600)
  455 + }
  456 + }
430 } 457 }
@@ -498,6 +498,7 @@ struct QualityCommentItem { @@ -498,6 +498,7 @@ struct QualityCommentItem {
498 content.relType = this.item.targetRelType; 498 content.relType = this.item.targetRelType;
499 content.pageId = this.item.pageId; 499 content.pageId = this.item.pageId;
500 content.linkUrl = this.item.h5Url; 500 content.linkUrl = this.item.h5Url;
  501 + content.customParamTargetLayout = "comment"
501 ProcessUtils.processPage(content) 502 ProcessUtils.processPage(content)
502 } 503 }
503 504
@@ -93,6 +93,7 @@ export struct HomePageBottomCommentComponent { @@ -93,6 +93,7 @@ export struct HomePageBottomCommentComponent {
93 .onClick(()=>{ 93 .onClick(()=>{
94 let content = getParams(item) 94 let content = getParams(item)
95 TrackingContent.common(TrackConstants.EventType.Click,TrackConstants.PageName.Main_Personal,TrackConstants.PageName.Main_Personal,TrackParamConvert.program(content)) 95 TrackingContent.common(TrackConstants.EventType.Click,TrackConstants.PageName.Main_Personal,TrackConstants.PageName.Main_Personal,TrackParamConvert.program(content))
  96 + content.customParamTargetLayout = "comment"
96 ProcessUtils.processPage(content) 97 ProcessUtils.processPage(content)
97 }) 98 })
98 .onVisibleAreaChange([0.0, 1.0], (isVisible: boolean, currentRatio: number) => { 99 .onVisibleAreaChange([0.0, 1.0], (isVisible: boolean, currentRatio: number) => {