chenquansheng

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

@@ -189,7 +189,7 @@ export class ProcessUtils { @@ -189,7 +189,7 @@ export class ProcessUtils {
189 if (typeof type == "number") { 189 if (typeof type == "number") {
190 type = `${type}` 190 type = `${type}`
191 } 191 }
192 - // console.log(TAG, 'objectType', `${JSON.stringify(content)}`); 192 + // Logger.debug(TAG, `objectType, ${JSON.stringify(content)}`);
193 switch (type) { 193 switch (type) {
194 case ContentConstants.TYPE_NONE: 194 case ContentConstants.TYPE_NONE:
195 // Logger.debug(TAG, "processPage, do nothing"); 195 // Logger.debug(TAG, "processPage, do nothing");
@@ -432,7 +432,8 @@ export class ProcessUtils { @@ -432,7 +432,8 @@ export class ProcessUtils {
432 commentId: content?.commentInfo?.commentId, 432 commentId: content?.commentInfo?.commentId,
433 title: content?.newsTitle 433 title: content?.newsTitle
434 } as ExtraDTO, 434 } as ExtraDTO,
435 - targetLayout: content.customParamTargetLayout 435 + targetLayout: content.customParamTargetLayout,
  436 + clickComment: content.clickComment
436 } as Params, 437 } as Params,
437 }; 438 };
438 WDRouterRule.jumpWithAction(taskAction) 439 WDRouterRule.jumpWithAction(taskAction)
@@ -454,7 +455,8 @@ export class ProcessUtils { @@ -454,7 +455,8 @@ export class ProcessUtils {
454 sourcePage: '5', 455 sourcePage: '5',
455 commentId: content?.commentInfo?.commentId 456 commentId: content?.commentInfo?.commentId
456 } as ExtraDTO, 457 } as ExtraDTO,
457 - targetLayout: content.customParamTargetLayout 458 + targetLayout: content.customParamTargetLayout,
  459 + clickComment: content.clickComment
458 } as Params, 460 } as Params,
459 }; 461 };
460 WDRouterRule.jumpWithAction(taskAction) 462 WDRouterRule.jumpWithAction(taskAction)
@@ -144,6 +144,7 @@ export class ContentDTO implements BaseDTO { @@ -144,6 +144,7 @@ export class ContentDTO implements BaseDTO {
144 isMourning?: boolean = false; 144 isMourning?: boolean = false;
145 145
146 author: string = ""; ///撰稿人 146 author: string = ""; ///撰稿人
  147 + clickComment:boolean = false;
147 148
148 static clone(old: ContentDTO): ContentDTO { 149 static clone(old: ContentDTO): ContentDTO {
149 let content = new ContentDTO(); 150 let content = new ContentDTO();
@@ -24,6 +24,6 @@ export interface Params { @@ -24,6 +24,6 @@ export interface Params {
24 videoCoverUrl?: string; 24 videoCoverUrl?: string;
25 pageId?: string; 25 pageId?: string;
26 backVisibility?: boolean; //展示顶部返回栏 26 backVisibility?: boolean; //展示顶部返回栏
27 - 27 + clickComment?:boolean;//点击评论按钮进入稿件详情页定位到评论区
28 targetLayout?: string; // "comment" 表示进入对应页面后,跳转至评论区 28 targetLayout?: string; // "comment" 表示进入对应页面后,跳转至评论区
29 } 29 }
@@ -101,6 +101,7 @@ export struct CarderInteraction { @@ -101,6 +101,7 @@ export struct CarderInteraction {
101 } 101 }
102 .justifyContent(FlexAlign.Center) 102 .justifyContent(FlexAlign.Center)
103 .onClick(() => { 103 .onClick(() => {
  104 + this.contentDTO.clickComment = true
104 ProcessUtils.processPage(this.contentDTO); 105 ProcessUtils.processPage(this.contentDTO);
105 }) 106 })
106 } 107 }
@@ -52,7 +52,7 @@ export struct ImageAndTextPageComponent { @@ -52,7 +52,7 @@ export struct ImageAndTextPageComponent {
52 @State recommendList: ContentDTO[] = [] 52 @State recommendList: ContentDTO[] = []
53 @State newsStatusOfUser: batchLikeAndCollectResult | undefined = undefined // 点赞、收藏状态 53 @State newsStatusOfUser: batchLikeAndCollectResult | undefined = undefined // 点赞、收藏状态
54 @State interactData: InteractDataDTO = {} as InteractDataDTO 54 @State interactData: InteractDataDTO = {} as InteractDataDTO
55 - @State isPageEnd: boolean = false 55 + // @State isPageEnd: boolean = false
56 @State publishTime: string = '' 56 @State publishTime: string = ''
57 @State publishCommentModel: publishCommentModel = new publishCommentModel() 57 @State publishCommentModel: publishCommentModel = new publishCommentModel()
58 // @State operationButtonList: string[] = ['comment', 'collect', 'share'] 58 // @State operationButtonList: string[] = ['comment', 'collect', 'share']
@@ -77,6 +77,7 @@ export struct ImageAndTextPageComponent { @@ -77,6 +77,7 @@ export struct ImageAndTextPageComponent {
77 lastTimeoutId?: number 77 lastTimeoutId?: number
78 @State needAnimation: boolean = false; 78 @State needAnimation: boolean = false;
79 79
  80 + @State @Watch("webPageIsPageEnd") isPageEnd: boolean = false
80 @Consume @Watch('pageShowForUpdateData') pageShow :number 81 @Consume @Watch('pageShowForUpdateData') pageShow :number
81 @Consume @Watch('pageHideForUpdateData') pageHide :number 82 @Consume @Watch('pageHideForUpdateData') pageHide :number
82 83
@@ -92,6 +93,15 @@ export struct ImageAndTextPageComponent { @@ -92,6 +93,15 @@ export struct ImageAndTextPageComponent {
92 TrackingPageBrowse.trackCommonPageExposureEnd(TrackConstants.PageName.Customer_Personal,TrackConstants.PageName.Customer_Personal,duration) 93 TrackingPageBrowse.trackCommonPageExposureEnd(TrackConstants.PageName.Customer_Personal,TrackConstants.PageName.Customer_Personal,duration)
93 } 94 }
94 95
  96 + webPageIsPageEnd() {
  97 + if (this.action.params?.clickComment) {
  98 + setTimeout(()=>{
  99 + this.pageScrollToCommonent()
  100 + },
  101 + 900)
  102 + }
  103 + }
  104 +
95 build() { 105 build() {
96 Stack({ alignContent: Alignment.Top }) { 106 Stack({ alignContent: Alignment.Top }) {
97 Stack({ alignContent: Alignment.Bottom }) { 107 Stack({ alignContent: Alignment.Bottom }) {
@@ -198,8 +208,8 @@ export struct ImageAndTextPageComponent { @@ -198,8 +208,8 @@ export struct ImageAndTextPageComponent {
198 208
199 .onAreaChange((oldValue: Area, newValue: Area) => { 209 .onAreaChange((oldValue: Area, newValue: Area) => {
200 this.info = newValue 210 this.info = newValue
201 - console.log(TAG, "总页面滑动偏移量", this.scroller.currentOffset().yOffset)  
202 - console.log(TAG, "总页面滑动偏移量111", newValue.globalPosition.y as number) 211 + // console.log(TAG, "总页面滑动偏移量", this.scroller.currentOffset().yOffset)
  212 + // console.log(TAG, "总页面滑动偏移量111", newValue.globalPosition.y as number)
203 this.checkToScrollCommentArea() 213 this.checkToScrollCommentArea()
204 }) 214 })
205 // .onMeasureSize() 215 // .onMeasureSize()
@@ -245,30 +255,7 @@ export struct ImageAndTextPageComponent { @@ -245,30 +255,7 @@ export struct ImageAndTextPageComponent {
245 showMainText:this.showMainText, 255 showMainText:this.showMainText,
246 styleType: 1, 256 styleType: 1,
247 onCommentIconClick: () => { 257 onCommentIconClick: () => {
248 - const info = componentUtils.getRectangleById('comment');  
249 - console.log(TAG, "点击滑动页面", JSON.stringify(info))  
250 -  
251 - //评论区当前位置  
252 - let currentCommonentOffSetY = this.info?.globalPosition.y as number  
253 - let offSetY = 0  
254 - if (currentCommonentOffSetY >= (this.screenHeight-this.bottomHeight) ) {  
255 - offSetY = currentCommonentOffSetY-200  
256 - }  
257 -  
258 - // if (!this.offsetY) {  
259 - // this.offsetY = componentUtils.getRectangleById('comment').windowOffset.y  
260 - // }  
261 - // 定位到评论区域  
262 - if (this.isScrollTop) {  
263 - this.scroller.scrollTo({  
264 - xOffset: 0,  
265 - yOffset: offSetY,  
266 - animation: { duration: 1000, curve: Curve.Ease }  
267 - })  
268 - } else {  
269 - this.scroller.scrollEdge(Edge.Top)  
270 - }  
271 - this.isScrollTop = !this.isScrollTop 258 + this.pageScrollToCommonent()
272 } 259 }
273 }) 260 })
274 } 261 }
@@ -288,6 +275,7 @@ export struct ImageAndTextPageComponent { @@ -288,6 +275,7 @@ export struct ImageAndTextPageComponent {
288 Text(this.publishTime) 275 Text(this.publishTime)
289 .fontColor($r('app.color.color_B0B0B0')) 276 .fontColor($r('app.color.color_B0B0B0'))
290 .fontSize(13) 277 .fontSize(13)
  278 + .height(20)
291 } 279 }
292 } 280 }
293 .width(CommonConstants.FULL_WIDTH) 281 .width(CommonConstants.FULL_WIDTH)
@@ -514,6 +502,29 @@ export struct ImageAndTextPageComponent { @@ -514,6 +502,29 @@ export struct ImageAndTextPageComponent {
514 } 502 }
515 } 503 }
516 504
  505 + private pageScrollToCommonent() {
  506 + const info = componentUtils.getRectangleById('comment');
  507 + console.log(TAG, "点击滑动页面", JSON.stringify(info))
  508 + //评论区当前位置
  509 + let currentCommonentOffSetY = this.info?.globalPosition.y as number
  510 + let offSetY = 0
  511 + if (currentCommonentOffSetY >= (this.screenHeight-this.bottomHeight) ) {
  512 + offSetY = currentCommonentOffSetY-200
  513 + }
  514 +
  515 + // 定位到评论区域
  516 + if (this.isScrollTop) {
  517 + this.scroller.scrollTo({
  518 + xOffset: 0,
  519 + yOffset: offSetY,
  520 + animation: { duration: 1000, curve: Curve.Ease }
  521 + })
  522 + } else {
  523 + this.scroller.scrollEdge(Edge.Top)
  524 + }
  525 + this.isScrollTop = !this.isScrollTop
  526 + }
  527 +
517 aboutToAppear() { 528 aboutToAppear() {
518 Logger.debug(TAG, '文章详情页 aboutToAppear,开始请求接口数据'); 529 Logger.debug(TAG, '文章详情页 aboutToAppear,开始请求接口数据');
519 this.getDetail() 530 this.getDetail()