Card4Component.ets 2.27 KB
//全标题 "compStyle":"4",
import { DateTimeUtils } from 'wdKit';
import { ContentDTO } from '../../repository/bean/ContentDTO';

const TAG: string = 'TriPicCardComponent';

/**
 * 三图卡:
 * compstyle:4
 * 卡片结构:上下结构
 * 卡片宽度:充满父窗口
 * 卡片高度,仅包含横板图片:图片高度由图片的宽度及宽高比决定,图片宽度占父窗口'100%',宽高比为16:9:
 */
@Entry
@Component
export struct Card4Component {
  @State contentDTO: ContentDTO = {} as ContentDTO;

  build() {
    Column() {


      //body
      Column() {
        //新闻标题
        Text(this.contentDTO.newsTitle)
          .fontSize(17)
          .fontColor('#222222')
          .maxLines(3)
          .textOverflow({ overflow: TextOverflow.Ellipsis }) // 超出的部分显示省略号。
        //三图
        Row() {
          Image(this.contentDTO.fullColumnImgUrls[0]?.url)
            .width('32%')
            .aspectRatio(113 / 75)
            .borderRadius({ topLeft: 4, bottomLeft: 4 })

          Image(this.contentDTO.fullColumnImgUrls[1]?.url)
            .width('32%')
            .aspectRatio(113 / 75)

          Image(this.contentDTO.fullColumnImgUrls[2]?.url)
            .width('32%')
            .aspectRatio(113 / 75)
            .borderRadius({ topRight: 4, bottomRight: 4 })

        }
        .justifyContent(FlexAlign.SpaceBetween)
        .width('100%')
        .margin({ top: 8 })
        .borderRadius(8)

      }
      .width('100%')
      .justifyContent(FlexAlign.Start)
      .alignItems(HorizontalAlign.Start)
      .padding({ top: 14 })


      //bottom
      Row() {
        Text(this.contentDTO.source)
          .bottomTextStyle()
        //间隔点
        Image($r('app.media.point'))
          .width(12)
          .height(12)

        Text(DateTimeUtils.getCommentTime(Number.parseFloat(this.contentDTO.publishTime)))
          .bottomTextStyle()
        Text(' ')

        Text('518条评论')
          .bottomTextStyle()

      }
      .width('100%')

      .justifyContent(FlexAlign.Start)
      // .padding({bottom:14})
      .margin({ top: 8 })
      .padding({ bottom: 14 })

    }
    .width('100%')
    .padding({ top: 8, left: 16, right: 16 })

  }
}


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