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

interface RmhInfo extends RmhInfoDTO {
  isSelected: boolean;
  headPhotoUrl: string;
  introduction: string;
  userName: string;
  publishTime: string;
}

@Entry
@Component
export struct rmhTitle {
  // TODO 这里需要传入rmh信息及是否显示关注,是否已关注
  @State isAttentionShow: Boolean = true
  @State rmhInfo: RmhInfo = {
    authIcon: "https://cdnjdphoto.aikan.pdnews.cn/creator-category/icon/auth/blue.png",
    authTitle: "四川农业大学",
    headPhotoUrl: "https://cdnjdphoto.aikan.pdnews.cn//upload/ueditor/image/20221208/a_785146000057561088.png?x-oss-process=image/resize,l_100/auto-orient,1/quality,q_90/format,jpg",
    introduction: "四川农业大学",
    userId: "554708665557894",
    userName: "四川农业大学",
    userType: "2",
    publishTime: '1712912775606'
  } as RmhInfo

  build() {
    Row() {
      Stack() {
        Image(this.rmhInfo.headPhotoUrl)
          .width(36)
          .height(36).borderRadius(50)
        Image(this.rmhInfo.authIcon)
          .width(14)
          .height(14)
          .borderRadius(50)
      }
      .margin({ right: 8 })
      .alignContent(Alignment.BottomEnd)
      Column() {
        Text(this.rmhInfo.userName)
          .fontSize($r('app.float.font_size_13'))
          .fontColor($r('app.color.color_222222'))
          .fontWeight(600)
          .alignSelf(ItemAlign.Start)
        Row() {
          Text(DateTimeUtils.formatDate(Number.parseFloat(this.rmhInfo.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.introduction)
            .fontSize($r("app.float.font_size_12"))
            .fontColor($r("app.color.color_B0B0B0"))
            .margin({ left: 6 })
            .maxLines(1)
            .textOverflow({overflow: TextOverflow.Ellipsis})
        }
      }
      .align(Alignment.Start)
      Blank()
      if(this.isAttentionShow) {
        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'))
        }
      }
    }
    .width(CommonConstants.FULL_WIDTH)
    .margin({bottom: 10})
  }
}