chenquansheng

ref |> 图文详情点击评论需要有正文和数字的切换功能开发

@@ -69,6 +69,7 @@ export struct ImageAndTextPageComponent { @@ -69,6 +69,7 @@ export struct ImageAndTextPageComponent {
69 private screenHeight: number = 0 69 private screenHeight: number = 0
70 private topHeight: number = 32 70 private topHeight: number = 32
71 private bottomHeight: number = 150 71 private bottomHeight: number = 150
  72 + @State showMainText: boolean = false
72 pageShowTime:number = 0; 73 pageShowTime:number = 0;
73 pageHideTime:number = 0; 74 pageHideTime:number = 0;
74 lastTimeoutId?: number 75 lastTimeoutId?: number
@@ -165,6 +166,7 @@ export struct ImageAndTextPageComponent { @@ -165,6 +166,7 @@ export struct ImageAndTextPageComponent {
165 .onAreaChange((oldValue: Area, newValue: Area) => { 166 .onAreaChange((oldValue: Area, newValue: Area) => {
166 this.info = newValue 167 this.info = newValue
167 console.log(TAG, "总页面滑动偏移量", this.scroller.currentOffset().yOffset) 168 console.log(TAG, "总页面滑动偏移量", this.scroller.currentOffset().yOffset)
  169 + console.log(TAG, "总页面滑动偏移量111", newValue.globalPosition.y as number)
168 this.checkToScrollCommentArea() 170 this.checkToScrollCommentArea()
169 }) 171 })
170 // .onMeasureSize() 172 // .onMeasureSize()
@@ -207,25 +209,41 @@ export struct ImageAndTextPageComponent { @@ -207,25 +209,41 @@ export struct ImageAndTextPageComponent {
207 contentDetailData: this.contentDetailData, 209 contentDetailData: this.contentDetailData,
208 publishCommentModel: this.publishCommentModel, 210 publishCommentModel: this.publishCommentModel,
209 operationButtonList: this.operationButtonList, 211 operationButtonList: this.operationButtonList,
  212 + showMainText:this.showMainText,
210 styleType: 1, 213 styleType: 1,
211 onCommentIconClick: () => { 214 onCommentIconClick: () => {
212 const info = componentUtils.getRectangleById('comment'); 215 const info = componentUtils.getRectangleById('comment');
213 console.log(TAG, "点击滑动页面", JSON.stringify(info)) 216 console.log(TAG, "点击滑动页面", JSON.stringify(info))
214 217
215 - if (!this.offsetY) {  
216 - this.offsetY = componentUtils.getRectangleById('comment').windowOffset.y  
217 - }  
218 - // 定位到评论区域  
219 - if (this.isScrollTop) {  
220 - this.scroller.scrollTo({  
221 - xOffset: 0,  
222 - yOffset: this.offsetY,  
223 - animation: true  
224 - })  
225 - } else {  
226 - this.scroller.scrollEdge(Edge.Top) 218 + //评论区当前位置
  219 + let currentCommonentOffSetY = this.info?.globalPosition.y as number
  220 + let offSetY = 0
  221 + if (currentCommonentOffSetY >= (this.screenHeight-this.bottomHeight) ) {
  222 + offSetY = currentCommonentOffSetY-200
  223 + this.showMainText = true
  224 + }else {
  225 + this.showMainText = false
227 } 226 }
228 - this.isScrollTop = !this.isScrollTop 227 + this.scroller.scrollTo({
  228 + yOffset: offSetY,
  229 + xOffset: 0,
  230 + animation: { duration: 1000, curve: Curve.Ease }
  231 + })
  232 +
  233 + // if (!this.offsetY) {
  234 + // this.offsetY = componentUtils.getRectangleById('comment').windowOffset.y
  235 + // }
  236 + // // 定位到评论区域
  237 + // if (this.isScrollTop) {
  238 + // this.scroller.scrollTo({
  239 + // xOffset: 0,
  240 + // yOffset: this.offsetY,
  241 + // animation: true
  242 + // })
  243 + // } else {
  244 + // this.scroller.scrollEdge(Edge.Top)
  245 + // }
  246 + // this.isScrollTop = !this.isScrollTop
229 } 247 }
230 }) 248 })
231 } 249 }
@@ -464,7 +482,7 @@ export struct ImageAndTextPageComponent { @@ -464,7 +482,7 @@ export struct ImageAndTextPageComponent {
464 return 482 return
465 } 483 }
466 let offSetY = currentScrollOffSetY 484 let offSetY = currentScrollOffSetY
467 - if (currentCommonentOffSetY > (this.screenHeight-this.bottomHeight) ) { 485 + if (currentCommonentOffSetY >= (this.screenHeight-this.bottomHeight) ) {
468 offSetY = currentCommonentOffSetY-200 486 offSetY = currentCommonentOffSetY-200
469 }else { 487 }else {
470 offSetY = currentScrollOffSetY + currentCommonentOffSetY-100 488 offSetY = currentScrollOffSetY + currentCommonentOffSetY-100
@@ -161,6 +161,7 @@ export struct CommentIconComponent { @@ -161,6 +161,7 @@ export struct CommentIconComponent {
161 /*展示类型*/ 161 /*展示类型*/
162 @State type: number = 1 162 @State type: number = 1
163 @Prop contentDetail: ContentDetailDTO 163 @Prop contentDetail: ContentDetailDTO
  164 + @Prop showMainText: boolean = false // 是否显示正文样式
164 styleType: number = 1 //1: 白色背景(图文底部栏) 2: 黑色背景(图集底部栏) 165 styleType: number = 1 //1: 白色背景(图文底部栏) 2: 黑色背景(图集底部栏)
165 // aboutToAppear(): void { 166 // aboutToAppear(): void {
166 // setTimeout(() => { 167 // setTimeout(() => {
@@ -186,7 +187,7 @@ export struct CommentIconComponent { @@ -186,7 +187,7 @@ export struct CommentIconComponent {
186 // Stack({alignContent:Alignment.Start}) { 187 // Stack({alignContent:Alignment.Start}) {
187 if (Number.parseInt(this.publishCommentModel.totalCommentNumer) != 0) { 188 if (Number.parseInt(this.publishCommentModel.totalCommentNumer) != 0) {
188 RelativeContainer() { 189 RelativeContainer() {
189 - Image(this.styleType == 1 ? $r('app.media.comment_icon_number_bg') : $r('app.media.ic_like_back_Select')) 190 + Image(this.styleType == 1 ? this.showMainText?$r('app.media.comment_icon_text_bg'):$r('app.media.comment_icon_number_bg') : this.showMainText?$r('app.media.comment_icon_text_block_bg'):$r('app.media.ic_like_back_Select'))
190 .objectFit(ImageFit.Fill) 191 .objectFit(ImageFit.Fill)
191 .resizable({ 192 .resizable({
192 slice: { 193 slice: {
@@ -205,10 +206,9 @@ export struct CommentIconComponent { @@ -205,10 +206,9 @@ export struct CommentIconComponent {
205 // x:-6 206 // x:-6
206 // }) 207 // })
207 .id("Image") 208 .id("Image")
208 -  
209 - Text(this.publishCommentModel.totalCommentNumer)// Text("44444444") 209 + Text(this.showMainText?'正文':this.publishCommentModel.totalCommentNumer)// Text("44444444")
210 .fontSize(8) 210 .fontSize(8)
211 - .fontColor('#ffffff')// .backgroundColor('#ED2800') 211 + .fontColor(this.showMainText?'#222222':'#ffffff')// .backgroundColor('#ED2800')
212 .height(12) 212 .height(12)
213 .textAlign(TextAlign.Center) 213 .textAlign(TextAlign.Center)
214 .alignRules({ 214 .alignRules({
@@ -79,6 +79,7 @@ export struct OperRowListView { @@ -79,6 +79,7 @@ export struct OperRowListView {
79 @ObjectLink publishCommentModel: publishCommentModel 79 @ObjectLink publishCommentModel: publishCommentModel
80 @State styleType: number = -1 80 @State styleType: number = -1
81 @State showCommentIcon: boolean = true // 评论图标 81 @State showCommentIcon: boolean = true // 评论图标
  82 + @Prop showMainText: boolean = false // 是否显示正文样式
82 @State bgColor: ResourceColor = Color.White 83 @State bgColor: ResourceColor = Color.White
83 @State interactData: InteractDataDTO = {} as InteractDataDTO 84 @State interactData: InteractDataDTO = {} as InteractDataDTO
84 @State newsStatusOfUser: batchLikeAndCollectResult | undefined = undefined // 点赞、收藏状态 85 @State newsStatusOfUser: batchLikeAndCollectResult | undefined = undefined // 点赞、收藏状态
@@ -299,7 +300,8 @@ export struct OperRowListView { @@ -299,7 +300,8 @@ export struct OperRowListView {
299 CommentIconComponent({ 300 CommentIconComponent({
300 publishCommentModel: this.publishCommentModel, 301 publishCommentModel: this.publishCommentModel,
301 styleType: this.styleType, 302 styleType: this.styleType,
302 - contentDetail: this.contentDetailData 303 + contentDetail: this.contentDetailData,
  304 + showMainText: this.showMainText
303 }) 305 })
304 .onClick(() => { 306 .onClick(() => {
305 console.log('akdbakdbakdbaksjd') 307 console.log('akdbakdbakdbaksjd')