RmhTitle.ets 2 KB
/**
 * 这里是人民号动态中的顶部信息:人民号logo,名字,描述,关注等
 */
import { RmhInfoDTO } from 'wdBean'
import { CommonConstants } from 'wdConstant/Index';
import { DateTimeUtils } from 'wdKit';

@Component
export struct RmhTitle {
  @Prop rmhInfo: RmhInfoDTO
  @Prop publishTime: string | undefined

  build() {
    Flex() {
      Stack() {
        Image(this.rmhInfo.rmhHeadUrl)
          .width(36)
          .height(36).borderRadius(50)
        Image(this.rmhInfo.authIcon)
          .width(14)
          .height(14)
          .borderRadius(50)
      }
      .margin({ right: 8 })
      .alignContent(Alignment.BottomEnd)
      .flexShrink(0)

      Column() {
        Text(this.rmhInfo.rmhName)
          .fontSize($r('app.float.font_size_13'))
          .fontColor($r('app.color.color_222222'))
          .fontWeight(600)
          .alignSelf(ItemAlign.Start)
        Row() {
          if (this.publishTime) {
            Text(DateTimeUtils.getCommentTime(Number.parseFloat(this.publishTime)))
              .fontSize($r("app.float.font_size_12"))
              .fontColor($r("app.color.color_B0B0B0"))
            Image($r('app.media.point'))
              .width(16)
              .height(16)
          }
          Text(this.rmhInfo.rmhDesc)
            .fontSize($r("app.float.font_size_12"))
            .fontColor($r("app.color.color_B0B0B0"))
            .maxLines(1)
            .alignSelf(ItemAlign.Start)
            .textOverflow({ overflow: TextOverflow.Ellipsis })
        }
      }

      Blank()
      if (this.rmhInfo.cnIsAttention) {
        Row() {
          Image($r('app.media.rmh_follow'))
            .width(16)
            .height(16)
          Text('关注')
            .fontSize($r('app.float.font_size_13'))
            .fontColor($r('app.color.color_ED2800'))
        }
        .flexShrink(0)
        .alignSelf(ItemAlign.Center)
        .onClick(() => {
          // TODO 调用关注接口
        })
      }
    }
    .width(CommonConstants.FULL_WIDTH)
    .margin({ bottom: 10 })
  }
}