wangliang_wd

feat:优化电子报弹出方式,优化电子报骨架图展示

@@ -9,7 +9,7 @@ import font from '@ohos.font'; @@ -9,7 +9,7 @@ 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 import { newsSkeleton } from './skeleton/newsSkeleton';
12 -import { Logger, ToastUtils, NetworkUtil, CustomToast } from 'wdKit/Index'; 12 +import { Logger, ToastUtils, NetworkUtil, CustomToast, DisplayUtils } from 'wdKit/Index';
13 import { TrackingContent, TrackConstants, TrackingButton } from 'wdTracking/Index'; 13 import { TrackingContent, TrackConstants, TrackingButton } from 'wdTracking/Index';
14 import { WDShare } from 'wdShare/Index'; 14 import { WDShare } from 'wdShare/Index';
15 import { window } from '@kit.ArkUI'; 15 import { window } from '@kit.ArkUI';
@@ -25,6 +25,9 @@ export struct ENewspaperPageComponent { @@ -25,6 +25,9 @@ export struct ENewspaperPageComponent {
25 @State picHeight: number = 0 25 @State picHeight: number = 0
26 @Provide itemPicWidth: number = 0 26 @Provide itemPicWidth: number = 0
27 @Provide itemPicHeight: number = 0 27 @Provide itemPicHeight: number = 0
  28 +
  29 + @Provide topMargin: number = DisplayUtils.getDeviceHeight()
  30 +
28 @State newspaperListBean: NewspaperListBean = {} as NewspaperListBean 31 @State newspaperListBean: NewspaperListBean = {} as NewspaperListBean
29 @Provide @Watch('onCurrentPageNumUpdated') currentPageNum: string = '01' 32 @Provide @Watch('onCurrentPageNumUpdated') currentPageNum: string = '01'
30 @State pageDialogShow: boolean = false 33 @State pageDialogShow: boolean = false
@@ -404,6 +407,14 @@ export struct ENewspaperPageComponent { @@ -404,6 +407,14 @@ export struct ENewspaperPageComponent {
404 } 407 }
405 if (this.newspaperListBean.list && this.newspaperListBean.list.length > 0) { 408 if (this.newspaperListBean.list && this.newspaperListBean.list.length > 0) {
406 this.isOpenListDialog = true 409 this.isOpenListDialog = true
  410 + animateTo({
  411 + duration: 300,
  412 + onFinish: () => {
  413 + }
  414 + }, () => {
  415 + this.topMargin = 0;
  416 + })
  417 +
407 //电子报--读报纸点击 418 //电子报--读报纸点击
408 TrackingContent.clickWithEvent('read_newspaper_click', TrackConstants.PageName.NewsPaperPage, 419 TrackingContent.clickWithEvent('read_newspaper_click', TrackConstants.PageName.NewsPaperPage,
409 TrackConstants.PageName.NewsPaperPage 420 TrackConstants.PageName.NewsPaperPage
@@ -429,8 +440,16 @@ export struct ENewspaperPageComponent { @@ -429,8 +440,16 @@ export struct ENewspaperPageComponent {
429 newspaperListBean: this.newspaperListBean, 440 newspaperListBean: this.newspaperListBean,
430 scrollIndex: this.swiperIndex, 441 scrollIndex: this.swiperIndex,
431 closeDialog: () => { 442 closeDialog: () => {
  443 + animateTo({
  444 + duration: 300,
  445 + onFinish: () => {
432 this.isOpenListDialog = false 446 this.isOpenListDialog = false
433 } 447 }
  448 + }, () => {
  449 + this.topMargin = DisplayUtils.getDeviceHeight();
  450 + })
  451 +
  452 + }
434 }) 453 })
435 } 454 }
436 } 455 }
@@ -451,6 +470,7 @@ export struct ENewspaperPageComponent { @@ -451,6 +470,7 @@ export struct ENewspaperPageComponent {
451 // 计算图片的内容宽高 470 // 计算图片的内容宽高
452 this.itemPicWidth = this.picWidth - vp2px(20) 471 this.itemPicWidth = this.picWidth - vp2px(20)
453 this.itemPicHeight = this.picHeight - vp2px(28) 472 this.itemPicHeight = this.picHeight - vp2px(28)
  473 +
454 try { 474 try {
455 if (NetworkUtil.isNetConnected()) { 475 if (NetworkUtil.isNetConnected()) {
456 let listBean = 476 let listBean =
@@ -7,7 +7,7 @@ @@ -7,7 +7,7 @@
7 export struct newsSkeleton { 7 export struct newsSkeleton {
8 @State quantity: Array<number> = [1, 2, 3,] 8 @State quantity: Array<number> = [1, 2, 3,]
9 @State showBottom: boolean = true 9 @State showBottom: boolean = true
10 - 10 + @Consume itemPicHeight: number
11 build() { 11 build() {
12 Row() { 12 Row() {
13 Column() { 13 Column() {
@@ -17,12 +17,12 @@ export struct newsSkeleton { @@ -17,12 +17,12 @@ export struct newsSkeleton {
17 Column() { 17 Column() {
18 Image($r('app.media.peopleSeleton')) 18 Image($r('app.media.peopleSeleton'))
19 .width('100%') 19 .width('100%')
20 - .height(47)// 后缀名不能省略 20 + .height(this.getCompHeight(47))// 后缀名不能省略
21 .interpolation(ImageInterpolation.High) 21 .interpolation(ImageInterpolation.High)
22 .margin({ 22 .margin({
23 bottom: 6 23 bottom: 6
24 }) 24 })
25 - textArea('100%', 8) 25 + textArea('100%', this.getCompHeight(8),this.getCompHeight(5))
26 } 26 }
27 .margin({ 27 .margin({
28 right: '2%' 28 right: '2%'
@@ -33,20 +33,17 @@ export struct newsSkeleton { @@ -33,20 +33,17 @@ export struct newsSkeleton {
33 Column() { 33 Column() {
34 Row() 34 Row()
35 .width(`100%`) 35 .width(`100%`)
36 - .height(25) 36 + .height(this.getCompHeight(25))
37 .backgroundColor('#FFF5F5F5') 37 .backgroundColor('#FFF5F5F5')
38 Row() 38 Row()
39 .width(`100%`) 39 .width(`100%`)
40 - .height(4) 40 + .height(this.getCompHeight(4))
41 .backgroundColor('#FFF5F5F5') 41 .backgroundColor('#FFF5F5F5')
42 - .margin({ top: 3, bottom: 3 }) 42 + .margin({ top: this.getCompHeight(3), bottom: this.getCompHeight(3) })
43 Row() 43 Row()
44 .width(`100%`) 44 .width(`100%`)
45 - .height(20) 45 + .height(this.getCompHeight(20))
46 .backgroundColor('#FFF5F5F5') 46 .backgroundColor('#FFF5F5F5')
47 - // textArea(27, 25)  
48 - // textArea(27, 4)  
49 - // textArea(27, 20)  
50 } 47 }
51 .width(`22%`) 48 .width(`22%`)
52 .border({ width: 1 }) 49 .border({ width: 1 })
@@ -63,59 +60,59 @@ export struct newsSkeleton { @@ -63,59 +60,59 @@ export struct newsSkeleton {
63 .width('100%') 60 .width('100%')
64 61
65 BoxAndLine().width('100%') 62 BoxAndLine().width('100%')
66 - BoxAndBox({ firstBoxNumber: '65%', boxHeight: 100 }) 63 + BoxAndBox({ firstBoxNumber: '65%', boxHeight: this.getCompHeight(100) })
67 Column() { 64 Column() {
68 - textArea('100%', 79) 65 + textArea('100%', this.getCompHeight(79),this.getCompHeight(5))
69 } 66 }
70 67
71 - BoxAndBox({ firstBoxNumber: '30%', boxHeight: 51 }) 68 + BoxAndBox({ firstBoxNumber: '30%', boxHeight: this.getCompHeight(48) })
72 69
73 } 70 }
74 - .width('50%') 71 + .width('49%')
75 .margin({ right: 5 }) 72 .margin({ right: 5 })
76 73
77 Column() { 74 Column() {
78 Column() { 75 Column() {
79 - textArea('100%', 13) 76 + textArea('100%', this.getCompHeight(13),this.getCompHeight(0))
80 }.width('100%') 77 }.width('100%')
81 78
82 Column() { 79 Column() {
83 - textArea('100%', 136)  
84 - textArea('100%', 13)  
85 - textArea('80%', 13) 80 + textArea('100%', this.getCompHeight(136),this.getCompHeight(5))
  81 + textArea('100%', this.getCompHeight(13),this.getCompHeight(5))
  82 + textArea('80%', this.getCompHeight(13),this.getCompHeight(5))
86 }.width('100%').alignItems(HorizontalAlign.Start) 83 }.width('100%').alignItems(HorizontalAlign.Start)
87 84
88 Column() { 85 Column() {
89 - textArea('100%', 126) 86 + textArea('100%', this.getCompHeight(126),this.getCompHeight(5))
90 } 87 }
91 88
92 Column() { 89 Column() {
93 - textArea('100%', 13) 90 + textArea('100%', this.getCompHeight(13),this.getCompHeight(5))
94 } 91 }
95 92
96 Row() { 93 Row() {
97 Column() { 94 Column() {
98 - textArea('100%', 30) 95 + textArea('100%', this.getCompHeight(30),this.getCompHeight(5))
99 }.width('50%').margin({ right: 5 }) 96 }.width('50%').margin({ right: 5 })
100 97
101 Column() { 98 Column() {
102 - textArea('100%', 30) 99 + textArea('100%', this.getCompHeight(30),this.getCompHeight(5))
103 }.layoutWeight(1) 100 }.layoutWeight(1)
104 }.width('100%').justifyContent(FlexAlign.SpaceBetween) 101 }.width('100%').justifyContent(FlexAlign.SpaceBetween)
105 102
106 Column() { 103 Column() {
107 - textArea('100%', 100) 104 + textArea('100%', this.getCompHeight(100),this.getCompHeight(5))
108 } 105 }
109 } 106 }
110 - .width('50%') 107 + .width('49%')
111 } 108 }
112 .justifyContent(FlexAlign.SpaceBetween) 109 .justifyContent(FlexAlign.SpaceBetween)
113 .backgroundColor(Color.White) 110 .backgroundColor(Color.White)
114 .padding({ 111 .padding({
115 - top: 15,  
116 - bottom: 15,  
117 - right: 15,  
118 - left: 15 112 + top: 14,
  113 + right: 10,
  114 + bottom: 14,
  115 + left: 10
119 }) 116 })
120 if (this.showBottom) { 117 if (this.showBottom) {
121 // Column().backgroundColor('#CBCBCB').height(5).width(339) 118 // Column().backgroundColor('#CBCBCB').height(5).width(339)
@@ -133,17 +130,31 @@ export struct newsSkeleton { @@ -133,17 +130,31 @@ export struct newsSkeleton {
133 .width('100%') 130 .width('100%')
134 131
135 } 132 }
  133 +
  134 + getCompHeight(height: number): number{
  135 + //设计图高度 478
  136 + let compH:number = height*px2vp(this.itemPicHeight)/478
  137 + return compH;
  138 +}
  139 +
136 } 140 }
137 141
138 @Component 142 @Component
139 struct BoxAndLine { 143 struct BoxAndLine {
  144 + @Consume itemPicHeight: number
140 build() { 145 build() {
141 Column() { 146 Column() {
142 - textArea('100%', 130)  
143 - textArea('100%', 13)  
144 - textArea('80%', 13) 147 + textArea('100%', this.getCompHeight(130),this.getCompHeight(5))
  148 + textArea('100%', this.getCompHeight(13),this.getCompHeight(5))
  149 + textArea('80%', this.getCompHeight(13),this.getCompHeight(5))
145 }.alignItems(HorizontalAlign.Start) 150 }.alignItems(HorizontalAlign.Start)
146 } 151 }
  152 +
  153 + getCompHeight(height: number): number{
  154 + //设计图高度 478
  155 + let compH:number = height*px2vp(this.itemPicHeight)/478
  156 + return compH;
  157 + }
147 } 158 }
148 159
149 160
@@ -151,29 +162,37 @@ struct BoxAndLine { @@ -151,29 +162,37 @@ struct BoxAndLine {
151 struct BoxAndBox { 162 struct BoxAndBox {
152 @Prop firstBoxNumber: number | Resource | string 163 @Prop firstBoxNumber: number | Resource | string
153 @Prop boxHeight: number | Resource | string 164 @Prop boxHeight: number | Resource | string
154 - 165 + @Consume itemPicHeight: number
155 build() { 166 build() {
156 Row() { 167 Row() {
157 Column() { 168 Column() {
158 - textArea('100%', this.boxHeight) 169 + textArea('100%', this.boxHeight,this.getCompHeight(5))
159 }.width(this.firstBoxNumber).margin({ right: 5 }) 170 }.width(this.firstBoxNumber).margin({ right: 5 })
160 171
161 Column() { 172 Column() {
162 - textArea('100%', this.boxHeight) 173 + textArea('100%', this.boxHeight,this.getCompHeight(5))
163 }.layoutWeight(1) 174 }.layoutWeight(1)
164 }.width('100%').justifyContent(FlexAlign.SpaceBetween) 175 }.width('100%').justifyContent(FlexAlign.SpaceBetween)
165 } 176 }
  177 +
  178 + getCompHeight(height: number): number{
  179 + //设计图高度 478
  180 + let compH:number = height*px2vp(this.itemPicHeight)/478
  181 + return compH;
  182 + }
166 } 183 }
167 184
168 @Builder 185 @Builder
169 -function textArea(width: number | Resource | string = '100%', height: number | Resource | string = '100%') { 186 +function textArea(width: number | Resource | string = '100%', height: number | Resource | string = '100%',topM:number) {
170 Row() 187 Row()
171 .width(width) 188 .width(width)
172 .height(height) 189 .height(height)
173 - .backgroundColor('#FFF5F5F5')  
174 - .margin({ top: 5 }) 190 + .backgroundColor(height === 13?Color.Red:'#FFF5F5F5')
  191 + .margin({ top: topM })
175 // .borderRadius(5) 192 // .borderRadius(5)
176 } 193 }
177 194
178 195
179 196
  197 +
  198 +
@@ -21,6 +21,7 @@ export struct ENewspaperListDialog { @@ -21,6 +21,7 @@ export struct ENewspaperListDialog {
21 @State scrollOffset: number = 0 21 @State scrollOffset: number = 0
22 @State isCurrentViewOpen: boolean = false 22 @State isCurrentViewOpen: boolean = false
23 @Consume bottomSafeHeight: number 23 @Consume bottomSafeHeight: number
  24 + @Consume topMargin:number
24 //文字版选择弹框 25 //文字版选择弹框
25 pageListDialogController: CustomDialogController = new CustomDialogController({ 26 pageListDialogController: CustomDialogController = new CustomDialogController({
26 builder: ENewspaperPageDialog({ 27 builder: ENewspaperPageDialog({
@@ -292,7 +293,7 @@ export struct ENewspaperListDialog { @@ -292,7 +293,7 @@ export struct ENewspaperListDialog {
292 left: 15, 293 left: 15,
293 right: 15, 294 right: 15,
294 // top: 16, 295 // top: 16,
295 - // bottom: 16 296 + bottom: 25
296 }) 297 })
297 .margin({ 298 .margin({
298 bottom: 85 299 bottom: 85
@@ -317,15 +318,13 @@ export struct ENewspaperListDialog { @@ -317,15 +318,13 @@ export struct ENewspaperListDialog {
317 318
318 }) 319 })
319 } 320 }
320 - .margin({ top: this.topHeight }) 321 + .margin({ top: this.topHeight + this.topMargin})
321 .width('100%') 322 .width('100%')
322 .backgroundColor(Color.White) 323 .backgroundColor(Color.White)
323 -  
324 } 324 }
325 .width('100%') 325 .width('100%')
326 .height('100%') 326 .height('100%')
327 .backgroundColor('#80000000') 327 .backgroundColor('#80000000')
328 - .margin({ bottom: 50 })  
329 .onClick(() => { 328 .onClick(() => {
330 if (this.closeDialog) { 329 if (this.closeDialog) {
331 this.closeDialog() 330 this.closeDialog()