Showing
1 changed file
with
25 additions
and
2 deletions
| 1 | import { Action, ContentDetailDTO, InteractDataDTO } from 'wdBean/Index'; | 1 | import { Action, ContentDetailDTO, InteractDataDTO } from 'wdBean/Index'; |
| 2 | +import { NetworkUtil, Logger, NetworkType, SPHelper, WindowModel, StringUtils } from 'wdKit'; | ||
| 2 | import { ContentDetailRequest } from 'wdDetailPlayApi/Index' | 3 | import { ContentDetailRequest } from 'wdDetailPlayApi/Index' |
| 3 | import { ResponseDTO } from 'wdNetwork/Index'; | 4 | import { ResponseDTO } from 'wdNetwork/Index'; |
| 4 | import { DetailPlayShortVideoPage } from './DetailPlayShortVideoPage' | 5 | import { DetailPlayShortVideoPage } from './DetailPlayShortVideoPage' |
| @@ -7,7 +8,7 @@ import { contentListParams } from 'wdDetailPlayApi/src/main/ets/request/ContentD | @@ -7,7 +8,7 @@ import { contentListParams } from 'wdDetailPlayApi/src/main/ets/request/ContentD | ||
| 7 | import { WindowModel } from 'wdKit'; | 8 | import { WindowModel } from 'wdKit'; |
| 8 | import { DisplayDirection } from 'wdConstant/Index'; | 9 | import { DisplayDirection } from 'wdConstant/Index'; |
| 9 | import { window } from '@kit.ArkUI'; | 10 | import { window } from '@kit.ArkUI'; |
| 10 | - | 11 | +import { EmptyComponent } from 'wdComponent/Index'; |
| 11 | const storage = LocalStorage.getShared(); | 12 | const storage = LocalStorage.getShared(); |
| 12 | const TAG = 'DetailVideoListPage' | 13 | const TAG = 'DetailVideoListPage' |
| 13 | 14 | ||
| @@ -29,10 +30,14 @@ export struct DetailVideoListPage { | @@ -29,10 +30,14 @@ export struct DetailVideoListPage { | ||
| 29 | @Provide displayDirection: DisplayDirection = DisplayDirection.VERTICAL | 30 | @Provide displayDirection: DisplayDirection = DisplayDirection.VERTICAL |
| 30 | @State data: ContentDetailDTO[] = [] | 31 | @State data: ContentDetailDTO[] = [] |
| 31 | @State currentIndex: number = 0 | 32 | @State currentIndex: number = 0 |
| 33 | + @State netStatus: number | undefined = undefined // 存储网络状态用来展示缺省图 | ||
| 32 | @State interactDataList: InteractDataDTO[] = [] | 34 | @State interactDataList: InteractDataDTO[] = [] |
| 33 | 35 | ||
| 34 | async aboutToAppear(): Promise<void> { | 36 | async aboutToAppear(): Promise<void> { |
| 35 | - this.openFullScreen() | 37 | + // 注册监听网络连接 |
| 38 | + let netStatus = NetworkUtil.isNetConnected() | ||
| 39 | + if (netStatus) { | ||
| 40 | + this.openFullScreen() | ||
| 36 | 41 | ||
| 37 | const action: Action = router.getParams() as Action | 42 | const action: Action = router.getParams() as Action |
| 38 | if (action) { | 43 | if (action) { |
| @@ -45,6 +50,12 @@ export struct DetailVideoListPage { | @@ -45,6 +50,12 @@ export struct DetailVideoListPage { | ||
| 45 | } | 50 | } |
| 46 | await this.queryVideoList() | 51 | await this.queryVideoList() |
| 47 | console.log(TAG, 'aboutToAppear', JSON.stringify(action.params)) | 52 | console.log(TAG, 'aboutToAppear', JSON.stringify(action.params)) |
| 53 | + | ||
| 54 | + } else { | ||
| 55 | + // 无网络 | ||
| 56 | + this.netStatus = 1 | ||
| 57 | + } | ||
| 58 | + | ||
| 48 | } | 59 | } |
| 49 | 60 | ||
| 50 | aboutToDisappear(): void { | 61 | aboutToDisappear(): void { |
| @@ -163,6 +174,18 @@ export struct DetailVideoListPage { | @@ -163,6 +174,18 @@ export struct DetailVideoListPage { | ||
| 163 | } | 174 | } |
| 164 | 175 | ||
| 165 | build() { | 176 | build() { |
| 177 | + if (this.netStatus !== undefined) { | ||
| 178 | + EmptyComponent({ | ||
| 179 | + emptyType: this.netStatus, emptyButton: true, retry: () => { | ||
| 180 | + this.getContentDetail() | ||
| 181 | + } | ||
| 182 | + }) | ||
| 183 | + .id('e_empty_content') | ||
| 184 | + .alignRules({ | ||
| 185 | + center: { anchor: "__container__", align: VerticalAlign.Center }, | ||
| 186 | + middle: { anchor: "__container__", align: HorizontalAlign.Center } | ||
| 187 | + }) | ||
| 188 | + } | ||
| 166 | Column() { | 189 | Column() { |
| 167 | Swiper(this.swiperController) { | 190 | Swiper(this.swiperController) { |
| 168 | ForEach(this.data, (item: ContentDetailDTO, index: number) => { | 191 | ForEach(this.data, (item: ContentDetailDTO, index: number) => { |
-
Please register or login to post a comment