douaojie

feat: 优化缺省页的交互

... ... @@ -3,9 +3,17 @@ import { EmptyComponent } from '../view/EmptyComponent'
@Entry
@Component
export struct DefaultPage {
retry() {
console.log('daj点击了重试')
}
build() {
Row() {
EmptyComponent({ emptyType: 8 })
EmptyComponent({
emptyType: 8, emptyButton: true, retry: () => {
this.retry()
}
})
}
}
}
\ No newline at end of file
... ...
... ... @@ -56,7 +56,9 @@ export struct EmptyComponent {
// private emptySize: SizeOptions = {};
@State emptyWidth: string | number = CommonConstants.FULL_PARENT;
@State emptyHeight: string | number = CommonConstants.FULL_PARENT;
@State emptyType: number = WDViewDefaultType.WDViewDefaultType_Default
@State emptyType: number = WDViewDefaultType.WDViewDefaultType_Default;
@State emptyButton: boolean = false
@State timeNum: number = 10
/**
* The empty image width percentage setting.
*/
... ... @@ -73,6 +75,42 @@ export struct EmptyComponent {
* The empty data text opacity.
*/
readonly TEXT_OPACITY: number = 0.4;
private timer: number = -1
retry: () => void = () => {
}
createTimer() {
if (this.emptyType === 8) {
this.timer = setInterval(() => {
this.timeNum--;
if (this.timeNum === 0) {
clearInterval(this.timer);
}
}, 1000);
}
}
destroyTimer() {
if (this.emptyType === 8) {
clearInterval(this.timer);
}
}
onPageShow(): void {
this.createTimer()
}
aboutToAppear(): void {
this.createTimer()
}
onPageHide(): void {
this.destroyTimer()
}
aboutToDisappear() {
this.destroyTimer()
}
build() {
this.noProgrammeData();
... ... @@ -90,7 +128,7 @@ export struct EmptyComponent {
.objectFit(ImageFit.Contain)
// .border({ width: 1, color: Color.Red, radius: 6 })
Text(this.buildNoDataTip())
Text(this.emptyType !== 8 ? this.buildNoDataTip() : `${this.buildNoDataTip()}(${this.timeNum}s)`)
.fontSize($r('app.float.normal_text_size'))
.fontColor('#000000')
.fontWeight(FontWeight.Normal)
... ... @@ -99,6 +137,23 @@ export struct EmptyComponent {
.onClick((event: ClickEvent) => {
Logger.info(TAG, `noProgrammeData onClick event?.source: ${event.source}`);
})
if (this.emptyButton) {
Button('点击重试')
.type(ButtonType.Normal)
.width(80)
.height(28)
.backgroundColor('#fffffff')
.fontColor('#FF666666')
.border({ width: 1 })
.borderColor('#FFEDEDED')
.fontSize($r('app.float.font_size_12'))
.margin({ top: 16 })
.padding(0)
.onClick(() => {
this.retry()
})
}
}
.justifyContent(FlexAlign.Center)
.width(this.emptyWidth)
... ... @@ -127,7 +182,7 @@ export struct EmptyComponent {
} else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoBooking) {
contentString = '暂无预约'
} else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NetworkFailed) {
contentString = '' // 前方拥堵,请耐心等待
contentString = '前方拥堵,请耐心等待...' // 前方拥堵,请耐心等待...
} else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoVisitAccount) {
contentString = '该号主暂时无法访问' // 前方拥堵,请耐心等待
} else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoLiveEnd) {
... ... @@ -163,7 +218,7 @@ export struct EmptyComponent {
} else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoBooking) {
imageString = $r('app.media.icon_no_appointmentMade')
} else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NetworkFailed) {
imageString = $r('app.media.icon_no_net')
imageString = $r('app.media.icon_no_limiting')
} else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoVisitAccount) {
imageString = $r('app.media.icon_no_master1')
} else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoLiveEnd) {
... ...