Showing
5 changed files
with
55 additions
and
28 deletions
| @@ -2,7 +2,7 @@ export interface VideoInfoDTO { | @@ -2,7 +2,7 @@ export interface VideoInfoDTO { | ||
| 2 | clarity: number; | 2 | clarity: number; |
| 3 | resolutionHeight: number; | 3 | resolutionHeight: number; |
| 4 | resolutionWidth: number; | 4 | resolutionWidth: number; |
| 5 | - videoDuration: string; // 视频时长 | 5 | + videoDuration: number; // 视频时长 |
| 6 | videoLandScape: number; // 1横屏 2竖屏 | 6 | videoLandScape: number; // 1横屏 2竖屏 |
| 7 | videoType: number; | 7 | videoType: number; |
| 8 | videoUrl: string; //视频播放地址 | 8 | videoUrl: string; //视频播放地址 |
| @@ -59,7 +59,7 @@ export struct LiveHorizontalCardComponent { | @@ -59,7 +59,7 @@ export struct LiveHorizontalCardComponent { | ||
| 59 | right: 4 | 59 | right: 4 |
| 60 | }) | 60 | }) |
| 61 | } else if (item.objectType === '1' && item.videoInfo) { | 61 | } else if (item.objectType === '1' && item.videoInfo) { |
| 62 | - LiveVideoTypeComponent({ nType: 1, name: item.videoInfo.videoDuration }) | 62 | + LiveVideoTypeComponent({ nType: 1, name: item.videoInfo.videoDuration + "" }) |
| 63 | .padding({ | 63 | .padding({ |
| 64 | bottom: 4, | 64 | bottom: 4, |
| 65 | right: 4 | 65 | right: 4 |
| @@ -27,7 +27,7 @@ export struct LiveHorizontalCardForOneComponent { | @@ -27,7 +27,7 @@ export struct LiveHorizontalCardForOneComponent { | ||
| 27 | right: 2 | 27 | right: 2 |
| 28 | }) | 28 | }) |
| 29 | } else if (this.contentDTO.objectType === '1' && this.contentDTO.videoInfo) { | 29 | } else if (this.contentDTO.objectType === '1' && this.contentDTO.videoInfo) { |
| 30 | - LiveVideoTypeComponent({ nType: 1, name: this.contentDTO.videoInfo.videoDuration ?? '00:00' }) | 30 | + LiveVideoTypeComponent({ nType: 1, name: this.contentDTO.videoInfo.videoDuration + "" ?? '00:00' }) |
| 31 | .padding({ | 31 | .padding({ |
| 32 | bottom: 2, | 32 | bottom: 2, |
| 33 | right: 2 | 33 | right: 2 |
| 1 | import { Action, CompDTO, ContentDTO, Params } from 'wdBean'; | 1 | import { Action, CompDTO, ContentDTO, Params } from 'wdBean'; |
| 2 | import { CompStyle } from 'wdConstant'; | 2 | import { CompStyle } from 'wdConstant'; |
| 3 | -import { Logger } from 'wdKit'; | 3 | +import { Logger, DateTimeUtils } from 'wdKit'; |
| 4 | import { WDRouterRule } from 'wdRouter'; | 4 | import { WDRouterRule } from 'wdRouter'; |
| 5 | 5 | ||
| 6 | -const TAG = 'SingleImageCardApp2Component'; | 6 | +const TAG = 'SingleImageCardAppComponent'; |
| 7 | const FULL_PARENT: string = '100%'; | 7 | const FULL_PARENT: string = '100%'; |
| 8 | 8 | ||
| 9 | /** | 9 | /** |
| @@ -30,7 +30,7 @@ export struct SingleImageCardAppComponent { | @@ -30,7 +30,7 @@ export struct SingleImageCardAppComponent { | ||
| 30 | // clarity: 1, | 30 | // clarity: 1, |
| 31 | resolutionHeight: 20, | 31 | resolutionHeight: 20, |
| 32 | resolutionWidth: 20, | 32 | resolutionWidth: 20, |
| 33 | - videoDuration: '229', | 33 | + videoDuration: 229, |
| 34 | videoLandScape: 1, | 34 | videoLandScape: 1, |
| 35 | videoType: 1, | 35 | videoType: 1, |
| 36 | videoUrl: "https://cdnjdout.aikan.pdnews.cn/zhbj-20240116/vod/content/output/c72f4170db2c4d34befa453f60d39a69_opt.mp4", | 36 | videoUrl: "https://cdnjdout.aikan.pdnews.cn/zhbj-20240116/vod/content/output/c72f4170db2c4d34befa453f60d39a69_opt.mp4", |
| @@ -58,18 +58,26 @@ export struct SingleImageCardAppComponent { | @@ -58,18 +58,26 @@ export struct SingleImageCardAppComponent { | ||
| 58 | .borderRadius(5) | 58 | .borderRadius(5) |
| 59 | .aspectRatio(16 / 9) | 59 | .aspectRatio(16 / 9) |
| 60 | .padding({ top: 10 }) | 60 | .padding({ top: 10 }) |
| 61 | - if(this.compDTO.operDataList[0].videoInfo) { | ||
| 62 | - Stack() { | ||
| 63 | - Text(this.compDTO.operDataList[0].videoInfo.videoDuration) | ||
| 64 | - .backgroundColor(Color.Black) | ||
| 65 | - .opacity(0.6) | ||
| 66 | - .width(FULL_PARENT) | ||
| 67 | - .padding({left:40}) | 61 | + if (this.compDTO.operDataList[0].videoInfo) { |
| 62 | + Row() { | ||
| 68 | Image($r('app.media.iv_card_play_yellow_flag')) | 63 | Image($r('app.media.iv_card_play_yellow_flag')) |
| 69 | - .fitOriginalSize(true) | ||
| 70 | - }.width(FULL_PARENT) | 64 | + .width(22) |
| 65 | + .height(18) | ||
| 66 | + Text(DateTimeUtils.getFormattedDuration(this.compDTO.operDataList[0].videoInfo.videoDuration * 1000)) | ||
| 67 | + .fontSize($r('app.float.font_size_13')) | ||
| 68 | + .fontWeight(400) | ||
| 69 | + .fontColor($r('app.color.color_fff')) | ||
| 71 | } | 70 | } |
| 71 | + .alignItems(VerticalAlign.Bottom) | ||
| 72 | + .height(18) | ||
| 73 | + .padding({ right: 4 }) | ||
| 74 | + .margin({ | ||
| 75 | + right: 4, | ||
| 76 | + bottom: 4 | ||
| 77 | + }) | ||
| 78 | + .backgroundColor($r('app.color.color_4d000000')) | ||
| 72 | } | 79 | } |
| 80 | + }.alignContent(Alignment.BottomEnd) | ||
| 73 | } | 81 | } |
| 74 | if (this.compDTO.operDataList[0].newsSummary) { | 82 | if (this.compDTO.operDataList[0].newsSummary) { |
| 75 | Text(this.compDTO.operDataList[0].newsSummary) | 83 | Text(this.compDTO.operDataList[0].newsSummary) |
| 1 | import { Action, CompDTO, Params } from 'wdBean'; | 1 | import { Action, CompDTO, Params } from 'wdBean'; |
| 2 | import { ExtraDTO } from 'wdBean/src/main/ets/bean/component/extra/ExtraDTO'; | 2 | import { ExtraDTO } from 'wdBean/src/main/ets/bean/component/extra/ExtraDTO'; |
| 3 | +import { Logger, DateTimeUtils } from 'wdKit'; | ||
| 3 | import { WDRouterRule } from 'wdRouter'; | 4 | import { WDRouterRule } from 'wdRouter'; |
| 4 | import { ProcessUtils } from '../../utils/ProcessUtils'; | 5 | import { ProcessUtils } from '../../utils/ProcessUtils'; |
| 5 | 6 | ||
| @@ -16,15 +17,10 @@ const FULL_PARENT: string = '100%'; | @@ -16,15 +17,10 @@ const FULL_PARENT: string = '100%'; | ||
| 16 | @Component | 17 | @Component |
| 17 | export struct SingleImageCardComponent { | 18 | export struct SingleImageCardComponent { |
| 18 | @State compDTO: CompDTO = {} as CompDTO | 19 | @State compDTO: CompDTO = {} as CompDTO |
| 19 | - @State titleNumber: number = 3 //标题行数 | ||
| 20 | 20 | ||
| 21 | aboutToAppear() { | 21 | aboutToAppear() { |
| 22 | - // Logger.debug(TAG + "" + JSON.stringify(this.compDTO.operDataList)); | ||
| 23 | - if (this.compDTO.operDataList[0].newsTitle.length > 26) { | ||
| 24 | - this.titleNumber = 3; | ||
| 25 | - } else { | ||
| 26 | - this.titleNumber = 2; | ||
| 27 | - } | 22 | + //Logger.debug(TAG + "" + JSON.stringify(this.compDTO.operDataList)); |
| 23 | + | ||
| 28 | } | 24 | } |
| 29 | 25 | ||
| 30 | build() { | 26 | build() { |
| @@ -33,12 +29,12 @@ export struct SingleImageCardComponent { | @@ -33,12 +29,12 @@ export struct SingleImageCardComponent { | ||
| 33 | Text(this.compDTO.operDataList[0].newsTitle) | 29 | Text(this.compDTO.operDataList[0].newsTitle) |
| 34 | .fontSize(16) | 30 | .fontSize(16) |
| 35 | .fontWeight(FontWeight.Normal) | 31 | .fontWeight(FontWeight.Normal) |
| 36 | - .maxLines(this.titleNumber)// | 32 | + .maxLines(3)// |
| 37 | .alignSelf(ItemAlign.Start) | 33 | .alignSelf(ItemAlign.Start) |
| 38 | .textOverflow({ overflow: TextOverflow.Ellipsis })// 超出的部分显示省略号。 | 34 | .textOverflow({ overflow: TextOverflow.Ellipsis })// 超出的部分显示省略号。 |
| 39 | - .height(this.titleNumber === 3 ? "80%" : '65%') | 35 | + .height("80%") |
| 40 | Row() { | 36 | Row() { |
| 41 | - Text('人民日报') | 37 | + Text(this.compDTO.operDataList[0].source ? this.compDTO.operDataList[0].source : '人民日报') |
| 42 | .height(40) | 38 | .height(40) |
| 43 | .fontSize(14) | 39 | .fontSize(14) |
| 44 | .fontColor(Color.Gray) | 40 | .fontColor(Color.Gray) |
| @@ -57,7 +53,7 @@ export struct SingleImageCardComponent { | @@ -57,7 +53,7 @@ export struct SingleImageCardComponent { | ||
| 57 | left: 10 | 53 | left: 10 |
| 58 | }) | 54 | }) |
| 59 | }.alignSelf(ItemAlign.Start) | 55 | }.alignSelf(ItemAlign.Start) |
| 60 | - .height(this.titleNumber === 3 ? "20%" : '35%') | 56 | + .height("20%") |
| 61 | .justifyContent(FlexAlign.SpaceBetween) | 57 | .justifyContent(FlexAlign.SpaceBetween) |
| 62 | } | 58 | } |
| 63 | .alignItems(HorizontalAlign.Start) | 59 | .alignItems(HorizontalAlign.Start) |
| @@ -65,10 +61,33 @@ export struct SingleImageCardComponent { | @@ -65,10 +61,33 @@ export struct SingleImageCardComponent { | ||
| 65 | .width('58%') | 61 | .width('58%') |
| 66 | 62 | ||
| 67 | Blank(16) | 63 | Blank(16) |
| 64 | + if (this.compDTO.operDataList[0].coverUrl) { | ||
| 65 | + Stack() { | ||
| 68 | Image(this.compDTO.operDataList[0].coverUrl) | 66 | Image(this.compDTO.operDataList[0].coverUrl) |
| 69 | - .height('78vp') | ||
| 70 | .borderRadius(5) | 67 | .borderRadius(5) |
| 71 | .aspectRatio(3 / 2) | 68 | .aspectRatio(3 / 2) |
| 69 | + .height('78vp') | ||
| 70 | + if (this.compDTO.operDataList[0].videoInfo) { | ||
| 71 | + Row() { | ||
| 72 | + Image($r('app.media.iv_card_play_yellow_flag')) | ||
| 73 | + .width(22) | ||
| 74 | + .height(18) | ||
| 75 | + Text(DateTimeUtils.getFormattedDuration(this.compDTO.operDataList[0].videoInfo.videoDuration * 1000)) | ||
| 76 | + .fontSize($r('app.float.font_size_13')) | ||
| 77 | + .fontWeight(400) | ||
| 78 | + .fontColor($r('app.color.color_fff')) | ||
| 79 | + } | ||
| 80 | + .alignItems(VerticalAlign.Bottom) | ||
| 81 | + .height(18) | ||
| 82 | + .padding({ right: 4 }) | ||
| 83 | + .margin({ | ||
| 84 | + right: 4, | ||
| 85 | + bottom: 4 | ||
| 86 | + }) | ||
| 87 | + .backgroundColor($r('app.color.color_4d000000')) | ||
| 88 | + } | ||
| 89 | + }.alignContent(Alignment.BottomEnd) | ||
| 90 | + } | ||
| 72 | } | 91 | } |
| 73 | .onClick((event: ClickEvent) => { | 92 | .onClick((event: ClickEvent) => { |
| 74 | ProcessUtils.processPage(this.compDTO?.operDataList[0]) | 93 | ProcessUtils.processPage(this.compDTO?.operDataList[0]) |
| @@ -76,7 +95,7 @@ export struct SingleImageCardComponent { | @@ -76,7 +95,7 @@ export struct SingleImageCardComponent { | ||
| 76 | .padding( | 95 | .padding( |
| 77 | { top: 16, bottom: 16, left: 14, right: 14 }) | 96 | { top: 16, bottom: 16, left: 14, right: 14 }) |
| 78 | .width(FULL_PARENT) | 97 | .width(FULL_PARENT) |
| 79 | - .height(this.titleNumber === 3 ? '127vp' : '106vp') | 98 | + .height('127vp') |
| 80 | .justifyContent(FlexAlign.SpaceBetween) | 99 | .justifyContent(FlexAlign.SpaceBetween) |
| 81 | } | 100 | } |
| 82 | } | 101 | } |
-
Please register or login to post a comment