yumaochao

更改

@@ -37,10 +37,6 @@ export const enum WDViewDefaultType { @@ -37,10 +37,6 @@ export const enum WDViewDefaultType {
37 WDViewDefaultType_NoVisitAccount, 37 WDViewDefaultType_NoVisitAccount,
38 /// 15.暂无关注 38 /// 15.暂无关注
39 WDViewDefaultType_NoFollow, 39 WDViewDefaultType_NoFollow,
40 - /// 16.直播结束  
41 - WDViewDefaultType_NoLiveEnd,  
42 - /// 17.直播暂停  
43 - WDViewDefaultType_NoLiveSuspend,  
44 /// 18.视频加载失败 40 /// 18.视频加载失败
45 WDViewDefaultType_NoVideo, 41 WDViewDefaultType_NoVideo,
46 /// 19.暂无内容1 42 /// 19.暂无内容1
@@ -130,10 +126,6 @@ export struct EmptyComponent { @@ -130,10 +126,6 @@ export struct EmptyComponent {
130 contentString = '' // 前方拥堵,请耐心等待 126 contentString = '' // 前方拥堵,请耐心等待
131 } else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoVisitAccount) { 127 } else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoVisitAccount) {
132 contentString = '该号主暂时无法访问' // 前方拥堵,请耐心等待 128 contentString = '该号主暂时无法访问' // 前方拥堵,请耐心等待
133 - } else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoLiveEnd) {  
134 - contentString = '直播已结束' // 前方拥堵,请耐心等待  
135 - } else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoLiveSuspend) {  
136 - contentString = '主播暂时离开,马上回来' // 前方拥堵,请耐心等待  
137 } else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoVideo) { 129 } else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoVideo) {
138 contentString = '获取内容失败请重试' // 前方拥堵,请耐心等待 130 contentString = '获取内容失败请重试' // 前方拥堵,请耐心等待
139 } else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoContent1) { 131 } else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoContent1) {
@@ -166,8 +158,6 @@ export struct EmptyComponent { @@ -166,8 +158,6 @@ export struct EmptyComponent {
166 imageString = $r('app.media.icon_no_net') 158 imageString = $r('app.media.icon_no_net')
167 } else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoVisitAccount) { 159 } else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoVisitAccount) {
168 imageString = $r('app.media.icon_no_master1') 160 imageString = $r('app.media.icon_no_master1')
169 - } else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoLiveEnd) {  
170 - imageString = $r('app.media.icon_no_end')  
171 } else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoVideo) { 161 } else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoVideo) {
172 imageString = $r('app.media.icon_no_content') 162 imageString = $r('app.media.icon_no_content')
173 } else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoContent1) { 163 } else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoContent1) {
  1 +import { CommonConstants } from 'wdConstant';
  2 +import { Logger } from 'wdKit';
  3 +
  4 +const TAG = 'LiveEmptyComponent';
  5 +
  6 +/**
  7 + * WDViewDefaultType 缺省页
  8 + */
  9 +export const enum WDViewDefaultType {
  10 + /// 1.默认
  11 + WDViewDefaultType_Default,
  12 + /// 16.直播结束
  13 + WDViewDefaultType_NoLiveEnd,
  14 + /// 17.直播暂停
  15 + WDViewDefaultType_NoLiveSuspend,
  16 +
  17 +}
  18 +
  19 +/**
  20 + * 空数据/无数据
  21 + */
  22 +@Preview
  23 +@Component
  24 +export struct LiveEmptyComponent {
  25 + // private emptySize: SizeOptions = {};
  26 + @State emptyWidth: string | number = CommonConstants.FULL_PARENT;
  27 + @State emptyHeight: string | number = CommonConstants.FULL_PARENT;
  28 + @State emptyType: number = WDViewDefaultType.WDViewDefaultType_Default
  29 + /**
  30 + * The empty image width percentage setting.
  31 + */
  32 + readonly EMPTY_IMAGE_WIDTH: string = '15%';
  33 + /**
  34 + * The empty image height percentage setting.
  35 + */
  36 + readonly EMPTY_IMAGE_HEIGHT: string = '15%';
  37 + /**
  38 + * The empty data text component margin top.
  39 + */
  40 + readonly EMPTY_TIP_TEXT_MARGIN_TOP: string = '10';
  41 + /**
  42 + * The empty data text opacity.
  43 + */
  44 + readonly TEXT_OPACITY: number = 0.4;
  45 +
  46 + build() {
  47 + this.noProgrammeData();
  48 + }
  49 +
  50 + /**
  51 + * 无数据,空白view组件
  52 + */
  53 + @Builder
  54 + noProgrammeData() {
  55 + Column() {
  56 + Image(this.buildNoDataTipImage())
  57 + .width('this.EMPTY_IMAGE_WIDTH')
  58 + .height(this.EMPTY_IMAGE_HEIGHT)
  59 + .objectFit(ImageFit.Contain)
  60 + // .border({ width: 1, color: Color.Red, radius: 6 })
  61 +
  62 + Text(this.buildNoDataTip())
  63 + .fontSize($r('app.float.normal_text_size'))
  64 + .fontColor('#000000')
  65 + .fontWeight(FontWeight.Normal)
  66 + .opacity(this.TEXT_OPACITY)
  67 + .margin({ top: this.EMPTY_TIP_TEXT_MARGIN_TOP })
  68 + .onClick((event: ClickEvent) => {
  69 + Logger.info(TAG, `noProgrammeData onClick event?.source: ${event.source}`);
  70 + })
  71 + }
  72 + .justifyContent(FlexAlign.Center)
  73 + .width(this.emptyWidth)
  74 + .height(this.emptyHeight)
  75 + }
  76 +
  77 + buildNoDataTip(): string {
  78 + Logger.info(TAG, "buildNoDataTip");
  79 + let contentString: string = '暂无内容'
  80 + if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoLiveEnd) {
  81 + contentString = '直播已结束' // 前方拥堵,请耐心等待
  82 + } else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoLiveSuspend) {
  83 + contentString = '主播暂时离开,马上回来' // 前方拥堵,请耐心等待
  84 + }
  85 + return contentString
  86 + }
  87 +
  88 + buildNoDataTipImage(): Resource | string {
  89 + Logger.info(TAG, "buildNoDataTip");
  90 + let imageString: Resource | string = $r('app.media.icon_no_content')
  91 + if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoLiveEnd) {
  92 + imageString = $r('app.media.icon_no_end')
  93 + } else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoLiveSuspend) {
  94 + imageString = $r('app.media.icon_no_liver')
  95 + }
  96 + return imageString
  97 + }
  98 +}