ActivityItemComponent.ets 4.33 KB
/**
 * 搜索活动 展示组件
 */
import { ContentDTO } from 'wdBean/Index';
import { ProcessUtils } from 'wdRouter/Index';

@Component
export struct ActivityItemComponent {
  @State contentDTO: ContentDTO = new ContentDTO();

  build() {
    Row() {
      Stack(){
        Image(this.contentDTO.coverUrl)
          .width('207lpx')
          .height('276lpx')
          .objectFit(ImageFit.Auto)
          .borderRadius('7lpx')

        Row(){
          Image(this.contentDTO.programType+"" === "1" ? $r('app.media.activity_is_start_icon') :$r('app.media.activity_not_begin_icon'))
            .width('42lpx')
            .height('35lpx')
            .objectFit(ImageFit.Auto)
            .interpolation(ImageInterpolation.Medium)

          Text(this.contentDTO.programType+"" === "1" ? "进行中" :"未开始")
            .fontColor($r('app.color.white'))
            .fontSize('21lpx')
            .fontWeight('400lpx')
            .lineHeight('31lpx')
            .textAlign(TextAlign.Center)
        }.margin({right:'19lpx',bottom:'13lpx'})
      }.alignContent(Alignment.BottomEnd)


      Column() {

        Row(){
          // Text(){
          //   // backgroundColor 不生效
          //   Span(this.contentDTO.objectType == "new_collect" ? "征稿" : this.contentDTO.objectType == "vote" ? "投票":"")
          //     .fontColor($r('app.color.main_red'))
          //     .fontSize('23lpx')
          //     .fontWeight('400lpx')
          //     .lineHeight('31lpx')
          //     .padding({left:'10lpx',right:'10lpx',top:'6lpx',bottom:'6lpx'})
          //     .backgroundColor( "#FF0"/*$r('app.color.color_ED2800')*/)
          //     .borderRadius('10lpx')
          //     .margin({ right: '10lpx' })
          //
          //   Span(this.contentDTO.newsTitle)
          //     .fontColor($r('app.color.color_222222'))
          //     .fontSize('33lpx')
          //     .fontWeight('400lpx')
          //     .lineHeight('48lpx')
          // }.textAlign(TextAlign.Start)
          // .maxLines(2)
          // .textOverflow({ overflow: TextOverflow.Ellipsis })

          //TODO 这里的样式(objectType) 只写了两个,其他的需要扩展
          Text(this.contentDTO.objectType == "new_collect" ? "征稿" : this.contentDTO.objectType == "vote" ? "投票":"")
            .fontColor($r('app.color.white'))
            .fontSize('23lpx')
            .fontWeight('400lpx')
            .lineHeight('31lpx')
            .textAlign(TextAlign.Center)
            .padding({left:'10lpx',right:'10lpx',top:'6lpx',bottom:'6lpx'})
            .backgroundColor( $r('app.color.color_ED2800'))
            .borderRadius('10lpx')
            .margin({ right: '10lpx' })


          Text(this.contentDTO.newsTitle)
            .fontColor($r('app.color.color_222222'))
            .fontSize('33lpx')
            .fontWeight('400lpx')
            .lineHeight('48lpx')
            .textAlign(TextAlign.Start)
            .maxLines(2)
            .layoutWeight(1)
        }
        .margin({ bottom: '15lpx' })
        .alignItems(VerticalAlign.Top)
        .width('100%')

        Row() {
          Image($r('app.media.time_icon'))
            .width('27lpx')
            .height('27lpx')
            .objectFit(ImageFit.Auto)
            .margin({ right: '4lpx' })
            .interpolation(ImageInterpolation.Medium)

          Text("时间:" + this.contentDTO.startTime.split(" ")[0] + "~" + this.contentDTO.endTime.split(" ")[0])
            .fontColor($r('app.color.color_999999'))
            .fontSize('23lpx')
            .fontWeight('400lpx')
            .lineHeight('31lpx')
        }

        Blank()

        Text(this.contentDTO.programType+"" === "1" ? "立即参与" : "立即查看")
          .fontColor($r('app.color.white'))
          .fontSize('23lpx')
          .fontWeight('500lpx')
          .lineHeight('38lpx')
          .width('154lpx')
          .height('54lpx')
          .textAlign(TextAlign.Center)
          .backgroundColor(this.contentDTO.programType+"" == "1" ? $r('app.color.color_ED2800') : $r('app.color.color_F07E47'))
          .borderRadius('6lpx')

      }.alignItems(HorizontalAlign.Start)
      .width('428lpx')
      .height('276lpx')

    }.height('330lpx')
    .justifyContent(FlexAlign.SpaceBetween)
    .width('100%')
    .padding({left:'31lpx',right:'31lpx'})
    .onClick(()=>{
        ProcessUtils._gotoDefaultWeb(this.contentDTO.linkUrl)
    })
  }
}