yanlu1_wd

视频直播横划卡16:9

@@ -10,6 +10,8 @@ import { HorizontalStrokeCardThreeTwoRadioForMoreComponent } from './view/Horizo @@ -10,6 +10,8 @@ import { HorizontalStrokeCardThreeTwoRadioForMoreComponent } from './view/Horizo
10 import { BigPicCardComponent } from './view/BigPicCardComponent'; 10 import { BigPicCardComponent } from './view/BigPicCardComponent';
11 import { TriPicCardComponent } from './view/TriPicCardComponent'; 11 import { TriPicCardComponent } from './view/TriPicCardComponent';
12 12
  13 +import { LiveHorizontalCardComponent } from './view/LiveHorizontalCardComponent';
  14 +
13 /** 15 /**
14 * comp适配器. 16 * comp适配器.
15 */ 17 */
@@ -36,6 +38,8 @@ export struct CompParser { @@ -36,6 +38,8 @@ export struct CompParser {
36 BigPicCardComponent({ compDTO: compDTO }) 38 BigPicCardComponent({ compDTO: compDTO })
37 } else if (compDTO.compStyle === "4") { 39 } else if (compDTO.compStyle === "4") {
38 TriPicCardComponent({ compDTO: compDTO }) 40 TriPicCardComponent({ compDTO: compDTO })
  41 + } else if (compDTO.compStyle === CompStyle.Zh_Single_Row_01 && compDTO.imageScale === 2 ) {
  42 + LiveHorizontalCardComponent({ compDTO: compDTO })
39 } else { 43 } else {
40 // todo:组件未实现 / Component Not Implemented 44 // todo:组件未实现 / Component Not Implemented
41 Text(compDTO.compStyle) 45 Text(compDTO.compStyle)
  1 +// @ts-nocheck
  2 +import { LiveVideoTypeComponent } from './LiveVideoTypeComponent'
  3 +import { LiveHorizontalCardForOneComponent } from './LiveHorizontalCardForOneComponent'
  4 +import { CompDTO } from '../../repository/bean/CompDTO'
  5 +import { CommonConstants } from 'wdConstant'
  6 +import { ContentDTO } from '../../repository/bean/ContentDTO'
  7 +
  8 +@Component
  9 +export struct LiveHorizontalCardComponent {
  10 + @State compDTO: CompDTO = {} as CompDTO
  11 + build() {
  12 + Column() {
  13 + Row() {
  14 + Row() {
  15 + Image($r("app.media.redLine"))
  16 + .width(3)
  17 + .height(16)
  18 + .margin({ right: 4 })
  19 + Text(this.compDTO.objectTitle)
  20 + .fontSize($r("app.float.font_size_17"))
  21 + .fontColor($r("app.color.color_222222"))
  22 + .fontWeight(600)
  23 + }
  24 +
  25 + if (this.compDTO.operDataList.length > 10) {
  26 + Row() {
  27 + Text("更多")
  28 + .fontSize($r("app.float.font_size_14"))
  29 + .fontColor($r("app.color.color_999999"))
  30 + .margin({ right: 1 })
  31 + Image($r("app.media.more"))
  32 + .width(14)
  33 + .height(14)
  34 + }
  35 + }
  36 + }.justifyContent(FlexAlign.SpaceBetween)
  37 + .padding({ left: 16, right: 16 })
  38 + .margin({ top: 8, bottom: 8 })
  39 + .width(CommonConstants.FULL_WIDTH)
  40 + // 多个
  41 + if (this.compDTO.operDataList.length >= 2) {
  42 + List({ space: 12 }) {
  43 +
  44 + ForEach(this.compDTO.operDataList, (item: ContentDTO, index: number) => {
  45 + ListItem() {
  46 + Column() {
  47 + Stack({ alignContent: Alignment.BottomEnd }) {
  48 + Image(item.coverUrl)
  49 + .aspectRatio(16 / 9)
  50 + .width(this.compDTO.operDataList.length == 2 ? 210 : 150)
  51 + .borderRadius(4)
  52 + .objectFit(ImageFit.Cover)
  53 + if (item.objectType === '2' && item.liveInfo && item.liveInfo.liveState === 'running') {
  54 + LiveVideoTypeComponent({ nType: 0, name: '直播中' })
  55 + .padding({
  56 + bottom: 4,
  57 + right: 4
  58 + })
  59 + } else if (item.objectType === '1' && item.videoInfo) {
  60 + LiveVideoTypeComponent({ nType: 1, name: item.videoInfo.videoDuration })
  61 + .padding({
  62 + bottom: 4,
  63 + right: 4
  64 + })
  65 + }
  66 + }
  67 +
  68 + Text(item.newsTitle)
  69 + .fontSize($r("app.float.font_size_14"))
  70 + .fontColor($r("app.color.color_212228"))
  71 + .fontWeight(400)
  72 + .maxLines(2)
  73 + .textOverflow({ overflow: TextOverflow.Ellipsis }) // 超出的部分显示省略号。
  74 + .textAlign(TextAlign.Start)
  75 + .margin({ top: 8 })
  76 + .width(this.compDTO.operDataList.length == 2 ? 210 : 150)
  77 + }
  78 + }
  79 + .padding({ left: (index == 0) ? 16 : 0, right: (index == this.compDTO.operDataList.length - 1) ? 16 : 0 })
  80 + .onClick(() => {
  81 + if (item.objectType != '0') {
  82 + console.log(item.objectId)
  83 + }
  84 + })
  85 + }, item => item)
  86 +
  87 + }.listDirection(Axis.Horizontal)
  88 + .width(CommonConstants.FULL_WIDTH)
  89 + .height(this.compDTO.operDataList.length == 2 ? 180 : 136)
  90 + } else if (this.compDTO.operDataList.length) {
  91 + // 一个
  92 + LiveHorizontalCardForOneComponent({ contentDTO: this.compDTO.operDataList[0] })
  93 + }
  94 + }
  95 + .width(CommonConstants.FULL_WIDTH)
  96 + .padding({
  97 + top: 14,
  98 + })
  99 + .backgroundColor($r("app.color.white"))
  100 + }
  101 +}
  102 +
  1 +import { CommonConstants } from 'wdConstant'
  2 +import { ContentDTO } from '../../repository/bean/ContentDTO'
  3 +import { LiveVideoTypeComponent } from './LiveVideoTypeComponent'
  4 +
  5 +@Component
  6 +export struct LiveHorizontalCardForOneComponent {
  7 + @State contentDTO: ContentDTO = {} as ContentDTO
  8 +
  9 + build() {
  10 + Column() {
  11 + Stack({ alignContent: Alignment.BottomEnd }) {
  12 + Image(this.contentDTO.coverUrl)
  13 + .aspectRatio(16 / 9)
  14 + .width(CommonConstants.FULL_WIDTH)
  15 + .borderRadius(4)
  16 + .objectFit(ImageFit.Cover)
  17 + if (this.contentDTO.objectType === '2'
  18 + && this.contentDTO.liveInfo
  19 + && this.contentDTO.liveInfo.liveState === 'running') {
  20 + LiveVideoTypeComponent({ nType: 0, name: '直播中' })
  21 + .padding({
  22 + bottom: 2,
  23 + right: 2
  24 + })
  25 + } else if (this.contentDTO.objectType === '1' && this.contentDTO.videoInfo) {
  26 + LiveVideoTypeComponent({ nType: 1, name: this.contentDTO.videoInfo.videoDuration ?? '00:00' })
  27 + .padding({
  28 + bottom: 2,
  29 + right: 2
  30 + })
  31 + }
  32 + }
  33 +
  34 + Text(this.contentDTO.newsTitle)
  35 + .fontSize($r("app.float.font_size_14"))
  36 + .fontColor($r("app.color.color_212228"))
  37 + .fontWeight(400)
  38 + .maxLines(1)
  39 + .textOverflow({ overflow: TextOverflow.Ellipsis }) // 超出的部分显示省略号。
  40 + .textAlign(TextAlign.Start)
  41 + .margin({ top: 8 })
  42 + .width(CommonConstants.FULL_WIDTH)
  43 + }
  44 + .padding({
  45 + left: 16,
  46 + right: 16
  47 + })
  48 + }
  49 +}
  1 +@Component
  2 +export struct LiveVideoTypeComponent {
  3 + @State nType: number = 0
  4 + @State name: string = '直播中'
  5 +
  6 + build() {
  7 + Row() {
  8 + // @ts-ignore
  9 + Image(this.nType == 0 ? $r('app.media.videoTypeIcon') : $r('app.media.iv_card_play_yellow_flag'))
  10 + .width(22)
  11 + .height(18)
  12 + .padding({
  13 + left: 1,
  14 + top: 1,
  15 + bottom: 1,
  16 + })
  17 + Text(LiveStateName(this.name))
  18 + .fontColor($r('app.color.white'))
  19 + .fontSize(this.nType == 0 ? $r('app.float.font_size_11') : $r('app.float.font_size_13'))
  20 + .align(Alignment.Center)
  21 + .padding({
  22 + top: 1,
  23 + bottom: 1,
  24 + })
  25 + }
  26 + .width(60)
  27 + .height(20)
  28 + .backgroundColor($r('app.color.color_80000000'))
  29 +
  30 + }
  31 +}
  32 +
  33 +
  34 +function LiveStateName(name: string): string {
  35 + if (name === 'wait') {
  36 + return '待开播'
  37 + }else if (name === 'running') {
  38 + return '直播中'
  39 + }else if (name === 'end') {
  40 + return '已结束'
  41 + }else if (name === 'cancel') {
  42 + return '已取消'
  43 + }else if (name === 'paused') {
  44 + return '暂停'
  45 + }
  46 + return name
  47 +}
@@ -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'; 1 import { FullColumnImgUrlsDTO } from './FullColumnImgUrlsDTO';
  2 +import { LiveInfo } from './LiveInfo'
  3 +import { VideoInfo } from './VideoInfo'
  4 +
2 export interface ContentDTO { 5 export interface ContentDTO {
3 cityCode: string; 6 cityCode: string;
4 coverSize: string; 7 coverSize: string;
@@ -43,4 +46,6 @@ export interface ContentDTO { @@ -43,4 +46,6 @@ export interface ContentDTO {
43 newsTitle:string; 46 newsTitle:string;
44 publishTime:string; 47 publishTime:string;
45 fullColumnImgUrls:FullColumnImgUrlsDTO[]; 48 fullColumnImgUrls:FullColumnImgUrlsDTO[];
  49 + liveInfo?: LiveInfo; // 直播新闻信息【BFF聚合】
  50 + videoInfo?: VideoInfo; // 视频新闻信息【BFF聚合】,视频非原片+清晰度最高的
46 } 51 }
  1 +export interface LiveInfo {
  2 + liveState: string; // 直播新闻-直播状态
  3 + liveUrl: string; //【暂时未使用,默认取第一个】直播新闻-直播地址
  4 + liveStartTime: string;
  5 + liveLandscape: string;
  6 + vrType: number; // 【迭代三】是否Vr,0:否,1:是
  7 + replayUri: string; // 直播回放地址【判断是否有回放;BFF: 允许展示回放+存在回放地址;默认取第一条】
  8 +}
  1 +export interface VideoInfo {
  2 + videoUrl: string; //视频播放地址
  3 + videoDuration: string; // 视频时长
  4 + videoLandscape: string; // 1横屏 2竖屏
  5 + firstFrameImageUri: string; // 首帧图;【视频内容,contentPictures中】
  6 +}
@@ -43,6 +43,10 @@ @@ -43,6 +43,10 @@
43 { 43 {
44 "name": "color_4d000000", 44 "name": "color_4d000000",
45 "value": "#4d000000" 45 "value": "#4d000000"
  46 + },
  47 + {
  48 + "name": "color_80000000",
  49 + "value": "#80000000"
46 } 50 }
47 ] 51 ]
48 } 52 }
@@ -21,4 +21,5 @@ export const enum CompStyle { @@ -21,4 +21,5 @@ export const enum CompStyle {
21 Masonry_Layout_01 = 'Masonry_Layout-01', // 双列瀑布流/瀑布流卡:视频、直播、专题、活动 21 Masonry_Layout_01 = 'Masonry_Layout-01', // 双列瀑布流/瀑布流卡:视频、直播、专题、活动
22 Title_Abbr_01 = 'Title_Abbr_01', // 标题缩略 22 Title_Abbr_01 = 'Title_Abbr_01', // 标题缩略
23 Title_All_01 = 'Title_All_01', // 全标题 23 Title_All_01 = 'Title_All_01', // 全标题
  24 + Zh_Single_Row_01 = 'Zh_Single_Row-01', // 横划卡
24 } 25 }