Card2Component.ets 2.6 KB
//全标题 "appStyle":"2",
import { ContentDTO } from 'wdBean';
import { CommonConstants } from 'wdConstant/Index';
import { ProcessUtils } from '../../utils/ProcessUtils';
import { CardMediaInfo } from '../cardCommon/CardMediaInfo'
import { CardSourceInfo } from '../cardCommon/CardSourceInfo'
const TAG: string = 'Card2Component';

/**
 * 大图卡:
 * compstyle:2
 * 卡片结构:上下结构
 * 卡片宽度:充满父窗口
 * 卡片高度,仅包含横板图片:图片高度由图片的宽度及宽高比决定,图片宽度占父窗口'100%',宽高比为16:9:
 */
@Component
export struct Card2Component {
  @State contentDTO: ContentDTO = {
    // appStyle: '2',
    // objectType: '1',
    // coverUrl:
    // 'https://rmrbcmsonline.peopleapp.com/upload/image/202404/202404141115457926.png?x-oss-process=image/resize,m_fill,h_450,w_800/quality,q_90',
    // newsTitle: '又见花开!新疆伊犁花海延绵清新怡人',
    // publishTime: '1713067227000',
    // source: '荔枝新闻',
    // videoInfo: {
    //   videoDuration: 25,
    //   videoLandscape: 1,
    //   videoUrl:
    //   'https://rmrbcmsonline.peopleapp.com/upload/video/mp4/202404/1713064515901314d148763996.mp4'
    // }
  } as ContentDTO;

  build() {
    Column() {
      Column() {
        //新闻标题
        Text(this.contentDTO.newsTitle)
          .fontSize($r('app.float.font_size_17'))
          .fontColor($r('app.color.color_222222'))
          .maxLines(3)
          .textOverflow({ overflow: TextOverflow.Ellipsis })// 超出的部分显示省略号。
          .align(Alignment.Start)
        //大图
        Stack() {
          Image(this.contentDTO.coverUrl)
            .width(CommonConstants.FULL_WIDTH)
            .aspectRatio(16 / 9)
            .borderRadius($r('app.float.image_border_radius'))
          //播放状态+时长
          CardMediaInfo({
            contentDTO: this.contentDTO
          })
        }
        .alignContent(Alignment.BottomEnd)
        .margin({ top: 8 })
      }
      .width(CommonConstants.FULL_WIDTH)
      .alignItems(HorizontalAlign.Start)

      //bottom
      // 评论等信息
      CardSourceInfo({ contentDTO: this.contentDTO })
    }
    .width(CommonConstants.FULL_WIDTH)
    .padding({
      left: $r('app.float.card_comp_pagePadding_lf'),
      right: $r('app.float.card_comp_pagePadding_lf'),
      top: $r('app.float.card_comp_pagePadding_tb'),
      bottom: $r('app.float.card_comp_pagePadding_tb')
    })
    .onClick((event: ClickEvent) => {
      ProcessUtils.processPage(this.contentDTO)
    })
  }
}

@Extend(Text)
function bottomTextStyle() {
  .fontSize(12)
  .fontColor('#B0B0B0')
}