Showing
2 changed files
with
57 additions
and
22 deletions
| @@ -3,6 +3,8 @@ import { EmptyComponent } from '../view/EmptyComponent' | @@ -3,6 +3,8 @@ import { EmptyComponent } from '../view/EmptyComponent' | ||
| 3 | @Entry | 3 | @Entry |
| 4 | @Component | 4 | @Component |
| 5 | export struct DefaultPage { | 5 | export struct DefaultPage { |
| 6 | + @State type: number = 1 | ||
| 7 | + | ||
| 6 | retry() { | 8 | retry() { |
| 7 | console.log('daj点击了重试') | 9 | console.log('daj点击了重试') |
| 8 | } | 10 | } |
| @@ -10,10 +12,14 @@ export struct DefaultPage { | @@ -10,10 +12,14 @@ export struct DefaultPage { | ||
| 10 | build() { | 12 | build() { |
| 11 | Row() { | 13 | Row() { |
| 12 | EmptyComponent({ | 14 | EmptyComponent({ |
| 13 | - emptyType: 8, emptyButton: true, retry: () => { | 15 | + emptyType: this.type, |
| 16 | + emptyButton: true, | ||
| 17 | + retry: () => { | ||
| 14 | this.retry() | 18 | this.retry() |
| 15 | } | 19 | } |
| 16 | }) | 20 | }) |
| 21 | + // .height('612lpx') | ||
| 22 | + // .width('100%') | ||
| 17 | } | 23 | } |
| 18 | } | 24 | } |
| 19 | } | 25 | } |
| @@ -7,39 +7,39 @@ const TAG = 'EmptyComponent'; | @@ -7,39 +7,39 @@ const TAG = 'EmptyComponent'; | ||
| 7 | * WDViewDefaultType 缺省页 | 7 | * WDViewDefaultType 缺省页 |
| 8 | */ | 8 | */ |
| 9 | export const enum WDViewDefaultType { | 9 | export const enum WDViewDefaultType { |
| 10 | - /// 1.默认 | 10 | + /// 0.默认 |
| 11 | WDViewDefaultType_Default, | 11 | WDViewDefaultType_Default, |
| 12 | - /// 2.无网 | 12 | + /// 1.无网 |
| 13 | WDViewDefaultType_NoNetwork, | 13 | WDViewDefaultType_NoNetwork, |
| 14 | - /// 3.暂无内容(列表页) | 14 | + /// 2.暂无内容(列表页) |
| 15 | WDViewDefaultType_NoListContent, | 15 | WDViewDefaultType_NoListContent, |
| 16 | - /// 4.内容找不到了(内容详情页) | 16 | + /// 3.内容找不到了(内容详情页) |
| 17 | WDViewDefaultType_NoContent, | 17 | WDViewDefaultType_NoContent, |
| 18 | - /// 5.无搜索内容 | 18 | + /// 4.无搜索内容 |
| 19 | WDViewDefaultType_NoSearchResult, | 19 | WDViewDefaultType_NoSearchResult, |
| 20 | - /// 6.无消息内容 | 20 | + /// 5.无消息内容 |
| 21 | WDViewDefaultType_NoMessage, | 21 | WDViewDefaultType_NoMessage, |
| 22 | - /// 7.无收藏内容 | 22 | + /// 6.无收藏内容 |
| 23 | WDViewDefaultType_NoCollection, | 23 | WDViewDefaultType_NoCollection, |
| 24 | - /// 8.无历史记录 | 24 | + /// 7.无历史记录 |
| 25 | WDViewDefaultType_NoHistory, | 25 | WDViewDefaultType_NoHistory, |
| 26 | - /// 9.网络失败 请稍后重试-倒计时 | 26 | + /// 8.网络失败 请稍后重试-倒计时 |
| 27 | WDViewDefaultType_NetworkFailed, | 27 | WDViewDefaultType_NetworkFailed, |
| 28 | - /// 10.内容获取失败 | 28 | + /// 9.内容获取失败 |
| 29 | WDViewDefaultType_ContentFailed, | 29 | WDViewDefaultType_ContentFailed, |
| 30 | - /// 11.无预约内容 | 30 | + /// 10.无预约内容 |
| 31 | WDViewDefaultType_NoBooking, | 31 | WDViewDefaultType_NoBooking, |
| 32 | - /// 12.无评论内容 | 32 | + /// 11.无评论内容 |
| 33 | WDViewDefaultType_NoComment, | 33 | WDViewDefaultType_NoComment, |
| 34 | - /// 13.暂无作品 | 34 | + /// 12.暂无作品 |
| 35 | WDViewDefaultType_NoCreation, | 35 | WDViewDefaultType_NoCreation, |
| 36 | - /// 14.该号主无法访问 | 36 | + /// 13.该号主无法访问 |
| 37 | WDViewDefaultType_NoVisitAccount, | 37 | WDViewDefaultType_NoVisitAccount, |
| 38 | - /// 15.暂无关注 | 38 | + /// 14.暂无关注 |
| 39 | WDViewDefaultType_NoFollow, | 39 | WDViewDefaultType_NoFollow, |
| 40 | - /// 18.视频加载失败 | 40 | + /// 15.视频图集加载失败 |
| 41 | WDViewDefaultType_NoVideo, | 41 | WDViewDefaultType_NoVideo, |
| 42 | - /// 19.暂无内容1 | 42 | + /// 16.暂无内容1 |
| 43 | WDViewDefaultType_NoContent1, | 43 | WDViewDefaultType_NoContent1, |
| 44 | } | 44 | } |
| 45 | 45 | ||
| @@ -52,7 +52,7 @@ export struct EmptyComponent { | @@ -52,7 +52,7 @@ export struct EmptyComponent { | ||
| 52 | // private emptySize: SizeOptions = {}; | 52 | // private emptySize: SizeOptions = {}; |
| 53 | @State emptyWidth: string | number = CommonConstants.FULL_PARENT; | 53 | @State emptyWidth: string | number = CommonConstants.FULL_PARENT; |
| 54 | @State emptyHeight: string | number = CommonConstants.FULL_PARENT; | 54 | @State emptyHeight: string | number = CommonConstants.FULL_PARENT; |
| 55 | - @Link emptyType: number | 55 | + @Link emptyType: number; // 缺省图类型,传枚举 |
| 56 | @State emptyButton: boolean = false | 56 | @State emptyButton: boolean = false |
| 57 | @State timeNum: number = 10 | 57 | @State timeNum: number = 10 |
| 58 | /** | 58 | /** |
| @@ -127,8 +127,8 @@ export struct EmptyComponent { | @@ -127,8 +127,8 @@ export struct EmptyComponent { | ||
| 127 | // .height(this.EMPTY_IMAGE_HEIGHT) | 127 | // .height(this.EMPTY_IMAGE_HEIGHT) |
| 128 | 128 | ||
| 129 | Text(this.emptyType !== 8 ? this.buildNoDataTip() : `${this.buildNoDataTip()}(${this.timeNum}s)`) | 129 | Text(this.emptyType !== 8 ? this.buildNoDataTip() : `${this.buildNoDataTip()}(${this.timeNum}s)`) |
| 130 | - .fontSize($r('app.float.normal_text_size')) | ||
| 131 | - .fontColor('#000000') | 130 | + .fontSize($r('app.float.font_size_14')) |
| 131 | + .fontColor('#FF999999') | ||
| 132 | .fontWeight(FontWeight.Normal) | 132 | .fontWeight(FontWeight.Normal) |
| 133 | .opacity(this.TEXT_OPACITY) | 133 | .opacity(this.TEXT_OPACITY) |
| 134 | .margin({ top: this.EMPTY_TIP_TEXT_MARGIN_TOP }) | 134 | .margin({ top: this.EMPTY_TIP_TEXT_MARGIN_TOP }) |
| @@ -136,7 +136,8 @@ export struct EmptyComponent { | @@ -136,7 +136,8 @@ export struct EmptyComponent { | ||
| 136 | Logger.info(TAG, `noProgrammeData onClick event?.source: ${event.source}`); | 136 | Logger.info(TAG, `noProgrammeData onClick event?.source: ${event.source}`); |
| 137 | }) | 137 | }) |
| 138 | 138 | ||
| 139 | - if (this.emptyButton) { | 139 | + if (this.isShowButton()) { |
| 140 | + if (this.emptyType !== 15) { | ||
| 140 | Button('点击重试') | 141 | Button('点击重试') |
| 141 | .type(ButtonType.Normal) | 142 | .type(ButtonType.Normal) |
| 142 | .width(80) | 143 | .width(80) |
| @@ -145,17 +146,37 @@ export struct EmptyComponent { | @@ -145,17 +146,37 @@ export struct EmptyComponent { | ||
| 145 | .fontColor('#FF666666') | 146 | .fontColor('#FF666666') |
| 146 | .border({ width: 1 }) | 147 | .border({ width: 1 }) |
| 147 | .borderColor('#FFEDEDED') | 148 | .borderColor('#FFEDEDED') |
| 149 | + .borderRadius(4) | ||
| 148 | .fontSize($r('app.float.font_size_12')) | 150 | .fontSize($r('app.float.font_size_12')) |
| 149 | .margin({ top: 16 }) | 151 | .margin({ top: 16 }) |
| 150 | .padding(0) | 152 | .padding(0) |
| 151 | .onClick(() => { | 153 | .onClick(() => { |
| 152 | this.retry() | 154 | this.retry() |
| 153 | }) | 155 | }) |
| 156 | + } else { | ||
| 157 | + Button('点击重试') | ||
| 158 | + .type(ButtonType.Normal) | ||
| 159 | + .width(80) | ||
| 160 | + .height(28) | ||
| 161 | + .backgroundColor(Color.Black) | ||
| 162 | + .fontColor('#FFCCCCCC') | ||
| 163 | + .border({ width: 1 }) | ||
| 164 | + .borderColor('#4DFFFFFF') | ||
| 165 | + .borderRadius(4) | ||
| 166 | + .fontSize($r('app.float.font_size_12')) | ||
| 167 | + .margin({ top: 16 }) | ||
| 168 | + .padding(0) | ||
| 169 | + .onClick(() => { | ||
| 170 | + this.retry() | ||
| 171 | + }) | ||
| 172 | + } | ||
| 154 | } | 173 | } |
| 155 | } | 174 | } |
| 156 | .justifyContent(FlexAlign.Center) | 175 | .justifyContent(FlexAlign.Center) |
| 157 | .width(this.emptyWidth) | 176 | .width(this.emptyWidth) |
| 158 | .height(this.emptyHeight) | 177 | .height(this.emptyHeight) |
| 178 | + | ||
| 179 | + // .backgroundColor(Color.Black) | ||
| 159 | } | 180 | } |
| 160 | 181 | ||
| 161 | buildNoDataTip(): string { | 182 | buildNoDataTip(): string { |
| @@ -224,4 +245,12 @@ export struct EmptyComponent { | @@ -224,4 +245,12 @@ export struct EmptyComponent { | ||
| 224 | } | 245 | } |
| 225 | return imageString | 246 | return imageString |
| 226 | } | 247 | } |
| 248 | + | ||
| 249 | + isShowButton() { | ||
| 250 | + if (this.emptyType === 1 || this.emptyType === 9 || this.emptyType === 15) { | ||
| 251 | + return true | ||
| 252 | + } else { | ||
| 253 | + return false | ||
| 254 | + } | ||
| 255 | + } | ||
| 227 | } | 256 | } |
-
Please register or login to post a comment