Showing
2 changed files
with
27 additions
and
12 deletions
| @@ -60,10 +60,11 @@ export struct ENewspaperPageComponent { | @@ -60,10 +60,11 @@ export struct ENewspaperPageComponent { | ||
| 60 | //watch监听报纸页码回调 | 60 | //watch监听报纸页码回调 |
| 61 | onCurrentPageNumUpdated(): void { | 61 | onCurrentPageNumUpdated(): void { |
| 62 | console.log("ENewspaperPageComponent-onCurrentPageNumUpdated", "currentPageNum:", this.currentPageNum) | 62 | console.log("ENewspaperPageComponent-onCurrentPageNumUpdated", "currentPageNum:", this.currentPageNum) |
| 63 | - let _swiperIndex = Number.parseInt(this.currentPageNum) | ||
| 64 | - console.log("ENewspaperPageComponent-onCurrentPageNumUpdated", "_swiperIndex:", _swiperIndex) | ||
| 65 | - this.swiperIndex = _swiperIndex > 0 ? _swiperIndex - 1 : _swiperIndex | 63 | + // let _swiperIndex = Number.parseInt(this.currentPageNum) |
| 64 | + // console.log("ENewspaperPageComponent-onCurrentPageNumUpdated", "_swiperIndex:", _swiperIndex) | ||
| 65 | + // this.swiperIndex = _swiperIndex > 0 ? _swiperIndex - 1 : _swiperIndex | ||
| 66 | 66 | ||
| 67 | + this.swiperIndex = this.newspaperListBean?.list.findIndex(_item => _item?.pageNum === this.currentPageNum) | ||
| 67 | //电子报--版面序号选择点击 | 68 | //电子报--版面序号选择点击 |
| 68 | TrackingContent.clickWithEvent('panel_number_selection_click', TrackConstants.PageName.NewsPaperPage, | 69 | TrackingContent.clickWithEvent('panel_number_selection_click', TrackConstants.PageName.NewsPaperPage, |
| 69 | TrackConstants.PageName.NewsPaperPage | 70 | TrackConstants.PageName.NewsPaperPage |
| @@ -140,7 +141,8 @@ export struct ENewspaperPageComponent { | @@ -140,7 +141,8 @@ export struct ENewspaperPageComponent { | ||
| 140 | let screenHeight = this.displayTool.height; | 141 | let screenHeight = this.displayTool.height; |
| 141 | // bottomSafeHeight 底导高度 topSafeHeight 顶导高度 44 顶部高度 60 底部高度 | 142 | // bottomSafeHeight 底导高度 topSafeHeight 顶导高度 44 顶部高度 60 底部高度 |
| 142 | // newspaper_shadow 49 高度 e_newspaper_content 59 margin top | 143 | // newspaper_shadow 49 高度 e_newspaper_content 59 margin top |
| 143 | - let height = screenHeight - this.bottomSafeHeight - this.topSafeHeight - vp2px(44) - vp2px(60) - vp2px(49) -vp2px(59) | 144 | + let height = |
| 145 | + screenHeight - this.bottomSafeHeight - this.topSafeHeight - vp2px(44) - vp2px(60) - vp2px(49) - vp2px(59) | ||
| 144 | this.picHeight = height | 146 | this.picHeight = height |
| 145 | 147 | ||
| 146 | let ratio = this.ratio == '100%' ? 1 : 0.5 | 148 | let ratio = this.ratio == '100%' ? 1 : 0.5 |
| @@ -176,6 +178,7 @@ export struct ENewspaperPageComponent { | @@ -176,6 +178,7 @@ export struct ENewspaperPageComponent { | ||
| 176 | this.resize() | 178 | this.resize() |
| 177 | }); | 179 | }); |
| 178 | } | 180 | } |
| 181 | + | ||
| 179 | resize() { | 182 | resize() { |
| 180 | this.screenWidth = this.windowClass?.getWindowProperties()?.windowRect.width || this.displayTool.width | 183 | this.screenWidth = this.windowClass?.getWindowProperties()?.windowRect.width || this.displayTool.width |
| 181 | // 2000折叠屏 TODO DeviceUtil 方法完善了换判断条件 | 184 | // 2000折叠屏 TODO DeviceUtil 方法完善了换判断条件 |
| @@ -262,7 +265,7 @@ export struct ENewspaperPageComponent { | @@ -262,7 +265,7 @@ export struct ENewspaperPageComponent { | ||
| 262 | .width(px2vp(this.picWidth)) | 265 | .width(px2vp(this.picWidth)) |
| 263 | .height(px2vp(this.picHeight)) | 266 | .height(px2vp(this.picHeight)) |
| 264 | .margin({ top: 59, left: 10, right: 10 }) | 267 | .margin({ top: 59, left: 10, right: 10 }) |
| 265 | - // .padding({ right: 10, left: 10 }) | 268 | + // .padding({ right: 10, left: 10 }) |
| 266 | } | 269 | } |
| 267 | 270 | ||
| 268 | if (this.newspaperListBean && this.newspaperListBean.list && this.newspaperListBean.list.length > 0) { | 271 | if (this.newspaperListBean && this.newspaperListBean.list && this.newspaperListBean.list.length > 0) { |
| @@ -422,7 +425,7 @@ export struct ENewspaperPageComponent { | @@ -422,7 +425,7 @@ export struct ENewspaperPageComponent { | ||
| 422 | .width('100%') | 425 | .width('100%') |
| 423 | .height('100%') | 426 | .height('100%') |
| 424 | .backgroundColor($r('app.color.color_80000000')) | 427 | .backgroundColor($r('app.color.color_80000000')) |
| 425 | - // .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM]) | 428 | + // .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM]) |
| 426 | .id('e_newspaper_container') | 429 | .id('e_newspaper_container') |
| 427 | 430 | ||
| 428 | if (this.isOpenListDialog) { | 431 | if (this.isOpenListDialog) { |
| @@ -455,7 +458,7 @@ export struct ENewspaperPageComponent { | @@ -455,7 +458,7 @@ export struct ENewspaperPageComponent { | ||
| 455 | try { | 458 | try { |
| 456 | if (NetworkUtil.isNetConnected()) { | 459 | if (NetworkUtil.isNetConnected()) { |
| 457 | let listBean = | 460 | let listBean = |
| 458 | - await NewspaperViewModel.getNewspaperList(this.calendarDate, this.itemPicWidth + 'x' + this.itemPicHeight) | 461 | + await NewspaperViewModel.getNewspaperList(this.calendarDate, this.itemPicWidth + 'x' + this.itemPicHeight) |
| 459 | this.newspaperListBean = listBean; | 462 | this.newspaperListBean = listBean; |
| 460 | } else { | 463 | } else { |
| 461 | this.showToastTip('网络出小差了,请检查网络后重试') | 464 | this.showToastTip('网络出小差了,请检查网络后重试') |
| @@ -48,6 +48,9 @@ export struct ENewspaperListDialog { | @@ -48,6 +48,9 @@ export struct ENewspaperListDialog { | ||
| 48 | @State topHeight: number = 124 | 48 | @State topHeight: number = 124 |
| 49 | private deviceHeight: number = 0 | 49 | private deviceHeight: number = 0 |
| 50 | 50 | ||
| 51 | + | ||
| 52 | + selectPageNum : boolean = true | ||
| 53 | + | ||
| 51 | //watch监听报纸页码回调 | 54 | //watch监听报纸页码回调 |
| 52 | onCurrentPageNumUpdated(): void { | 55 | onCurrentPageNumUpdated(): void { |
| 53 | // console.log(TAG, "onCurrentPageNumUpdated currentPageNum:", this.currentPageNum) | 56 | // console.log(TAG, "onCurrentPageNumUpdated currentPageNum:", this.currentPageNum) |
| @@ -56,6 +59,8 @@ export struct ENewspaperListDialog { | @@ -56,6 +59,8 @@ export struct ENewspaperListDialog { | ||
| 56 | // let scrollIndexEnd = _scrollIndex > 0 ? _scrollIndex - 1 : _scrollIndex | 59 | // let scrollIndexEnd = _scrollIndex > 0 ? _scrollIndex - 1 : _scrollIndex |
| 57 | 60 | ||
| 58 | if (this.newspaperListBean != undefined) { | 61 | if (this.newspaperListBean != undefined) { |
| 62 | + | ||
| 63 | + this.selectPageNum = false | ||
| 59 | // 从业务数据中找到编号 | 64 | // 从业务数据中找到编号 |
| 60 | let scrollIndexEnd = this.newspaperListBean?.list.findIndex(_item => _item?.pageNum === this.currentPageNum) | 65 | let scrollIndexEnd = this.newspaperListBean?.list.findIndex(_item => _item?.pageNum === this.currentPageNum) |
| 61 | 66 | ||
| @@ -82,10 +87,12 @@ export struct ENewspaperListDialog { | @@ -82,10 +87,12 @@ export struct ENewspaperListDialog { | ||
| 82 | 87 | ||
| 83 | this.isCurrentViewOpen = true | 88 | this.isCurrentViewOpen = true |
| 84 | console.log(TAG, "aboutToAppear currentPageNum:", this.currentPageNum) | 89 | console.log(TAG, "aboutToAppear currentPageNum:", this.currentPageNum) |
| 85 | - let _scrollIndex = Number.parseInt(this.currentPageNum) | ||
| 86 | - console.log(TAG, "aboutToAppear _scrollIndex:", _scrollIndex) | ||
| 87 | - this.scrollIndex = _scrollIndex > 0 ? _scrollIndex - 1 : _scrollIndex | 90 | + // let _scrollIndex = Number.parseInt(this.currentPageNum) |
| 91 | + // console.log(TAG, "aboutToAppear _scrollIndex:", _scrollIndex) | ||
| 92 | + // this.scrollIndex = _scrollIndex > 0 ? _scrollIndex - 1 : _scrollIndex | ||
| 88 | // this.listScroller.scrollToIndex(this.scrollIndex) | 93 | // this.listScroller.scrollToIndex(this.scrollIndex) |
| 94 | + | ||
| 95 | + this.scrollIndex = this.newspaperListBean?.list.findIndex(_item => _item?.pageNum === this.currentPageNum) | ||
| 89 | } | 96 | } |
| 90 | 97 | ||
| 91 | aboutToDisappear() { | 98 | aboutToDisappear() { |
| @@ -292,10 +299,15 @@ export struct ENewspaperListDialog { | @@ -292,10 +299,15 @@ export struct ENewspaperListDialog { | ||
| 292 | 299 | ||
| 293 | // this.currentPageNum = `${firstIndex < 9 ? '0' + (firstIndex + 1) : firstIndex + 1}` | 300 | // this.currentPageNum = `${firstIndex < 9 ? '0' + (firstIndex + 1) : firstIndex + 1}` |
| 294 | 301 | ||
| 295 | - if (this.newspaperListBean != undefined) { | ||
| 296 | - this.currentPageNum = this.newspaperListBean?.list[lastIndex].pageNum | 302 | + if(this.selectPageNum){ |
| 303 | + if (this.newspaperListBean != undefined) { | ||
| 304 | + this.currentPageNum = this.newspaperListBean?.list[lastIndex].pageNum | ||
| 305 | + } | ||
| 306 | + }else { | ||
| 307 | + this.selectPageNum = true | ||
| 297 | } | 308 | } |
| 298 | 309 | ||
| 310 | + | ||
| 299 | }) | 311 | }) |
| 300 | } | 312 | } |
| 301 | .margin({ top: this.topHeight }) | 313 | .margin({ top: this.topHeight }) |
-
Please register or login to post a comment