Showing
3 changed files
with
31 additions
and
48 deletions
| 1 | import { ContentDTO, LiveRoomDataBean } from 'wdBean'; | 1 | import { ContentDTO, LiveRoomDataBean } from 'wdBean'; |
| 2 | import { ProcessUtils } from 'wdRouter'; | 2 | import { ProcessUtils } from 'wdRouter'; |
| 3 | import PageViewModel from '../../viewmodel/PageViewModel'; | 3 | import PageViewModel from '../../viewmodel/PageViewModel'; |
| 4 | -import { DateTimeUtils, LazyDataSource, Logger } from 'wdKit/Index'; | 4 | +import { DateTimeUtils, LazyDataSource, Logger, NetworkUtil } from 'wdKit/Index'; |
| 5 | import { router } from '@kit.ArkUI'; | 5 | import { router } from '@kit.ArkUI'; |
| 6 | import { ViewType } from 'wdConstant/src/main/ets/enum/ViewType'; | 6 | import { ViewType } from 'wdConstant/src/main/ets/enum/ViewType'; |
| 7 | import { CustomPullToRefresh } from '../reusable/CustomPullToRefresh'; | 7 | import { CustomPullToRefresh } from '../reusable/CustomPullToRefresh'; |
| 8 | import { PeopleShipNoMoreData } from '../reusable/PeopleShipNoMoreData'; | 8 | import { PeopleShipNoMoreData } from '../reusable/PeopleShipNoMoreData'; |
| 9 | -import { EmptyComponent } from '../view/EmptyComponent'; | 9 | +import { EmptyComponent, WDViewDefaultType } from '../view/EmptyComponent'; |
| 10 | import { ErrorComponent } from '../view/ErrorComponent'; | 10 | import { ErrorComponent } from '../view/ErrorComponent'; |
| 11 | import LoadMoreLayout from '../page/LoadMoreLayout'; | 11 | import LoadMoreLayout from '../page/LoadMoreLayout'; |
| 12 | import { LottieView } from '../../components/lottie/LottieView'; | 12 | import { LottieView } from '../../components/lottie/LottieView'; |
| 13 | import dataPreferences from '@ohos.data.preferences'; | 13 | import dataPreferences from '@ohos.data.preferences'; |
| 14 | import { BusinessError } from '@ohos.base'; | 14 | import { BusinessError } from '@ohos.base'; |
| 15 | import { onlyWifiLoadImg } from '../../utils/lazyloadImg'; | 15 | import { onlyWifiLoadImg } from '../../utils/lazyloadImg'; |
| 16 | +import { channelSkeleton } from '../skeleton/channelSkeleton'; | ||
| 16 | 17 | ||
| 17 | const TAG: string = 'LiveMorePage'; | 18 | const TAG: string = 'LiveMorePage'; |
| 18 | 19 | ||
| @@ -41,12 +42,13 @@ struct LiveMorePage { | @@ -41,12 +42,13 @@ struct LiveMorePage { | ||
| 41 | @State private hasMore: boolean = true | 42 | @State private hasMore: boolean = true |
| 42 | @State private currentPage: number = 1 | 43 | @State private currentPage: number = 1 |
| 43 | @State private isLoading: boolean = false | 44 | @State private isLoading: boolean = false |
| 44 | - @State viewType: ViewType = ViewType.LOADING | ||
| 45 | private scroller: Scroller = new Scroller() | 45 | private scroller: Scroller = new Scroller() |
| 46 | @State liveRoomList: LiveRoomDataBean[] = [] | 46 | @State liveRoomList: LiveRoomDataBean[] = [] |
| 47 | // 点击过的数据 | 47 | // 点击过的数据 |
| 48 | @State clickDatas: Array<string> = [] | 48 | @State clickDatas: Array<string> = [] |
| 49 | @State loadImg: boolean = false; | 49 | @State loadImg: boolean = false; |
| 50 | + @State viewType: ViewType = ViewType.LOADING | ||
| 51 | + emptyType: WDViewDefaultType = WDViewDefaultType.WDViewDefaultType_Default | ||
| 50 | 52 | ||
| 51 | async aboutToAppear(): Promise<void> { | 53 | async aboutToAppear(): Promise<void> { |
| 52 | await this.getPreferencesFromStorage() | 54 | await this.getPreferencesFromStorage() |
| @@ -63,15 +65,14 @@ struct LiveMorePage { | @@ -63,15 +65,14 @@ struct LiveMorePage { | ||
| 63 | this.TabbarNormal() | 65 | this.TabbarNormal() |
| 64 | if (this.viewType == ViewType.LOADING) { | 66 | if (this.viewType == ViewType.LOADING) { |
| 65 | this.LoadingLayout() | 67 | this.LoadingLayout() |
| 66 | - } else if (this.viewType == ViewType.ERROR) { | ||
| 67 | - ErrorComponent() | ||
| 68 | - .onTouch(() => { | ||
| 69 | - if (this.viewType === ViewType.ERROR) { | 68 | + } else if (this.viewType == ViewType.EMPTY || this.viewType == ViewType.ERROR) { |
| 69 | + EmptyComponent({ | ||
| 70 | + emptyType: this.emptyType, | ||
| 71 | + emptyButton: true, | ||
| 72 | + retry: () => { | ||
| 70 | this.getData() | 73 | this.getData() |
| 71 | } | 74 | } |
| 72 | }) | 75 | }) |
| 73 | - } else if (this.viewType == ViewType.EMPTY) { | ||
| 74 | - EmptyComponent() | ||
| 75 | } else { | 76 | } else { |
| 76 | CustomPullToRefresh({ | 77 | CustomPullToRefresh({ |
| 77 | alldata: this.data, | 78 | alldata: this.data, |
| @@ -91,13 +92,15 @@ struct LiveMorePage { | @@ -91,13 +92,15 @@ struct LiveMorePage { | ||
| 91 | .padding({ | 92 | .padding({ |
| 92 | left: $r('app.float.card_comp_pagePadding_lf'), | 93 | left: $r('app.float.card_comp_pagePadding_lf'), |
| 93 | right: $r('app.float.card_comp_pagePadding_lf'), | 94 | right: $r('app.float.card_comp_pagePadding_lf'), |
| 94 | - top:px2vp(this.topSafeHeight),bottom:px2vp(this.bottomSafeHeight) | 95 | + top: px2vp(this.topSafeHeight), |
| 96 | + bottom: px2vp(this.bottomSafeHeight) | ||
| 95 | }) | 97 | }) |
| 96 | 98 | ||
| 97 | } | 99 | } |
| 98 | 100 | ||
| 99 | @Builder | 101 | @Builder |
| 100 | LoadingLayout() { | 102 | LoadingLayout() { |
| 103 | + channelSkeleton() | ||
| 101 | } | 104 | } |
| 102 | 105 | ||
| 103 | @Builder | 106 | @Builder |
| @@ -208,6 +211,7 @@ struct LiveMorePage { | @@ -208,6 +211,7 @@ struct LiveMorePage { | ||
| 208 | /*导航栏*/ | 211 | /*导航栏*/ |
| 209 | @Builder | 212 | @Builder |
| 210 | TabbarNormal() { | 213 | TabbarNormal() { |
| 214 | + | ||
| 211 | RelativeContainer() { | 215 | RelativeContainer() { |
| 212 | //标题栏目 | 216 | //标题栏目 |
| 213 | Image($r('app.media.icon_arrow_left')) | 217 | Image($r('app.media.icon_arrow_left')) |
| @@ -223,7 +227,7 @@ struct LiveMorePage { | @@ -223,7 +227,7 @@ struct LiveMorePage { | ||
| 223 | router.back() | 227 | router.back() |
| 224 | }) | 228 | }) |
| 225 | 229 | ||
| 226 | - Text(this.title)// .height('42lpx') | 230 | + Text(this.title) |
| 227 | .maxLines(1) | 231 | .maxLines(1) |
| 228 | .id("title") | 232 | .id("title") |
| 229 | .fontSize('18vp') | 233 | .fontSize('18vp') |
| @@ -298,6 +302,18 @@ struct LiveMorePage { | @@ -298,6 +302,18 @@ struct LiveMorePage { | ||
| 298 | } | 302 | } |
| 299 | return | 303 | return |
| 300 | } | 304 | } |
| 305 | + | ||
| 306 | + // 检测网络 | ||
| 307 | + let netStatus = NetworkUtil.isNetConnected() | ||
| 308 | + if (!netStatus) { | ||
| 309 | + | ||
| 310 | + this.emptyType = WDViewDefaultType.WDViewDefaultType_NoNetwork | ||
| 311 | + this.viewType = ViewType.ERROR | ||
| 312 | + | ||
| 313 | + return | ||
| 314 | + } | ||
| 315 | + | ||
| 316 | + | ||
| 301 | this.isLoading = true | 317 | this.isLoading = true |
| 302 | try { | 318 | try { |
| 303 | const liveReviewDTO = await PageViewModel.getLiveMoreUrl(this.type, this.currentPage, this.pageSize) | 319 | const liveReviewDTO = await PageViewModel.getLiveMoreUrl(this.type, this.currentPage, this.pageSize) |
| @@ -319,17 +335,12 @@ struct LiveMorePage { | @@ -319,17 +335,12 @@ struct LiveMorePage { | ||
| 319 | this.resolveEnd(true, resolve) | 335 | this.resolveEnd(true, resolve) |
| 320 | if (liveReviewDTO.list.length == 0 && this.currentPage == 1) { | 336 | if (liveReviewDTO.list.length == 0 && this.currentPage == 1) { |
| 321 | this.viewType = ViewType.EMPTY | 337 | this.viewType = ViewType.EMPTY |
| 338 | + this.emptyType = WDViewDefaultType.WDViewDefaultType_NoListContent | ||
| 322 | } | 339 | } |
| 323 | } catch (exception) { | 340 | } catch (exception) { |
| 324 | this.resolveEnd(false, resolve) | 341 | this.resolveEnd(false, resolve) |
| 325 | } | 342 | } |
| 326 | - // PageViewModel.getLiveMoreUrl(this.type, this.currentPage, this.pageSize).then(async (liveReviewDTO) => { | ||
| 327 | - // // this.operDataList = [] | ||
| 328 | - // // this.operDataList.push(...liveReviewDTO.list) | ||
| 329 | - // this.data.push(...liveReviewDTO.list) | ||
| 330 | - // | ||
| 331 | - // // this.getAppointmentInfo() | ||
| 332 | - // }) | 343 | + |
| 333 | } | 344 | } |
| 334 | 345 | ||
| 335 | private resolveEnd(isTop: boolean, resolve?: (value: string | PromiseLike<string>) => void) { | 346 | private resolveEnd(isTop: boolean, resolve?: (value: string | PromiseLike<string>) => void) { |
| @@ -341,7 +352,9 @@ struct LiveMorePage { | @@ -341,7 +352,9 @@ struct LiveMorePage { | ||
| 341 | } | 352 | } |
| 342 | } | 353 | } |
| 343 | if (this.currentPage == 1 && !isTop) { | 354 | if (this.currentPage == 1 && !isTop) { |
| 355 | + | ||
| 344 | this.viewType = ViewType.ERROR | 356 | this.viewType = ViewType.ERROR |
| 357 | + this.emptyType = WDViewDefaultType.WDViewDefaultType_NoListContent | ||
| 345 | } else { | 358 | } else { |
| 346 | this.viewType = ViewType.LOADED | 359 | this.viewType = ViewType.LOADED |
| 347 | } | 360 | } |
sight_harmony/features/wdComponent/src/main/ets/components/skeleton/DefaultPage.ets
deleted
100644 → 0
| 1 | -import { EmptyComponent } from '../view/EmptyComponent' | ||
| 2 | - | ||
| 3 | -@Entry | ||
| 4 | -@Component | ||
| 5 | -export struct DefaultPage { | ||
| 6 | - @State type: number = 15 | ||
| 7 | - | ||
| 8 | - retry() { | ||
| 9 | - console.log('daj点击了重试') | ||
| 10 | - } | ||
| 11 | - | ||
| 12 | - build() { | ||
| 13 | - Row() { | ||
| 14 | - EmptyComponent({ | ||
| 15 | - emptyType: this.type, | ||
| 16 | - retry: () => { | ||
| 17 | - this.retry() | ||
| 18 | - } | ||
| 19 | - }) | ||
| 20 | - // .height('612lpx') | ||
| 21 | - // .width('100%') | ||
| 22 | - } | ||
| 23 | - } | ||
| 24 | -} |
| @@ -96,17 +96,11 @@ export struct EmptyComponent { | @@ -96,17 +96,11 @@ export struct EmptyComponent { | ||
| 96 | } | 96 | } |
| 97 | } | 97 | } |
| 98 | 98 | ||
| 99 | - onPageShow(): void { | ||
| 100 | - this.createTimer() | ||
| 101 | - } | ||
| 102 | 99 | ||
| 103 | aboutToAppear(): void { | 100 | aboutToAppear(): void { |
| 104 | this.createTimer() | 101 | this.createTimer() |
| 105 | } | 102 | } |
| 106 | 103 | ||
| 107 | - onPageHide(): void { | ||
| 108 | - this.destroyTimer() | ||
| 109 | - } | ||
| 110 | 104 | ||
| 111 | aboutToDisappear() { | 105 | aboutToDisappear() { |
| 112 | this.destroyTimer() | 106 | this.destroyTimer() |
-
Please register or login to post a comment