Showing
3 changed files
with
142 additions
and
19 deletions
| 1 | - | ||
| 2 | -import { Logger, DateTimeUtils, CollectionUtils } from 'wdKit'; | 1 | +import { CollectionUtils, DateTimeUtils, Logger } from 'wdKit'; |
| 3 | import { CommonConstants, CompStyle, ViewType } from 'wdConstant'; | 2 | import { CommonConstants, CompStyle, ViewType } from 'wdConstant'; |
| 4 | import PageViewModel from '../../viewmodel/PageViewModel'; | 3 | import PageViewModel from '../../viewmodel/PageViewModel'; |
| 5 | import { EmptyComponent } from '../view/EmptyComponent'; | 4 | import { EmptyComponent } from '../view/EmptyComponent'; |
| @@ -14,7 +13,7 @@ import CustomRefreshLoadLayout from './CustomRefreshLoadLayout'; | @@ -14,7 +13,7 @@ import CustomRefreshLoadLayout from './CustomRefreshLoadLayout'; | ||
| 14 | import { CompParser } from '../CompParser'; | 13 | import { CompParser } from '../CompParser'; |
| 15 | import { GroupInfoDTO } from 'wdBean/src/main/ets/bean/navigation/PageInfoDTO'; | 14 | import { GroupInfoDTO } from 'wdBean/src/main/ets/bean/navigation/PageInfoDTO'; |
| 16 | import { VideoChannelDetail } from 'wdDetailPlayShortVideo/Index'; | 15 | import { VideoChannelDetail } from 'wdDetailPlayShortVideo/Index'; |
| 17 | -import { CompDTO, LiveReviewDTO, PageDTO ,PageInfoDTO} from 'wdBean'; | 16 | +import { CompDTO, LiveReviewDTO, PageDTO, PageInfoBean } from 'wdBean'; |
| 18 | 17 | ||
| 19 | 18 | ||
| 20 | const TAG = 'PageComponent'; | 19 | const TAG = 'PageComponent'; |
| @@ -158,6 +157,16 @@ export struct PageComponent { | @@ -158,6 +157,16 @@ export struct PageComponent { | ||
| 158 | this.pageModel.viewType = ViewType.EMPTY; | 157 | this.pageModel.viewType = ViewType.EMPTY; |
| 159 | return; | 158 | return; |
| 160 | } | 159 | } |
| 160 | + if (this.navIndex === 0) { | ||
| 161 | + await this.getVideoListData(pageInfo); | ||
| 162 | + } else { | ||
| 163 | + await this.getLiveListData(pageInfo); | ||
| 164 | + } | ||
| 165 | + | ||
| 166 | + | ||
| 167 | + } | ||
| 168 | + | ||
| 169 | + private async getVideoListData(pageInfo: PageInfoBean) { | ||
| 161 | let groupInfo: GroupInfoDTO = CollectionUtils.getElement(pageInfo.groups, 0); | 170 | let groupInfo: GroupInfoDTO = CollectionUtils.getElement(pageInfo.groups, 0); |
| 162 | if (groupInfo != null) { | 171 | if (groupInfo != null) { |
| 163 | this.pageModel.isRecGroup = groupInfo.groupStrategy === 1; | 172 | this.pageModel.isRecGroup = groupInfo.groupStrategy === 1; |
| @@ -165,7 +174,89 @@ export struct PageComponent { | @@ -165,7 +174,89 @@ export struct PageComponent { | ||
| 165 | } | 174 | } |
| 166 | // pageInfo.groups.forEach(async (group) => { 不能按顺序加载用for...of替代 | 175 | // pageInfo.groups.forEach(async (group) => { 不能按顺序加载用for...of替代 |
| 167 | // for (const group of pageInfo.groups) { | 176 | // for (const group of pageInfo.groups) { |
| 168 | - this.pageDto = await PageViewModel.getPageData(this.pageModel, getContext(this)) | 177 | + this.pageDto = await PageViewModel.getPageData(this.pageModel, getContext(this)); |
| 178 | + this.pageModel.timestamp = DateTimeUtils.getTimeStamp().toString(); | ||
| 179 | + if (this.pageDto && this.pageDto.compList && this.pageDto.compList.length > 0) { | ||
| 180 | + this.pageDto.compList.forEach((comp) => { | ||
| 181 | + if (comp.compStyle === CompStyle.Zh_Grid_Layout_02 && this.liveReviewDTO && this.liveReviewDTO.list && this.liveReviewDTO.list.length > 0) { | ||
| 182 | + comp.operDataList.push(...this.liveReviewDTO.list); | ||
| 183 | + } | ||
| 184 | + }); | ||
| 185 | + | ||
| 186 | + this.pageModel.viewType = ViewType.LOADED; | ||
| 187 | + this.pageModel.compList.push(...this.pageDto.compList); | ||
| 188 | + if (this.pageDto.compList.length === this.pageModel.pageSize) { | ||
| 189 | + this.pageModel.currentPage++; | ||
| 190 | + this.pageModel.hasMore = true; | ||
| 191 | + } else { | ||
| 192 | + this.pageModel.hasMore = false; | ||
| 193 | + } | ||
| 194 | + // // 二次请求,批查互动数据 | ||
| 195 | + // PageViewModel.getInteractData(pageDto.compList).then((data: CompDTO[]) => { | ||
| 196 | + // // 刷新,替换所有数据 | ||
| 197 | + // this.pageModel.compList.replaceAll(...data) | ||
| 198 | + // this.pageModel.timestamp = DateTimeUtils.getTimeStamp().toString() | ||
| 199 | + // }) | ||
| 200 | + this.isFirstIn = false; | ||
| 201 | + Logger.debug(TAG, 'cj111'); | ||
| 202 | + // } else { | ||
| 203 | + // Logger.debug(TAG, 'aboutToAppear, data response page ' + this.pageId + ', comp list is empty.'); | ||
| 204 | + // this.pageModel.viewType = ViewType.EMPTY; | ||
| 205 | + // } | ||
| 206 | + } | ||
| 207 | + } | ||
| 208 | + | ||
| 209 | + // private async getLiveListData(pageInfo: PageInfoBean) { | ||
| 210 | + // // pageInfo.groups.forEach(async (group) => { 不能按顺序加载用for...of替代 | ||
| 211 | + // for (const group of pageInfo.groups) { | ||
| 212 | + // this.pageDto = await PageViewModel.getPageData(this.pageModel, getContext(this)); | ||
| 213 | + // this.pageModel.timestamp = DateTimeUtils.getTimeStamp().toString(); | ||
| 214 | + // if (this.pageDto && this.pageDto.compList && this.pageDto.compList.length > 0) { | ||
| 215 | + // this.pageDto.compList.forEach((comp) => { | ||
| 216 | + // if (comp.compStyle === CompStyle.Zh_Grid_Layout_02 && this.liveReviewDTO && this.liveReviewDTO.list && this.liveReviewDTO.list.length > 0) { | ||
| 217 | + // comp.operDataList.push(...this.liveReviewDTO.list); | ||
| 218 | + // } | ||
| 219 | + // }); | ||
| 220 | + // | ||
| 221 | + // this.pageModel.viewType = ViewType.LOADED; | ||
| 222 | + // this.pageModel.compList.push(...this.pageDto.compList); | ||
| 223 | + // if (this.pageDto.compList.length === this.pageModel.pageSize) { | ||
| 224 | + // this.pageModel.currentPage++; | ||
| 225 | + // this.pageModel.hasMore = true; | ||
| 226 | + // } else { | ||
| 227 | + // this.pageModel.hasMore = false; | ||
| 228 | + // } | ||
| 229 | + // // // 二次请求,批查互动数据 | ||
| 230 | + // // PageViewModel.getInteractData(pageDto.compList).then((data: CompDTO[]) => { | ||
| 231 | + // // // 刷新,替换所有数据 | ||
| 232 | + // // this.pageModel.compList.replaceAll(...data) | ||
| 233 | + // // this.pageModel.timestamp = DateTimeUtils.getTimeStamp().toString() | ||
| 234 | + // // }) | ||
| 235 | + // this.isFirstIn = false; | ||
| 236 | + // Logger.debug(TAG, 'cj111'); | ||
| 237 | + // // } else { | ||
| 238 | + // // Logger.debug(TAG, 'aboutToAppear, data response page ' + this.pageId + ', comp list is empty.'); | ||
| 239 | + // // this.pageModel.viewType = ViewType.EMPTY; | ||
| 240 | + // } | ||
| 241 | + // } | ||
| 242 | + // } | ||
| 243 | + | ||
| 244 | + async getLiveListData(pageInfo: PageInfoBean) { | ||
| 245 | + // Logger.info(TAG, `getData id: ${this.pageId} , ${this.channelId} , navIndex: ${this.currentTopNavSelectedIndex}`); | ||
| 246 | + // this.pageModel.pageId = this.pageId; | ||
| 247 | + // this.pageModel.groupId = this.pageId; | ||
| 248 | + // this.pageModel.channelId = this.channelId; | ||
| 249 | + // this.pageModel.currentPage = 1; | ||
| 250 | + // let pageInfo = await PageViewModel.getPageUrlData(this.pageModel.pageId); | ||
| 251 | + // if (pageInfo == null) { | ||
| 252 | + // this.pageModel.viewType = ViewType.EMPTY; | ||
| 253 | + // return; | ||
| 254 | + // } | ||
| 255 | + Logger.debug(TAG, 'getPageUrlData ' + pageInfo.id); | ||
| 256 | + // pageInfo.groups.forEach(async (group) => { 不能按顺序加载用for...of替代 | ||
| 257 | + for (const group of pageInfo.groups) { | ||
| 258 | + this.pageDto = await PageViewModel.getLivePageData(this.pageModel.pageId, `${group.id}`, this.pageModel.channelId, group.groupStrategy | ||
| 259 | + , this.pageModel.currentPage, this.pageModel.pageSize, getContext(this)) | ||
| 169 | this.pageModel.timestamp = DateTimeUtils.getTimeStamp().toString() | 260 | this.pageModel.timestamp = DateTimeUtils.getTimeStamp().toString() |
| 170 | if (this.pageDto && this.pageDto.compList && this.pageDto.compList.length > 0) { | 261 | if (this.pageDto && this.pageDto.compList && this.pageDto.compList.length > 0) { |
| 171 | this.pageDto.compList.forEach((comp) => { | 262 | this.pageDto.compList.forEach((comp) => { |
| @@ -189,12 +280,11 @@ export struct PageComponent { | @@ -189,12 +280,11 @@ export struct PageComponent { | ||
| 189 | this.pageModel.timestamp = DateTimeUtils.getTimeStamp().toString() | 280 | this.pageModel.timestamp = DateTimeUtils.getTimeStamp().toString() |
| 190 | }) | 281 | }) |
| 191 | this.isFirstIn = false | 282 | this.isFirstIn = false |
| 192 | - // } else { | ||
| 193 | - // Logger.debug(TAG, 'aboutToAppear, data response page ' + this.pageId + ', comp list is empty.'); | ||
| 194 | - // this.pageModel.viewType = ViewType.EMPTY; | ||
| 195 | - // } | 283 | + } else { |
| 284 | + Logger.debug(TAG, 'aboutToAppear, data response page ' + this.pageId + ', comp list is empty.'); | ||
| 285 | + this.pageModel.viewType = ViewType.EMPTY; | ||
| 286 | + } | ||
| 196 | } | 287 | } |
| 197 | - | ||
| 198 | } | 288 | } |
| 199 | 289 | ||
| 200 | async getPreviewData() { | 290 | async getPreviewData() { |
| @@ -6,6 +6,7 @@ import { | @@ -6,6 +6,7 @@ import { | ||
| 6 | CompInfoBean, | 6 | CompInfoBean, |
| 7 | ContentDetailDTO, | 7 | ContentDetailDTO, |
| 8 | ContentDTO, | 8 | ContentDTO, |
| 9 | + contentListParams, | ||
| 9 | InteractDataDTO, | 10 | InteractDataDTO, |
| 10 | LiveReviewDTO, | 11 | LiveReviewDTO, |
| 11 | MorningEveningPaperDTO, | 12 | MorningEveningPaperDTO, |
| @@ -14,11 +15,10 @@ import { | @@ -14,11 +15,10 @@ import { | ||
| 14 | NewspaperTimeInfoBean, | 15 | NewspaperTimeInfoBean, |
| 15 | PageDTO, | 16 | PageDTO, |
| 16 | PageInfoBean, | 17 | PageInfoBean, |
| 18 | + PageInfoDTO, | ||
| 17 | postBatchAttentionStatusParams, | 19 | postBatchAttentionStatusParams, |
| 18 | postBatchAttentionStatusResult, | 20 | postBatchAttentionStatusResult, |
| 19 | postExecuteCollectRecordParams, | 21 | postExecuteCollectRecordParams, |
| 20 | - contentListParams, | ||
| 21 | - PageInfoDTO, | ||
| 22 | postExecuteLikeParams, | 22 | postExecuteLikeParams, |
| 23 | postInteractAccentionOperateParams, | 23 | postInteractAccentionOperateParams, |
| 24 | postRecommendListParams | 24 | postRecommendListParams |
| @@ -48,10 +48,10 @@ export class PageRepository { | @@ -48,10 +48,10 @@ export class PageRepository { | ||
| 48 | 48 | ||
| 49 | static getCompInfoUrl(pageId: string, groupId: string, channelId: string, groupStrategy: number, currentPage: number, pageSize: number) { | 49 | static getCompInfoUrl(pageId: string, groupId: string, channelId: string, groupStrategy: number, currentPage: number, pageSize: number) { |
| 50 | let url = HttpUrlUtils.getHost(); | 50 | let url = HttpUrlUtils.getHost(); |
| 51 | - if(1 == groupStrategy){ | 51 | + if (1 == groupStrategy) { |
| 52 | //推荐 | 52 | //推荐 |
| 53 | url = url + HttpUrlUtils.COMP_REC_PATH; | 53 | url = url + HttpUrlUtils.COMP_REC_PATH; |
| 54 | - }else{ | 54 | + } else { |
| 55 | //非推荐 | 55 | //非推荐 |
| 56 | url = url + HttpUrlUtils.COMP_PATH; | 56 | url = url + HttpUrlUtils.COMP_PATH; |
| 57 | } | 57 | } |
| @@ -194,8 +194,14 @@ export class PageRepository { | @@ -194,8 +194,14 @@ export class PageRepository { | ||
| 194 | return WDHttp.get<ResponseDTO<PageInfoDTO>>(url, headers) | 194 | return WDHttp.get<ResponseDTO<PageInfoDTO>>(url, headers) |
| 195 | }; | 195 | }; |
| 196 | 196 | ||
| 197 | - static fetchCompData(pageId: string, groupId: string, channelId: string,groupStrategy:number, currentPage: number, pageSize: number) { | ||
| 198 | - let url = PageRepository.getCompInfoUrl(pageId, groupId, channelId,groupStrategy, currentPage, pageSize) | 197 | + static fetchLivePageData(pageId: string, groupId: string, channelId: string, groupStrategy: number, currentPage: number, pageSize: number) { |
| 198 | + let url = PageRepository.getCompInfoUrl(pageId, groupId, channelId, groupStrategy, currentPage, pageSize) | ||
| 199 | + let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | ||
| 200 | + return WDHttp.get<ResponseDTO<PageDTO>>(url, headers) | ||
| 201 | + }; | ||
| 202 | + | ||
| 203 | + static fetchCompData(pageId: string, groupId: string, channelId: string, groupStrategy: number, currentPage: number, pageSize: number) { | ||
| 204 | + let url = PageRepository.getCompInfoUrl(pageId, groupId, channelId, groupStrategy, currentPage, pageSize) | ||
| 199 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | 205 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); |
| 200 | return WDHttp.get<ResponseDTO<PageDTO>>(url, headers) | 206 | return WDHttp.get<ResponseDTO<PageDTO>>(url, headers) |
| 201 | }; | 207 | }; |
| @@ -7,11 +7,9 @@ import { | @@ -7,11 +7,9 @@ import { | ||
| 7 | MorningEveningPaperDTO, | 7 | MorningEveningPaperDTO, |
| 8 | NavigationBodyDTO, | 8 | NavigationBodyDTO, |
| 9 | PageDTO, | 9 | PageDTO, |
| 10 | - PageInfoBean, | ||
| 11 | - PageInfoDTO | 10 | + PageInfoBean |
| 12 | } from 'wdBean'; | 11 | } from 'wdBean'; |
| 13 | 12 | ||
| 14 | - | ||
| 15 | import { CollectionUtils, Logger, ResourcesUtils, StringUtils } from 'wdKit'; | 13 | import { CollectionUtils, Logger, ResourcesUtils, StringUtils } from 'wdKit'; |
| 16 | import { ResponseDTO, } from 'wdNetwork'; | 14 | import { ResponseDTO, } from 'wdNetwork'; |
| 17 | import { PageRepository } from '../repository/PageRepository'; | 15 | import { PageRepository } from '../repository/PageRepository'; |
| @@ -145,7 +143,36 @@ export class PageViewModel extends BaseViewModel { | @@ -145,7 +143,36 @@ export class PageViewModel extends BaseViewModel { | ||
| 145 | 143 | ||
| 146 | async getPageData(pageModel: PageModel, context?: Context): Promise<PageDTO> { | 144 | async getPageData(pageModel: PageModel, context?: Context): Promise<PageDTO> { |
| 147 | Logger.debug(TAG, 'getPageData pageId: ' + pageModel.pageId); | 145 | Logger.debug(TAG, 'getPageData pageId: ' + pageModel.pageId); |
| 148 | - return this.parseComp(PageRepository.fetchCompData(pageModel.pageId, pageModel.groupId, pageModel.channelId, pageModel.isRecGroup==true?1:0,pageModel.currentPage, pageModel.pageSize)) | 146 | + return this.parseComp(PageRepository.fetchCompData(pageModel.pageId, pageModel.groupId, pageModel.channelId, pageModel.isRecGroup == true ? 1 : 0, pageModel.currentPage, pageModel.pageSize)) |
| 147 | + } | ||
| 148 | + | ||
| 149 | + async getLivePageData(pageId: string, groupId: string, channelId: string, groupStrategy: number, currentPage: number | ||
| 150 | + , pageSize: number, context: Context): Promise<PageDTO> { | ||
| 151 | + Logger.debug(TAG, 'getPageData pageId: ' + pageId); | ||
| 152 | + if (mock_switch) { | ||
| 153 | + return this.getPageData1(currentPage, context); | ||
| 154 | + } | ||
| 155 | + return new Promise<PageDTO>((success, error) => { | ||
| 156 | + PageRepository.fetchLivePageData(pageId, groupId, channelId, groupStrategy, currentPage, pageSize) | ||
| 157 | + .then((resDTO: ResponseDTO<PageDTO>) => { | ||
| 158 | + if (!resDTO || !resDTO.data) { | ||
| 159 | + Logger.error(TAG, 'getNavData then resDTO is empty'); | ||
| 160 | + error('resDTO is empty'); | ||
| 161 | + return | ||
| 162 | + } | ||
| 163 | + if (resDTO.code != 0) { | ||
| 164 | + Logger.error(TAG, `getNavData then code:${resDTO.code}, message:${resDTO.message}`); | ||
| 165 | + error('resDTO Response Code is failure'); | ||
| 166 | + return | ||
| 167 | + } | ||
| 168 | + Logger.info(TAG, "getNavData then,resDTO.timestamp:" + resDTO.timestamp); | ||
| 169 | + success(resDTO.data); | ||
| 170 | + }) | ||
| 171 | + .catch((err: Error) => { | ||
| 172 | + Logger.error(TAG, `getPageData catch, error.name : ${err.name}, error.message:${err.message}`); | ||
| 173 | + error(err); | ||
| 174 | + }) | ||
| 175 | + }) | ||
| 149 | } | 176 | } |
| 150 | 177 | ||
| 151 | private parseComp(getData: Promise<ResponseDTO<PageDTO>>): Promise<PageDTO> { | 178 | private parseComp(getData: Promise<ResponseDTO<PageDTO>>): Promise<PageDTO> { |
-
Please register or login to post a comment