liyubing

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

... ... @@ -4,7 +4,9 @@ import { WDRouterRule } from 'wdRouter/Index'
import { ENewspaperPageDialog } from '../dialog/ENewspaperPageDialog'
import { Logger } from 'wdKit';
import { font, window } from '@kit.ArkUI';
const TAG: string = 'ENewspaperListDialog';
/**
* 读报纸半屏弹窗
* 弹窗嵌套参考资料(https://developer.harmonyos.com/cn/docs/documentation/doc-references-V2/ts-methods-custom-dialog-box-0000001580345722-V2)
... ... @@ -18,9 +20,7 @@ export struct ENewspaperListDialog {
private listScroller: Scroller = new Scroller()
@State scrollOffset: number = 0
@State isCurrentViewOpen: boolean = false
@Consume bottomSafeHeight:number
firstFlag : boolean = true
@Consume bottomSafeHeight: number
//文字版选择弹框
pageListDialogController: CustomDialogController = new CustomDialogController({
builder: ENewspaperPageDialog({
... ... @@ -42,7 +42,6 @@ export struct ENewspaperListDialog {
// 那么此处需要将指向自己的controller放在所有controller的后面
// listDialogController: CustomDialogController
public closeDialog?: () => void
// 手势滑动相关
private panOption: PanGestureOptions = new PanGestureOptions({ direction: PanDirection.Up | PanDirection.Down })
private topFixedHeight = 124
... ... @@ -51,19 +50,23 @@ export struct ENewspaperListDialog {
//watch监听报纸页码回调
onCurrentPageNumUpdated(): void {
this.firstFlag = false
console.log(TAG, "onCurrentPageNumUpdated currentPageNum:", this.currentPageNum)
let _scrollIndex = Number.parseInt(this.currentPageNum)
console.log(TAG, "onCurrentPageNumUpdated _scrollIndex:", _scrollIndex)
let scrollIndexEnd = _scrollIndex > 0 ? _scrollIndex - 1 : _scrollIndex
// console.log(TAG, "onCurrentPageNumUpdated currentPageNum:", this.currentPageNum)
// let _scrollIndex = Number.parseInt(this.currentPageNum)
// console.log(TAG, "onCurrentPageNumUpdated _scrollIndex:", _scrollIndex)
// let scrollIndexEnd = _scrollIndex > 0 ? _scrollIndex - 1 : _scrollIndex
if (this.newspaperListBean != undefined) {
// 从业务数据中找到编号
let scrollIndexEnd = this.newspaperListBean?.list.findIndex(_item => _item?.pageNum === this.currentPageNum)
console.log(TAG, "onCurrentPageNumUpdated scrollIndexEnd:", scrollIndexEnd)
console.log(TAG, "onCurrentPageNumUpdated (!this.isCurrentViewOpen):", ""+!this.isCurrentViewOpen)
console.log(TAG, "onCurrentPageNumUpdated (!this.isCurrentViewOpen):", "" + !this.isCurrentViewOpen)
if (!this.isCurrentViewOpen) {
this.listScroller.scrollToIndex(scrollIndexEnd)
}
}
}
async aboutToAppear() {
//注册字体
... ... @@ -143,7 +146,7 @@ export struct ENewspaperListDialog {
.gesture(
PanGesture(this.panOption)
.onActionStart((event: GestureEvent) => {
Logger.debug('ENewspaperListDialog','Pan start')
Logger.debug('ENewspaperListDialog', 'Pan start')
})
.onActionUpdate((event: GestureEvent) => {
if (this.topFixedHeight + event.offsetY >= this.topFixedHeight) {
... ... @@ -182,8 +185,7 @@ export struct ENewspaperListDialog {
Text(positionItem.shortTitle)
.fontSize($r('app.float.font_size_13'))
.fontColor($r('app.color.color_222222'))
.fontWeight(600)
// .maxLines(2)
.fontWeight(600)// .maxLines(2)
.margin({
bottom: 8
})
... ... @@ -287,30 +289,24 @@ export struct ENewspaperListDialog {
console.info('ENewspaperListDialog::first' + firstIndex)
console.info('ENewspaperListDialog::last' + lastIndex)
console.info('ENewspaperListDialog::center' + centerIndex)
// this.updateCurrentPageNum(firstIndex)
// const tempIndex = this.findClassIndex(firstIndex)
// if (firstIndex !== centerIndex) {
// return
// }
// console.info(`this.scrollOffset:` + this.scrollOffset)
// if (this.scrollOffset == 0) {
if(this.firstFlag){
this.currentPageNum = `${firstIndex < 9 ? '0' + (firstIndex + 1) : firstIndex + 1}`
}else {
this.firstFlag = true
// this.currentPageNum = `${firstIndex < 9 ? '0' + (firstIndex + 1) : firstIndex + 1}`
if (this.newspaperListBean != undefined) {
this.currentPageNum = this.newspaperListBean?.list[lastIndex].pageNum
}
// }
})
}
.margin({ top: this.topHeight })
.width('100%')
.backgroundColor(Color.White)
}.width('100%')
}
.width('100%')
.height('100%')
.backgroundColor('#80000000')
.margin({bottom:50})
.margin({ bottom: 50 })
.onClick(() => {
if (this.closeDialog) {
this.closeDialog()
... ... @@ -319,7 +315,7 @@ export struct ENewspaperListDialog {
.gesture(
PanGesture(this.panOption)
.onActionStart((event: GestureEvent) => {
Logger.debug('ENewspaperListDialog','Pan start')
Logger.debug('ENewspaperListDialog', 'Pan start')
})
.onActionUpdate((event: GestureEvent) => {
if (event) {
... ... @@ -336,7 +332,7 @@ export struct ENewspaperListDialog {
}
onCloseGestureDialog() {
if (this.topHeight >= this.deviceHeight ) {
if (this.topHeight >= this.deviceHeight) {
if (this.closeDialog) {
this.closeDialog()
}
... ...