yangchenggong1_wd

fix |> 17457 无网络时进入协议节目鸿蒙与安卓显示不一致

1 import { CommonConstants } from 'wdConstant'; 1 import { CommonConstants } from 'wdConstant';
2 import { Logger } from 'wdKit'; 2 import { Logger } from 'wdKit';
  3 +import { router } from '@kit.ArkUI';
3 4
4 const TAG = 'EmptyComponent'; 5 const TAG = 'EmptyComponent';
5 6
@@ -19,11 +20,15 @@ export const enum WDViewDefaultType { @@ -19,11 +20,15 @@ export const enum WDViewDefaultType {
19 @Preview 20 @Preview
20 @Component 21 @Component
21 export struct EmptyComponent { 22 export struct EmptyComponent {
  23 + // private emptySize: SizeOptions = {};
22 @State emptyWidth: string | number = CommonConstants.FULL_PARENT; 24 @State emptyWidth: string | number = CommonConstants.FULL_PARENT;
23 @State emptyHeight: string | number = CommonConstants.FULL_PARENT; 25 @State emptyHeight: string | number = CommonConstants.FULL_PARENT;
24 - @State emptyType: number = WDViewDefaultType.WDViewDefaultType_NoNetwork; // 缺省图类型,传枚举 26 + @State emptyType: number = WDViewDefaultType.WDViewDefaultType_Default; // 缺省图类型,传枚举
25 @State emptyButton: boolean = false 27 @State emptyButton: boolean = false
  28 + @State isBlack: boolean = false // 背景是否为黑色 默认白色
26 @State timeNum: number = 10 29 @State timeNum: number = 10
  30 + ///占位图上是否显示返回按钮
  31 + @State showBackButton: boolean = true
27 /** 32 /**
28 * The empty image width percentage setting. 33 * The empty image width percentage setting.
29 */ 34 */
@@ -39,13 +44,27 @@ export struct EmptyComponent { @@ -39,13 +44,27 @@ export struct EmptyComponent {
39 /** 44 /**
40 * The empty data text opacity. 45 * The empty data text opacity.
41 */ 46 */
42 - readonly TEXT_OPACITY: number = 0.4;  
43 - private timer: number = -1 47 + readonly TEXT_OPACITY: number = 1.0;
44 retry: () => void = () => { 48 retry: () => void = () => {
45 } 49 }
46 50
47 build() { 51 build() {
  52 + Stack({alignContent:Alignment.Bottom}) {
48 this.noProgrammeData(); 53 this.noProgrammeData();
  54 +
  55 + if (this.showBackButton) {
  56 + Image($r("app.media.icon_arrow_left_white"))
  57 + .width(24)
  58 + .height(24)
  59 + .onClick(() => {
  60 + router.back();
  61 + })
  62 + .position({
  63 + bottom: 15,
  64 + left: 16
  65 + })
  66 + }
  67 + }
49 } 68 }
50 69
51 /** 70 /**
@@ -64,17 +83,18 @@ export struct EmptyComponent { @@ -64,17 +83,18 @@ export struct EmptyComponent {
64 .fontWeight(FontWeight.Normal) 83 .fontWeight(FontWeight.Normal)
65 .opacity(this.TEXT_OPACITY) 84 .opacity(this.TEXT_OPACITY)
66 .margin({ top: this.EMPTY_TIP_TEXT_MARGIN_TOP }) 85 .margin({ top: this.EMPTY_TIP_TEXT_MARGIN_TOP })
  86 + .fontColor('#666666')
67 .onClick((event: ClickEvent) => { 87 .onClick((event: ClickEvent) => {
68 Logger.info(TAG, `noProgrammeData onClick event?.source: ${event.source}`); 88 Logger.info(TAG, `noProgrammeData onClick event?.source: ${event.source}`);
69 }) 89 })
70 90
71 if (this.isShowButton()) { 91 if (this.isShowButton()) {
72 - if (this.emptyType !== 15) { 92 + if (this.emptyType !== 15 && !this.isBlack) {
73 Button('点击重试') 93 Button('点击重试')
74 .type(ButtonType.Normal) 94 .type(ButtonType.Normal)
75 .width(80) 95 .width(80)
76 .height(28) 96 .height(28)
77 - .backgroundColor('#fffffff') 97 + .backgroundColor(Color.White)
78 .fontColor('#FF666666') 98 .fontColor('#FF666666')
79 .border({ width: 1 }) 99 .border({ width: 1 })
80 .borderColor('#FFEDEDED') 100 .borderColor('#FFEDEDED')
@@ -106,7 +126,9 @@ export struct EmptyComponent { @@ -106,7 +126,9 @@ export struct EmptyComponent {
106 } 126 }
107 .justifyContent(FlexAlign.Center) 127 .justifyContent(FlexAlign.Center)
108 .width(this.emptyWidth) 128 .width(this.emptyWidth)
  129 + .layoutWeight(1)
109 .height(this.emptyHeight) 130 .height(this.emptyHeight)
  131 +
110 } 132 }
111 133
112 buildNoDataTip(): string { 134 buildNoDataTip(): string {
@@ -120,7 +142,7 @@ export struct EmptyComponent { @@ -120,7 +142,7 @@ export struct EmptyComponent {
120 142
121 buildNoDataTipImage(): Resource | string { 143 buildNoDataTipImage(): Resource | string {
122 Logger.info(TAG, "buildNoDataTip"); 144 Logger.info(TAG, "buildNoDataTip");
123 - let imageString: Resource | string = "" 145 + let imageString: Resource | string = $r('app.media.icon_no_net1')
124 if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoNetwork) { 146 if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoNetwork) {
125 imageString = $r('app.media.icon_no_net1') 147 imageString = $r('app.media.icon_no_net1')
126 } 148 }
@@ -128,7 +150,7 @@ export struct EmptyComponent { @@ -128,7 +150,7 @@ export struct EmptyComponent {
128 } 150 }
129 151
130 isShowButton() { 152 isShowButton() {
131 - if (this.emptyType === 1 || this.emptyType === 9 || this.emptyType === 15) { 153 + if (this.emptyType === 1 || this.emptyType === 9 || this.emptyType === 15 && this.emptyButton) {
132 return true 154 return true
133 } else { 155 } else {
134 return false 156 return false