wangyujian_wd

feat:

1)电子版-日历和期刊弹窗和联动优化;
2)电子版-数据加载初始化调整优化;
@@ -16,31 +16,33 @@ export struct ENewspaperPageComponent { @@ -16,31 +16,33 @@ export struct ENewspaperPageComponent {
16 private picWidth: number = 0 16 private picWidth: number = 0
17 @State picHeight: number = 0 17 @State picHeight: number = 0
18 @State newspaperListBean: NewspaperListBean = {} as NewspaperListBean 18 @State newspaperListBean: NewspaperListBean = {} as NewspaperListBean
19 - @State currentPageNum: string = '01' 19 + @Provide @Watch('onCurrentPageNumUpdated') currentPageNum: string = '01'
20 @State pageDialogShow: boolean = false 20 @State pageDialogShow: boolean = false
21 @State calendarDialogShow: boolean = false 21 @State calendarDialogShow: boolean = false
22 @State calendarDate: string = '' 22 @State calendarDate: string = ''
23 private swiperController: SwiperController = new SwiperController() 23 private swiperController: SwiperController = new SwiperController()
24 @State swiperIndex: number = 0; 24 @State swiperIndex: number = 0;
  25 +
25 //watch监听报纸页码回调 26 //watch监听报纸页码回调
26 - // onCurrentPageNumUpdated(): void {  
27 - // console.log("ENewspaperPageComponent-onCurrentPageNumUpdated", "date:", this.currentPageNum)  
28 - // let _swiperIndex = Number.parseInt(this.currentPageNum)  
29 - // console.log("ENewspaperPageComponent-onCurrentPageNumUpdated", "_swiperIndex:", _swiperIndex)  
30 - // this.swiperIndex = _swiperIndex > 0 ? _swiperIndex - 1 : _swiperIndex  
31 - // } 27 + onCurrentPageNumUpdated(): void {
  28 + console.log("ENewspaperPageComponent-onCurrentPageNumUpdated", "currentPageNum:", this.currentPageNum)
  29 + let _swiperIndex = Number.parseInt(this.currentPageNum)
  30 + console.log("ENewspaperPageComponent-onCurrentPageNumUpdated", "_swiperIndex:", _swiperIndex)
  31 + this.swiperIndex = _swiperIndex > 0 ? _swiperIndex - 1 : _swiperIndex
  32 + }
32 33
33 //日历选择弹框 34 //日历选择弹框
34 calendarDialogController: CustomDialogController = new CustomDialogController({ 35 calendarDialogController: CustomDialogController = new CustomDialogController({
35 - builder: ENewspaperCalendarDialog({ onDateChange: (date: RMCalendarBean) => { 36 + builder: ENewspaperCalendarDialog({
  37 + onDateChange: (date: RMCalendarBean) => {
36 console.log("onDateChange-日历选择弹框", "date:", JSON.stringify(date)) 38 console.log("onDateChange-日历选择弹框", "date:", JSON.stringify(date))
37 if (date.fullYear && date.month && date.date) { 39 if (date.fullYear && date.month && date.date) {
38 this.calendarDate = `${date.fullYear}-${date.month > 9 ? date.month + 1 : '0' + (date.month + 1)}-${date.date > 9 ? date.date : '0' + date.date}` 40 this.calendarDate = `${date.fullYear}-${date.month > 9 ? date.month + 1 : '0' + (date.month + 1)}-${date.date > 9 ? date.date : '0' + date.date}`
39 - this.currentPageNum = '01'  
40 this.getNewspaperTime() 41 this.getNewspaperTime()
41 this.getNewspaperList() 42 this.getNewspaperList()
42 } 43 }
43 - } }), 44 + }
  45 + }),
44 alignment: DialogAlignment.Top, 46 alignment: DialogAlignment.Top,
45 offset: { dx: 0, dy: 80 }, 47 offset: { dx: 0, dy: 80 },
46 customStyle: true, 48 customStyle: true,
@@ -48,16 +50,8 @@ export struct ENewspaperPageComponent { @@ -48,16 +50,8 @@ export struct ENewspaperPageComponent {
48 //图片版选择弹框 50 //图片版选择弹框
49 pageDialogController: CustomDialogController = new CustomDialogController({ 51 pageDialogController: CustomDialogController = new CustomDialogController({
50 builder: ENewspaperPageDialog({ 52 builder: ENewspaperPageDialog({
51 - currentPageNum: this.currentPageNum,  
52 dialogType: 0, 53 dialogType: 0,
53 newspaperListBean: this.newspaperListBean, 54 newspaperListBean: this.newspaperListBean,
54 - onDateChange: (date: string, dialogType: number) => {  
55 - if (dialogType == 0) {  
56 - let _swiperIndex = Number.parseInt(this.currentPageNum)  
57 - console.log("ENewspaperPageComponent-onCurrentPageNumUpdated", "_swiperIndex:", _swiperIndex)  
58 - this.swiperIndex = _swiperIndex > 0 ? _swiperIndex - 1 : _swiperIndex  
59 - }  
60 - }  
61 }), 55 }),
62 alignment: DialogAlignment.BottomStart, 56 alignment: DialogAlignment.BottomStart,
63 offset: { dx: 0, dy: -90 }, 57 offset: { dx: 0, dy: -90 },
@@ -66,8 +60,8 @@ export struct ENewspaperPageComponent { @@ -66,8 +60,8 @@ export struct ENewspaperPageComponent {
66 //文字报纸弹框 60 //文字报纸弹框
67 listDialogController: CustomDialogController = new CustomDialogController({ 61 listDialogController: CustomDialogController = new CustomDialogController({
68 builder: ENewspaperListDialog({ 62 builder: ENewspaperListDialog({
69 - currentPageNum: this.currentPageNum,  
70 - newspaperListBean: this.newspaperListBean }), 63 + newspaperListBean: this.newspaperListBean
  64 + }),
71 alignment: DialogAlignment.Bottom, 65 alignment: DialogAlignment.Bottom,
72 offset: { dx: 0, dy: 0 } 66 offset: { dx: 0, dy: 0 }
73 }) 67 })
@@ -78,8 +72,10 @@ export struct ENewspaperPageComponent { @@ -78,8 +72,10 @@ export struct ENewspaperPageComponent {
78 Image($r('app.media.icon_arrow_down')) 72 Image($r('app.media.icon_arrow_down'))
79 .height($r('app.float.top_arrow_size')) 73 .height($r('app.float.top_arrow_size'))
80 .width($r('app.float.top_arrow_size')) 74 .width($r('app.float.top_arrow_size'))
81 - .alignRules({ left: { anchor: "__container__", align: HorizontalAlign.Start },  
82 - center: { anchor: "__container__", align: VerticalAlign.Center } }) 75 + .alignRules({
  76 + left: { anchor: "__container__", align: HorizontalAlign.Start },
  77 + center: { anchor: "__container__", align: VerticalAlign.Center }
  78 + })
83 .id('e_newspaper_back') 79 .id('e_newspaper_back')
84 .onClick((event: ClickEvent) => { 80 .onClick((event: ClickEvent) => {
85 router.back() 81 router.back()
@@ -98,8 +94,10 @@ export struct ENewspaperPageComponent { @@ -98,8 +94,10 @@ export struct ENewspaperPageComponent {
98 .margin({ left: 2, bottom: 5 }) 94 .margin({ left: 2, bottom: 5 })
99 } 95 }
100 .alignItems(VerticalAlign.Bottom) 96 .alignItems(VerticalAlign.Bottom)
101 - .alignRules({ middle: { anchor: "__container__", align: HorizontalAlign.Center },  
102 - center: { anchor: "__container__", align: VerticalAlign.Center } }) 97 + .alignRules({
  98 + middle: { anchor: "__container__", align: HorizontalAlign.Center },
  99 + center: { anchor: "__container__", align: VerticalAlign.Center }
  100 + })
103 .id('e_newspaper_date') 101 .id('e_newspaper_date')
104 .onClick(() => { 102 .onClick(() => {
105 this.calendarDialogShow = !this.calendarDialogShow 103 this.calendarDialogShow = !this.calendarDialogShow
@@ -113,15 +111,19 @@ export struct ENewspaperPageComponent { @@ -113,15 +111,19 @@ export struct ENewspaperPageComponent {
113 Image($r('app.media.icon_share')) 111 Image($r('app.media.icon_share'))
114 .height($r('app.float.top_arrow_size')) 112 .height($r('app.float.top_arrow_size'))
115 .width($r('app.float.top_arrow_size')) 113 .width($r('app.float.top_arrow_size'))
116 - .alignRules({ right: { anchor: "__container__", align: HorizontalAlign.End },  
117 - center: { anchor: "__container__", align: VerticalAlign.Center } }) 114 + .alignRules({
  115 + right: { anchor: "__container__", align: HorizontalAlign.End },
  116 + center: { anchor: "__container__", align: VerticalAlign.Center }
  117 + })
118 .id('e_newspaper_share') 118 .id('e_newspaper_share')
119 } 119 }
120 .margin({ left: $r('app.float.margin_16'), right: $r('app.float.margin_16') }) 120 .margin({ left: $r('app.float.margin_16'), right: $r('app.float.margin_16') })
121 .height($r('app.float.top_bar_height')) 121 .height($r('app.float.top_bar_height'))
122 - .alignRules({ top: { anchor: '__container__', align: VerticalAlign.Top }, 122 + .alignRules({
  123 + top: { anchor: '__container__', align: VerticalAlign.Top },
123 left: { anchor: '__container__', align: HorizontalAlign.Start }, 124 left: { anchor: '__container__', align: HorizontalAlign.Start },
124 - right: { anchor: '__container__', align: HorizontalAlign.End } }) 125 + right: { anchor: '__container__', align: HorizontalAlign.End }
  126 + })
125 .id('e_newspaper_top') 127 .id('e_newspaper_top')
126 128
127 if (this.newspaperListBean && this.newspaperListBean.list && this.newspaperListBean.list.length > 0) { 129 if (this.newspaperListBean && this.newspaperListBean.list && this.newspaperListBean.list.length > 0) {
@@ -140,19 +142,24 @@ export struct ENewspaperPageComponent { @@ -140,19 +142,24 @@ export struct ENewspaperPageComponent {
140 .displayCount(1) 142 .displayCount(1)
141 .margin({ top: 35, left: 10, right: 10 }) 143 .margin({ top: 35, left: 10, right: 10 })
142 .id('e_newspaper_content') 144 .id('e_newspaper_content')
143 - .alignRules({ top: { anchor: "e_newspaper_top", align: VerticalAlign.Bottom },  
144 - middle: { anchor: "__container__", align: HorizontalAlign.Center } }) 145 + .alignRules({
  146 + top: { anchor: "e_newspaper_top", align: VerticalAlign.Bottom },
  147 + middle: { anchor: "__container__", align: HorizontalAlign.Center }
  148 + })
145 .onChange((index: number) => { 149 .onChange((index: number) => {
146 this.currentPageNum = this.newspaperListBean?.list[index]?.pageNum 150 this.currentPageNum = this.newspaperListBean?.list[index]?.pageNum
  151 + this.swiperIndex = index
147 }) 152 })
148 153
149 Image($r('app.media.newspaper_shadow')) 154 Image($r('app.media.newspaper_shadow'))
150 .height($r('app.float.vp_12')) 155 .height($r('app.float.vp_12'))
151 .margin({ left: 20, right: 20, top: -1 }) 156 .margin({ left: 20, right: 20, top: -1 })
152 .objectFit(ImageFit.Contain) 157 .objectFit(ImageFit.Contain)
153 - .alignRules({ top: { anchor: "e_newspaper_content", align: VerticalAlign.Bottom }, 158 + .alignRules({
  159 + top: { anchor: "e_newspaper_content", align: VerticalAlign.Bottom },
154 left: { anchor: 'e_newspaper_content', align: HorizontalAlign.Start }, 160 left: { anchor: 'e_newspaper_content', align: HorizontalAlign.Start },
155 - right: { anchor: 'e_newspaper_content', align: HorizontalAlign.End } }) 161 + right: { anchor: 'e_newspaper_content', align: HorizontalAlign.End }
  162 + })
156 .id('e_newspaper_shadow') 163 .id('e_newspaper_shadow')
157 164
158 Row() { 165 Row() {
@@ -165,8 +172,10 @@ export struct ENewspaperPageComponent { @@ -165,8 +172,10 @@ export struct ENewspaperPageComponent {
165 } 172 }
166 .justifyContent(FlexAlign.Center) 173 .justifyContent(FlexAlign.Center)
167 .margin({ top: $r('app.float.margin_16') }) 174 .margin({ top: $r('app.float.margin_16') })
168 - .alignRules({ top: { anchor: "e_newspaper_shadow", align: VerticalAlign.Bottom },  
169 - middle: { anchor: "__container__", align: HorizontalAlign.Center } }) 175 + .alignRules({
  176 + top: { anchor: "e_newspaper_shadow", align: VerticalAlign.Bottom },
  177 + middle: { anchor: "__container__", align: HorizontalAlign.Center }
  178 + })
170 .id('e_newspaper_next') 179 .id('e_newspaper_next')
171 .onClick((event: ClickEvent) => { 180 .onClick((event: ClickEvent) => {
172 this.swiperController.showNext() 181 this.swiperController.showNext()
@@ -190,8 +199,10 @@ export struct ENewspaperPageComponent { @@ -190,8 +199,10 @@ export struct ENewspaperPageComponent {
190 } 199 }
191 .alignItems(VerticalAlign.Bottom) 200 .alignItems(VerticalAlign.Bottom)
192 .margin({ left: $r('app.float.margin_16'), bottom: $r('app.float.top_tab_bar_height') }) 201 .margin({ left: $r('app.float.margin_16'), bottom: $r('app.float.top_tab_bar_height') })
193 - .alignRules({ bottom: { anchor: '__container__', align: VerticalAlign.Bottom },  
194 - left: { anchor: '__container__', align: HorizontalAlign.Start } }) 202 + .alignRules({
  203 + bottom: { anchor: '__container__', align: VerticalAlign.Bottom },
  204 + left: { anchor: '__container__', align: HorizontalAlign.Start }
  205 + })
195 .id('e_newspaper_page_num') 206 .id('e_newspaper_page_num')
196 .onClick((event: ClickEvent) => { 207 .onClick((event: ClickEvent) => {
197 this.pageDialogShow = !this.pageDialogShow 208 this.pageDialogShow = !this.pageDialogShow
@@ -219,8 +230,10 @@ export struct ENewspaperPageComponent { @@ -219,8 +230,10 @@ export struct ENewspaperPageComponent {
219 } 230 }
220 .alignItems(VerticalAlign.Center) 231 .alignItems(VerticalAlign.Center)
221 .margin({ right: $r('app.float.margin_16'), bottom: $r('app.float.top_tab_bar_height') }) 232 .margin({ right: $r('app.float.margin_16'), bottom: $r('app.float.top_tab_bar_height') })
222 - .alignRules({ bottom: { anchor: '__container__', align: VerticalAlign.Bottom },  
223 - right: { anchor: '__container__', align: HorizontalAlign.End } }) 233 + .alignRules({
  234 + bottom: { anchor: '__container__', align: VerticalAlign.Bottom },
  235 + right: { anchor: '__container__', align: HorizontalAlign.End }
  236 + })
224 .id('e_newspaper_read') 237 .id('e_newspaper_read')
225 .onClick((event: ClickEvent) => { 238 .onClick((event: ClickEvent) => {
226 this.listDialogController.open() 239 this.listDialogController.open()
@@ -250,6 +263,8 @@ export struct ENewspaperPageComponent { @@ -250,6 +263,8 @@ export struct ENewspaperPageComponent {
250 let newspaperTimes = await NewspaperViewModel.getNewspaperTime(this.calendarDate) 263 let newspaperTimes = await NewspaperViewModel.getNewspaperTime(this.calendarDate)
251 if (newspaperTimes && newspaperTimes.length > 0) { 264 if (newspaperTimes && newspaperTimes.length > 0) {
252 this.calendarDate = newspaperTimes[0].date 265 this.calendarDate = newspaperTimes[0].date
  266 + this.currentPageNum = '01'
  267 + this.swiperIndex = 0
253 } 268 }
254 } 269 }
255 270
@@ -7,26 +7,26 @@ import { ENewspaperPageDialog } from '../dialog/ENewspaperPageDialog' @@ -7,26 +7,26 @@ import { ENewspaperPageDialog } from '../dialog/ENewspaperPageDialog'
7 */ 7 */
8 @CustomDialog 8 @CustomDialog
9 export struct ENewspaperListDialog { 9 export struct ENewspaperListDialog {
10 - @Link currentPageNum: string 10 + @Consume @Watch('onCurrentPageNumUpdated') currentPageNum: string
11 @State pageDialogShow: boolean = false 11 @State pageDialogShow: boolean = false
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 +
15 //文字版选择弹框 25 //文字版选择弹框
16 pageListDialogController: CustomDialogController = new CustomDialogController({ 26 pageListDialogController: CustomDialogController = new CustomDialogController({
17 builder: ENewspaperPageDialog({ 27 builder: ENewspaperPageDialog({
18 - currentPageNum: this.currentPageNum,  
19 dialogType: 1, 28 dialogType: 1,
20 newspaperListBean: this.newspaperListBean, 29 newspaperListBean: this.newspaperListBean,
21 - onDateChange: (date: string, dialogType: number) => {  
22 - if (dialogType == 1) {  
23 - console.log("ENewspaperListDialog-pageListDialogController", "date:", this.currentPageNum)  
24 - let _scrollIndex = Number.parseInt(this.currentPageNum)  
25 - console.log("ENewspaperListDialog-pageListDialogController", "_swiperIndex:", _scrollIndex)  
26 - this.scrollIndex = _scrollIndex > 0 ? _scrollIndex - 1 : _scrollIndex  
27 - this.listScroller.scrollToIndex(this.scrollIndex)  
28 - }  
29 - }  
30 }), 30 }),
31 alignment: DialogAlignment.TopStart, 31 alignment: DialogAlignment.TopStart,
32 offset: { dx: 0, dy: 214 }, 32 offset: { dx: 0, dy: 214 },
@@ -43,8 +43,10 @@ export struct ENewspaperListDialog { @@ -43,8 +43,10 @@ export struct ENewspaperListDialog {
43 .width(43) 43 .width(43)
44 .height(4) 44 .height(4)
45 .backgroundColor('#EDEDED') 45 .backgroundColor('#EDEDED')
46 - .margin({ top: 10,  
47 - bottom: 10 }) 46 + .margin({
  47 + top: 10,
  48 + bottom: 10
  49 + })
48 Row() { 50 Row() {
49 Text(this.currentPageNum) 51 Text(this.currentPageNum)
50 .fontSize($r('app.float.font_size_36')) 52 .fontSize($r('app.float.font_size_36'))
@@ -155,7 +157,7 @@ export struct ENewspaperListDialog { @@ -155,7 +157,7 @@ export struct ENewspaperListDialog {
155 for (let item of itemBean.items) { 157 for (let item of itemBean.items) {
156 index++ 158 index++
157 if (index == firstIndex) { 159 if (index == firstIndex) {
158 - this.currentPageNum = itemBean.pageNum 160 + // this.currentPageNum = itemBean.pageNum
159 return 161 return
160 } 162 }
161 } 163 }
@@ -7,10 +7,12 @@ import { NewspaperListBean, NewspaperListItemBean } from 'wdBean/Index' @@ -7,10 +7,12 @@ import { NewspaperListBean, NewspaperListItemBean } from 'wdBean/Index'
7 export struct ENewspaperPageDialog { 7 export struct ENewspaperPageDialog {
8 dialogType: number = 0 //0:图片版,1:文字版 8 dialogType: number = 0 //0:图片版,1:文字版
9 pageDialogController?: CustomDialogController 9 pageDialogController?: CustomDialogController
10 - @Link currentPageNum: string 10 + @Consume @Watch('onCurrentPageNumUpdated') currentPageNum: string
11 @Prop newspaperListBean: NewspaperListBean = {} as NewspaperListBean 11 @Prop newspaperListBean: NewspaperListBean = {} as NewspaperListBean
12 - // 选择变化监听,  
13 - onDateChange?: (date: string, dialogType: number) => void 12 +
  13 + onCurrentPageNumUpdated(): void {
  14 + console.log("ENewspaperListDialog-onCurrentPageNumUpdated", "currentPageNum:", this.currentPageNum)
  15 + }
14 16
15 build() { 17 build() {
16 Column() { 18 Column() {
@@ -36,9 +38,6 @@ export struct ENewspaperPageDialog { @@ -36,9 +38,6 @@ export struct ENewspaperPageDialog {
36 .backgroundColor(this.currentPageNum != item.pageNum ? Color.White : $r('app.color.color_ED2800')) 38 .backgroundColor(this.currentPageNum != item.pageNum ? Color.White : $r('app.color.color_ED2800'))
37 .onClick((event: ClickEvent) => { 39 .onClick((event: ClickEvent) => {
38 this.currentPageNum = item.pageNum 40 this.currentPageNum = item.pageNum
39 - if (this.onDateChange) {  
40 - this.onDateChange(item.pageNum, this.dialogType)  
41 - }  
42 if (this.pageDialogController) { 41 if (this.pageDialogController) {
43 this.pageDialogController.close() 42 this.pageDialogController.close()
44 } 43 }