SelectedColumns.ets 2.45 KB
import { CompInfoBean, CompDTO } from  'wdBean'
import { DateTimeUtils } from 'wdKit/Index'
import { CommonConstants } from 'wdConstant';
import { ProcessUtils } from 'wdRouter';
/**
 * 精选栏目
 */
@Component
export  struct SelectedColumns {
  @Prop columnsCompInfoBean: CompInfoBean = {} as CompInfoBean // 精选栏目组件信息
  @Prop columnsCompTitle: string = ''
  build() {
    Column(){
      Text(this.columnsCompTitle)
        .fontSize($r('app.float.selected_text_size'))
        .fontColor($r('app.color.color_222222'))
        .fontWeight(500)
        .width(CommonConstants.FULL_WIDTH)
      ForEach(this.columnsCompInfoBean.compList, (item: CompDTO) => {
        this.SelectedColumnsItem(item)
      })

    }
    .padding({left: 16,top: 12, right: 16})
    .backgroundColor($r('app.color.white'))
  }

  @Builder
  SelectedColumnsItem(item: CompDTO) {
    Row() {
      Image(item.operDataList[0].coverUrl)
        .height(53)
        .width(80)
        .objectFit(ImageFit.Cover)
        .margin({right: 12})
      Column({space: 4}){
        Text(item.operDataList[0].newsTitle)
          .fontSize($r('app.float.font_size_16'))
          .fontColor($r('app.color.color_222222'))
          .width(CommonConstants.FULL_WIDTH)
          .maxLines(1)
          .textOverflow({overflow: TextOverflow.Ellipsis})
        Text(item.operDataList[0].newsSummary)
          .fontSize($r('app.float.font_size_12'))
          .fontColor($r('app.color.color_999999'))
          .width(CommonConstants.FULL_WIDTH)
          .maxLines(1)
          .textOverflow({overflow: TextOverflow.Ellipsis})
        Row(){
          Image($r('app.media.broadcast_clock'))
            .width(12)
            .height(12)
            .margin({right: 4})
          Text(DateTimeUtils.getCommentTime(Number.parseFloat(item.operDataList[0].publishTime)))
            .fontSize($r('app.float.font_size_12'))
            .fontColor($r('app.color.color_999999'))
            .margin({ right :24 })
          Image($r('app.media.broadcast_listen'))
            .width(12)
            .height(12)
            .margin({right: 4})
          Text('0')
            .fontSize($r('app.float.font_size_12'))
            .fontColor($r('app.color.color_999999'))
            .margin({ right :24})
        }
        .width(CommonConstants.FULL_WIDTH)
      }
      .layoutWeight(1)
    }
    .onClick((event: ClickEvent) => {
      // TODO 跳转到音频专题页
    })
    .width(CommonConstants.FULL_WIDTH)
    .height(73)
  }
}