liyubing

fix:1)电子报-电子报最后一版进入读报纸列表后_未展示该版内容

@@ -4,7 +4,9 @@ import { WDRouterRule } from 'wdRouter/Index' @@ -4,7 +4,9 @@ import { WDRouterRule } from 'wdRouter/Index'
4 import { ENewspaperPageDialog } from '../dialog/ENewspaperPageDialog' 4 import { ENewspaperPageDialog } from '../dialog/ENewspaperPageDialog'
5 import { Logger } from 'wdKit'; 5 import { Logger } from 'wdKit';
6 import { font, window } from '@kit.ArkUI'; 6 import { font, window } from '@kit.ArkUI';
  7 +
7 const TAG: string = 'ENewspaperListDialog'; 8 const TAG: string = 'ENewspaperListDialog';
  9 +
8 /** 10 /**
9 * 读报纸半屏弹窗 11 * 读报纸半屏弹窗
10 * 弹窗嵌套参考资料(https://developer.harmonyos.com/cn/docs/documentation/doc-references-V2/ts-methods-custom-dialog-box-0000001580345722-V2) 12 * 弹窗嵌套参考资料(https://developer.harmonyos.com/cn/docs/documentation/doc-references-V2/ts-methods-custom-dialog-box-0000001580345722-V2)
@@ -18,9 +20,7 @@ export struct ENewspaperListDialog { @@ -18,9 +20,7 @@ export struct ENewspaperListDialog {
18 private listScroller: Scroller = new Scroller() 20 private listScroller: Scroller = new Scroller()
19 @State scrollOffset: number = 0 21 @State scrollOffset: number = 0
20 @State isCurrentViewOpen: boolean = false 22 @State isCurrentViewOpen: boolean = false
21 - @Consume bottomSafeHeight:number  
22 -  
23 - firstFlag : boolean = true 23 + @Consume bottomSafeHeight: number
24 //文字版选择弹框 24 //文字版选择弹框
25 pageListDialogController: CustomDialogController = new CustomDialogController({ 25 pageListDialogController: CustomDialogController = new CustomDialogController({
26 builder: ENewspaperPageDialog({ 26 builder: ENewspaperPageDialog({
@@ -42,7 +42,6 @@ export struct ENewspaperListDialog { @@ -42,7 +42,6 @@ export struct ENewspaperListDialog {
42 // 那么此处需要将指向自己的controller放在所有controller的后面 42 // 那么此处需要将指向自己的controller放在所有controller的后面
43 // listDialogController: CustomDialogController 43 // listDialogController: CustomDialogController
44 public closeDialog?: () => void 44 public closeDialog?: () => void
45 -  
46 // 手势滑动相关 45 // 手势滑动相关
47 private panOption: PanGestureOptions = new PanGestureOptions({ direction: PanDirection.Up | PanDirection.Down }) 46 private panOption: PanGestureOptions = new PanGestureOptions({ direction: PanDirection.Up | PanDirection.Down })
48 private topFixedHeight = 124 47 private topFixedHeight = 124
@@ -51,19 +50,23 @@ export struct ENewspaperListDialog { @@ -51,19 +50,23 @@ export struct ENewspaperListDialog {
51 50
52 //watch监听报纸页码回调 51 //watch监听报纸页码回调
53 onCurrentPageNumUpdated(): void { 52 onCurrentPageNumUpdated(): void {
54 - this.firstFlag = false  
55 - console.log(TAG, "onCurrentPageNumUpdated currentPageNum:", this.currentPageNum)  
56 - let _scrollIndex = Number.parseInt(this.currentPageNum)  
57 - console.log(TAG, "onCurrentPageNumUpdated _scrollIndex:", _scrollIndex)  
58 - let scrollIndexEnd = _scrollIndex > 0 ? _scrollIndex - 1 : _scrollIndex 53 + // console.log(TAG, "onCurrentPageNumUpdated currentPageNum:", this.currentPageNum)
  54 + // let _scrollIndex = Number.parseInt(this.currentPageNum)
  55 + // console.log(TAG, "onCurrentPageNumUpdated _scrollIndex:", _scrollIndex)
  56 + // let scrollIndexEnd = _scrollIndex > 0 ? _scrollIndex - 1 : _scrollIndex
  57 +
  58 + if (this.newspaperListBean != undefined) {
  59 + // 从业务数据中找到编号
  60 + let scrollIndexEnd = this.newspaperListBean?.list.findIndex(_item => _item?.pageNum === this.currentPageNum)
59 61
60 console.log(TAG, "onCurrentPageNumUpdated scrollIndexEnd:", scrollIndexEnd) 62 console.log(TAG, "onCurrentPageNumUpdated scrollIndexEnd:", scrollIndexEnd)
61 63
62 - console.log(TAG, "onCurrentPageNumUpdated (!this.isCurrentViewOpen):", ""+!this.isCurrentViewOpen) 64 + console.log(TAG, "onCurrentPageNumUpdated (!this.isCurrentViewOpen):", "" + !this.isCurrentViewOpen)
63 if (!this.isCurrentViewOpen) { 65 if (!this.isCurrentViewOpen) {
64 this.listScroller.scrollToIndex(scrollIndexEnd) 66 this.listScroller.scrollToIndex(scrollIndexEnd)
65 } 67 }
66 } 68 }
  69 + }
67 70
68 async aboutToAppear() { 71 async aboutToAppear() {
69 //注册字体 72 //注册字体
@@ -143,7 +146,7 @@ export struct ENewspaperListDialog { @@ -143,7 +146,7 @@ export struct ENewspaperListDialog {
143 .gesture( 146 .gesture(
144 PanGesture(this.panOption) 147 PanGesture(this.panOption)
145 .onActionStart((event: GestureEvent) => { 148 .onActionStart((event: GestureEvent) => {
146 - Logger.debug('ENewspaperListDialog','Pan start') 149 + Logger.debug('ENewspaperListDialog', 'Pan start')
147 }) 150 })
148 .onActionUpdate((event: GestureEvent) => { 151 .onActionUpdate((event: GestureEvent) => {
149 if (this.topFixedHeight + event.offsetY >= this.topFixedHeight) { 152 if (this.topFixedHeight + event.offsetY >= this.topFixedHeight) {
@@ -182,8 +185,7 @@ export struct ENewspaperListDialog { @@ -182,8 +185,7 @@ export struct ENewspaperListDialog {
182 Text(positionItem.shortTitle) 185 Text(positionItem.shortTitle)
183 .fontSize($r('app.float.font_size_13')) 186 .fontSize($r('app.float.font_size_13'))
184 .fontColor($r('app.color.color_222222')) 187 .fontColor($r('app.color.color_222222'))
185 - .fontWeight(600)  
186 - // .maxLines(2) 188 + .fontWeight(600)// .maxLines(2)
187 .margin({ 189 .margin({
188 bottom: 8 190 bottom: 8
189 }) 191 })
@@ -287,30 +289,24 @@ export struct ENewspaperListDialog { @@ -287,30 +289,24 @@ export struct ENewspaperListDialog {
287 console.info('ENewspaperListDialog::first' + firstIndex) 289 console.info('ENewspaperListDialog::first' + firstIndex)
288 console.info('ENewspaperListDialog::last' + lastIndex) 290 console.info('ENewspaperListDialog::last' + lastIndex)
289 console.info('ENewspaperListDialog::center' + centerIndex) 291 console.info('ENewspaperListDialog::center' + centerIndex)
290 - // this.updateCurrentPageNum(firstIndex)  
291 - // const tempIndex = this.findClassIndex(firstIndex)  
292 - // if (firstIndex !== centerIndex) {  
293 - // return  
294 - // }  
295 - // console.info(`this.scrollOffset:` + this.scrollOffset)  
296 - // if (this.scrollOffset == 0) {  
297 - if(this.firstFlag){  
298 - this.currentPageNum = `${firstIndex < 9 ? '0' + (firstIndex + 1) : firstIndex + 1}`  
299 - }else {  
300 - this.firstFlag = true 292 +
  293 + // this.currentPageNum = `${firstIndex < 9 ? '0' + (firstIndex + 1) : firstIndex + 1}`
  294 +
  295 + if (this.newspaperListBean != undefined) {
  296 + this.currentPageNum = this.newspaperListBean?.list[lastIndex].pageNum
301 } 297 }
302 298
303 - // }  
304 }) 299 })
305 } 300 }
306 .margin({ top: this.topHeight }) 301 .margin({ top: this.topHeight })
307 .width('100%') 302 .width('100%')
308 .backgroundColor(Color.White) 303 .backgroundColor(Color.White)
309 304
310 - }.width('100%') 305 + }
  306 + .width('100%')
311 .height('100%') 307 .height('100%')
312 .backgroundColor('#80000000') 308 .backgroundColor('#80000000')
313 - .margin({bottom:50}) 309 + .margin({ bottom: 50 })
314 .onClick(() => { 310 .onClick(() => {
315 if (this.closeDialog) { 311 if (this.closeDialog) {
316 this.closeDialog() 312 this.closeDialog()
@@ -319,7 +315,7 @@ export struct ENewspaperListDialog { @@ -319,7 +315,7 @@ export struct ENewspaperListDialog {
319 .gesture( 315 .gesture(
320 PanGesture(this.panOption) 316 PanGesture(this.panOption)
321 .onActionStart((event: GestureEvent) => { 317 .onActionStart((event: GestureEvent) => {
322 - Logger.debug('ENewspaperListDialog','Pan start') 318 + Logger.debug('ENewspaperListDialog', 'Pan start')
323 }) 319 })
324 .onActionUpdate((event: GestureEvent) => { 320 .onActionUpdate((event: GestureEvent) => {
325 if (event) { 321 if (event) {
@@ -336,7 +332,7 @@ export struct ENewspaperListDialog { @@ -336,7 +332,7 @@ export struct ENewspaperListDialog {
336 } 332 }
337 333
338 onCloseGestureDialog() { 334 onCloseGestureDialog() {
339 - if (this.topHeight >= this.deviceHeight ) { 335 + if (this.topHeight >= this.deviceHeight) {
340 if (this.closeDialog) { 336 if (this.closeDialog) {
341 this.closeDialog() 337 this.closeDialog()
342 } 338 }