Showing
5 changed files
with
52 additions
and
19 deletions
| @@ -50,6 +50,8 @@ export { GroupDTO } from './src/main/ets/bean/component/GroupDTO'; | @@ -50,6 +50,8 @@ export { GroupDTO } from './src/main/ets/bean/component/GroupDTO'; | ||
| 50 | 50 | ||
| 51 | export { CompDTO } from './src/main/ets/bean/component/CompDTO'; | 51 | export { CompDTO } from './src/main/ets/bean/component/CompDTO'; |
| 52 | 52 | ||
| 53 | +export { LiveReviewDTO } from './src/main/ets/bean/component/LiveReviewDTO'; | ||
| 54 | + | ||
| 53 | export { NewspaperListBean } from './src/main/ets/bean/newspaper/NewspaperListBean'; | 55 | export { NewspaperListBean } from './src/main/ets/bean/newspaper/NewspaperListBean'; |
| 54 | 56 | ||
| 55 | export { NewspaperListItemBean } from './src/main/ets/bean/newspaper/NewspaperListItemBean'; | 57 | export { NewspaperListItemBean } from './src/main/ets/bean/newspaper/NewspaperListItemBean'; |
| 1 | import { CommonConstants, ViewType } from 'wdConstant'; | 1 | import { CommonConstants, ViewType } from 'wdConstant'; |
| 2 | -import { Logger, DateTimeUtils } from 'wdKit'; | 2 | +import { DateTimeUtils, Logger } from 'wdKit'; |
| 3 | import PageViewModel from '../../viewmodel/PageViewModel'; | 3 | import PageViewModel from '../../viewmodel/PageViewModel'; |
| 4 | import { EmptyComponent } from '../view/EmptyComponent'; | 4 | import { EmptyComponent } from '../view/EmptyComponent'; |
| 5 | import { ErrorComponent } from '../view/ErrorComponent'; | 5 | import { ErrorComponent } from '../view/ErrorComponent'; |
| @@ -11,7 +11,7 @@ import NoMoreLayout from './NoMoreLayout'; | @@ -11,7 +11,7 @@ import NoMoreLayout from './NoMoreLayout'; | ||
| 11 | import LoadMoreLayout from './LoadMoreLayout'; | 11 | import LoadMoreLayout from './LoadMoreLayout'; |
| 12 | import CustomRefreshLoadLayout from './CustomRefreshLoadLayout'; | 12 | import CustomRefreshLoadLayout from './CustomRefreshLoadLayout'; |
| 13 | import { CompParser } from '../CompParser'; | 13 | import { CompParser } from '../CompParser'; |
| 14 | -import { CompDTO } from 'wdBean'; | 14 | +import { CompDTO, LiveReviewDTO } from 'wdBean'; |
| 15 | 15 | ||
| 16 | const TAG = 'PageComponent'; | 16 | const TAG = 'PageComponent'; |
| 17 | 17 | ||
| @@ -21,6 +21,14 @@ export struct PageComponent { | @@ -21,6 +21,14 @@ export struct PageComponent { | ||
| 21 | navIndex: number = 0; | 21 | navIndex: number = 0; |
| 22 | pageId: string = ""; | 22 | pageId: string = ""; |
| 23 | channelId: string = ""; | 23 | channelId: string = ""; |
| 24 | + pageNum: number = 1; | ||
| 25 | + liveReviewDTO: LiveReviewDTO = { | ||
| 26 | + hasNext: false, | ||
| 27 | + pageNum: 0, | ||
| 28 | + pageSize: 0, | ||
| 29 | + totalCount: 0, | ||
| 30 | + list: [] | ||
| 31 | + }; | ||
| 24 | @Link @Watch('onChange') currentTopNavSelectedIndex: number | 32 | @Link @Watch('onChange') currentTopNavSelectedIndex: number |
| 25 | 33 | ||
| 26 | build() { | 34 | build() { |
| @@ -94,15 +102,20 @@ export struct PageComponent { | @@ -94,15 +102,20 @@ export struct PageComponent { | ||
| 94 | 102 | ||
| 95 | @Builder | 103 | @Builder |
| 96 | LoadingLayout() { | 104 | LoadingLayout() { |
| 97 | - CustomRefreshLoadLayout({ refreshBean: new RefreshLayoutBean(true, | ||
| 98 | - $r('app.media.ic_pull_up_load'), $r('app.string.pull_up_load_text'), this.pageModel.pullDownRefreshHeight) }) | 105 | + CustomRefreshLoadLayout({ |
| 106 | + refreshBean: new RefreshLayoutBean(true, | ||
| 107 | + $r('app.media.ic_pull_up_load'), $r('app.string.pull_up_load_text'), this.pageModel.pullDownRefreshHeight) | ||
| 108 | + }) | ||
| 99 | } | 109 | } |
| 100 | 110 | ||
| 101 | async aboutToAppear() { | 111 | async aboutToAppear() { |
| 102 | // 选中tab,才请求数据。拦截大量接口请求 | 112 | // 选中tab,才请求数据。拦截大量接口请求 |
| 103 | - if (this.navIndex === this.currentTopNavSelectedIndex) { | 113 | + if (this.navIndex === 0 && this.navIndex === this.currentTopNavSelectedIndex) { |
| 104 | this.getData(); | 114 | this.getData(); |
| 115 | + } else if (this.navIndex === 1) { | ||
| 116 | + this.getPreviewData() | ||
| 105 | } | 117 | } |
| 118 | + | ||
| 106 | } | 119 | } |
| 107 | 120 | ||
| 108 | onChange() { | 121 | onChange() { |
| @@ -140,6 +153,13 @@ export struct PageComponent { | @@ -140,6 +153,13 @@ export struct PageComponent { | ||
| 140 | Logger.debug(TAG, 'aboutToAppear, data response page ' + this.pageId + ', comp list is empty.'); | 153 | Logger.debug(TAG, 'aboutToAppear, data response page ' + this.pageId + ', comp list is empty.'); |
| 141 | this.pageModel.viewType = ViewType.EMPTY; | 154 | this.pageModel.viewType = ViewType.EMPTY; |
| 142 | } | 155 | } |
| 156 | + | ||
| 157 | + } | ||
| 158 | + | ||
| 159 | + async getPreviewData() { | ||
| 160 | + this.liveReviewDTO = await PageViewModel.getLiveReviewUrl(this.pageNum, this.pageModel.pageSize) | ||
| 161 | + Logger.debug(TAG, 'aboutToAppear, getPreviewData ' + this.liveReviewDTO.hasNext); | ||
| 162 | + this.getData(); | ||
| 143 | } | 163 | } |
| 144 | } | 164 | } |
| 145 | 165 |
| @@ -5,8 +5,10 @@ import { | @@ -5,8 +5,10 @@ import { | ||
| 5 | batchLikeAndCollectResult, | 5 | batchLikeAndCollectResult, |
| 6 | CompInfoBean, | 6 | CompInfoBean, |
| 7 | ContentDetailDTO, | 7 | ContentDetailDTO, |
| 8 | + ContentDTO, | ||
| 8 | contentListParams, | 9 | contentListParams, |
| 9 | InteractDataDTO, | 10 | InteractDataDTO, |
| 11 | + LiveReviewDTO, | ||
| 10 | MorningEveningPaperDTO, | 12 | MorningEveningPaperDTO, |
| 11 | NavigationBodyDTO, | 13 | NavigationBodyDTO, |
| 12 | NewspaperListBean, | 14 | NewspaperListBean, |
| @@ -18,8 +20,7 @@ import { | @@ -18,8 +20,7 @@ import { | ||
| 18 | postExecuteCollectRecordParams, | 20 | postExecuteCollectRecordParams, |
| 19 | postExecuteLikeParams, | 21 | postExecuteLikeParams, |
| 20 | postInteractAccentionOperateParams, | 22 | postInteractAccentionOperateParams, |
| 21 | - postRecommendListParams, | ||
| 22 | - ContentDTO | 23 | + postRecommendListParams |
| 23 | } from 'wdBean'; | 24 | } from 'wdBean'; |
| 24 | 25 | ||
| 25 | const TAG = 'HttpRequest'; | 26 | const TAG = 'HttpRequest'; |
| @@ -146,9 +147,9 @@ export class PageRepository { | @@ -146,9 +147,9 @@ export class PageRepository { | ||
| 146 | return url; | 147 | return url; |
| 147 | } | 148 | } |
| 148 | 149 | ||
| 149 | - static getLivePreviewUrl() { | ||
| 150 | - let url = HttpUrlUtils.getHost() + HttpUrlUtils.LIVE_REVIEW_PATH; | ||
| 151 | - Logger.info(TAG, "getLivePreviewUrl url = " + url) | 150 | + static getLiveReviewUrl(pageNum: number = 1, pageSize: number = 20) { |
| 151 | + let url = HttpUrlUtils.getHost() + HttpUrlUtils.LIVE_REVIEW_PATH + "?pageNum=" + pageNum + "&pageSize=" + pageSize; | ||
| 152 | + Logger.info(TAG, "getLiveReviewUrl url = " + url) | ||
| 152 | return url; | 153 | return url; |
| 153 | } | 154 | } |
| 154 | 155 | ||
| @@ -322,10 +323,10 @@ export class PageRepository { | @@ -322,10 +323,10 @@ export class PageRepository { | ||
| 322 | /** | 323 | /** |
| 323 | * 获取直播回顾双卡位数据 | 324 | * 获取直播回顾双卡位数据 |
| 324 | * */ | 325 | * */ |
| 325 | - static fetchLivePreviewUrl() { | ||
| 326 | - let url = PageRepository.getLivePreviewUrl() | 326 | + static fetchLiveReviewUrl(pageNum: number, pageSize: number) { |
| 327 | + let url = PageRepository.getLiveReviewUrl(pageNum, pageSize) | ||
| 327 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | 328 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); |
| 328 | - return WDHttp.get<ResponseDTO<PageInfoBean>>(url, headers) | 329 | + return WDHttp.get<ResponseDTO<LiveReviewDTO>>(url, headers) |
| 329 | }; | 330 | }; |
| 330 | 331 | ||
| 331 | /** | 332 | /** |
| @@ -334,7 +335,7 @@ export class PageRepository { | @@ -334,7 +335,7 @@ export class PageRepository { | ||
| 334 | * @param params | 335 | * @param params |
| 335 | * @returns | 336 | * @returns |
| 336 | * */ | 337 | * */ |
| 337 | - static postRecommendList(params:postRecommendListParams){ | 338 | + static postRecommendList(params: postRecommendListParams) { |
| 338 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.RECOMMEND_LIST | 339 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.RECOMMEND_LIST |
| 339 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | 340 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); |
| 340 | Logger.info(TAG, "postRecommendList url = " + url + JSON.stringify(params)) | 341 | Logger.info(TAG, "postRecommendList url = " + url + JSON.stringify(params)) |
| @@ -3,11 +3,12 @@ import { | @@ -3,11 +3,12 @@ import { | ||
| 3 | ContentBean, | 3 | ContentBean, |
| 4 | InteractDataDTO, | 4 | InteractDataDTO, |
| 5 | InteractParam, | 5 | InteractParam, |
| 6 | + LiveReviewDTO, | ||
| 6 | MorningEveningPaperDTO, | 7 | MorningEveningPaperDTO, |
| 7 | NavigationBodyDTO, | 8 | NavigationBodyDTO, |
| 8 | - PageDTO, | ||
| 9 | - PageInfoBean | 9 | + PageDTO |
| 10 | } from 'wdBean'; | 10 | } from 'wdBean'; |
| 11 | + | ||
| 11 | import { CollectionUtils, Logger, ResourcesUtils, StringUtils } from 'wdKit'; | 12 | import { CollectionUtils, Logger, ResourcesUtils, StringUtils } from 'wdKit'; |
| 12 | import { ResponseDTO, } from 'wdNetwork'; | 13 | import { ResponseDTO, } from 'wdNetwork'; |
| 13 | import { PageRepository } from '../repository/PageRepository'; | 14 | import { PageRepository } from '../repository/PageRepository'; |
| @@ -285,10 +286,10 @@ export class PageViewModel extends BaseViewModel { | @@ -285,10 +286,10 @@ export class PageViewModel extends BaseViewModel { | ||
| 285 | return param; | 286 | return param; |
| 286 | } | 287 | } |
| 287 | 288 | ||
| 288 | - async getLivePreviewUrl(): Promise<PageInfoBean> { | ||
| 289 | - return new Promise<PageInfoBean>((success, error) => { | 289 | + async getLiveReviewUrl(pageNum: number, pageSize: number): Promise<LiveReviewDTO> { |
| 290 | + return new Promise<LiveReviewDTO>((success, error) => { | ||
| 290 | Logger.info(TAG, `getLivePreviewUrl pageInfo start`); | 291 | Logger.info(TAG, `getLivePreviewUrl pageInfo start`); |
| 291 | - PageRepository.fetchLivePreviewUrl().then((resDTO: ResponseDTO<PageInfoBean>) => { | 292 | + PageRepository.fetchLiveReviewUrl(pageNum, pageSize).then((resDTO: ResponseDTO<LiveReviewDTO>) => { |
| 292 | if (!resDTO || !resDTO.data) { | 293 | if (!resDTO || !resDTO.data) { |
| 293 | Logger.error(TAG, 'getLivePreviewUrl then navResDTO is empty'); | 294 | Logger.error(TAG, 'getLivePreviewUrl then navResDTO is empty'); |
| 294 | error('resDTO is empty'); | 295 | error('resDTO is empty'); |
-
Please register or login to post a comment