wangyujian_wd

feat:

1)电子报-日历选择/图片报刊/文字报刊切换更新数据时,联动交互优化;
@@ -66,6 +66,29 @@ export struct ENewspaperPageComponent { @@ -66,6 +66,29 @@ export struct ENewspaperPageComponent {
66 offset: { dx: 0, dy: 0 } 66 offset: { dx: 0, dy: 0 }
67 }) 67 })
68 68
  69 + async aboutToAppear() {
  70 + //获取宽高尺寸
  71 + this.screenWidth = this.displayTool.width
  72 + this.picWidth = this.screenWidth - vp2px(52)
  73 + this.picHeight = this.picWidth * 566 / 378
  74 + //注册字体
  75 + font.registerFont({
  76 + familyName: 'BebasNeue_Regular',
  77 + familySrc: $rawfile('font/BebasNeue_Regular.otf')
  78 + })
  79 + this.getNewspaperTime()
  80 + this.getNewspaperList()
  81 + }
  82 +
  83 + aboutToDisappear() {
  84 + // if (this.calendarDialogController) {
  85 + // this.calendarDialogController = null
  86 + // }
  87 + // if (this.listDialogController) {
  88 + // this.listDialogController = null
  89 + // }
  90 + }
  91 +
69 build() { 92 build() {
70 RelativeContainer() { 93 RelativeContainer() {
71 RelativeContainer() { 94 RelativeContainer() {
@@ -245,26 +268,11 @@ export struct ENewspaperPageComponent { @@ -245,26 +268,11 @@ export struct ENewspaperPageComponent {
245 .id('e_newspaper_container') 268 .id('e_newspaper_container')
246 } 269 }
247 270
248 - async aboutToAppear() {  
249 - //获取宽高尺寸  
250 - this.screenWidth = this.displayTool.width  
251 - this.picWidth = this.screenWidth - vp2px(52)  
252 - this.picHeight = this.picWidth * 566 / 378  
253 - //注册字体  
254 - font.registerFont({  
255 - familyName: 'BebasNeue_Regular',  
256 - familySrc: $rawfile('font/BebasNeue_Regular.otf')  
257 - })  
258 - this.getNewspaperTime()  
259 - this.getNewspaperList()  
260 - }  
261 -  
262 private async getNewspaperTime() { 271 private async getNewspaperTime() {
263 let newspaperTimes = await NewspaperViewModel.getNewspaperTime(this.calendarDate) 272 let newspaperTimes = await NewspaperViewModel.getNewspaperTime(this.calendarDate)
264 if (newspaperTimes && newspaperTimes.length > 0) { 273 if (newspaperTimes && newspaperTimes.length > 0) {
265 this.calendarDate = newspaperTimes[0].date 274 this.calendarDate = newspaperTimes[0].date
266 this.currentPageNum = '01' 275 this.currentPageNum = '01'
267 - this.swiperIndex = 0  
268 } 276 }
269 } 277 }
270 278
@@ -12,16 +12,6 @@ export struct ENewspaperListDialog { @@ -12,16 +12,6 @@ export struct ENewspaperListDialog {
12 @State scrollIndex: number = 0 12 @State scrollIndex: number = 0
13 newspaperListBean: NewspaperListBean = {} as NewspaperListBean 13 newspaperListBean: NewspaperListBean = {} as NewspaperListBean
14 private listScroller: Scroller = new Scroller(); 14 private listScroller: Scroller = new Scroller();
15 -  
16 - //watch监听报纸页码回调  
17 - onCurrentPageNumUpdated(): void {  
18 - console.log("ENewspaperListDialog-onCurrentPageNumUpdated", "currentPageNum:", this.currentPageNum)  
19 - let _scrollIndex = Number.parseInt(this.currentPageNum)  
20 - console.log("ENewspaperListDialog-onCurrentPageNumUpdated", "_swiperIndex:", _scrollIndex)  
21 - this.scrollIndex = _scrollIndex > 0 ? _scrollIndex - 1 : _scrollIndex  
22 - this.listScroller.scrollToIndex(this.scrollIndex)  
23 - }  
24 -  
25 //文字版选择弹框 15 //文字版选择弹框
26 pageListDialogController: CustomDialogController = new CustomDialogController({ 16 pageListDialogController: CustomDialogController = new CustomDialogController({
27 builder: ENewspaperPageDialog({ 17 builder: ENewspaperPageDialog({
@@ -37,6 +27,29 @@ export struct ENewspaperListDialog { @@ -37,6 +27,29 @@ export struct ENewspaperListDialog {
37 // 那么此处需要将指向自己的controller放在所有controller的后面 27 // 那么此处需要将指向自己的controller放在所有controller的后面
38 listDialogController: CustomDialogController 28 listDialogController: CustomDialogController
39 29
  30 + //watch监听报纸页码回调
  31 + onCurrentPageNumUpdated(): void {
  32 + console.log("ENewspaperListDialog-onCurrentPageNumUpdated", "currentPageNum:", this.currentPageNum)
  33 + let _scrollIndex = Number.parseInt(this.currentPageNum)
  34 + console.log("ENewspaperListDialog-onCurrentPageNumUpdated", "_scrollIndex:", _scrollIndex)
  35 + this.scrollIndex = _scrollIndex > 0 ? _scrollIndex - 1 : _scrollIndex
  36 + this.listScroller.scrollToIndex(this.scrollIndex)
  37 + }
  38 +
  39 + aboutToAppear(): void {
  40 + console.log("ENewspaperListDialog-aboutToAppear", "currentPageNum:", this.currentPageNum)
  41 + let _scrollIndex = Number.parseInt(this.currentPageNum)
  42 + console.log("ENewspaperListDialog-aboutToAppear", "_scrollIndex:", _scrollIndex)
  43 + this.scrollIndex = _scrollIndex > 0 ? _scrollIndex - 1 : _scrollIndex
  44 + // this.listScroller.scrollToIndex(this.scrollIndex)
  45 + }
  46 +
  47 + aboutToDisappear() {
  48 + // if (this.pageListDialogController) {
  49 + // this.pageListDialogController = null
  50 + // }
  51 + }
  52 +
40 build() { 53 build() {
41 Column() { 54 Column() {
42 Row() 55 Row()
@@ -80,8 +93,10 @@ export struct ENewspaperListDialog { @@ -80,8 +93,10 @@ export struct ENewspaperListDialog {
80 .margin({ top: 20, left: 16, right: 16 }) 93 .margin({ top: 20, left: 16, right: 16 })
81 .objectFit(ImageFit.Contain) 94 .objectFit(ImageFit.Contain)
82 95
83 - List({ scroller: this.listScroller }) { 96 + List({ scroller: this.listScroller, initialIndex: this.scrollIndex }) {
84 ForEach(this.newspaperListBean?.list, (item: NewspaperListItemBean, index: number) => { 97 ForEach(this.newspaperListBean?.list, (item: NewspaperListItemBean, index: number) => {
  98 + ListItem() {
  99 + List() {
85 ForEach(item.items, (positionItem: NewspaperPositionItemBean, itemIndex: number) => { 100 ForEach(item.items, (positionItem: NewspaperPositionItemBean, itemIndex: number) => {
86 ListItem() { 101 ListItem() {
87 Column() { 102 Column() {
@@ -131,6 +146,8 @@ export struct ENewspaperListDialog { @@ -131,6 +146,8 @@ export struct ENewspaperListDialog {
131 } 146 }
132 147
133 }) 148 })
  149 + }
  150 + }
134 }) 151 })
135 } 152 }
136 .width('100%') 153 .width('100%')
@@ -141,7 +158,17 @@ export struct ENewspaperListDialog { @@ -141,7 +158,17 @@ export struct ENewspaperListDialog {
141 color: '#EDEDED' 158 color: '#EDEDED'
142 }) 159 })
143 .onScrollIndex((firstIndex: number) => { 160 .onScrollIndex((firstIndex: number) => {
144 - this.updateCurrentPageNum(firstIndex) 161 + console.log('firstIndex', firstIndex)
  162 + })
  163 + .onScrollIndex((firstIndex: number, lastIndex: number, centerIndex: number) => {
  164 + console.info('first' + firstIndex)
  165 + console.info('last' + lastIndex)
  166 + console.info('center' + centerIndex)
  167 + // this.updateCurrentPageNum(firstIndex)
  168 + this.currentPageNum = `${centerIndex < 9 ? '0' + (centerIndex + 1) : centerIndex + 1}`
  169 + })
  170 + .onScroll((scrollOffset: number, scrollState: ScrollState) => {
  171 + console.info(`onScroll scrollState = ScrollState` + scrollState + `, scrollOffset = ` + scrollOffset)
145 }) 172 })
146 } 173 }
147 .width('100%') 174 .width('100%')
@@ -157,7 +184,7 @@ export struct ENewspaperListDialog { @@ -157,7 +184,7 @@ export struct ENewspaperListDialog {
157 for (let item of itemBean.items) { 184 for (let item of itemBean.items) {
158 index++ 185 index++
159 if (index == firstIndex) { 186 if (index == firstIndex) {
160 - // this.currentPageNum = itemBean.pageNum 187 + this.currentPageNum = itemBean.pageNum
161 return 188 return
162 } 189 }
163 } 190 }