yumaochao

fix: 视频增加网络连接错误的缺省图

import { Action, ContentDetailDTO, InteractDataDTO } from 'wdBean/Index';
import { NetworkUtil, Logger, NetworkType, SPHelper, WindowModel, StringUtils } from 'wdKit';
import { ContentDetailRequest } from 'wdDetailPlayApi/Index'
import { ResponseDTO } from 'wdNetwork/Index';
import { DetailPlayShortVideoPage } from './DetailPlayShortVideoPage'
... ... @@ -7,7 +8,7 @@ import { contentListParams } from 'wdDetailPlayApi/src/main/ets/request/ContentD
import { WindowModel } from 'wdKit';
import { DisplayDirection } from 'wdConstant/Index';
import { window } from '@kit.ArkUI';
import { EmptyComponent } from 'wdComponent/Index';
const storage = LocalStorage.getShared();
const TAG = 'DetailVideoListPage'
... ... @@ -29,9 +30,13 @@ export struct DetailVideoListPage {
@Provide displayDirection: DisplayDirection = DisplayDirection.VERTICAL
@State data: ContentDetailDTO[] = []
@State currentIndex: number = 0
@State netStatus: number | undefined = undefined // 存储网络状态用来展示缺省图
@State interactDataList: InteractDataDTO[] = []
async aboutToAppear(): Promise<void> {
// 注册监听网络连接
let netStatus = NetworkUtil.isNetConnected()
if (netStatus) {
this.openFullScreen()
const action: Action = router.getParams() as Action
... ... @@ -45,6 +50,12 @@ export struct DetailVideoListPage {
}
await this.queryVideoList()
console.log(TAG, 'aboutToAppear', JSON.stringify(action.params))
} else {
// 无网络
this.netStatus = 1
}
}
aboutToDisappear(): void {
... ... @@ -163,6 +174,18 @@ export struct DetailVideoListPage {
}
build() {
if (this.netStatus !== undefined) {
EmptyComponent({
emptyType: this.netStatus, emptyButton: true, retry: () => {
this.getContentDetail()
}
})
.id('e_empty_content')
.alignRules({
center: { anchor: "__container__", align: VerticalAlign.Center },
middle: { anchor: "__container__", align: HorizontalAlign.Center }
})
}
Column() {
Swiper(this.swiperController) {
ForEach(this.data, (item: ContentDetailDTO, index: number) => {
... ...