wangyong_wd

新增大专题卡类型

  1 +import { CompDTO, slideShows } from 'wdBean';
  2 +import { CommonConstants } from 'wdConstant'
  3 +import { DateTimeUtils } from 'wdKit';
  4 +
  5 +/**
  6 + * 大专题卡--CompStyle: 10
  7 + */
  8 +@Component
  9 +export struct CompStyle_10 {
  10 + @State compDTO: CompDTO = {} as CompDTO
  11 +
  12 + build() {
  13 + Column(){
  14 + // 顶部标题,最多两行
  15 + if(this.compDTO.operDataList[0].newsTitle) {
  16 + Text(this.compDTO.operDataList[0].newsTitle)
  17 + .width(CommonConstants.FULL_WIDTH)
  18 + .fontSize($r('app.float.font_size_17'))
  19 + .fontWeight(600)
  20 + .maxLines(2)
  21 + .textOverflow({overflow: TextOverflow.Ellipsis})
  22 + .margin({ bottom: 19 })
  23 + }
  24 + // 大图
  25 + Image(this.compDTO.operDataList[0].coverUrl)
  26 + .width('100%')
  27 + // 专题列表--后端返回三个,
  28 + Column(){
  29 + ForEach(this.compDTO.operDataList[0].slideShows, (item:slideShows, index:number) => {
  30 + this.timelineItem(item, index)
  31 + })
  32 + }
  33 + // 底部-查看更多。根据接口返回的isMore判断是否显示查看更多
  34 + if(this.compDTO.operDataList[0].hasMore == 1) {
  35 + Row() {
  36 + Text("查看更多")
  37 + .fontSize($r("app.float.font_size_14"))
  38 + .fontColor($r("app.color.color_222222"))
  39 + .margin({ right: 1 })
  40 + Image($r("app.media.more"))
  41 + .width(14)
  42 + .height(14)
  43 + }
  44 + .backgroundColor($r('app.color.color_F5F5F5'))
  45 + .width(CommonConstants.FULL_WIDTH)
  46 + .height(40)
  47 + .borderRadius(3)
  48 + .justifyContent(FlexAlign.Center)
  49 + .margin({top: 5})
  50 + .onClick(() => {
  51 + // TODO
  52 + console.log('跳转到查看更多的页面')
  53 + })
  54 + }
  55 + }
  56 + .width(CommonConstants.FULL_WIDTH)
  57 + .padding({
  58 + top: 14,
  59 + left: 16,
  60 + right: 16,
  61 + bottom: 14
  62 + })
  63 + .backgroundColor($r("app.color.white"))
  64 + .margin({ bottom: 8 })
  65 + }
  66 +
  67 + @Builder timelineItem (item:slideShows, index:number) {
  68 + Column(){
  69 + Row() {
  70 + Column(){
  71 + Text(item.newsTitle)
  72 + .fontSize($r('app.float.font_size_17'))
  73 + .fontWeight(400)
  74 + .fontColor($r('app.color.color_222222'))
  75 + .maxLines(2)
  76 + .textOverflow({ overflow: TextOverflow.Ellipsis })
  77 + .alignSelf(ItemAlign.Center)
  78 + Row(){
  79 + // 展示发稿人
  80 + Text(item.source)
  81 + .fontSize($r('app.float.font_size_12'))
  82 + .fontColor($r('app.color.color_B0B0B0'))
  83 + .layoutWeight(1)
  84 + .textOverflow({overflow: TextOverflow.Ellipsis})
  85 + .maxLines(1)
  86 + Image($r('app.media.point'))
  87 + .width(16)
  88 + .height(16)
  89 + Text(DateTimeUtils.getCommentTime(Number.parseFloat(String(item.publishTime))))
  90 + .fontSize($r("app.float.font_size_12"))
  91 + .fontColor($r("app.color.color_B0B0B0"))
  92 + }
  93 + .margin({top: 12})
  94 + }
  95 + .layoutWeight(1)
  96 + .alignItems(HorizontalAlign.Start)
  97 +
  98 + // 右侧图片
  99 + if(item.fullColumnImgUrls[0] && item.fullColumnImgUrls[0].url) {
  100 + Image(item.fullColumnImgUrls[0].url)
  101 + .width(117)
  102 + .height(78)
  103 + .objectFit(ImageFit.Cover)
  104 + .borderRadius(4)
  105 + .margin({left: 12})
  106 + }
  107 + }
  108 + .padding({top: 10, bottom: 10})
  109 + }
  110 + }
  111 +}