TabLiveItemComponent.ets 3.1 KB
import { LiveRoomItemBean, PhotoListBean } from 'wdBean/Index'
import { DateTimeUtils, StringUtils } from 'wdKit/Index'

@Component
export struct TabLiveItemComponent {
  item: LiveRoomItemBean = {} as LiveRoomItemBean
  photoList: PhotoListBean[] = []

  aboutToAppear(): void {

  }

  build() {
    Column() {
      Row() {
        Image(StringUtils.isEmpty(this.item.senderUserAvatarUrl) ? $r('app.media.default_head') : this.item.senderUserAvatarUrl)
          .borderRadius(90)
          .width(24)
          .height(24)
        Text(this.item.senderUserName)
          .maxLines(1)
          .textOverflow({ overflow: TextOverflow.Ellipsis })
          .fontSize('14fp')
          .fontWeight(400)
          .fontColor('#222222')
          .margin({ left: 8 })
        Text('主持人')
          .maxLines(1)
          .textOverflow({ overflow: TextOverflow.Ellipsis })
          .fontSize('11fp')
          .fontWeight(400)
          .fontColor('#968562')
          .backgroundColor('#F1EFEB')
          .padding({
            left: 4,
            top: 1,
            right: 4,
            bottom: 1
          })
          .borderRadius(2)
          .margin({ left: 8 })
          .visibility('host' == this.item.role ? Visibility.Visible : Visibility.None)
        Text(DateTimeUtils.getCommentTime(new Date(this.item.time).getTime()))
          .maxLines(1)
          .textOverflow({ overflow: TextOverflow.Ellipsis })
          .fontSize('12fp')
          .fontWeight(400)
          .fontColor('#999999')
          .margin({ left: 8 })
          .visibility(StringUtils.isNotEmpty(this.item.time) ? Visibility.Visible : Visibility.None)
        Blank()
        Text('置顶')
          .maxLines(1)
          .textOverflow({ overflow: TextOverflow.Ellipsis })
          .fontSize('11fp')
          .fontWeight(400)
          .fontColor('#ED2800')
          .backgroundColor('#F1EFEB')
          .padding({
            left: 4,
            top: 1,
            right: 4,
            bottom: 1
          })
          .borderRadius(2)
          .margin({ left: 8 })
          .visibility(1 == this.item.isTop ? Visibility.Visible : Visibility.None)
      }
      .width('100%')

      Text(this.item.text)
        .fontSize('14fp')
        .fontWeight(400)
        .fontColor('#222222')
        .margin({
          left: 32,
          top: 6
        })
        .width('100%')
        .textAlign(TextAlign.Start)
      List() {
        ForEach(this.item.pictureUrls, (item: string, index: number) => {
          ListItem() {
            Image(item)
              .height(174)
              .width(310)
              .aspectRatio(310 / 174)
              .objectFit(ImageFit.Auto)
              .borderRadius(4)
          }.onClick(() => {
            for (let item of this.item.pictureUrls) {
              this.photoList.push({
                width: 0,
                height: 0,
                picPath: item,
                picDesc: ''
              })
            }
          })
        })
      }.margin({
        left: 32,
        top: 8
      })
    }.margin({
      left: 15,
      top: 15,
      right: 15
    })
  }

  aboutToDisappear(): void {

  }
}