Merge branch 'main' of http://192.168.1.42/developOne/harmonyPool
Showing
8 changed files
with
86 additions
and
23 deletions
| @@ -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 | } |
| @@ -17,6 +17,7 @@ import { | @@ -17,6 +17,7 @@ import { | ||
| 17 | batchLikeAndCollectResult, | 17 | batchLikeAndCollectResult, |
| 18 | RmhInfoDTO, | 18 | RmhInfoDTO, |
| 19 | InteractDataDTO, | 19 | InteractDataDTO, |
| 20 | + Action, | ||
| 20 | } from 'wdBean'; | 21 | } from 'wdBean'; |
| 21 | import media from '@ohos.multimedia.media'; | 22 | import media from '@ohos.multimedia.media'; |
| 22 | import { OperRowListView } from './view/OperRowListView'; | 23 | import { OperRowListView } from './view/OperRowListView'; |
| @@ -56,9 +57,7 @@ const PATTERN_DATE_CN_RN: string = 'yyyy年MM月dd日 HH:mm'; | @@ -56,9 +57,7 @@ const PATTERN_DATE_CN_RN: string = 'yyyy年MM月dd日 HH:mm'; | ||
| 56 | @Component | 57 | @Component |
| 57 | export struct DynamicDetailComponent { | 58 | export struct DynamicDetailComponent { |
| 58 | //入参 | 59 | //入参 |
| 59 | - private relId: string = '' | ||
| 60 | - private contentId: string = '' | ||
| 61 | - private relType: string = '' | 60 | + action: Action = {} as Action |
| 62 | //出参 | 61 | //出参 |
| 63 | @Provide contentDetailData: ContentDetailDTO = {} as ContentDetailDTO | 62 | @Provide contentDetailData: ContentDetailDTO = {} as ContentDetailDTO |
| 64 | //UI | 63 | //UI |
| @@ -82,6 +81,8 @@ export struct DynamicDetailComponent { | @@ -82,6 +81,8 @@ export struct DynamicDetailComponent { | ||
| 82 | @State openLikes: boolean = false // 是否可以点赞 1:可以 0:不可以 | 81 | @State openLikes: boolean = false // 是否可以点赞 1:可以 0:不可以 |
| 83 | 82 | ||
| 84 | pageParam: ParamType = {} | 83 | pageParam: ParamType = {} |
| 84 | + commentListAreaInfo?: Area | ||
| 85 | + lastTimeoutId?: number | ||
| 85 | 86 | ||
| 86 | // @Provide bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0 | 87 | // @Provide bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0 |
| 87 | @Provide topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0 | 88 | @Provide topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0 |
| @@ -553,6 +554,12 @@ export struct DynamicDetailComponent { | @@ -553,6 +554,12 @@ export struct DynamicDetailComponent { | ||
| 553 | CommentComponent({ | 554 | CommentComponent({ |
| 554 | publishCommentModel: this.publishCommentModel | 555 | publishCommentModel: this.publishCommentModel |
| 555 | }) | 556 | }) |
| 557 | + .id("comment") | ||
| 558 | + .onAreaChange((oldValue: Area, newValue: Area) => { | ||
| 559 | + this.commentListAreaInfo = newValue | ||
| 560 | + this.checkToScrollCommentArea() | ||
| 561 | + }) | ||
| 562 | + | ||
| 556 | } | 563 | } |
| 557 | Blank().layoutWeight(1) | 564 | Blank().layoutWeight(1) |
| 558 | } | 565 | } |
| @@ -587,7 +594,10 @@ export struct DynamicDetailComponent { | @@ -587,7 +594,10 @@ export struct DynamicDetailComponent { | ||
| 587 | private async getContentDetailData() { | 594 | private async getContentDetailData() { |
| 588 | this.isNetConnected = NetworkUtil.isNetConnected() | 595 | this.isNetConnected = NetworkUtil.isNetConnected() |
| 589 | try { | 596 | try { |
| 590 | - let data = await MultiPictureDetailViewModel.getDetailData(this.relId, this.contentId, this.relType) | 597 | + const relId = this.action.params?.extra?.relId || ''; |
| 598 | + const relType = this.action.params?.extra?.relType || ''; | ||
| 599 | + const contentId = this.action.params?.contentID || ''; | ||
| 600 | + let data = await MultiPictureDetailViewModel.getDetailData(relId, contentId, relType) | ||
| 591 | this.isPageEnd = true; | 601 | this.isPageEnd = true; |
| 592 | this.contentDetailData = data[0]; | 602 | this.contentDetailData = data[0]; |
| 593 | let dateTime = | 603 | let dateTime = |
| @@ -804,6 +814,29 @@ export struct DynamicDetailComponent { | @@ -804,6 +814,29 @@ export struct DynamicDetailComponent { | ||
| 804 | let context = getContext(this) as common.UIAbilityContext; | 814 | let context = getContext(this) as common.UIAbilityContext; |
| 805 | viewBlogItemInsightIntentShare(context,this.contentDetailData, this.interactDataDTO) | 815 | viewBlogItemInsightIntentShare(context,this.contentDetailData, this.interactDataDTO) |
| 806 | } | 816 | } |
| 817 | + | ||
| 818 | + checkToScrollCommentArea() { | ||
| 819 | + if (!this.commentListAreaInfo) { | ||
| 820 | + // 需要评论区位置,调用前 请确保它有值 | ||
| 821 | + return | ||
| 822 | + } | ||
| 823 | + if (this.action.params?.targetLayout && this.action.params.targetLayout == "comment") { | ||
| 824 | + if (this.lastTimeoutId) { | ||
| 825 | + clearTimeout(this.lastTimeoutId) | ||
| 826 | + } | ||
| 827 | + this.lastTimeoutId = setTimeout(() => { | ||
| 828 | + let offSetY = this.commentListAreaInfo?.globalPosition.y as number | ||
| 829 | + Logger.debug(TAG, "即将滚动至yOffset: " + (offSetY - 100)) | ||
| 830 | + //头部距离48 | ||
| 831 | + this.scroller.scrollTo({ | ||
| 832 | + yOffset: offSetY - 100, | ||
| 833 | + xOffset: 0, | ||
| 834 | + animation: { duration: 1000, curve: Curve.Ease } | ||
| 835 | + }) | ||
| 836 | + this.action.params!.targetLayout = undefined | ||
| 837 | + }, 600) | ||
| 838 | + } | ||
| 839 | + } | ||
| 807 | } | 840 | } |
| 808 | 841 | ||
| 809 | interface radiusType { | 842 | interface radiusType { |
| @@ -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 | } |
sight_harmony/features/wdComponent/src/main/ets/components/comment/view/QualityCommentsComponent.ets
| @@ -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) => { |
| @@ -9,35 +9,25 @@ const TAG = 'DynamicDetailPage'; | @@ -9,35 +9,25 @@ const TAG = 'DynamicDetailPage'; | ||
| 9 | @Component | 9 | @Component |
| 10 | struct DynamicDetailPage { | 10 | struct DynamicDetailPage { |
| 11 | pageShowTime:number = 0; | 11 | pageShowTime:number = 0; |
| 12 | - @State relId: string = '' | ||
| 13 | - @State contentId: string = '' | ||
| 14 | - @State relType: string = '' | ||
| 15 | 12 | ||
| 16 | @Provide pageName: string = TrackConstants.PageName.DynamicDetail | 13 | @Provide pageName: string = TrackConstants.PageName.DynamicDetail |
| 17 | @Provide pageId: string = TrackConstants.PageName.DynamicDetail | 14 | @Provide pageId: string = TrackConstants.PageName.DynamicDetail |
| 18 | 15 | ||
| 19 | build() { | 16 | build() { |
| 20 | Column() { | 17 | Column() { |
| 21 | - DynamicDetailComponent({ | ||
| 22 | - relId: this.relId, | ||
| 23 | - contentId: this.contentId, | ||
| 24 | - relType: this.relType | ||
| 25 | - }) | 18 | + DynamicDetailComponent({action: router.getParams() as Action }) |
| 26 | } | 19 | } |
| 27 | .height('100%') | 20 | .height('100%') |
| 28 | .width('100%') | 21 | .width('100%') |
| 29 | .backgroundColor('#20272E') | 22 | .backgroundColor('#20272E') |
| 30 | } | 23 | } |
| 31 | aboutToAppear() { | 24 | aboutToAppear() { |
| 32 | - let par:Action = router.getParams() as Action; | ||
| 33 | - let params = par?.params; | ||
| 34 | - this.relId = params?.extra?.relId || ''; | ||
| 35 | - this.relType = params?.extra?.relType || ''; | ||
| 36 | - this.contentId = params?.contentID || ''; | ||
| 37 | } | 25 | } |
| 26 | + | ||
| 38 | onPageShow() { | 27 | onPageShow() { |
| 39 | this.pageShowTime = DateTimeUtils.getTimeStamp() | 28 | this.pageShowTime = DateTimeUtils.getTimeStamp() |
| 40 | } | 29 | } |
| 30 | + | ||
| 41 | onPageHide() { | 31 | onPageHide() { |
| 42 | //页面浏览 | 32 | //页面浏览 |
| 43 | TrackingPageBrowse.trackCommonPageExposureEnd(TrackConstants.PageName.DynamicDetail,TrackConstants.PageName.DynamicDetail,Math.floor((DateTimeUtils.getTimeStamp() - this.pageShowTime)/1000)) | 33 | TrackingPageBrowse.trackCommonPageExposureEnd(TrackConstants.PageName.DynamicDetail,TrackConstants.PageName.DynamicDetail,Math.floor((DateTimeUtils.getTimeStamp() - this.pageShowTime)/1000)) |
-
Please register or login to post a comment