Showing
8 changed files
with
310 additions
and
2 deletions
| @@ -15,4 +15,8 @@ export { TopNavigationComponent } from "./components/TopNavigationComponent" | @@ -15,4 +15,8 @@ export { TopNavigationComponent } from "./components/TopNavigationComponent" | ||
| 15 | 15 | ||
| 16 | export { LabelComponent } from "./components/LabelComponent" | 16 | export { LabelComponent } from "./components/LabelComponent" |
| 17 | 17 | ||
| 18 | -export { SmallVideoCardComponent } from "./components/SmallVideoCardComponent" | ||
| 18 | +export { SmallVideoCardComponent } from "./components/SmallVideoCardComponent" | ||
| 19 | + | ||
| 20 | +export { TriPicCardComponent } from "./components/TriPicCardComponent" | ||
| 21 | + | ||
| 22 | +export { BigPicCardComponent } from "./components/BigPicCardComponent" |
| 1 | +//全标题 "compStyle":"2", | ||
| 2 | +import { CommonConstants } from 'wdConstant' | ||
| 3 | +import { CompDTO } from '../repository/bean/CompDTO' | ||
| 4 | +const TAG: string = 'BigPicCardComponent'; | ||
| 5 | + | ||
| 6 | +/** | ||
| 7 | + * 大图卡: | ||
| 8 | + * compstyle:2 | ||
| 9 | + * 卡片结构:上下结构 | ||
| 10 | + * 卡片宽度:充满父窗口 | ||
| 11 | + * 卡片高度,仅包含横板图片:图片高度由图片的宽度及宽高比决定,图片宽度占父窗口'100%',宽高比为16:9: | ||
| 12 | + */ | ||
| 13 | +// @Entry | ||
| 14 | +@Component | ||
| 15 | +export struct BigPicCardComponent { | ||
| 16 | + @State compDTO: CompDTO = {} as CompDTO | ||
| 17 | + | ||
| 18 | + build() { | ||
| 19 | + Column() { | ||
| 20 | + | ||
| 21 | + Column() { | ||
| 22 | + //新闻标题 | ||
| 23 | + Text(this.compDTO.operDataList[0].newsTitle) | ||
| 24 | + .fontSize(17) | ||
| 25 | + .fontColor('#222222') | ||
| 26 | + .maxLines(3) | ||
| 27 | + .textOverflow({ overflow: TextOverflow.Ellipsis }) // 超出的部分显示省略号。 | ||
| 28 | + .align(Alignment.Start) | ||
| 29 | + //大图 | ||
| 30 | + Stack() { | ||
| 31 | + Image(this.compDTO.operDataList[0].coverUrl) | ||
| 32 | + .borderRadius(4) | ||
| 33 | + | ||
| 34 | + | ||
| 35 | + //播放状态+时长 | ||
| 36 | + Row() { | ||
| 37 | + Image($r('app.media.icon_live')) | ||
| 38 | + .width(22) | ||
| 39 | + .height(18) | ||
| 40 | + | ||
| 41 | + Stack() { | ||
| 42 | + Text('直播中') | ||
| 43 | + .fontColor('#FFFFFF') | ||
| 44 | + .fontSize(11) | ||
| 45 | + } | ||
| 46 | + .width(44) | ||
| 47 | + .height(18) | ||
| 48 | + .backgroundColor('#4d000000') | ||
| 49 | + }.margin({right:8,bottom:8}) | ||
| 50 | + | ||
| 51 | + } | ||
| 52 | + .width('100%') | ||
| 53 | + .height(192) | ||
| 54 | + .alignContent(Alignment.BottomEnd) | ||
| 55 | + .margin({top:8}) | ||
| 56 | + | ||
| 57 | + } | ||
| 58 | + .width('100%') | ||
| 59 | + .justifyContent(FlexAlign.Start) | ||
| 60 | + .alignItems(HorizontalAlign.Start) | ||
| 61 | + .padding({top:14}) | ||
| 62 | + | ||
| 63 | + //bottom | ||
| 64 | + Row() { | ||
| 65 | + Text(this.compDTO.operDataList[0].source) | ||
| 66 | + .bottomTextStyle() | ||
| 67 | + //间隔点 | ||
| 68 | + Image($r('app.media.point')) | ||
| 69 | + .width(12) | ||
| 70 | + .height(12) | ||
| 71 | + | ||
| 72 | + Text(this.compDTO.operDataList[0].source) | ||
| 73 | + .bottomTextStyle() | ||
| 74 | + Text(' ') | ||
| 75 | + | ||
| 76 | + Text(this.compDTO.operDataList[0].subtitle) | ||
| 77 | + .bottomTextStyle() | ||
| 78 | + | ||
| 79 | + } | ||
| 80 | + .width('100%') | ||
| 81 | + .height(18) | ||
| 82 | + .justifyContent(FlexAlign.Start) | ||
| 83 | + // .padding({bottom:14}) | ||
| 84 | + .margin({top:8}) | ||
| 85 | + } | ||
| 86 | + .width('100%') | ||
| 87 | + .padding({left:16,right:16}) | ||
| 88 | + | ||
| 89 | + | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | +} | ||
| 93 | + | ||
| 94 | + | ||
| 95 | + | ||
| 96 | +/** | ||
| 97 | + * 大图卡 中部 | ||
| 98 | + * 包括:视频图、视频时长 | ||
| 99 | + */ | ||
| 100 | +@Component | ||
| 101 | +export struct myBigCard_body { | ||
| 102 | + private newsSrc:string ="https://k.sinaimg.cn/n/default/crawl/190/w550h440/20240118/6772-7c2385bb2741c6f88906af3514d27343.png/w700d1q75cms.jpg"; | ||
| 103 | + private newsTitle:string ="时政微观察丨新征程金融工作怎么干?“新年第一课”这样讲"; | ||
| 104 | + | ||
| 105 | + build() { | ||
| 106 | + Column() { | ||
| 107 | + //新闻标题 | ||
| 108 | + Text(this.newsTitle) | ||
| 109 | + .fontSize(17) | ||
| 110 | + .fontColor('#222222') | ||
| 111 | + .maxLines(3) | ||
| 112 | + .textOverflow({ overflow: TextOverflow.Ellipsis }) // 超出的部分显示省略号。 | ||
| 113 | + //大图 | ||
| 114 | + Stack() { | ||
| 115 | + Image(this.newsSrc) | ||
| 116 | + .borderRadius(4) | ||
| 117 | + | ||
| 118 | + | ||
| 119 | + //播放状态+时长 | ||
| 120 | + Row() { | ||
| 121 | + Image($r('app.media.icon_live')) | ||
| 122 | + .width(22) | ||
| 123 | + .height(18) | ||
| 124 | + | ||
| 125 | + Stack() { | ||
| 126 | + Text('直播中') | ||
| 127 | + .fontColor('#FFFFFF') | ||
| 128 | + .fontSize(11) | ||
| 129 | + } | ||
| 130 | + .width(44) | ||
| 131 | + .height(18) | ||
| 132 | + .backgroundColor('#4d000000') | ||
| 133 | + }.margin({right:8,bottom:8}) | ||
| 134 | + | ||
| 135 | + } | ||
| 136 | + .width('100%') | ||
| 137 | + .height(192) | ||
| 138 | + .alignContent(Alignment.BottomEnd) | ||
| 139 | + .margin({top:8}) | ||
| 140 | + | ||
| 141 | + } | ||
| 142 | + .width('100%') | ||
| 143 | + .justifyContent(FlexAlign.Start) | ||
| 144 | + } | ||
| 145 | + | ||
| 146 | +} | ||
| 147 | + | ||
| 148 | +/** | ||
| 149 | + * 大图卡 底部 | ||
| 150 | + * 包括:分享、评论、点赞 三个按钮 | ||
| 151 | + */ | ||
| 152 | + | ||
| 153 | +@Component | ||
| 154 | +export struct myBigCard_bottom { | ||
| 155 | + private bottom_height:number = 18 | ||
| 156 | + private itemSubtitle1:string = "人民日报" | ||
| 157 | + private itemSubtitle2:string = "25分钟前" | ||
| 158 | + private itemSubtitle3:string = "786条评论" | ||
| 159 | + build() { | ||
| 160 | + //子标题 | ||
| 161 | + Row() { | ||
| 162 | + Text(this.itemSubtitle1) | ||
| 163 | + .bottomTextStyle() | ||
| 164 | + //间隔点 | ||
| 165 | + Image($r('app.media.point')) | ||
| 166 | + .width(12) | ||
| 167 | + .height(12) | ||
| 168 | + | ||
| 169 | + Text(this.itemSubtitle2) | ||
| 170 | + .bottomTextStyle() | ||
| 171 | + Text(' ') | ||
| 172 | + | ||
| 173 | + Text(this.itemSubtitle3) | ||
| 174 | + .bottomTextStyle() | ||
| 175 | + | ||
| 176 | + } | ||
| 177 | + .width('100%') | ||
| 178 | + .height(this.bottom_height) | ||
| 179 | + .justifyContent(FlexAlign.Start) | ||
| 180 | + | ||
| 181 | + } | ||
| 182 | + | ||
| 183 | +} | ||
| 184 | + | ||
| 185 | +@Extend(Text) function bottomTextStyle() { | ||
| 186 | + .fontSize(12) | ||
| 187 | + .fontColor('#B0B0B0') | ||
| 188 | +} |
| @@ -8,6 +8,8 @@ import { LabelComponent } from './LabelComponent'; | @@ -8,6 +8,8 @@ import { LabelComponent } from './LabelComponent'; | ||
| 8 | import { LoadingComponent } from './LoadingComponent'; | 8 | import { LoadingComponent } from './LoadingComponent'; |
| 9 | import { TitleAbbrComponent } from './TitleAbbrComponent'; | 9 | import { TitleAbbrComponent } from './TitleAbbrComponent'; |
| 10 | import { TitleAllComponent } from './TitleAllComponent'; | 10 | import { TitleAllComponent } from './TitleAllComponent'; |
| 11 | +import { BigPicCardComponent } from './BigPicCardComponent'; | ||
| 12 | +import { TriPicCardComponent } from './TriPicCardComponent'; | ||
| 11 | 13 | ||
| 12 | const TAG = 'PageComponent'; | 14 | const TAG = 'PageComponent'; |
| 13 | 15 | ||
| @@ -52,6 +54,10 @@ export struct PageComponent { | @@ -52,6 +54,10 @@ export struct PageComponent { | ||
| 52 | TitleAbbrComponent({ compDTO: compDTO }) | 54 | TitleAbbrComponent({ compDTO: compDTO }) |
| 53 | } else if (compDTO.compStyle === CompStyle.Title_All_01) { | 55 | } else if (compDTO.compStyle === CompStyle.Title_All_01) { |
| 54 | TitleAllComponent({ compDTO: compDTO }) | 56 | TitleAllComponent({ compDTO: compDTO }) |
| 57 | + } else if (compDTO.compStyle === "2") { | ||
| 58 | + BigPicCardComponent({ compDTO: compDTO }) | ||
| 59 | + } else if (compDTO.compStyle === "4") { | ||
| 60 | + TriPicCardComponent({ compDTO: compDTO }) | ||
| 55 | } else { | 61 | } else { |
| 56 | // todo:组件未实现 / Component Not Implemented | 62 | // todo:组件未实现 / Component Not Implemented |
| 57 | Text(compDTO.compStyle) | 63 | Text(compDTO.compStyle) |
| 1 | +//全标题 "compStyle":"4", | ||
| 2 | +import { CommonConstants } from 'wdConstant' | ||
| 3 | +import { CompDTO } from '../repository/bean/CompDTO' | ||
| 4 | +const TAG: string = 'TriPicCardComponent'; | ||
| 5 | + | ||
| 6 | +/** | ||
| 7 | + * 三图卡: | ||
| 8 | + * compstyle:4 | ||
| 9 | + * 卡片结构:上下结构 | ||
| 10 | + * 卡片宽度:充满父窗口 | ||
| 11 | + * 卡片高度,仅包含横板图片:图片高度由图片的宽度及宽高比决定,图片宽度占父窗口'100%',宽高比为16:9: | ||
| 12 | + */ | ||
| 13 | +// @Entry | ||
| 14 | +@Component | ||
| 15 | +export struct TriPicCardComponent { | ||
| 16 | + @State compDTO: CompDTO = {} as CompDTO | ||
| 17 | + | ||
| 18 | + build() { | ||
| 19 | + Column() { | ||
| 20 | + | ||
| 21 | + | ||
| 22 | + //body | ||
| 23 | + Column() { | ||
| 24 | + //新闻标题 | ||
| 25 | + Text(this.compDTO.operDataList[0].newsTitle) | ||
| 26 | + .fontSize(17) | ||
| 27 | + .fontColor('#222222') | ||
| 28 | + .maxLines(3) | ||
| 29 | + .textOverflow({ overflow: TextOverflow.Ellipsis }) // 超出的部分显示省略号。 | ||
| 30 | + //三图 | ||
| 31 | + Row() { | ||
| 32 | + Image(this.compDTO.operDataList[0].fullColumnImgUrls[0].url) | ||
| 33 | + .width('32%') | ||
| 34 | + | ||
| 35 | + .height(75) | ||
| 36 | + .borderRadius({ topLeft:4,bottomLeft:4 }) | ||
| 37 | + | ||
| 38 | + Image(this.compDTO.operDataList[0].fullColumnImgUrls[1].url) | ||
| 39 | + .width('32%') | ||
| 40 | + .height(75) | ||
| 41 | + | ||
| 42 | + Image(this.compDTO.operDataList[0].fullColumnImgUrls[2].url) | ||
| 43 | + .width('32%') | ||
| 44 | + .height(75) | ||
| 45 | + .borderRadius({ topRight:4,bottomRight:4 }) | ||
| 46 | + | ||
| 47 | + } | ||
| 48 | + .justifyContent(FlexAlign.SpaceBetween) | ||
| 49 | + .width('100%') | ||
| 50 | + .height(75) | ||
| 51 | + .margin({top:8}) | ||
| 52 | + .borderRadius(8) | ||
| 53 | + | ||
| 54 | + } | ||
| 55 | + .width('100%') | ||
| 56 | + .justifyContent(FlexAlign.Start) | ||
| 57 | + .alignItems(HorizontalAlign.Start) | ||
| 58 | + .padding({top:14}) | ||
| 59 | + | ||
| 60 | + | ||
| 61 | + //bottom | ||
| 62 | + Row() { | ||
| 63 | + Text(this.compDTO.operDataList[0].source) | ||
| 64 | + .bottomTextStyle() | ||
| 65 | + //间隔点 | ||
| 66 | + Image($r('app.media.point')) | ||
| 67 | + .width(12) | ||
| 68 | + .height(12) | ||
| 69 | + | ||
| 70 | + Text(this.compDTO.operDataList[0].publishTime+"分钟前") | ||
| 71 | + .bottomTextStyle() | ||
| 72 | + Text(' ') | ||
| 73 | + | ||
| 74 | + Text(this.compDTO.operDataList[0].openLikes.toString()+"条评论") | ||
| 75 | + .bottomTextStyle() | ||
| 76 | + | ||
| 77 | + } | ||
| 78 | + .width('100%') | ||
| 79 | + | ||
| 80 | + .justifyContent(FlexAlign.Start) | ||
| 81 | + // .padding({bottom:14}) | ||
| 82 | + .margin({top:8}) | ||
| 83 | + .padding({bottom:14}) | ||
| 84 | + | ||
| 85 | + } | ||
| 86 | + .width('100%') | ||
| 87 | + .padding({top:8,left:16,right:16}) | ||
| 88 | + | ||
| 89 | + | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | +} | ||
| 93 | + | ||
| 94 | + | ||
| 95 | +@Extend(Text) function bottomTextStyle() { | ||
| 96 | + .fontSize(12) | ||
| 97 | + .fontColor('#B0B0B0') | ||
| 98 | +} |
| 1 | +import { FullColumnImgUrlsDTO } from './FullColumnImgUrlsDTO'; | ||
| 1 | export interface ContentDTO { | 2 | export interface ContentDTO { |
| 2 | cityCode: string; | 3 | cityCode: string; |
| 3 | coverSize: string; | 4 | coverSize: string; |
| @@ -34,4 +35,7 @@ export interface ContentDTO { | @@ -34,4 +35,7 @@ export interface ContentDTO { | ||
| 34 | vImageUrl: string; | 35 | vImageUrl: string; |
| 35 | screenType: string; | 36 | screenType: string; |
| 36 | source:string; | 37 | source:string; |
| 38 | + newsTitle:string; | ||
| 39 | + publishTime:string; | ||
| 40 | + fullColumnImgUrls:FullColumnImgUrlsDTO[]; | ||
| 37 | } | 41 | } |
| @@ -14,7 +14,7 @@ const TAG = 'PageViewModel'; | @@ -14,7 +14,7 @@ const TAG = 'PageViewModel'; | ||
| 14 | * mock数据开关,默认关。 | 14 | * mock数据开关,默认关。 |
| 15 | * mock数据是本地json数据,可自行修改内容(‘entry\src\main\resources\rawfile\’目录) | 15 | * mock数据是本地json数据,可自行修改内容(‘entry\src\main\resources\rawfile\’目录) |
| 16 | */ | 16 | */ |
| 17 | -const mock_switch = true; | 17 | +const mock_switch = false; |
| 18 | 18 | ||
| 19 | /** | 19 | /** |
| 20 | * 处理返回后的数据 | 20 | * 处理返回后的数据 |
1.76 KB
-
Please register or login to post a comment