把DevEco3.1的PeopleDaily_Harmony中的代码合并到DevEco4.0的sight_harmony中,修复没有参与编译而没有报错的文件
Showing
22 changed files
with
567 additions
and
32 deletions
| @@ -10,12 +10,13 @@ export { ItemDTO } from './src/main/ets/bean/ItemDTO'; | @@ -10,12 +10,13 @@ export { ItemDTO } from './src/main/ets/bean/ItemDTO'; | ||
| 10 | 10 | ||
| 11 | export { ItemBean } from './src/main/ets/bean/ItemBean'; | 11 | export { ItemBean } from './src/main/ets/bean/ItemBean'; |
| 12 | 12 | ||
| 13 | -// component | ||
| 14 | -export { Action } from './src/main/ets/bean/programme/Action' | 13 | +// Content |
| 14 | +export { ContentDTO } from './src/main/ets/bean/content/ContentDTO'; | ||
| 15 | +export { Action } from './src/main/ets/bean/content/Action' | ||
| 15 | 16 | ||
| 16 | -export { Params } from './src/main/ets/bean/programme/Params' | 17 | +export { Params } from './src/main/ets/bean/content/Params' |
| 17 | 18 | ||
| 18 | -export { Pic } from './src/main/ets/bean/programme/Pic' | 19 | +export { Pic } from './src/main/ets/bean/content/Pic' |
| 19 | 20 | ||
| 20 | export { LabelBean } from './src/main/ets/bean/component/extra/LabelBean'; | 21 | export { LabelBean } from './src/main/ets/bean/component/extra/LabelBean'; |
| 21 | 22 | ||
| @@ -27,7 +28,6 @@ export { GroupDTO } from './src/main/ets/bean/component/GroupDTO'; | @@ -27,7 +28,6 @@ export { GroupDTO } from './src/main/ets/bean/component/GroupDTO'; | ||
| 27 | 28 | ||
| 28 | export { CompDTO } from './src/main/ets/bean/component/CompDTO'; | 29 | export { CompDTO } from './src/main/ets/bean/component/CompDTO'; |
| 29 | 30 | ||
| 30 | -export { ContentDTO } from './src/main/ets/bean/component/ContentDTO'; | ||
| 31 | 31 | ||
| 32 | export { NewspaperListBean } from './src/main/ets/bean/newspaper/NewspaperListBean'; | 32 | export { NewspaperListBean } from './src/main/ets/bean/newspaper/NewspaperListBean'; |
| 33 | 33 |
| 1 | import { ItemDTO } from './ItemDTO'; | 1 | import { ItemDTO } from './ItemDTO'; |
| 2 | -import { Action } from './programme/Action'; | ||
| 3 | -import { Pic } from './programme/Pic'; | 2 | +import { Action } from './content/Action'; |
| 3 | +import { Pic } from './content/Pic'; | ||
| 4 | 4 | ||
| 5 | /** | 5 | /** |
| 6 | * 绑定到组件comp/view的数据Bean | 6 | * 绑定到组件comp/view的数据Bean |
| 1 | -import { ContentDTO } from './ContentDTO'; | 1 | +import { ContentDTO } from '../content/ContentDTO'; |
| 2 | 2 | ||
| 3 | export interface CompDTO { | 3 | export interface CompDTO { |
| 4 | backgroundColor: string; | 4 | backgroundColor: string; |
| @@ -26,4 +26,5 @@ export interface CompDTO { | @@ -26,4 +26,5 @@ export interface CompDTO { | ||
| 26 | provinceCode: string; | 26 | provinceCode: string; |
| 27 | sortValue: number; | 27 | sortValue: number; |
| 28 | subType: string; | 28 | subType: string; |
| 29 | + imageScale: number; // 封面图比例 1-4:3, 2-16:9, 3-3:2 | ||
| 29 | } | 30 | } |
| 1 | +import { FullColumnImgUrlsDTO } from './FullColumnImgUrlsDTO'; | ||
| 2 | +import { LiveInfo } from './LiveInfo'; | ||
| 3 | +import { VideoInfo } from './VideoInfo'; | ||
| 4 | + | ||
| 1 | export interface ContentDTO { | 5 | export interface ContentDTO { |
| 2 | cityCode: string; | 6 | cityCode: string; |
| 3 | coverSize: string; | 7 | coverSize: string; |
| @@ -45,4 +49,7 @@ export interface ContentDTO { | @@ -45,4 +49,7 @@ export interface ContentDTO { | ||
| 45 | newsTitle:string; | 49 | newsTitle:string; |
| 46 | publishTime:string; | 50 | publishTime:string; |
| 47 | visitorComment:number; | 51 | visitorComment:number; |
| 52 | + fullColumnImgUrls:FullColumnImgUrlsDTO[]; | ||
| 53 | + liveInfo?: LiveInfo; // 直播新闻信息【BFF聚合】 | ||
| 54 | + videoInfo?: VideoInfo; // 视频新闻信息【BFF聚合】,视频非原片+清晰度最高的 | ||
| 48 | } | 55 | } |
| @@ -40,4 +40,10 @@ export { ImageAndTextWebComponent } from "./src/main/ets/components/ImageAndText | @@ -40,4 +40,10 @@ export { ImageAndTextWebComponent } from "./src/main/ets/components/ImageAndText | ||
| 40 | 40 | ||
| 41 | export { DetailViewModel } from "./src/main/ets/viewmodel/DetailViewModel" | 41 | export { DetailViewModel } from "./src/main/ets/viewmodel/DetailViewModel" |
| 42 | 42 | ||
| 43 | -export { SingleImageCardComponent } from "./src/main/ets/components/view/SingleImageCardComponent" | ||
| 43 | +export { SingleImageCardComponent } from "./src/main/ets/components/view/SingleImageCardComponent" | ||
| 44 | + | ||
| 45 | +export { TriPicCardComponent } from "./src/main/ets/components/view/TriPicCardComponent" | ||
| 46 | + | ||
| 47 | +export { BigPicCardComponent } from "./src/main/ets/components/view/BigPicCardComponent" | ||
| 48 | + | ||
| 49 | +export { HeadPictureCardComponent } from "./src/main/ets/components/view/HeadPictureCardComponent" |
| 1 | +import { CompDTO } from 'wdBean'; | ||
| 1 | import { CommonConstants, CompStyle } from 'wdConstant'; | 2 | import { CommonConstants, CompStyle } from 'wdConstant'; |
| 2 | import { BannerComponent } from './view/BannerComponent'; | 3 | import { BannerComponent } from './view/BannerComponent'; |
| 3 | import { LabelComponent } from './view/LabelComponent'; | 4 | import { LabelComponent } from './view/LabelComponent'; |
| 4 | import { TitleAbbrComponent } from './view/TitleAbbrComponent'; | 5 | import { TitleAbbrComponent } from './view/TitleAbbrComponent'; |
| 5 | import { TitleAllComponent } from './view/TitleAllComponent'; | 6 | import { TitleAllComponent } from './view/TitleAllComponent'; |
| 6 | -import { HorizontalStrokeCardThreeTwoRadioForOneComponent } from './view/HorizontalStrokeCardThreeTwoRadioForOneComponent'; | ||
| 7 | -import { HorizontalStrokeCardThreeTwoRadioForTwoComponent } from './view/HorizontalStrokeCardThreeTwoRadioForTwoComponent'; | ||
| 8 | -import { HorizontalStrokeCardThreeTwoRadioForMoreComponent } from './view/HorizontalStrokeCardThreeTwoRadioForMoreComponent'; | ||
| 9 | -import { CompDTO } from 'wdBean'; | ||
| 10 | import { SingleImageCardComponent } from './view/SingleImageCardComponent'; | 7 | import { SingleImageCardComponent } from './view/SingleImageCardComponent'; |
| 8 | +import { BigPicCardComponent } from './view/BigPicCardComponent'; | ||
| 9 | +import { TriPicCardComponent } from './view/TriPicCardComponent'; | ||
| 10 | +import { LiveHorizontalCardComponent } from './view/LiveHorizontalCardComponent'; | ||
| 11 | +import { HeadPictureCardComponent } from './view/HeadPictureCardComponent'; | ||
| 11 | 12 | ||
| 12 | /** | 13 | /** |
| 13 | * comp适配器. | 14 | * comp适配器. |
| @@ -33,6 +34,14 @@ export struct CompParser { | @@ -33,6 +34,14 @@ export struct CompParser { | ||
| 33 | BannerComponent({ compDTO: compDTO }) | 34 | BannerComponent({ compDTO: compDTO }) |
| 34 | } else if (compDTO.compStyle === CompStyle.Single_Imagecard_02 || compDTO.compStyle === CompStyle.Single_Imagecard_03) { | 35 | } else if (compDTO.compStyle === CompStyle.Single_Imagecard_02 || compDTO.compStyle === CompStyle.Single_Imagecard_03) { |
| 35 | SingleImageCardComponent({ compDTO: compDTO }) | 36 | SingleImageCardComponent({ compDTO: compDTO }) |
| 37 | + } else if (compDTO.compStyle === "2") { | ||
| 38 | + BigPicCardComponent({ compDTO: compDTO }) | ||
| 39 | + } else if (compDTO.compStyle === "4") { | ||
| 40 | + TriPicCardComponent({ compDTO: compDTO }) | ||
| 41 | + } else if (compDTO.compStyle === CompStyle.Zh_Single_Row_01 && compDTO.imageScale === 2) { | ||
| 42 | + LiveHorizontalCardComponent({ compDTO: compDTO }) | ||
| 43 | + } else if (compDTO.compStyle === CompStyle.Zh_Single_Column_02) { | ||
| 44 | + HeadPictureCardComponent({ compDTO: compDTO }) | ||
| 36 | } else { | 45 | } else { |
| 37 | // todo:组件未实现 / Component Not Implemented | 46 | // todo:组件未实现 / Component Not Implemented |
| 38 | Text(compDTO.compStyle) | 47 | Text(compDTO.compStyle) |
| 1 | +import { CompDTO } from 'wdBean'; | ||
| 2 | +import { CommonConstants } from 'wdConstant' | ||
| 3 | + | ||
| 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 | +@Component | ||
| 98 | +export struct myBigCard_body { | ||
| 99 | + private newsSrc: string = "https://k.sinaimg.cn/n/default/crawl/190/w550h440/20240118/6772-7c2385bb2741c6f88906af3514d27343.png/w700d1q75cms.jpg"; | ||
| 100 | + private newsTitle: string = "时政微观察丨新征程金融工作怎么干?“新年第一课”这样讲"; | ||
| 101 | + | ||
| 102 | + build() { | ||
| 103 | + Column() { | ||
| 104 | + //新闻标题 | ||
| 105 | + Text(this.newsTitle) | ||
| 106 | + .fontSize(17) | ||
| 107 | + .fontColor('#222222') | ||
| 108 | + .maxLines(3) | ||
| 109 | + .textOverflow({ overflow: TextOverflow.Ellipsis }) // 超出的部分显示省略号。 | ||
| 110 | + //大图 | ||
| 111 | + Stack() { | ||
| 112 | + Image(this.newsSrc) | ||
| 113 | + .borderRadius(4) | ||
| 114 | + | ||
| 115 | + | ||
| 116 | + //播放状态+时长 | ||
| 117 | + Row() { | ||
| 118 | + Image($r('app.media.icon_live')) | ||
| 119 | + .width(22) | ||
| 120 | + .height(18) | ||
| 121 | + | ||
| 122 | + Stack() { | ||
| 123 | + Text('直播中') | ||
| 124 | + .fontColor('#FFFFFF') | ||
| 125 | + .fontSize(11) | ||
| 126 | + } | ||
| 127 | + .width(44) | ||
| 128 | + .height(18) | ||
| 129 | + .backgroundColor('#4d000000') | ||
| 130 | + }.margin({ right: 8, bottom: 8 }) | ||
| 131 | + | ||
| 132 | + } | ||
| 133 | + .width('100%') | ||
| 134 | + .height(192) | ||
| 135 | + .alignContent(Alignment.BottomEnd) | ||
| 136 | + .margin({ top: 8 }) | ||
| 137 | + | ||
| 138 | + } | ||
| 139 | + .width('100%') | ||
| 140 | + .justifyContent(FlexAlign.Start) | ||
| 141 | + } | ||
| 142 | +} | ||
| 143 | + | ||
| 144 | +/** | ||
| 145 | + * 大图卡 底部 | ||
| 146 | + * 包括:分享、评论、点赞 三个按钮 | ||
| 147 | + */ | ||
| 148 | + | ||
| 149 | +@Component | ||
| 150 | +export struct myBigCard_bottom { | ||
| 151 | + private bottom_height: number = 18 | ||
| 152 | + private itemSubtitle1: string = "人民日报" | ||
| 153 | + private itemSubtitle2: string = "25分钟前" | ||
| 154 | + private itemSubtitle3: string = "786条评论" | ||
| 155 | + | ||
| 156 | + build() { | ||
| 157 | + //子标题 | ||
| 158 | + Row() { | ||
| 159 | + Text(this.itemSubtitle1) | ||
| 160 | + .bottomTextStyle() | ||
| 161 | + //间隔点 | ||
| 162 | + Image($r('app.media.point')) | ||
| 163 | + .width(12) | ||
| 164 | + .height(12) | ||
| 165 | + | ||
| 166 | + Text(this.itemSubtitle2) | ||
| 167 | + .bottomTextStyle() | ||
| 168 | + Text(' ') | ||
| 169 | + | ||
| 170 | + Text(this.itemSubtitle3) | ||
| 171 | + .bottomTextStyle() | ||
| 172 | + | ||
| 173 | + } | ||
| 174 | + .width('100%') | ||
| 175 | + .height(this.bottom_height) | ||
| 176 | + .justifyContent(FlexAlign.Start) | ||
| 177 | + | ||
| 178 | + } | ||
| 179 | +} | ||
| 180 | + | ||
| 181 | +@Extend(Text) | ||
| 182 | +function bottomTextStyle() { | ||
| 183 | + .fontSize(12) | ||
| 184 | + .fontColor('#B0B0B0') | ||
| 185 | +} |
| 1 | import { CompDTO } from 'wdBean'; | 1 | import { CompDTO } from 'wdBean'; |
| 2 | import { CommonConstants } from 'wdConstant'; | 2 | import { CommonConstants } from 'wdConstant'; |
| 3 | -import { CompUtils } from '../utils/CompUtils'; | 3 | +import { CompUtils } from '../../utils/CompUtils'; |
| 4 | 4 | ||
| 5 | @Component | 5 | @Component |
| 6 | export struct HeadPictureCardComponent { | 6 | export struct HeadPictureCardComponent { |
| @@ -11,25 +11,31 @@ export struct HeadPictureCardComponent { | @@ -11,25 +11,31 @@ export struct HeadPictureCardComponent { | ||
| 11 | Image(this.compDTO.backgroundImgUrl) | 11 | Image(this.compDTO.backgroundImgUrl) |
| 12 | .width(CommonConstants.FULL_WIDTH) | 12 | .width(CommonConstants.FULL_WIDTH) |
| 13 | .height(CommonConstants.FULL_HEIGHT) | 13 | .height(CommonConstants.FULL_HEIGHT) |
| 14 | - Row() | ||
| 15 | - .width(CommonConstants.FULL_WIDTH) | ||
| 16 | - .height(59) | ||
| 17 | - .linearGradient({ | ||
| 18 | - colors:[ | ||
| 19 | - ['rgba(0, 0, 0, 0.0)', 0.0], ['rgba(0, 0, 0, 0.3)', 1.0] | ||
| 20 | - ] | ||
| 21 | - }) | ||
| 22 | - Row() { | ||
| 23 | - Text(CompUtils.getLabelTitle(this.compDTO.extraData)) | 14 | + |
| 15 | + if (this.compDTO.extraData) { | ||
| 16 | + Row() | ||
| 24 | .width(CommonConstants.FULL_WIDTH) | 17 | .width(CommonConstants.FULL_WIDTH) |
| 25 | - .height(CommonConstants.FULL_HEIGHT) | ||
| 26 | - .fontColor(Color.White) | ||
| 27 | - .fontSize($r('app.float.normal_text_size')) | ||
| 28 | - .fontWeight(FontWeight.Bold) | 18 | + .height(59) |
| 19 | + .linearGradient({ | ||
| 20 | + colors: [ | ||
| 21 | + ['rgba(0, 0, 0, 0.0)', 0.0], ['rgba(0, 0, 0, 0.3)', 1.0] | ||
| 22 | + ] | ||
| 23 | + }) | ||
| 24 | + Row() { | ||
| 25 | + Text(CompUtils.getLabelTitle(this.compDTO.extraData)) | ||
| 26 | + .width(CommonConstants.FULL_WIDTH) | ||
| 27 | + .height(CommonConstants.FULL_HEIGHT) | ||
| 28 | + .fontColor(Color.White) | ||
| 29 | + .fontSize($r('app.float.normal_text_size')) | ||
| 30 | + .fontWeight(FontWeight.Bold) | ||
| 31 | + .maxLines(2) | ||
| 32 | + } | ||
| 33 | + .height(25) | ||
| 34 | + .margin({ left: 12, bottom: 10, right: 12 }) | ||
| 29 | } | 35 | } |
| 30 | - .height(25) | ||
| 31 | - .margin({left: 12, bottom: 10, right: 12}) | ||
| 32 | } | 36 | } |
| 33 | .alignContent(Alignment.Bottom) | 37 | .alignContent(Alignment.Bottom) |
| 38 | + .width(CommonConstants.FULL_WIDTH) | ||
| 39 | + .height(200) | ||
| 34 | } | 40 | } |
| 35 | } | 41 | } |
| 1 | +import { CommonConstants } from 'wdConstant' | ||
| 2 | +import { CompDTO, ContentDTO } from 'wdBean' | ||
| 3 | +import { LiveVideoTypeComponent } from './LiveVideoTypeComponent' | ||
| 4 | +import { LiveHorizontalCardForOneComponent } from './LiveHorizontalCardForOneComponent' | ||
| 5 | + | ||
| 6 | +/** | ||
| 7 | + * 视频直播横划卡16:9 | ||
| 8 | + */ | ||
| 9 | +@Component | ||
| 10 | +export struct LiveHorizontalCardComponent { | ||
| 11 | + @State compDTO: CompDTO = {} as CompDTO | ||
| 12 | + build() { | ||
| 13 | + Column() { | ||
| 14 | + Row() { | ||
| 15 | + Row() { | ||
| 16 | + Image($r("app.media.redLine")) | ||
| 17 | + .width(3) | ||
| 18 | + .height(16) | ||
| 19 | + .margin({ right: 4 }) | ||
| 20 | + Text(this.compDTO.objectTitle) | ||
| 21 | + .fontSize($r("app.float.font_size_17")) | ||
| 22 | + .fontColor($r("app.color.color_222222")) | ||
| 23 | + .fontWeight(600) | ||
| 24 | + } | ||
| 25 | + | ||
| 26 | + if (this.compDTO.operDataList.length > 10) { | ||
| 27 | + Row() { | ||
| 28 | + Text("更多") | ||
| 29 | + .fontSize($r("app.float.font_size_14")) | ||
| 30 | + .fontColor($r("app.color.color_999999")) | ||
| 31 | + .margin({ right: 1 }) | ||
| 32 | + Image($r("app.media.more")) | ||
| 33 | + .width(14) | ||
| 34 | + .height(14) | ||
| 35 | + } | ||
| 36 | + } | ||
| 37 | + }.justifyContent(FlexAlign.SpaceBetween) | ||
| 38 | + .padding({ left: 16, right: 16 }) | ||
| 39 | + .margin({ top: 8, bottom: 8 }) | ||
| 40 | + .width(CommonConstants.FULL_WIDTH) | ||
| 41 | + // 多个 | ||
| 42 | + if (this.compDTO.operDataList.length >= 2) { | ||
| 43 | + List({ space: 12 }) { | ||
| 44 | + | ||
| 45 | + ForEach(this.compDTO.operDataList, (item: ContentDTO, index: number) => { | ||
| 46 | + ListItem() { | ||
| 47 | + Column() { | ||
| 48 | + Stack({ alignContent: Alignment.BottomEnd }) { | ||
| 49 | + Image(item.coverUrl) | ||
| 50 | + .aspectRatio(16 / 9) | ||
| 51 | + .width(this.compDTO.operDataList.length == 2 ? 210 : 150) | ||
| 52 | + .borderRadius(4) | ||
| 53 | + .objectFit(ImageFit.Cover) | ||
| 54 | + if (item.objectType === '2' && item.liveInfo && item.liveInfo.liveState === 'running') { | ||
| 55 | + LiveVideoTypeComponent({ nType: 0, name: '直播中' }) | ||
| 56 | + .padding({ | ||
| 57 | + bottom: 4, | ||
| 58 | + right: 4 | ||
| 59 | + }) | ||
| 60 | + } else if (item.objectType === '1' && item.videoInfo) { | ||
| 61 | + LiveVideoTypeComponent({ nType: 1, name: item.videoInfo.videoDuration }) | ||
| 62 | + .padding({ | ||
| 63 | + bottom: 4, | ||
| 64 | + right: 4 | ||
| 65 | + }) | ||
| 66 | + } | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + Text(item.newsTitle) | ||
| 70 | + .fontSize($r("app.float.font_size_14")) | ||
| 71 | + .fontColor($r("app.color.color_212228")) | ||
| 72 | + .fontWeight(400) | ||
| 73 | + .maxLines(2) | ||
| 74 | + .textOverflow({ overflow: TextOverflow.Ellipsis }) // 超出的部分显示省略号。 | ||
| 75 | + .textAlign(TextAlign.Start) | ||
| 76 | + .margin({ top: 8 }) | ||
| 77 | + .width(this.compDTO.operDataList.length == 2 ? 210 : 150) | ||
| 78 | + } | ||
| 79 | + } | ||
| 80 | + .padding({ left: (index == 0) ? 16 : 0, right: (index == this.compDTO.operDataList.length - 1) ? 16 : 0 }) | ||
| 81 | + .onClick(() => { | ||
| 82 | + if (item.objectType != '0') { | ||
| 83 | + console.log(item.objectId) | ||
| 84 | + } | ||
| 85 | + }) | ||
| 86 | + }, (item: ContentDTO, index: number) => JSON.stringify(item)) | ||
| 87 | + | ||
| 88 | + }.listDirection(Axis.Horizontal) | ||
| 89 | + .width(CommonConstants.FULL_WIDTH) | ||
| 90 | + .height(this.compDTO.operDataList.length == 2 ? 180 : 136) | ||
| 91 | + } else if (this.compDTO.operDataList.length) { | ||
| 92 | + // 一个 | ||
| 93 | + LiveHorizontalCardForOneComponent({ contentDTO: this.compDTO.operDataList[0] }) | ||
| 94 | + } | ||
| 95 | + } | ||
| 96 | + .width(CommonConstants.FULL_WIDTH) | ||
| 97 | + .padding({ | ||
| 98 | + top: 14, | ||
| 99 | + }) | ||
| 100 | + .backgroundColor($r("app.color.white")) | ||
| 101 | + } | ||
| 102 | +} | ||
| 103 | + |
sight_harmony/wdComponent/src/main/ets/components/view/LiveHorizontalCardForOneComponent.ets
0 → 100644
| 1 | +import { ContentDTO } from 'wdBean' | ||
| 2 | +import { CommonConstants } from 'wdConstant' | ||
| 3 | +import { LiveVideoTypeComponent } from './LiveVideoTypeComponent' | ||
| 4 | + | ||
| 5 | +/** | ||
| 6 | + * 视频直播横划卡16:9/1个 | ||
| 7 | + */ | ||
| 8 | +@Component | ||
| 9 | +export struct LiveHorizontalCardForOneComponent { | ||
| 10 | + @State contentDTO: ContentDTO = {} as ContentDTO | ||
| 11 | + | ||
| 12 | + build() { | ||
| 13 | + Column() { | ||
| 14 | + Stack({ alignContent: Alignment.BottomEnd }) { | ||
| 15 | + Image(this.contentDTO.coverUrl) | ||
| 16 | + .aspectRatio(16 / 9) | ||
| 17 | + .width(CommonConstants.FULL_WIDTH) | ||
| 18 | + .borderRadius(4) | ||
| 19 | + .objectFit(ImageFit.Cover) | ||
| 20 | + if (this.contentDTO.objectType === '2' | ||
| 21 | + && this.contentDTO.liveInfo | ||
| 22 | + && this.contentDTO.liveInfo.liveState === 'running') { | ||
| 23 | + LiveVideoTypeComponent({ nType: 0, name: '直播中' }) | ||
| 24 | + .padding({ | ||
| 25 | + bottom: 2, | ||
| 26 | + right: 2 | ||
| 27 | + }) | ||
| 28 | + } else if (this.contentDTO.objectType === '1' && this.contentDTO.videoInfo) { | ||
| 29 | + LiveVideoTypeComponent({ nType: 1, name: this.contentDTO.videoInfo.videoDuration ?? '00:00' }) | ||
| 30 | + .padding({ | ||
| 31 | + bottom: 2, | ||
| 32 | + right: 2 | ||
| 33 | + }) | ||
| 34 | + } | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + Text(this.contentDTO.newsTitle) | ||
| 38 | + .fontSize($r("app.float.font_size_14")) | ||
| 39 | + .fontColor($r("app.color.color_212228")) | ||
| 40 | + .fontWeight(400) | ||
| 41 | + .maxLines(1) | ||
| 42 | + .textOverflow({ overflow: TextOverflow.Ellipsis }) // 超出的部分显示省略号。 | ||
| 43 | + .textAlign(TextAlign.Start) | ||
| 44 | + .margin({ top: 8 }) | ||
| 45 | + .width(CommonConstants.FULL_WIDTH) | ||
| 46 | + } | ||
| 47 | + .padding({ | ||
| 48 | + left: 16, | ||
| 49 | + right: 16 | ||
| 50 | + }) | ||
| 51 | + } | ||
| 52 | +} |
| 1 | +/** | ||
| 2 | + * 视频直播横划卡标签 | ||
| 3 | + */ | ||
| 4 | +@Component | ||
| 5 | +export struct LiveVideoTypeComponent { | ||
| 6 | + @State nType: number = 0 | ||
| 7 | + @State name: string = '直播中' | ||
| 8 | + | ||
| 9 | + build() { | ||
| 10 | + Row() { | ||
| 11 | + Image(this.nType == 0 ? $r('app.media.videoTypeIcon') : $r('app.media.iv_card_play_yellow_flag')) | ||
| 12 | + .width(22) | ||
| 13 | + .height(18) | ||
| 14 | + .padding({ | ||
| 15 | + left: 1, | ||
| 16 | + top: 1, | ||
| 17 | + bottom: 1, | ||
| 18 | + }) | ||
| 19 | + Text(this.name) | ||
| 20 | + .fontColor($r('app.color.white')) | ||
| 21 | + .fontSize(this.nType == 0 ? $r('app.float.font_size_11') : $r('app.float.font_size_13')) | ||
| 22 | + .align(Alignment.Center) | ||
| 23 | + .padding({ | ||
| 24 | + top: 1, | ||
| 25 | + bottom: 1, | ||
| 26 | + }) | ||
| 27 | + } | ||
| 28 | + .width(60) | ||
| 29 | + .height(20) | ||
| 30 | + .backgroundColor($r('app.color.color_80000000')) | ||
| 31 | + | ||
| 32 | + } | ||
| 33 | +} | ||
| 34 | + | ||
| 35 | + |
| 1 | +import { CompDTO } from 'wdBean'; | ||
| 2 | +import { CommonConstants } from 'wdConstant' | ||
| 3 | + | ||
| 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('518条评论') | ||
| 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.76 KB
| @@ -6,6 +6,7 @@ export const enum CompStyle { | @@ -6,6 +6,7 @@ export const enum CompStyle { | ||
| 6 | Carousel_Layout_01 = 'Zh_Carousel_Layout-01', // 通用轮播卡:视频、直播、活动、专题、榜单、外链 | 6 | Carousel_Layout_01 = 'Zh_Carousel_Layout-01', // 通用轮播卡:视频、直播、活动、专题、榜单、外链 |
| 7 | Carousel_Layout_02 = 'Carousel_Layout-02', // 直播轮播卡:直播 | 7 | Carousel_Layout_02 = 'Carousel_Layout-02', // 直播轮播卡:直播 |
| 8 | Single_Row_01 = 'Zh_Single_Row-01', // 三格方形小卡(排名):专题、活动 | 8 | Single_Row_01 = 'Zh_Single_Row-01', // 三格方形小卡(排名):专题、活动 |
| 9 | + Zh_Single_Row_01 = 'Zh_Single_Row-01', // 横划卡 | ||
| 9 | Single_Row_02 = 'Zh_Single_Row-02', // 通用横划卡:视频、直播、专题 | 10 | Single_Row_02 = 'Zh_Single_Row-02', // 通用横划卡:视频、直播、专题 |
| 10 | Single_Row_03 = 'Single_Row-03', // 直播横划卡:直播 | 11 | Single_Row_03 = 'Single_Row-03', // 直播横划卡:直播 |
| 11 | Single_Row_04 = 'Single_Row-04', // 三格方形小卡:专题、活动 | 12 | Single_Row_04 = 'Single_Row-04', // 三格方形小卡:专题、活动 |
| @@ -16,6 +17,7 @@ export const enum CompStyle { | @@ -16,6 +17,7 @@ export const enum CompStyle { | ||
| 16 | Single_Column_04 = 'Single_Column-04', // 大卡横屏(带背景):视频、直播 | 17 | Single_Column_04 = 'Single_Column-04', // 大卡横屏(带背景):视频、直播 |
| 17 | Single_Column_05 = 'Single_Column-05', // 海报图卡:/ | 18 | Single_Column_05 = 'Single_Column-05', // 海报图卡:/ |
| 18 | Single_Column_06 = 'Single_Column-06', // 留言板卡:/ | 19 | Single_Column_06 = 'Single_Column-06', // 留言板卡:/ |
| 20 | + Zh_Single_Column_02 = 'Zh_Single_Column-02', // 头图卡 | ||
| 19 | Grid_Layout_01 = 'Grid_Layout-01', // 横屏宫格卡:视频、直播 | 21 | Grid_Layout_01 = 'Grid_Layout-01', // 横屏宫格卡:视频、直播 |
| 20 | Grid_Layout_02 = 'Grid_Layout-02', // 竖屏宫格卡:视频、直播、榜单 | 22 | Grid_Layout_02 = 'Grid_Layout-02', // 竖屏宫格卡:视频、直播、榜单 |
| 21 | Masonry_Layout_01 = 'Masonry_Layout-01', // 双列瀑布流/瀑布流卡:视频、直播、专题、活动 | 23 | Masonry_Layout_01 = 'Masonry_Layout-01', // 双列瀑布流/瀑布流卡:视频、直播、专题、活动 |
-
Please register or login to post a comment