douaojie

fix: 缺省图晚上

... ... @@ -3,6 +3,8 @@ import { EmptyComponent } from '../view/EmptyComponent'
@Entry
@Component
export struct DefaultPage {
@State type: number = 1
retry() {
console.log('daj点击了重试')
}
... ... @@ -10,10 +12,14 @@ export struct DefaultPage {
build() {
Row() {
EmptyComponent({
emptyType: 8, emptyButton: true, retry: () => {
emptyType: this.type,
emptyButton: true,
retry: () => {
this.retry()
}
})
// .height('612lpx')
// .width('100%')
}
}
}
\ No newline at end of file
... ...
... ... @@ -7,39 +7,39 @@ const TAG = 'EmptyComponent';
* WDViewDefaultType 缺省页
*/
export const enum WDViewDefaultType {
/// 1.默认
/// 0.默认
WDViewDefaultType_Default,
/// 2.无网
/// 1.无网
WDViewDefaultType_NoNetwork,
/// 3.暂无内容(列表页)
/// 2.暂无内容(列表页)
WDViewDefaultType_NoListContent,
/// 4.内容找不到了(内容详情页)
/// 3.内容找不到了(内容详情页)
WDViewDefaultType_NoContent,
/// 5.无搜索内容
/// 4.无搜索内容
WDViewDefaultType_NoSearchResult,
/// 6.无消息内容
/// 5.无消息内容
WDViewDefaultType_NoMessage,
/// 7.无收藏内容
/// 6.无收藏内容
WDViewDefaultType_NoCollection,
/// 8.无历史记录
/// 7.无历史记录
WDViewDefaultType_NoHistory,
/// 9.网络失败 请稍后重试-倒计时
/// 8.网络失败 请稍后重试-倒计时
WDViewDefaultType_NetworkFailed,
/// 10.内容获取失败
/// 9.内容获取失败
WDViewDefaultType_ContentFailed,
/// 11.无预约内容
/// 10.无预约内容
WDViewDefaultType_NoBooking,
/// 12.无评论内容
/// 11.无评论内容
WDViewDefaultType_NoComment,
/// 13.暂无作品
/// 12.暂无作品
WDViewDefaultType_NoCreation,
/// 14.该号主无法访问
/// 13.该号主无法访问
WDViewDefaultType_NoVisitAccount,
/// 15.暂无关注
/// 14.暂无关注
WDViewDefaultType_NoFollow,
/// 18.视频加载失败
/// 15.视频图集加载失败
WDViewDefaultType_NoVideo,
/// 19.暂无内容1
/// 16.暂无内容1
WDViewDefaultType_NoContent1,
}
... ... @@ -52,7 +52,7 @@ export struct EmptyComponent {
// private emptySize: SizeOptions = {};
@State emptyWidth: string | number = CommonConstants.FULL_PARENT;
@State emptyHeight: string | number = CommonConstants.FULL_PARENT;
@Link emptyType: number
@Link emptyType: number; // 缺省图类型,传枚举
@State emptyButton: boolean = false
@State timeNum: number = 10
/**
... ... @@ -127,8 +127,8 @@ export struct EmptyComponent {
// .height(this.EMPTY_IMAGE_HEIGHT)
Text(this.emptyType !== 8 ? this.buildNoDataTip() : `${this.buildNoDataTip()}(${this.timeNum}s)`)
.fontSize($r('app.float.normal_text_size'))
.fontColor('#000000')
.fontSize($r('app.float.font_size_14'))
.fontColor('#FF999999')
.fontWeight(FontWeight.Normal)
.opacity(this.TEXT_OPACITY)
.margin({ top: this.EMPTY_TIP_TEXT_MARGIN_TOP })
... ... @@ -136,7 +136,8 @@ export struct EmptyComponent {
Logger.info(TAG, `noProgrammeData onClick event?.source: ${event.source}`);
})
if (this.emptyButton) {
if (this.isShowButton()) {
if (this.emptyType !== 15) {
Button('点击重试')
.type(ButtonType.Normal)
.width(80)
... ... @@ -145,17 +146,37 @@ export struct EmptyComponent {
.fontColor('#FF666666')
.border({ width: 1 })
.borderColor('#FFEDEDED')
.borderRadius(4)
.fontSize($r('app.float.font_size_12'))
.margin({ top: 16 })
.padding(0)
.onClick(() => {
this.retry()
})
} else {
Button('点击重试')
.type(ButtonType.Normal)
.width(80)
.height(28)
.backgroundColor(Color.Black)
.fontColor('#FFCCCCCC')
.border({ width: 1 })
.borderColor('#4DFFFFFF')
.borderRadius(4)
.fontSize($r('app.float.font_size_12'))
.margin({ top: 16 })
.padding(0)
.onClick(() => {
this.retry()
})
}
}
}
.justifyContent(FlexAlign.Center)
.width(this.emptyWidth)
.height(this.emptyHeight)
// .backgroundColor(Color.Black)
}
buildNoDataTip(): string {
... ... @@ -224,4 +245,12 @@ export struct EmptyComponent {
}
return imageString
}
isShowButton() {
if (this.emptyType === 1 || this.emptyType === 9 || this.emptyType === 15) {
return true
} else {
return false
}
}
}
... ...