notes.ets 1.11 KB
/**
 * 表示
 *  objectType 0:不跳转 1:点播,2:直播,3:活动,4:广告,5:专题,6:链接,7:榜单,8:图文,9:组图,10:H5新闻,11:频道,12:组件,13:音频,
 14动态图文,15动态视频16问政;100人民号,101标签
 */

@Preview
@Component
export struct Notes {
  @State objectType: number | string = 5
  @State newTags: string = ''

  build() {
    if (this.returnTypeTitleFn()) {
      Text(this.returnTypeTitleFn())
        .fontSize($r('app.float.font_size_11'))
        .padding({
          left: 4,
          right: 4,
          top: 3,
          bottom: 3
        })
        .linearGradient({ angle: 90, colors: [['#FFFF2B00', 0.0], ['#FFFE6A00', 1.0]] })
        .fontColor(Color.White)// .borderRadius($r('app.float.button_border_radius'))
        .borderRadius(2)
        .margin({ top: 1 })
    }
  }

  returnTypeTitleFn(): string {
    if (this.newTags) {
      return this.newTags
    } else {
      if (this.objectType == 5) {
        return '专题'
      } else if (this.objectType == 10) {
        return 'H5'
      } else if (this.objectType == 8) {
        return '文章'
      }
    }

    return ''
  }
}