TitleAllComponent.ets 2.08 KB
//全标题 "compStyle":"3",
import { CommonConstants } from 'wdConstant'
import { CompDTO } from '../../repository/bean/CompDTO'
import { DateTimeUtils } from 'wdKit/src/main/ets/utils/DateTimeUtils'
import { Logger } from 'wdKit/src/main/ets/utils/Logger'

@Component
export struct TitleAllComponent {
  @State compDTO: CompDTO = {} as CompDTO
  @State @Watch('isPoint') source: boolean = false; //来源是否为空 publishTime 字段是否为空
  @State isPo: number = Visibility.Visible;

  isPoint() {
    if (this.source) {
      this.isPo = Visibility.None
    }
  }

  build() {
    Column() {
      Text(this.compDTO.operDataList[0].newsTitle)
        .fontSize($r("app.float.font_size_17"))
        .fontColor($r("app.color.color_222222"))
        .width(CommonConstants.FULL_WIDTH)
        .fontWeight(400)
      Row() {
        Text(this.compDTO.operDataList[0].corner)
          .fontSize($r("app.float.font_size_12"))
          .fontColor($r("app.color.color_ED2800"))
          .fontWeight(400)
        Text(this.compDTO.operDataList[0].source)
          .fontSize($r("app.float.font_size_12"))
          .fontColor($r("app.color.color_B0B0B0"))
          .margin({ left: 6 })
          .fontWeight(400)
        Image($r("app.media.point"))
          .width(16)
          .height(16)
          .visibility(this.isPo)

        Text(DateTimeUtils.getCommentTime(Number.parseFloat(this.compDTO.operDataList[0].publishTime)))
          .fontSize($r("app.float.font_size_12"))
          .fontColor($r("app.color.color_B0B0B0"))
          .fontWeight(400)

      }.width(CommonConstants.FULL_WIDTH)
      .justifyContent(FlexAlign.Start)
      .margin({ top: 8 })

    }.width("100%")
    .padding({
      top: 14,
      left: 16,
      right: 16,
      bottom: 14
    })
    .backgroundColor($r("app.color.white"))
    .margin({ bottom: 8 })
  }

  aboutToAppear() {
    // Logger.info("ssx",JSON.stringify(this.compDTO.operDataList[0]))
    if (this.compDTO.operDataList[0].source == "") {
      this.source = true;
    }
    if (this.compDTO.operDataList[0].publishTime == "") {
      this.source = true;
    }

  }
}