douaojie

fix: 电子报骨架图,轮播图添加标签

1 import { CompDTO, ContentDTO, } from 'wdBean'; 1 import { CompDTO, ContentDTO, } from 'wdBean';
2 -import { BreakpointConstants, CommonConstants, DurationEnum } from 'wdConstant'; 2 +import { BreakpointConstants, CommonConstants } from 'wdConstant';
3 import { BreakPointType, Logger } from 'wdKit'; 3 import { BreakPointType, Logger } from 'wdKit';
4 import { CompUtils } from '../../utils/CompUtils'; 4 import { CompUtils } from '../../utils/CompUtils';
5 import { ProcessUtils } from 'wdRouter'; 5 import { ProcessUtils } from 'wdRouter';
6 import { EmptyComponent } from '../view/EmptyComponent'; 6 import { EmptyComponent } from '../view/EmptyComponent';
7 import { CardMediaInfo } from '../cardCommon/CardMediaInfo'; 7 import { CardMediaInfo } from '../cardCommon/CardMediaInfo';
8 import { onlyWifiLoadImg } from '../../utils/lazyloadImg'; 8 import { onlyWifiLoadImg } from '../../utils/lazyloadImg';
  9 +import { Notes } from '../cardview/notes';
9 10
10 const TAG = 'Zh_Carousel_Layout-01'; 11 const TAG = 'Zh_Carousel_Layout-01';
11 12
@@ -40,19 +41,21 @@ class MyDataSource implements IDataSource { @@ -40,19 +41,21 @@ class MyDataSource implements IDataSource {
40 41
41 @Component 42 @Component
42 export struct ZhCarouselLayout01 { 43 export struct ZhCarouselLayout01 {
43 - @StorageLink('currentBreakpoint') @Watch('watchCurrentBreakpoint') currentBreakpoint: string = BreakpointConstants.BREAKPOINT_XS; 44 + @StorageLink('currentBreakpoint') @Watch('watchCurrentBreakpoint') currentBreakpoint: string =
  45 + BreakpointConstants.BREAKPOINT_XS;
44 @State compDTO: CompDTO = {} as CompDTO 46 @State compDTO: CompDTO = {} as CompDTO
45 - private data: MyDataSource = new MyDataSource([])  
46 @State firstWd: number = 0 47 @State firstWd: number = 0
47 @State SecondWd: number = 0 48 @State SecondWd: number = 0
48 @State swiperIndex: number = 0 49 @State swiperIndex: number = 0
  50 + private data: MyDataSource = new MyDataSource([])
49 51
50 watchCurrentBreakpoint() { 52 watchCurrentBreakpoint() {
51 Logger.info(TAG, `watchCurrentBreakpoint, this.currentBreakpoint: ${this.currentBreakpoint}`); 53 Logger.info(TAG, `watchCurrentBreakpoint, this.currentBreakpoint: ${this.currentBreakpoint}`);
52 } 54 }
53 55
54 aboutToAppear() { 56 aboutToAppear() {
55 - Logger.info(TAG, `aboutToAppear, beanList:${this.compDTO?.operDataList?.length}, currentBreakpoint:${this.currentBreakpoint}`); 57 + Logger.info(TAG,
  58 + `aboutToAppear, beanList:${this.compDTO?.operDataList?.length}, currentBreakpoint:${this.currentBreakpoint}`);
56 let list: number[] = [] 59 let list: number[] = []
57 for (let i = 1; i <= this.compDTO?.operDataList?.length; i++) { 60 for (let i = 1; i <= this.compDTO?.operDataList?.length; i++) {
58 list.push(i); 61 list.push(i);
@@ -155,16 +158,21 @@ export struct ZhCarouselLayout01 { @@ -155,16 +158,21 @@ export struct ZhCarouselLayout01 {
155 } 158 }
156 159
157 public buildDisplayCount(): number { 160 public buildDisplayCount(): number {
158 - return new BreakPointType({ xs: 1, sm: 1, md: 2, lg: 3 }).getValue(this.currentBreakpoint) 161 + return new BreakPointType({
  162 + xs: 1,
  163 + sm: 1,
  164 + md: 2,
  165 + lg: 3
  166 + }).getValue(this.currentBreakpoint)
159 } 167 }
160 } 168 }
161 169
162 170
163 @Component 171 @Component
164 struct CarouselLayout01CardView { 172 struct CarouselLayout01CardView {
  173 + @State loadImg: boolean = false;
165 private item: ContentDTO = new ContentDTO(); 174 private item: ContentDTO = new ContentDTO();
166 private length: number = 1; // 轮播图数量 175 private length: number = 1; // 轮播图数量
167 - @State loadImg: boolean = false;  
168 176
169 async aboutToAppear(): Promise<void> { 177 async aboutToAppear(): Promise<void> {
170 this.loadImg = await onlyWifiLoadImg(); 178 this.loadImg = await onlyWifiLoadImg();
@@ -187,22 +195,18 @@ struct CarouselLayout01CardView { @@ -187,22 +195,18 @@ struct CarouselLayout01CardView {
187 }) 195 })
188 Column() { 196 Column() {
189 // 这里用于展示轮播图右上角信息,这里只对直播类型的展示 197 // 这里用于展示轮播图右上角信息,这里只对直播类型的展示
190 - if (this.item.objectType === '2' || this.item.objectType ==='4') { 198 + if (this.item.objectType === '2' || this.item.objectType === '4') {
191 CardMediaInfo({ contentDTO: this.item }) 199 CardMediaInfo({ contentDTO: this.item })
192 .width(CommonConstants.FULL_PARENT) 200 .width(CommonConstants.FULL_PARENT)
193 } 201 }
194 Blank() 202 Blank()
195 // 文本信息 203 // 文本信息
  204 + Stack() {
  205 + if (this.item.objectType == '5') {
  206 + Notes({ objectType: this.item.objectType })
  207 + }
196 Text(`${this.item.corner}${this.item.newsTitle}`) 208 Text(`${this.item.corner}${this.item.newsTitle}`)
197 .width(CommonConstants.FULL_PARENT) 209 .width(CommonConstants.FULL_PARENT)
198 - .height(39)  
199 - .padding({  
200 - left: 10,  
201 - right: 10  
202 - })  
203 - .margin({  
204 - bottom: this.length > 1 ? 28 : 10  
205 - })  
206 .fontColor(Color.White) 210 .fontColor(Color.White)
207 .fontSize($r('app.float.font_size_16')) 211 .fontSize($r('app.float.font_size_16'))
208 .fontWeight(FontWeight.Medium) 212 .fontWeight(FontWeight.Medium)
@@ -210,6 +214,18 @@ struct CarouselLayout01CardView { @@ -210,6 +214,18 @@ struct CarouselLayout01CardView {
210 .align(Alignment.Bottom) 214 .align(Alignment.Bottom)
211 .maxLines(CompUtils.MAX_LINES_2) 215 .maxLines(CompUtils.MAX_LINES_2)
212 .textOverflow({ overflow: TextOverflow.Ellipsis }) 216 .textOverflow({ overflow: TextOverflow.Ellipsis })
  217 + .textIndent(this.item.objectType == '5' ? 40 : 0)
  218 + }
  219 + // .height(39)
  220 + .padding({
  221 + left: 10,
  222 + right: 10
  223 + })
  224 + .margin({
  225 + bottom: this.length > 1 ? 28 : 10
  226 + })
  227 + .alignContent(Alignment.TopStart)
  228 +
213 } 229 }
214 .width(CommonConstants.FULL_PARENT) 230 .width(CommonConstants.FULL_PARENT)
215 .height(CommonConstants.FULL_PARENT) 231 .height(CommonConstants.FULL_PARENT)
@@ -16,29 +16,42 @@ export struct newsSkeleton { @@ -16,29 +16,42 @@ export struct newsSkeleton {
16 Column() { 16 Column() {
17 Image($r('app.media.peopleSeleton')).width('100%').height(47)// 后缀名不能省略 17 Image($r('app.media.peopleSeleton')).width('100%').height(47)// 后缀名不能省略
18 .interpolation(ImageInterpolation.High) 18 .interpolation(ImageInterpolation.High)
19 - textArea('100%', 9)  
20 - }.width('72.00%').alignItems(HorizontalAlign.Start).margin({ right: 5 }) 19 + textArea('100%', 8)
  20 + }
  21 + .width(124)
  22 + .alignItems(HorizontalAlign.Start)
  23 + .margin({ right: 5 })
21 24
22 Column() { 25 Column() {
23 - textArea(27, 25)  
24 - textArea(27, 4)  
25 - textArea(27, 20) 26 + Row()
  27 + .width(27)
  28 + .height(25)
  29 + .backgroundColor('#FFF5F5F5')
  30 + Row()
  31 + .width(27)
  32 + .height(4)
  33 + .backgroundColor('#FFF5F5F5')
  34 + .margin({ top: 3, bottom: 3 })
  35 + Row()
  36 + .width(27)
  37 + .height(20)
  38 + .backgroundColor('#FFF5F5F5')
  39 + // textArea(27, 25)
  40 + // textArea(27, 4)
  41 + // textArea(27, 20)
26 } 42 }
27 .border({ width: 1 }) 43 .border({ width: 1 })
28 .borderColor('#FFF5F5F5') 44 .borderColor('#FFF5F5F5')
29 .padding({ 45 .padding({
30 - right: 2,  
31 - left: 2,  
32 - top: 0,  
33 - bottom: 2 46 + right: 5,
  47 + left: 5,
  48 + top: 4,
  49 + bottom: 4
34 }) 50 })
35 - .justifyContent(FlexAlign.SpaceEvenly) 51 + .justifyContent(FlexAlign.SpaceBetween)
36 .alignItems(HorizontalAlign.Start) 52 .alignItems(HorizontalAlign.Start)
37 } 53 }
38 - .justifyContent(FlexAlign.SpaceBetween)  
39 - .width('98%')  
40 -  
41 - // .height(64) 54 + .width('100%')
42 55
43 BoxAndLine().width('100%') 56 BoxAndLine().width('100%')
44 BoxAndBox({ firstBoxNumber: '65%', boxHeight: 100 }) 57 BoxAndBox({ firstBoxNumber: '65%', boxHeight: 100 })
@@ -48,24 +61,27 @@ export struct newsSkeleton { @@ -48,24 +61,27 @@ export struct newsSkeleton {
48 61
49 BoxAndBox({ firstBoxNumber: '30%', boxHeight: 51 }) 62 BoxAndBox({ firstBoxNumber: '30%', boxHeight: 51 })
50 63
51 - }.width('45%')  
52 - .opacity(1)  
53 - .align(Alignment.Start)  
54 - .alignItems(HorizontalAlign.Start) 64 + }
  65 + .width('50%')
  66 + .margin({ right: 5 })
55 67
56 Column() { 68 Column() {
57 Column() { 69 Column() {
58 textArea('100%', 13) 70 textArea('100%', 13)
59 }.width('100%') 71 }.width('100%')
60 72
61 - BoxAndLine() 73 + Column() {
  74 + textArea('100%', 136)
  75 + textArea('100%', 13)
  76 + textArea('80%', 13)
  77 + }.width('100%').alignItems(HorizontalAlign.Start)
62 78
63 Column() { 79 Column() {
64 - textArea('95%', 126) 80 + textArea('100%', 126)
65 } 81 }
66 82
67 Column() { 83 Column() {
68 - textArea('95%', 13) 84 + textArea('100%', 13)
69 } 85 }
70 86
71 Row() { 87 Row() {
@@ -76,24 +92,28 @@ export struct newsSkeleton { @@ -76,24 +92,28 @@ export struct newsSkeleton {
76 Column() { 92 Column() {
77 textArea('100%', 30) 93 textArea('100%', 30)
78 }.layoutWeight(1) 94 }.layoutWeight(1)
79 - }.width('95%').justifyContent(FlexAlign.SpaceBetween) 95 + }.width('100%').justifyContent(FlexAlign.SpaceBetween)
80 96
81 Column() { 97 Column() {
82 - textArea('95%', 100) 98 + textArea('100%', 100)
  99 + }
83 } 100 }
84 - }.width('45%') 101 + .width('50%')
85 } 102 }
86 .justifyContent(FlexAlign.SpaceBetween) 103 .justifyContent(FlexAlign.SpaceBetween)
87 .backgroundColor(Color.White) 104 .backgroundColor(Color.White)
88 .padding({ 105 .padding({
89 - top: 5,  
90 - bottom: 5,  
91 - right: 5,  
92 - left: 5 106 + top: 15,
  107 + bottom: 15,
  108 + right: 15,
  109 + left: 15
93 }) 110 })
  111 +
  112 + Column().backgroundColor('#CBCBCB').height(5).width(339)
  113 + Column().backgroundColor('#909090').height(5).width(326)
94 } 114 }
95 .width('100%') 115 .width('100%')
96 - 116 + .padding({ right: 10, left: 10 })
97 } 117 }
98 .height('100%') 118 .height('100%')
99 119
@@ -107,7 +127,7 @@ struct BoxAndLine { @@ -107,7 +127,7 @@ struct BoxAndLine {
107 textArea('100%', 130) 127 textArea('100%', 130)
108 textArea('100%', 13) 128 textArea('100%', 13)
109 textArea('80%', 13) 129 textArea('80%', 13)
110 - }.width('98%').alignItems(HorizontalAlign.Start) 130 + }.alignItems(HorizontalAlign.Start)
111 } 131 }
112 } 132 }
113 133
@@ -140,18 +160,5 @@ function textArea(width: number | Resource | string = '100%', height: number | R @@ -140,18 +160,5 @@ function textArea(width: number | Resource | string = '100%', height: number | R
140 // .borderRadius(5) 160 // .borderRadius(5)
141 } 161 }
142 162
143 -// 全局公共样式  
144 -@Styles  
145 -function SkeletonStyle() {  
146 - .padding({ right: 14, left: 14 })  
147 - .width('100%')  
148 - .margin({ top: 5 })  
149 -}  
150 163
151 -@Extend(Column)  
152 -function RightStyle() {  
153 - .alignItems(HorizontalAlign.Start)  
154 - .justifyContent(FlexAlign.SpaceAround)  
155 - .height('100%')  
156 -}  
157 164