Showing
7 changed files
with
271 additions
and
134 deletions
| 1 | -import { ContentDTO , Action,GoldenPositionExtraBean, CompDTO} from 'wdBean'; | ||
| 2 | -import { CommonConstants ,ViewType} from 'wdConstant'; | 1 | +import { Action, CompDTO, ContentDTO } from 'wdBean'; |
| 2 | +import { CommonConstants, ViewType } from 'wdConstant'; | ||
| 3 | import PageViewModel from '../../viewmodel/PageViewModel'; | 3 | import PageViewModel from '../../viewmodel/PageViewModel'; |
| 4 | import PageModel from '../../viewmodel/PageModel'; | 4 | import PageModel from '../../viewmodel/PageModel'; |
| 5 | -import { DateTimeUtils, LazyDataSource } from 'wdKit/Index'; | ||
| 6 | import router from '@ohos.router'; | 5 | import router from '@ohos.router'; |
| 7 | import { CardParser } from '../CardParser'; | 6 | import { CardParser } from '../CardParser'; |
| 8 | -import { channelSkeleton } from '../skeleton/channelSkeleton' | 7 | +import { channelSkeleton } from '../skeleton/channelSkeleton'; |
| 9 | import { ErrorComponent } from '../view/ErrorComponent'; | 8 | import { ErrorComponent } from '../view/ErrorComponent'; |
| 10 | import { EmptyComponent } from '../view/EmptyComponent'; | 9 | import { EmptyComponent } from '../view/EmptyComponent'; |
| 11 | import { listTouchEvent } from '../../utils/PullDownRefresh'; | 10 | import { listTouchEvent } from '../../utils/PullDownRefresh'; |
| @@ -14,13 +13,21 @@ import { RefreshLayoutBean } from '../refresh/RefreshLayoutBean'; | @@ -14,13 +13,21 @@ import { RefreshLayoutBean } from '../refresh/RefreshLayoutBean'; | ||
| 14 | import RefreshLayout from '../refresh/RefreshLayout'; | 13 | import RefreshLayout from '../refresh/RefreshLayout'; |
| 15 | import PageNoMoreLayout from './PageNoMoreLayout'; | 14 | import PageNoMoreLayout from './PageNoMoreLayout'; |
| 16 | import { NoMoreBean } from './NoMoreBean'; | 15 | import { NoMoreBean } from './NoMoreBean'; |
| 16 | +import CommonPageTitle from './CommonPageTitle'; | ||
| 17 | +import TemplatePageComponent from './template/TemplatePageComponent'; | ||
| 18 | +import { TemplatePageConstant } from './template/TemplatePageConstant'; | ||
| 17 | 19 | ||
| 18 | const TAG: string = 'ThemeListPage'; | 20 | const TAG: string = 'ThemeListPage'; |
| 19 | 21 | ||
| 22 | +/** | ||
| 23 | + * 金刚卡位聚合页 | ||
| 24 | + */ | ||
| 20 | @Entry | 25 | @Entry |
| 21 | @Component | 26 | @Component |
| 22 | struct ThemeListPage { | 27 | struct ThemeListPage { |
| 23 | - @State private pageModel: PageModel = new PageModel(); | 28 | + @State topSafeHeight: number = AppStorage.get<number>('topSafeHeight') as number; |
| 29 | + @State bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0 | ||
| 30 | + // @State private pageModel: PageModel = new PageModel(); | ||
| 24 | sort: number = 1; | 31 | sort: number = 1; |
| 25 | currentPage: number = 1; | 32 | currentPage: number = 1; |
| 26 | pageSize: number = 20; | 33 | pageSize: number = 20; |
| @@ -29,129 +36,27 @@ struct ThemeListPage { | @@ -29,129 +36,27 @@ struct ThemeListPage { | ||
| 29 | @State private pageAdvModel: PageAdModel = new PageAdModel(); | 36 | @State private pageAdvModel: PageAdModel = new PageAdModel(); |
| 30 | 37 | ||
| 31 | aboutToAppear(): void { | 38 | aboutToAppear(): void { |
| 32 | - let par:Action = router.getParams() as Action; | 39 | + let par: Action = router.getParams() as Action; |
| 33 | let params = par?.params; | 40 | let params = par?.params; |
| 34 | this.extra = params?.extra?.extra || ''; | 41 | this.extra = params?.extra?.extra || ''; |
| 35 | this.title = params?.extra?.title || ''; | 42 | this.title = params?.extra?.title || ''; |
| 36 | 43 | ||
| 37 | - this.pageModel.pageType = 1; | ||
| 38 | - this.pageModel.extra = this.extra; | ||
| 39 | - | ||
| 40 | - PageViewModel.postThemeList(this.currentPage, this.pageSize,this.extra).then((liveReviewDTO) => { | ||
| 41 | - console.log(`postThemeList${JSON.stringify(liveReviewDTO)}`) | ||
| 42 | - this.pageModel.compList.addItems(liveReviewDTO.list) | ||
| 43 | - if(this.pageModel.compList.getDataArray().length > 0){ | ||
| 44 | - this.pageModel.viewType = ViewType.LOADED; | ||
| 45 | - }else{ | ||
| 46 | - this.pageModel.viewType = ViewType.EMPTY | ||
| 47 | - } | ||
| 48 | - }) | ||
| 49 | } | 44 | } |
| 50 | 45 | ||
| 51 | build() { | 46 | build() { |
| 47 | + | ||
| 52 | Column() { | 48 | Column() { |
| 53 | - this.TabbarNormal() | ||
| 54 | - if (this.pageModel.viewType == ViewType.LOADING) { | ||
| 55 | - this.LoadingLayout() | ||
| 56 | - } else if (this.pageModel.viewType == ViewType.ERROR) { | ||
| 57 | - ErrorComponent() | ||
| 58 | - } else if (this.pageModel.viewType == ViewType.EMPTY) { | ||
| 59 | - EmptyComponent() | ||
| 60 | - } else { | ||
| 61 | - this.ListLayout() | ||
| 62 | - } | ||
| 63 | - } | ||
| 64 | - .padding({ | ||
| 65 | - bottom: $r('app.float.card_comp_pagePadding_tb') | ||
| 66 | - }) | ||
| 67 | - .onTouch((event: TouchEvent | undefined) => { | ||
| 68 | - if (event) { | ||
| 69 | - if (this.pageModel.viewType === ViewType.LOADED) { | ||
| 70 | - listTouchEvent(this.pageModel, this.pageAdvModel, event); | ||
| 71 | - } | ||
| 72 | - } | ||
| 73 | - }) | ||
| 74 | - } | ||
| 75 | - @Builder | ||
| 76 | - LoadingLayout() { | ||
| 77 | - channelSkeleton() | ||
| 78 | - } | ||
| 79 | - /*导航栏*/ | ||
| 80 | - @Builder | ||
| 81 | - TabbarNormal() { | ||
| 82 | - RelativeContainer() { | ||
| 83 | - //标题栏目 | ||
| 84 | - Image($r('app.media.icon_arrow_left')) | ||
| 85 | - .width(24) | ||
| 86 | - .height(24) | ||
| 87 | - .objectFit(ImageFit.Auto) | ||
| 88 | - .id("back_icon") | ||
| 89 | - .alignRules({ | ||
| 90 | - center: { anchor: "__container__", align: VerticalAlign.Center }, | ||
| 91 | - left: { anchor: "__container__", align: HorizontalAlign.Start } | ||
| 92 | - }) | ||
| 93 | - .onClick(() => { | ||
| 94 | - router.back() | ||
| 95 | - }) | ||
| 96 | 49 | ||
| 97 | - Text(this.title)// .height('42lpx') | ||
| 98 | - .maxLines(1) | ||
| 99 | - .id("title") | ||
| 100 | - .fontSize('35lpx') | ||
| 101 | - .fontWeight(400) | ||
| 102 | - .fontColor($r('app.color.color_222222')) | ||
| 103 | - .lineHeight('42lpx') | ||
| 104 | - .alignRules({ | ||
| 105 | - center: { anchor: "__container__", align: VerticalAlign.Center }, | ||
| 106 | - middle: { anchor: "__container__", align: HorizontalAlign.Center } | ||
| 107 | - }) | 50 | + //常见标题 |
| 51 | + CommonPageTitle({ title: this.title }) | ||
| 52 | + // 通用模板组件 | ||
| 53 | + TemplatePageComponent({ pageDataSourceType: TemplatePageConstant.THEME_LIST_PAGE, extra: this.extra }) | ||
| 108 | } | 54 | } |
| 109 | - .height(44) | ||
| 110 | - .width('100%') | 55 | + .height('100%') |
| 56 | + .backgroundColor(Color.White) | ||
| 111 | .padding({ | 57 | .padding({ |
| 112 | - left: $r('app.float.card_comp_pagePadding_lf'), | ||
| 113 | - right: $r('app.float.card_comp_pagePadding_lf'), | ||
| 114 | - }) | ||
| 115 | - } | ||
| 116 | - | ||
| 117 | - @Builder | ||
| 118 | - ListLayout() { | ||
| 119 | - List() { | ||
| 120 | - // 下拉刷新 | ||
| 121 | - ListItem() { | ||
| 122 | - RefreshLayout({ | ||
| 123 | - refreshBean: new RefreshLayoutBean(this.pageModel.isVisiblePullDown, this.pageModel.load, | ||
| 124 | - this.pageModel.offsetY) | ||
| 125 | - }) | ||
| 126 | - } | ||
| 127 | - | ||
| 128 | - LazyForEach(this.pageModel.compList, (contentDTO: ContentDTO, contentIndex: number) => { | ||
| 129 | - ListItem() { | ||
| 130 | - Column() { | ||
| 131 | - CardParser({compDTO:new CompDTO, contentDTO }); | ||
| 132 | - } | ||
| 133 | - } | ||
| 134 | - }, | ||
| 135 | - (contentDTO: ContentDTO, contentIndex: number) => contentDTO.pageId + contentIndex.toString() | ||
| 136 | - ) | ||
| 137 | - // 加载更多 | ||
| 138 | - ListItem() { | ||
| 139 | - if (this.pageModel.hasMore) { | ||
| 140 | - // LoadMoreLayout({ | ||
| 141 | - // refreshBean: new RefreshLayoutBean(this.pageModel.isVisiblePullUpLoad, this.pageModel.pullUpLoadImage, | ||
| 142 | - // this.pageModel.pullUpLoadText, this.pageModel.pullUpLoadHeight) | ||
| 143 | - // }) | ||
| 144 | - } else { | ||
| 145 | - PageNoMoreLayout({ noMoreBean: new NoMoreBean(this.pageModel.pageInfo.baselineCopywriting) }) | ||
| 146 | - } | ||
| 147 | - } | ||
| 148 | - } | ||
| 149 | - .scrollBar(BarState.Off) | ||
| 150 | - .cachedCount(8) | ||
| 151 | - .height(CommonConstants.FULL_PARENT) | ||
| 152 | - .onScrollIndex((start: number, end: number) => { | ||
| 153 | - this.pageModel.startIndex = start; | ||
| 154 | - this.pageModel.endIndex = end; | 58 | + top: px2vp(this.topSafeHeight), |
| 59 | + bottom: px2vp(this.bottomSafeHeight) | ||
| 155 | }) | 60 | }) |
| 156 | } | 61 | } |
| 157 | } | 62 | } |
| 1 | -import { CompDTO, ContentDTO, LiveRoomDataBean, ReserveBean, ReserveItemBean } from 'wdBean/Index' | ||
| 2 | -import { DateTimeUtils, Logger } from 'wdKit/Index' | ||
| 3 | -import { HttpUtils } from 'wdNetwork/Index' | 1 | +import { CompDTO, |
| 2 | + ContentBean, | ||
| 3 | + ContentDTO, | ||
| 4 | + InteractDataDTO, | ||
| 5 | + InteractParam, LiveRoomDataBean, ReserveBean, ReserveItemBean } from 'wdBean/Index' | ||
| 6 | +import { BaseDTO } from 'wdBean/src/main/ets/bean/component/BaseDTO' | ||
| 7 | +import { CollectionUtils, DateTimeUtils, LazyDataSource, Logger, StringUtils } from 'wdKit/Index' | ||
| 8 | +import { HttpUtils, ResponseDTO } from 'wdNetwork/Index' | ||
| 9 | +import { PageRepository } from '../../../repository/PageRepository' | ||
| 4 | import { LiveModel } from '../../../viewmodel/LiveModel' | 10 | import { LiveModel } from '../../../viewmodel/LiveModel' |
| 5 | import PageViewModel from '../../../viewmodel/PageViewModel' | 11 | import PageViewModel from '../../../viewmodel/PageViewModel' |
| 6 | 12 | ||
| @@ -64,7 +70,6 @@ export class BasePageHelp { | @@ -64,7 +70,6 @@ export class BasePageHelp { | ||
| 64 | * 请求获取直播房间的动态数据 | 70 | * 请求获取直播房间的动态数据 |
| 65 | * @param compList | 71 | * @param compList |
| 66 | */ | 72 | */ |
| 67 | - | ||
| 68 | getLiveRoomDataInfo(compList: CompDTO[]) { | 73 | getLiveRoomDataInfo(compList: CompDTO[]) { |
| 69 | 74 | ||
| 70 | let list: ContentDTO[] = [] | 75 | let list: ContentDTO[] = [] |
| @@ -110,4 +115,143 @@ export class BasePageHelp { | @@ -110,4 +115,143 @@ export class BasePageHelp { | ||
| 110 | }); | 115 | }); |
| 111 | return idList.join(',') | 116 | return idList.join(',') |
| 112 | } | 117 | } |
| 118 | + | ||
| 119 | +/** | ||
| 120 | + * 批查稿件的互动数据,如 评论人数等 | ||
| 121 | + * @param compList | ||
| 122 | + * @returns | ||
| 123 | + */ | ||
| 124 | + async getInteractData(compList: CompDTO[]) { | ||
| 125 | + let param: InteractParam = this.getInteractParams(compList); | ||
| 126 | + const SIZE = 20; | ||
| 127 | + // 批查接口,参数size限制20,这里截断分批查询,0,20;20,40... | ||
| 128 | + let count = Math.ceil(param.contentList.length / SIZE); | ||
| 129 | + let promises: Array<Promise<InteractDataDTO[]>> = new Array; | ||
| 130 | + if (count == 1) { | ||
| 131 | + let promise: Promise<InteractDataDTO[]> = this.createInteractDataPromise(param); | ||
| 132 | + promises.push(promise); | ||
| 133 | + } else { | ||
| 134 | + for (let i = 1; i <= count; i++) { | ||
| 135 | + // 将查询参数截断(参数限制20个),分批请求接口 | ||
| 136 | + let subList = new Array<ContentBean>(); | ||
| 137 | + let start = 0; | ||
| 138 | + let end = 0; | ||
| 139 | + if (i == count) { | ||
| 140 | + start = (i - 1) * SIZE; | ||
| 141 | + end = param.contentList.length; | ||
| 142 | + subList = CollectionUtils.getSubElements(param.contentList, start, end) | ||
| 143 | + } else { | ||
| 144 | + start = (i - 1) * SIZE; | ||
| 145 | + end = start + SIZE; | ||
| 146 | + subList = CollectionUtils.getSubElements(param.contentList, start, end) | ||
| 147 | + } | ||
| 148 | + let subParam: InteractParam = {} as InteractParam; | ||
| 149 | + subParam.contentList = subList; | ||
| 150 | + let promise: Promise<InteractDataDTO[]> = this.createInteractDataPromise(subParam); | ||
| 151 | + promises.push(promise); | ||
| 152 | + } | ||
| 153 | + } | ||
| 154 | + | ||
| 155 | + return new Promise<InteractDataDTO[]>((success, error) => { | ||
| 156 | + Promise.all(promises).then((result) => { | ||
| 157 | + if (!CollectionUtils.isArray(result)) { | ||
| 158 | + success(new Array<InteractDataDTO>()); | ||
| 159 | + return; | ||
| 160 | + } | ||
| 161 | + | ||
| 162 | + let allInteractDataList: Array<InteractDataDTO> = new Array(); | ||
| 163 | + result.forEach((value: InteractDataDTO[]) => { | ||
| 164 | + if (value != null && value.length > 0) { | ||
| 165 | + allInteractDataList.push(...value); | ||
| 166 | + } | ||
| 167 | + }) | ||
| 168 | + // 批查全部完成,统一设置到comp里 | ||
| 169 | + // this.resetInteract(allInteractDataList, compList); | ||
| 170 | + success(allInteractDataList); | ||
| 171 | + }) | ||
| 172 | + }) | ||
| 173 | + } | ||
| 174 | + | ||
| 175 | + private getInteractParams(compList: CompDTO[]): InteractParam { | ||
| 176 | + if (compList == null || compList.length == 0) { | ||
| 177 | + return {} as InteractParam; | ||
| 178 | + } | ||
| 179 | + | ||
| 180 | + let param: InteractParam = {} as InteractParam; | ||
| 181 | + param.contentList = new Array<ContentBean>(); | ||
| 182 | + compList.forEach((value) => { | ||
| 183 | + let contentList = value.operDataList; | ||
| 184 | + | ||
| 185 | + let letBatch = false | ||
| 186 | + // 只有稿件才能批查 | ||
| 187 | + if (!Number.isNaN(Number(value.compStyle))) { | ||
| 188 | + letBatch = true | ||
| 189 | + } | ||
| 190 | + | ||
| 191 | + if (letBatch) { | ||
| 192 | + if (contentList != null && contentList.length == 1) { // 对只有一条数据的稿件参与批查 | ||
| 193 | + contentList.forEach((v) => { | ||
| 194 | + if (StringUtils.isNotEmpty(v.objectId)) { | ||
| 195 | + let bean = {} as ContentBean; | ||
| 196 | + bean.contentId = v.objectId; | ||
| 197 | + bean.contentType = v.objectType; | ||
| 198 | + param.contentList.push(bean); | ||
| 199 | + } | ||
| 200 | + }) | ||
| 201 | + } | ||
| 202 | + } | ||
| 203 | + }) | ||
| 204 | + return param; | ||
| 205 | + } | ||
| 206 | + | ||
| 207 | + private createInteractDataPromise(param: InteractParam) { | ||
| 208 | + return new Promise<InteractDataDTO[]>((success, error) => { | ||
| 209 | + PageRepository.fetchInteractData(param).then((resDTO: ResponseDTO<InteractDataDTO[]>) => { | ||
| 210 | + if (!resDTO || !resDTO.data) { | ||
| 211 | + Logger.info(TAG, "getInteractData then,resDTO.timeStamp:" + resDTO.timestamp); | ||
| 212 | + success([]); | ||
| 213 | + return; | ||
| 214 | + } | ||
| 215 | + success(resDTO.data); | ||
| 216 | + }).catch((err: Error) => { | ||
| 217 | + Logger.error(TAG, `getInteractData catch, error.name : ${err.name}, error.message:${err.message}`); | ||
| 218 | + // 无论是否成功(暂不做重试),都回调结果,通知刷新数据 | ||
| 219 | + success([]); | ||
| 220 | + }) | ||
| 221 | + }); | ||
| 222 | + } | ||
| 223 | + | ||
| 224 | + /** | ||
| 225 | + * 刷新互动数据到compList | ||
| 226 | + * @param interact 批查互动数据结果 | ||
| 227 | + * @param compList comp list | ||
| 228 | + */ | ||
| 229 | + resetInteract(interact: InteractDataDTO[], compList: BaseDTO[]) { | ||
| 230 | + if (interact == null || interact.length == 0) { | ||
| 231 | + return | ||
| 232 | + } | ||
| 233 | + let time = DateTimeUtils.getTimeStamp().toString() | ||
| 234 | + interact.forEach((interactData) => { | ||
| 235 | + let id = interactData.contentId; | ||
| 236 | + outer: for (let i = 0; i < compList.length; i++) { | ||
| 237 | + let comp = compList[i] as CompDTO; | ||
| 238 | + if (comp == null || comp.operDataList == null || comp.operDataList.length == 0) { | ||
| 239 | + continue; | ||
| 240 | + } | ||
| 241 | + for (let j = 0; j < comp.operDataList.length; j++) { | ||
| 242 | + let content = comp.operDataList[j]; | ||
| 243 | + if (content == null) { | ||
| 244 | + continue; | ||
| 245 | + } | ||
| 246 | + if (id == content.objectId) { | ||
| 247 | + content.interactData = interactData; | ||
| 248 | + comp.timestamp = time | ||
| 249 | + break outer; | ||
| 250 | + } | ||
| 251 | + } | ||
| 252 | + } | ||
| 253 | + }) | ||
| 254 | + } | ||
| 255 | + | ||
| 256 | + | ||
| 113 | } | 257 | } |
| @@ -23,6 +23,7 @@ const TAG: string = 'TemplatePageComponent'; | @@ -23,6 +23,7 @@ const TAG: string = 'TemplatePageComponent'; | ||
| 23 | */ | 23 | */ |
| 24 | @Component | 24 | @Component |
| 25 | export default struct TemplatePageComponent { | 25 | export default struct TemplatePageComponent { |
| 26 | + | ||
| 26 | // 模板页面的数据驱动对象 | 27 | // 模板页面的数据驱动对象 |
| 27 | @State private templatePage: TemplatePageModel = new TemplatePageModel | 28 | @State private templatePage: TemplatePageModel = new TemplatePageModel |
| 28 | // 此内容主要因CustomPullToRefresh需要,目前没任何业务意义要求 | 29 | // 此内容主要因CustomPullToRefresh需要,目前没任何业务意义要求 |
| @@ -31,11 +32,14 @@ export default struct TemplatePageComponent { | @@ -31,11 +32,14 @@ export default struct TemplatePageComponent { | ||
| 31 | private templateScroller: Scroller = new Scroller() | 32 | private templateScroller: Scroller = new Scroller() |
| 32 | //识别不同页面的业务类型 | 33 | //识别不同页面的业务类型 |
| 33 | pageDataSourceType: string = '' | 34 | pageDataSourceType: string = '' |
| 35 | + | ||
| 34 | @State listColor: Resource = $r('app.color.color_fff') | 36 | @State listColor: Resource = $r('app.color.color_fff') |
| 35 | // 埋点字段 | 37 | // 埋点字段 |
| 36 | pageId: string = '' | 38 | pageId: string = '' |
| 37 | pageName: string = '' | 39 | pageName: string = '' |
| 38 | 40 | ||
| 41 | + extra: string = '' | ||
| 42 | + | ||
| 39 | async aboutToAppear() { | 43 | async aboutToAppear() { |
| 40 | Logger.debug(TAG, 'aboutToAppear') | 44 | Logger.debug(TAG, 'aboutToAppear') |
| 41 | this.requestPageData() | 45 | this.requestPageData() |
| @@ -81,8 +85,6 @@ export default struct TemplatePageComponent { | @@ -81,8 +85,6 @@ export default struct TemplatePageComponent { | ||
| 81 | if (this.templatePage.pageCompType === TemplatePageStateType.LOADING) { | 85 | if (this.templatePage.pageCompType === TemplatePageStateType.LOADING) { |
| 82 | this.LoadingLayout() | 86 | this.LoadingLayout() |
| 83 | } else if (this.templatePage.pageCompType === TemplatePageStateType.LOADED) { | 87 | } else if (this.templatePage.pageCompType === TemplatePageStateType.LOADED) { |
| 84 | - | ||
| 85 | - | ||
| 86 | CustomPullToRefresh({ | 88 | CustomPullToRefresh({ |
| 87 | alldata: this.pageData, | 89 | alldata: this.pageData, |
| 88 | scroller: this.templateScroller, | 90 | scroller: this.templateScroller, |
| @@ -167,6 +169,7 @@ export default struct TemplatePageComponent { | @@ -167,6 +169,7 @@ export default struct TemplatePageComponent { | ||
| 167 | } | 169 | } |
| 168 | 170 | ||
| 169 | this.templatePage.pageDataSourceType = this.pageDataSourceType | 171 | this.templatePage.pageDataSourceType = this.pageDataSourceType |
| 172 | + this.templatePage.extra = this.extra | ||
| 170 | 173 | ||
| 171 | TemplatePageHelp.requestPageData(this.templatePage) | 174 | TemplatePageHelp.requestPageData(this.templatePage) |
| 172 | } | 175 | } |
| @@ -18,4 +18,10 @@ export class TemplatePageConstant { | @@ -18,4 +18,10 @@ export class TemplatePageConstant { | ||
| 18 | public static LIVE_PORTEND_PAGE :string = 'live_portend_page' | 18 | public static LIVE_PORTEND_PAGE :string = 'live_portend_page' |
| 19 | 19 | ||
| 20 | 20 | ||
| 21 | + /** | ||
| 22 | + * 金刚卡位聚会页 | ||
| 23 | + */ | ||
| 24 | + public static THEME_LIST_PAGE :string = 'theme_list_page' | ||
| 25 | + | ||
| 26 | + | ||
| 21 | } | 27 | } |
| 1 | -import { CompDTO } from 'wdBean/Index'; | 1 | +import { CompDTO, InteractDataDTO } from 'wdBean/Index'; |
| 2 | import { CompStyle } from 'wdConstant/Index'; | 2 | import { CompStyle } from 'wdConstant/Index'; |
| 3 | import { DateTimeUtils, NetworkUtil } from 'wdKit/Index'; | 3 | import { DateTimeUtils, NetworkUtil } from 'wdKit/Index'; |
| 4 | import PageViewModel from '../../../viewmodel/PageViewModel'; | 4 | import PageViewModel from '../../../viewmodel/PageViewModel'; |
| @@ -40,8 +40,8 @@ export class TemplatePageHelp extends BasePageHelp { | @@ -40,8 +40,8 @@ export class TemplatePageHelp extends BasePageHelp { | ||
| 40 | // 加载缓存数据了,不用无网络提示 | 40 | // 加载缓存数据了,不用无网络提示 |
| 41 | } else { | 41 | } else { |
| 42 | // 无网情况 | 42 | // 无网情况 |
| 43 | - pageModel.pageCompType = TemplatePageStateType.OTHER; | ||
| 44 | - pageModel.noNormalState = WDViewDefaultType.WDViewDefaultType_NoNetwork | 43 | + this.pageModel.pageCompType = TemplatePageStateType.OTHER |
| 44 | + this.pageModel.noNormalState = WDViewDefaultType.WDViewDefaultType_NoNetwork | ||
| 45 | } | 45 | } |
| 46 | } | 46 | } |
| 47 | 47 | ||
| @@ -61,6 +61,9 @@ export class TemplatePageHelp extends BasePageHelp { | @@ -61,6 +61,9 @@ export class TemplatePageHelp extends BasePageHelp { | ||
| 61 | } else if (this.pageModel.pageDataSourceType === TemplatePageConstant.LIVE_PORTEND_PAGE) { | 61 | } else if (this.pageModel.pageDataSourceType === TemplatePageConstant.LIVE_PORTEND_PAGE) { |
| 62 | // 直播预告 | 62 | // 直播预告 |
| 63 | this.requestLivePortendData(this.pageModel.resolve) | 63 | this.requestLivePortendData(this.pageModel.resolve) |
| 64 | + } else if (this.pageModel.pageDataSourceType === TemplatePageConstant.THEME_LIST_PAGE) { | ||
| 65 | + // 金刚卡位聚合页 | ||
| 66 | + this.requestThemeListData(this.pageModel.resolve) | ||
| 64 | } | 67 | } |
| 65 | 68 | ||
| 66 | } | 69 | } |
| @@ -171,15 +174,80 @@ export class TemplatePageHelp extends BasePageHelp { | @@ -171,15 +174,80 @@ export class TemplatePageHelp extends BasePageHelp { | ||
| 171 | this.pageModel.isLoading = false | 174 | this.pageModel.isLoading = false |
| 172 | } | 175 | } |
| 173 | 176 | ||
| 177 | + | ||
| 178 | + /** | ||
| 179 | + * 请求金刚卡位聚合页数据 | ||
| 180 | + */ | ||
| 181 | + private async requestThemeListData(resolve?: (value: string | PromiseLike<string>) => void) { | ||
| 182 | + | ||
| 183 | + this.pageModel.isLoading = true | ||
| 184 | + | ||
| 185 | + const liveReviewDTO = | ||
| 186 | + await PageViewModel.postThemeList(this.pageModel.currentPage, this.pageModel.pageSize, this.pageModel.extra) | ||
| 187 | + | ||
| 188 | + if (liveReviewDTO && liveReviewDTO.list && liveReviewDTO.list.length > 0) { | ||
| 189 | + | ||
| 190 | + if (liveReviewDTO.list.length === this.pageModel.pageSize) { | ||
| 191 | + this.pageModel.hasMore = true | ||
| 192 | + } else { | ||
| 193 | + this.pageModel.hasMore = false | ||
| 194 | + } | ||
| 195 | + | ||
| 196 | + // 依据业务请求获取的数据,转换成compDTO数据 | ||
| 197 | + let time = DateTimeUtils.getTimeStamp().toString() | ||
| 198 | + let pageContentList: CompDTO[] = [] // 收集页面组件、稿件和本地组件容器 | ||
| 199 | + for (let contentDto of liveReviewDTO.list) { | ||
| 200 | + let compDTO: CompDTO = new CompDTO() | ||
| 201 | + compDTO.compType = 'appStyle' | ||
| 202 | + contentDto.appStyle = contentDto.appStyle | ||
| 203 | + if (this.pageModel.isEmitter) { | ||
| 204 | + contentDto.timestamp = time | ||
| 205 | + } | ||
| 206 | + compDTO.operDataList.push(contentDto) | ||
| 207 | + | ||
| 208 | + pageContentList.push(compDTO) | ||
| 209 | + } | ||
| 210 | + | ||
| 211 | + // 推送数据到懒加载机制 | ||
| 212 | + this.pushDataToPage(pageContentList) | ||
| 213 | + | ||
| 214 | + // 批查 | ||
| 215 | + this.allCompBatchRequest(pageContentList) | ||
| 216 | + | ||
| 217 | + | ||
| 218 | + } else { | ||
| 219 | + | ||
| 220 | + this.pageModel.hasMore = false | ||
| 221 | + if (this.pageModel.currentPage === 1) { | ||
| 222 | + // 无业务数据 | ||
| 223 | + this.pageNoHaveData() | ||
| 224 | + this.pageModel.pageCompType = TemplatePageStateType.OTHER | ||
| 225 | + this.pageModel.noNormalState = WDViewDefaultType.WDViewDefaultType_NoContent2 | ||
| 226 | + } | ||
| 227 | + } | ||
| 228 | + | ||
| 229 | + this.resolveEnd(resolve) | ||
| 230 | + | ||
| 231 | + // 完成业务请求加载 | ||
| 232 | + this.pageModel.isLoading = false | ||
| 233 | + } | ||
| 234 | + | ||
| 174 | /** | 235 | /** |
| 175 | * 处理页面批查业务方法 | 236 | * 处理页面批查业务方法 |
| 176 | * @param list | 237 | * @param list |
| 177 | */ | 238 | */ |
| 178 | private allCompBatchRequest(compList: CompDTO[]) { | 239 | private allCompBatchRequest(compList: CompDTO[]) { |
| 179 | 240 | ||
| 180 | - // 获取直播房间的动态数据 | 241 | + // 获取直播房间的动态数据 如直播观看人数 |
| 181 | this.getLiveRoomDataInfo(compList) | 242 | this.getLiveRoomDataInfo(compList) |
| 182 | 243 | ||
| 244 | + // 获取互动数据,如评论数量等 | ||
| 245 | + this.getInteractData(compList).then((data: InteractDataDTO[]) => { | ||
| 246 | + // 刷新,替换所有数据 | ||
| 247 | + this.resetInteract(data, compList) | ||
| 248 | + | ||
| 249 | + }) | ||
| 250 | + | ||
| 183 | } | 251 | } |
| 184 | 252 | ||
| 185 | 253 | ||
| @@ -207,9 +275,10 @@ export class TemplatePageHelp extends BasePageHelp { | @@ -207,9 +275,10 @@ export class TemplatePageHelp extends BasePageHelp { | ||
| 207 | */ | 275 | */ |
| 208 | private pageNoHaveData() { | 276 | private pageNoHaveData() { |
| 209 | this.pageModel.pageCompType = TemplatePageStateType.OTHER | 277 | this.pageModel.pageCompType = TemplatePageStateType.OTHER |
| 210 | - this.pageModel.noNormalState = WDViewDefaultType.WDViewDefaultType_NoNetwork | 278 | + this.pageModel.noNormalState = WDViewDefaultType.WDViewDefaultType_NoListContent |
| 211 | } | 279 | } |
| 212 | 280 | ||
| 281 | + | ||
| 213 | /** | 282 | /** |
| 214 | * 解析结束 | 283 | * 解析结束 |
| 215 | * @param resolve | 284 | * @param resolve |
| @@ -33,6 +33,9 @@ export default class TemplatePageModel { | @@ -33,6 +33,9 @@ export default class TemplatePageModel { | ||
| 33 | haveDataShow: boolean = false | 33 | haveDataShow: boolean = false |
| 34 | // 接收Emitter事件,需要刷新界面,此时就需要对展示业务进行驱动更新 | 34 | // 接收Emitter事件,需要刷新界面,此时就需要对展示业务进行驱动更新 |
| 35 | isEmitter: boolean = false | 35 | isEmitter: boolean = false |
| 36 | + | ||
| 37 | + // 扩展字段 | ||
| 38 | + extra :string = '' | ||
| 36 | /** | 39 | /** |
| 37 | * 此字段可驱动组件展示不同业务的组件, | 40 | * 此字段可驱动组件展示不同业务的组件, |
| 38 | */ | 41 | */ |
| @@ -41,5 +44,6 @@ export default class TemplatePageModel { | @@ -41,5 +44,6 @@ export default class TemplatePageModel { | ||
| 41 | * 异常状态 ——> 记录在获取数据中的不同状态,如无数据、无网络等情况 | 44 | * 异常状态 ——> 记录在获取数据中的不同状态,如无数据、无网络等情况 |
| 42 | */ | 45 | */ |
| 43 | noNormalState: WDViewDefaultType = WDViewDefaultType.WDViewDefaultType_Default | 46 | noNormalState: WDViewDefaultType = WDViewDefaultType.WDViewDefaultType_Default |
| 47 | + | ||
| 44 | resolve?: (value: string | PromiseLike<string>) => void | 48 | resolve?: (value: string | PromiseLike<string>) => void |
| 45 | } | 49 | } |
| @@ -296,22 +296,28 @@ export class PageViewModel extends BaseViewModel { | @@ -296,22 +296,28 @@ export class PageViewModel extends BaseViewModel { | ||
| 296 | }) | 296 | }) |
| 297 | }) | 297 | }) |
| 298 | } | 298 | } |
| 299 | - | ||
| 300 | - async postThemeList(pageNum: number, pageSize: number, extra: string): Promise<LiveReviewDTO> { | 299 | + /** |
| 300 | + * 金刚卡聚合页 | ||
| 301 | + * @param pageNum | ||
| 302 | + * @param pageSize | ||
| 303 | + * @param extra | ||
| 304 | + * @returns | ||
| 305 | + */ | ||
| 306 | + async postThemeList(pageNum: number, pageSize: number, extra: string): Promise<LiveReviewDTO | null> { | ||
| 301 | let bean: GoldenPositionExtraBean = JSON.parse(extra) | 307 | let bean: GoldenPositionExtraBean = JSON.parse(extra) |
| 302 | bean.pageNum = pageNum | 308 | bean.pageNum = pageNum |
| 303 | bean.pageSize = pageSize | 309 | bean.pageSize = pageSize |
| 304 | - return new Promise<LiveReviewDTO>((success, error) => { | 310 | + return new Promise<LiveReviewDTO| null>((success, error) => { |
| 305 | Logger.info(TAG, `postThemeList pageInfo start`); | 311 | Logger.info(TAG, `postThemeList pageInfo start`); |
| 306 | PageRepository.postThemeList(bean).then((resDTO) => { | 312 | PageRepository.postThemeList(bean).then((resDTO) => { |
| 307 | if (!resDTO || !resDTO.data) { | 313 | if (!resDTO || !resDTO.data) { |
| 308 | Logger.error(TAG, 'postThemeList then navResDTO is empty'); | 314 | Logger.error(TAG, 'postThemeList then navResDTO is empty'); |
| 309 | - error('resDTO is empty'); | 315 | + success(null); |
| 310 | return | 316 | return |
| 311 | } | 317 | } |
| 312 | if (resDTO.code != 0) { | 318 | if (resDTO.code != 0) { |
| 313 | Logger.error(TAG, `postThemeList then code:${resDTO.code}, message:${resDTO.message}`); | 319 | Logger.error(TAG, `postThemeList then code:${resDTO.code}, message:${resDTO.message}`); |
| 314 | - error('resDTO Response Code is failure'); | 320 | + success(null); |
| 315 | return | 321 | return |
| 316 | } | 322 | } |
| 317 | // let navResStr = JSON.stringify(navResDTO); | 323 | // let navResStr = JSON.stringify(navResDTO); |
| @@ -319,7 +325,7 @@ export class PageViewModel extends BaseViewModel { | @@ -319,7 +325,7 @@ export class PageViewModel extends BaseViewModel { | ||
| 319 | success(resDTO.data); | 325 | success(resDTO.data); |
| 320 | }).catch((err: Error) => { | 326 | }).catch((err: Error) => { |
| 321 | Logger.error(TAG, `postThemeList catch, error.name : ${err.name}, error.message:${err.message}`); | 327 | Logger.error(TAG, `postThemeList catch, error.name : ${err.name}, error.message:${err.message}`); |
| 322 | - error(err); | 328 | + success(null); |
| 323 | }) | 329 | }) |
| 324 | }) | 330 | }) |
| 325 | } | 331 | } |
-
Please register or login to post a comment