PeopleShipRecommendHeadComponent.ets 2.33 KB
import { RmhRecommendDTO } from 'wdBean';
import { ToastUtils } from 'wdKit/Index';

@Component
export struct PeopleShipRecommendHeadComponent {
  @State isSelected: boolean = true
  @Consume rmhSelectedList: string[]
  @State rmhInfo: RmhRecommendDTO = {} as RmhRecommendDTO
  clickCallback: () => void = () => {
  }
  build() {
    Column(){
      Stack({ alignContent: Alignment.BottomEnd }) {
        Image(this.rmhInfo.headPhotoUrl.length > 0 ? this.rmhInfo.headPhotoUrl : $r('app.media.WDAccountOwnerHedaerDefaultIcon'))
          .width('44vp')
          .height('44vp')
          .borderRadius('22vp')
          .objectFit(ImageFit.Cover)
          .border({
            width: 0.5,
            color: '#0D000000',  // 5% 透明度的黑色
            style: BorderStyle.Solid
          })

        Image( this.isSelectedRmhInfo() ? $r('app.media.rmh_selected') :  $r('app.media.rmh_unselected') )
          .width('18vp')
          .height('18vp')
          .objectFit(ImageFit.Cover)
          .margin({
            right: '-3vp'
          }).onClick(()=>{
            this.clickCallback()
        })
      }.margin({ top: 4, bottom: 8 })

      Row() {
        Text(this.rmhInfo.userName)
          .fontColor($r('app.color.color_222222'))
          .fontSize($r('app.float.vp_14'))
          .fontWeight(600)
          .maxLines(1)
          .textOverflow({overflow: TextOverflow.Ellipsis})
        if (this.rmhInfo.authIcon) {
          Image(this.rmhInfo.authIcon)
            .width('12vp')
            .height('12vp')
            .borderRadius(6)
            .objectFit(ImageFit.Cover)
            .margin({
              left: '2vp'
            })
        }
      }
      .alignItems(VerticalAlign.Center)
      .justifyContent(FlexAlign.Center)

      Row() {
        Text(this.rmhInfo.introduction)
          .fontColor($r('app.color.color_B0B0B0'))
          .fontSize(12)
          .margin({ top: 4, bottom: 14 })
          .textOverflow({overflow: TextOverflow.Ellipsis})
          .maxLines(2)
          .height(34)
          .lineHeight(17)
          .textAlign(TextAlign.Center)
      }

    }
    .width('100%')
    .height('110vp')

  }

  private isSelectedRmhInfo() {
    if (this.rmhSelectedList.length > 0 && this.rmhInfo ) {
      if (this.rmhSelectedList.indexOf(this.rmhInfo.creatorId) != -1) {
        return true
      }
    }
    return false
  }
}