wangyujian_wd

feat:1)电子报修改优化

@@ -8,6 +8,7 @@ import { ENewspaperCalendarDialog } from '../dialog/ENewspaperCalendarDialog'; @@ -8,6 +8,7 @@ import { ENewspaperCalendarDialog } from '../dialog/ENewspaperCalendarDialog';
8 import font from '@ohos.font'; 8 import font from '@ohos.font';
9 import { ENewspaperPageDialog } from '../dialog/ENewspaperPageDialog'; 9 import { ENewspaperPageDialog } from '../dialog/ENewspaperPageDialog';
10 import { RMCalendarBean } from './calendar/RMCalendarBean'; 10 import { RMCalendarBean } from './calendar/RMCalendarBean';
  11 +import { newsSkeleton } from './skeleton/newsSkeleton';
11 12
12 @Component 13 @Component
13 export struct ENewspaperPageComponent { 14 export struct ENewspaperPageComponent {
@@ -63,13 +64,15 @@ export struct ENewspaperPageComponent { @@ -63,13 +64,15 @@ export struct ENewspaperPageComponent {
63 customStyle: true, 64 customStyle: true,
64 }) 65 })
65 //文字报纸弹框 66 //文字报纸弹框
66 - listDialogController: CustomDialogController = new CustomDialogController({  
67 - builder: ENewspaperListDialog({  
68 - newspaperListBean: this.newspaperListBean  
69 - }),  
70 - alignment: DialogAlignment.Bottom,  
71 - offset: { dx: 0, dy: 0 }  
72 - }) 67 + @State isOpenListDialog: boolean = false
  68 +
  69 + // listDialogController: CustomDialogController = new CustomDialogController({
  70 + // builder: ENewspaperListDialog({
  71 + // newspaperListBean: this.newspaperListBean
  72 + // }),
  73 + // alignment: DialogAlignment.Bottom,
  74 + // offset: { dx: 0, dy: 0 }
  75 + // })
73 76
74 async aboutToAppear() { 77 async aboutToAppear() {
75 //获取宽高尺寸 78 //获取宽高尺寸
@@ -95,6 +98,7 @@ export struct ENewspaperPageComponent { @@ -95,6 +98,7 @@ export struct ENewspaperPageComponent {
95 } 98 }
96 99
97 build() { 100 build() {
  101 + Stack() {
98 RelativeContainer() { 102 RelativeContainer() {
99 RelativeContainer() { 103 RelativeContainer() {
100 Image($r('app.media.icon_arrow_down')) 104 Image($r('app.media.icon_arrow_down'))
@@ -154,6 +158,18 @@ export struct ENewspaperPageComponent { @@ -154,6 +158,18 @@ export struct ENewspaperPageComponent {
154 }) 158 })
155 .id('e_newspaper_top') 159 .id('e_newspaper_top')
156 160
  161 + if (!this.newspaperListBean || !this.newspaperListBean.list || this.newspaperListBean.list.length == 0) {
  162 + newsSkeleton()
  163 + .alignRules({
  164 + top: { anchor: "e_newspaper_top", align: VerticalAlign.Bottom },
  165 + middle: { anchor: "__container__", align: HorizontalAlign.Center }
  166 + })
  167 + .id('news_skeleton_id')
  168 + .width('100%')
  169 + .height(px2vp(this.picHeight) + 32)
  170 + .margin({ top: 35, left: 10, right: 10 })
  171 + }
  172 +
157 if (this.newspaperListBean && this.newspaperListBean.list && this.newspaperListBean.list.length > 0) { 173 if (this.newspaperListBean && this.newspaperListBean.list && this.newspaperListBean.list.length > 0) {
158 Swiper(this.swiperController) { 174 Swiper(this.swiperController) {
159 ForEach(this.newspaperListBean?.list, (item: NewspaperListItemBean, index: number) => { 175 ForEach(this.newspaperListBean?.list, (item: NewspaperListItemBean, index: number) => {
@@ -266,13 +282,23 @@ export struct ENewspaperPageComponent { @@ -266,13 +282,23 @@ export struct ENewspaperPageComponent {
266 }) 282 })
267 .id('e_newspaper_read') 283 .id('e_newspaper_read')
268 .onClick((event: ClickEvent) => { 284 .onClick((event: ClickEvent) => {
269 - this.listDialogController.open() 285 + this.isOpenListDialog = true
270 }) 286 })
271 } 287 }
272 .width('100%') 288 .width('100%')
273 .height('100%') 289 .height('100%')
274 .backgroundColor($r('app.color.color_80000000')) 290 .backgroundColor($r('app.color.color_80000000'))
275 .id('e_newspaper_container') 291 .id('e_newspaper_container')
  292 +
  293 + ENewspaperListDialog({
  294 + newspaperListBean: this.newspaperListBean,
  295 + closeDialog: () => {
  296 + this.isOpenListDialog = false
  297 + }
  298 + })
  299 + .visibility(this.isOpenListDialog ? Visibility.Visible : Visibility.None)
  300 + }
  301 +
276 } 302 }
277 303
278 private async getNewspaperTime() { 304 private async getNewspaperTime() {
@@ -12,7 +12,7 @@ export struct ENewspaperListDialog { @@ -12,7 +12,7 @@ export struct ENewspaperListDialog {
12 @Consume @Watch('onCurrentPageNumUpdated') currentPageNum: string 12 @Consume @Watch('onCurrentPageNumUpdated') currentPageNum: string
13 @State pageDialogShow: boolean = false 13 @State pageDialogShow: boolean = false
14 @State scrollIndex: number = 0 14 @State scrollIndex: number = 0
15 - newspaperListBean: NewspaperListBean = {} as NewspaperListBean 15 + @Prop newspaperListBean: NewspaperListBean = {} as NewspaperListBean
16 private listScroller: Scroller = new Scroller(); 16 private listScroller: Scroller = new Scroller();
17 //文字版选择弹框 17 //文字版选择弹框
18 pageListDialogController: CustomDialogController = new CustomDialogController({ 18 pageListDialogController: CustomDialogController = new CustomDialogController({
@@ -21,13 +21,14 @@ export struct ENewspaperListDialog { @@ -21,13 +21,14 @@ export struct ENewspaperListDialog {
21 newspaperListBean: this.newspaperListBean, 21 newspaperListBean: this.newspaperListBean,
22 }), 22 }),
23 alignment: DialogAlignment.TopStart, 23 alignment: DialogAlignment.TopStart,
24 - offset: { dx: 0, dy: 214 }, 24 + offset: { dx: 0, dy: 224 },
25 customStyle: true, 25 customStyle: true,
26 }) 26 })
27 //页面半屏弹窗(实现在上个组件)若尝试在CustomDialog中传入多个其他的Controller, 27 //页面半屏弹窗(实现在上个组件)若尝试在CustomDialog中传入多个其他的Controller,
28 // 以实现在CustomDialog中打开另一个或另一些CustomDialog, 28 // 以实现在CustomDialog中打开另一个或另一些CustomDialog,
29 // 那么此处需要将指向自己的controller放在所有controller的后面 29 // 那么此处需要将指向自己的controller放在所有controller的后面
30 - listDialogController: CustomDialogController 30 + // listDialogController: CustomDialogController
  31 + public closeDialog?: () => void
31 32
32 //watch监听报纸页码回调 33 //watch监听报纸页码回调
33 onCurrentPageNumUpdated(): void { 34 onCurrentPageNumUpdated(): void {
@@ -53,6 +54,7 @@ export struct ENewspaperListDialog { @@ -53,6 +54,7 @@ export struct ENewspaperListDialog {
53 } 54 }
54 55
55 build() { 56 build() {
  57 + Stack() {
56 Column() { 58 Column() {
57 Row() 59 Row()
58 .width(43) 60 .width(43)
@@ -62,6 +64,11 @@ export struct ENewspaperListDialog { @@ -62,6 +64,11 @@ export struct ENewspaperListDialog {
62 top: 10, 64 top: 10,
63 bottom: 10 65 bottom: 10
64 }) 66 })
  67 + .onClick(() => {
  68 + if (this.closeDialog) {
  69 + this.closeDialog()
  70 + }
  71 + })
65 Row() { 72 Row() {
66 Text(this.currentPageNum) 73 Text(this.currentPageNum)
67 .fontSize($r('app.float.font_size_36')) 74 .fontSize($r('app.float.font_size_36'))
@@ -142,6 +149,7 @@ export struct ENewspaperListDialog { @@ -142,6 +149,7 @@ export struct ENewspaperListDialog {
142 .fontColor($r('app.color.color_999999')) 149 .fontColor($r('app.color.color_999999'))
143 .margin({ top: 15, bottom: 15 }) 150 .margin({ top: 15, bottom: 15 })
144 .maxLines(5) 151 .maxLines(5)
  152 + .textOverflow({ overflow: TextOverflow.Ellipsis })
145 } 153 }
146 } 154 }
147 .alignItems(HorizontalAlign.Start) 155 .alignItems(HorizontalAlign.Start)
@@ -159,9 +167,9 @@ export struct ENewspaperListDialog { @@ -159,9 +167,9 @@ export struct ENewspaperListDialog {
159 } as Params, 167 } as Params,
160 }; 168 };
161 WDRouterRule.jumpWithAction(taskAction) 169 WDRouterRule.jumpWithAction(taskAction)
162 - if (this.listDialogController) {  
163 - this.listDialogController.close()  
164 - } 170 + // if (this.listDialogController) {
  171 + // this.listDialogController.close()
  172 + // }
165 }) 173 })
166 } 174 }
167 175
@@ -172,6 +180,9 @@ export struct ENewspaperListDialog { @@ -172,6 +180,9 @@ export struct ENewspaperListDialog {
172 } 180 }
173 .width('100%') 181 .width('100%')
174 .padding({ left: 15, right: 15 }) 182 .padding({ left: 15, right: 15 })
  183 + .margin({
  184 + bottom: 85
  185 + })
175 .scrollBar(BarState.Off) 186 .scrollBar(BarState.Off)
176 .divider({ 187 .divider({
177 strokeWidth: 0.5, 188 strokeWidth: 0.5,
@@ -191,9 +202,20 @@ export struct ENewspaperListDialog { @@ -191,9 +202,20 @@ export struct ENewspaperListDialog {
191 console.info(`onScroll scrollState = ScrollState` + scrollState + `, scrollOffset = ` + scrollOffset) 202 console.info(`onScroll scrollState = ScrollState` + scrollState + `, scrollOffset = ` + scrollOffset)
192 }) 203 })
193 } 204 }
  205 + .margin({ top: 124 })
194 .width('100%') 206 .width('100%')
195 .backgroundColor(Color.White) 207 .backgroundColor(Color.White)
  208 + .onClick(() => {
196 209
  210 + })
  211 + }.width('100%')
  212 + .height('100%')
  213 + .backgroundColor('#80000000')
  214 + .onClick(() => {
  215 + if (this.closeDialog) {
  216 + this.closeDialog()
  217 + }
  218 + })
197 } 219 }
198 220
199 updateCurrentPageNum(firstIndex: number): void { 221 updateCurrentPageNum(firstIndex: number): void {