Showing
10 changed files
with
350 additions
and
247 deletions
| @@ -29,4 +29,9 @@ export interface CompDTO { | @@ -29,4 +29,9 @@ export interface CompDTO { | ||
| 29 | subType: string; | 29 | subType: string; |
| 30 | imageScale: number; // 封面图比例 1-4:3, 2-16:9, 3-3:2 | 30 | imageScale: number; // 封面图比例 1-4:3, 2-16:9, 3-3:2 |
| 31 | audioDataList: AudioDTO[]; | 31 | audioDataList: AudioDTO[]; |
| 32 | + | ||
| 33 | + /** | ||
| 34 | + * 组件内容源类型 (LIVE_HORIZONTAL_CARD\LIVE_RESERVATION\LIVE_LARGE_CARD\LIVE_END\LIVE_MONTHLY_RANKING ) | ||
| 35 | + */ | ||
| 36 | + dataSourceType: string; | ||
| 32 | } | 37 | } |
| @@ -2,6 +2,7 @@ import { CompDTO } from './CompDTO'; | @@ -2,6 +2,7 @@ import { CompDTO } from './CompDTO'; | ||
| 2 | 2 | ||
| 3 | /** | 3 | /** |
| 4 | * Page数据DTO | 4 | * Page数据DTO |
| 5 | + * 其实是comp接口(display/zh/c/compInfo)返回 | ||
| 5 | */ | 6 | */ |
| 6 | export interface PageDTO { | 7 | export interface PageDTO { |
| 7 | pageId: string; // 页面id | 8 | pageId: string; // 页面id |
| 1 | -import { CollectionUtils, DateTimeUtils, Logger } from 'wdKit'; | ||
| 2 | -import { CommonConstants, CompStyle, ViewType } from 'wdConstant'; | 1 | +import { CommonConstants, ViewType } from 'wdConstant'; |
| 2 | +import { 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,9 +11,8 @@ import NoMoreLayout from './NoMoreLayout'; | @@ -11,9 +11,8 @@ 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 { GroupInfoDTO } from 'wdBean/src/main/ets/bean/navigation/PageInfoDTO'; | ||
| 15 | -import { CompDTO, LiveReviewDTO, PageDTO, PageInfoBean } from 'wdBean'; | ||
| 16 | - | 14 | +import { CompDTO } from 'wdBean'; |
| 15 | +import PageHelper from '../../viewmodel/PageHelper'; | ||
| 17 | 16 | ||
| 18 | const TAG = 'PageComponent'; | 17 | const TAG = 'PageComponent'; |
| 19 | 18 | ||
| @@ -23,22 +22,6 @@ export struct PageComponent { | @@ -23,22 +22,6 @@ export struct PageComponent { | ||
| 23 | navIndex: number = 0; | 22 | navIndex: number = 0; |
| 24 | pageId: string = ""; | 23 | pageId: string = ""; |
| 25 | channelId: string = ""; | 24 | channelId: string = ""; |
| 26 | - pageNum: number = 1; | ||
| 27 | - isFirstIn: boolean = true | ||
| 28 | - pageDto: PageDTO = { | ||
| 29 | - pageId: '', | ||
| 30 | - id: 0, | ||
| 31 | - name: '', | ||
| 32 | - branchMark: false, | ||
| 33 | - compList: [] | ||
| 34 | - } | ||
| 35 | - liveReviewDTO: LiveReviewDTO = { | ||
| 36 | - hasNext: false, | ||
| 37 | - pageNum: 0, | ||
| 38 | - pageSize: 0, | ||
| 39 | - totalCount: 0, | ||
| 40 | - list: [] | ||
| 41 | - }; | ||
| 42 | @Link @Watch('onChange') currentTopNavSelectedIndex: number | 25 | @Link @Watch('onChange') currentTopNavSelectedIndex: number |
| 43 | 26 | ||
| 44 | build() { | 27 | build() { |
| @@ -69,7 +52,6 @@ export struct PageComponent { | @@ -69,7 +52,6 @@ export struct PageComponent { | ||
| 69 | @Builder | 52 | @Builder |
| 70 | ListLayout() { | 53 | ListLayout() { |
| 71 | List() { | 54 | List() { |
| 72 | - | ||
| 73 | // 下拉刷新 | 55 | // 下拉刷新 |
| 74 | ListItem() { | 56 | ListItem() { |
| 75 | RefreshLayout({ | 57 | RefreshLayout({ |
| @@ -99,7 +81,6 @@ export struct PageComponent { | @@ -99,7 +81,6 @@ export struct PageComponent { | ||
| 99 | NoMoreLayout() | 81 | NoMoreLayout() |
| 100 | } | 82 | } |
| 101 | } | 83 | } |
| 102 | - | ||
| 103 | } | 84 | } |
| 104 | .scrollBar(BarState.Off) | 85 | .scrollBar(BarState.Off) |
| 105 | .cachedCount(8) | 86 | .cachedCount(8) |
| @@ -122,171 +103,32 @@ export struct PageComponent { | @@ -122,171 +103,32 @@ export struct PageComponent { | ||
| 122 | 103 | ||
| 123 | async aboutToAppear() { | 104 | async aboutToAppear() { |
| 124 | // 选中tab,才请求数据。拦截大量接口请求 | 105 | // 选中tab,才请求数据。拦截大量接口请求 |
| 125 | - if (this.navIndex === 0 && this.navIndex === this.currentTopNavSelectedIndex) { | 106 | + if (this.navIndex === this.currentTopNavSelectedIndex) { |
| 126 | this.getData(); | 107 | this.getData(); |
| 127 | - } else if (this.navIndex === 1) { | ||
| 128 | - this.getPreviewData() | ||
| 129 | } | 108 | } |
| 130 | - | ||
| 131 | } | 109 | } |
| 132 | 110 | ||
| 133 | onChange() { | 111 | onChange() { |
| 134 | - Logger.info(TAG, `onChangezz id: ${this.pageId} , ${this.channelId} , ${this.navIndex} , ${this.isFirstIn} , navIndex: ${this.currentTopNavSelectedIndex}`); | ||
| 135 | - // if (this.navIndex === this.currentTopNavSelectedIndex && !this.isFirstIn) { | 112 | + Logger.info(TAG, `onChangezz id: ${this.pageId} , ${this.channelId} , ${this.navIndex} , navIndex: ${this.currentTopNavSelectedIndex}`); |
| 136 | if (this.navIndex === this.currentTopNavSelectedIndex) { | 113 | if (this.navIndex === this.currentTopNavSelectedIndex) { |
| 137 | this.getData(); | 114 | this.getData(); |
| 138 | } | 115 | } |
| 139 | } | 116 | } |
| 140 | 117 | ||
| 141 | - /** | ||
| 142 | - * 要按顺序处理pageInfo.groups中的每个元素,并确保每个异步操作完成后再继续执行下一个,你应该避免使用forEach。 | ||
| 143 | - * 取而代之的是,你可以使用for...of循环,并配合async/await来确保按顺序执行操作。 | ||
| 144 | - * */ | ||
| 145 | async getData() { | 118 | async getData() { |
| 146 | Logger.info(TAG, `getData id: ${this.pageId} , ${this.channelId} , navIndex: ${this.currentTopNavSelectedIndex}`); | 119 | Logger.info(TAG, `getData id: ${this.pageId} , ${this.channelId} , navIndex: ${this.currentTopNavSelectedIndex}`); |
| 147 | this.pageModel.pageId = this.pageId; | 120 | this.pageModel.pageId = this.pageId; |
| 148 | this.pageModel.groupId = this.pageId; | 121 | this.pageModel.groupId = this.pageId; |
| 149 | this.pageModel.channelId = this.channelId; | 122 | this.pageModel.channelId = this.channelId; |
| 150 | this.pageModel.currentPage = 1; | 123 | this.pageModel.currentPage = 1; |
| 151 | - let pageInfo = await PageViewModel.getPageUrlData(this.pageModel.pageId); | 124 | + let pageInfo = await PageViewModel.getPageInfo(this.pageModel.pageId); |
| 152 | if (pageInfo == null) { | 125 | if (pageInfo == null) { |
| 153 | this.pageModel.viewType = ViewType.EMPTY; | 126 | this.pageModel.viewType = ViewType.EMPTY; |
| 154 | return; | 127 | return; |
| 155 | } | 128 | } |
| 156 | - if (this.navIndex === 0) { | ||
| 157 | - await this.getVideoListData(pageInfo); | ||
| 158 | - } else { | ||
| 159 | - await this.getLiveListData(pageInfo); | ||
| 160 | - } | ||
| 161 | - | ||
| 162 | - | ||
| 163 | - } | ||
| 164 | - | ||
| 165 | - private async getVideoListData(pageInfo: PageInfoBean) { | ||
| 166 | - let groupInfo: GroupInfoDTO = CollectionUtils.getElement(pageInfo.groups, 0); | ||
| 167 | - if (groupInfo != null) { | ||
| 168 | - this.pageModel.isRecGroup = groupInfo.groupStrategy === 1; | ||
| 169 | - this.pageModel.groupId = groupInfo.id; | ||
| 170 | - } | ||
| 171 | - // pageInfo.groups.forEach(async (group) => { 不能按顺序加载用for...of替代 | ||
| 172 | - // for (const group of pageInfo.groups) { | ||
| 173 | - this.pageDto = await PageViewModel.getPageData(this.pageModel, getContext(this)); | ||
| 174 | - this.pageModel.timestamp = DateTimeUtils.getTimeStamp().toString(); | ||
| 175 | - if (this.pageDto && this.pageDto.compList && this.pageDto.compList.length > 0) { | ||
| 176 | - this.pageDto.compList.forEach((comp) => { | ||
| 177 | - if (comp.compStyle === CompStyle.Zh_Grid_Layout_02 && this.liveReviewDTO && this.liveReviewDTO.list && this.liveReviewDTO.list.length > 0) { | ||
| 178 | - comp.operDataList.push(...this.liveReviewDTO.list); | ||
| 179 | - } | ||
| 180 | - }); | ||
| 181 | - | ||
| 182 | - this.pageModel.viewType = ViewType.LOADED; | ||
| 183 | - this.pageModel.compList.push(...this.pageDto.compList); | ||
| 184 | - if (this.pageDto.compList.length === this.pageModel.pageSize) { | ||
| 185 | - this.pageModel.currentPage++; | ||
| 186 | - this.pageModel.hasMore = true; | ||
| 187 | - } else { | ||
| 188 | - this.pageModel.hasMore = false; | ||
| 189 | - } | ||
| 190 | - // // 二次请求,批查互动数据 | ||
| 191 | - // PageViewModel.getInteractData(pageDto.compList).then((data: CompDTO[]) => { | ||
| 192 | - // // 刷新,替换所有数据 | ||
| 193 | - // this.pageModel.compList.replaceAll(...data) | ||
| 194 | - // this.pageModel.timestamp = DateTimeUtils.getTimeStamp().toString() | ||
| 195 | - // }) | ||
| 196 | - this.isFirstIn = false; | ||
| 197 | - Logger.debug(TAG, 'cj111'); | ||
| 198 | - // } else { | ||
| 199 | - // Logger.debug(TAG, 'aboutToAppear, data response page ' + this.pageId + ', comp list is empty.'); | ||
| 200 | - // this.pageModel.viewType = ViewType.EMPTY; | ||
| 201 | - // } | ||
| 202 | - } | ||
| 203 | - } | ||
| 204 | - | ||
| 205 | - // private async getLiveListData(pageInfo: PageInfoBean) { | ||
| 206 | - // // pageInfo.groups.forEach(async (group) => { 不能按顺序加载用for...of替代 | ||
| 207 | - // for (const group of pageInfo.groups) { | ||
| 208 | - // this.pageDto = await PageViewModel.getPageData(this.pageModel, getContext(this)); | ||
| 209 | - // this.pageModel.timestamp = DateTimeUtils.getTimeStamp().toString(); | ||
| 210 | - // if (this.pageDto && this.pageDto.compList && this.pageDto.compList.length > 0) { | ||
| 211 | - // this.pageDto.compList.forEach((comp) => { | ||
| 212 | - // if (comp.compStyle === CompStyle.Zh_Grid_Layout_02 && this.liveReviewDTO && this.liveReviewDTO.list && this.liveReviewDTO.list.length > 0) { | ||
| 213 | - // comp.operDataList.push(...this.liveReviewDTO.list); | ||
| 214 | - // } | ||
| 215 | - // }); | ||
| 216 | - // | ||
| 217 | - // this.pageModel.viewType = ViewType.LOADED; | ||
| 218 | - // this.pageModel.compList.push(...this.pageDto.compList); | ||
| 219 | - // if (this.pageDto.compList.length === this.pageModel.pageSize) { | ||
| 220 | - // this.pageModel.currentPage++; | ||
| 221 | - // this.pageModel.hasMore = true; | ||
| 222 | - // } else { | ||
| 223 | - // this.pageModel.hasMore = false; | ||
| 224 | - // } | ||
| 225 | - // // // 二次请求,批查互动数据 | ||
| 226 | - // // PageViewModel.getInteractData(pageDto.compList).then((data: CompDTO[]) => { | ||
| 227 | - // // // 刷新,替换所有数据 | ||
| 228 | - // // this.pageModel.compList.replaceAll(...data) | ||
| 229 | - // // this.pageModel.timestamp = DateTimeUtils.getTimeStamp().toString() | ||
| 230 | - // // }) | ||
| 231 | - // this.isFirstIn = false; | ||
| 232 | - // Logger.debug(TAG, 'cj111'); | ||
| 233 | - // // } else { | ||
| 234 | - // // Logger.debug(TAG, 'aboutToAppear, data response page ' + this.pageId + ', comp list is empty.'); | ||
| 235 | - // // this.pageModel.viewType = ViewType.EMPTY; | ||
| 236 | - // } | ||
| 237 | - // } | ||
| 238 | - // } | ||
| 239 | - | ||
| 240 | - async getLiveListData(pageInfo: PageInfoBean) { | ||
| 241 | - // Logger.info(TAG, `getData id: ${this.pageId} , ${this.channelId} , navIndex: ${this.currentTopNavSelectedIndex}`); | ||
| 242 | - // this.pageModel.pageId = this.pageId; | ||
| 243 | - // this.pageModel.groupId = this.pageId; | ||
| 244 | - // this.pageModel.channelId = this.channelId; | ||
| 245 | - // this.pageModel.currentPage = 1; | ||
| 246 | - // let pageInfo = await PageViewModel.getPageUrlData(this.pageModel.pageId); | ||
| 247 | - // if (pageInfo == null) { | ||
| 248 | - // this.pageModel.viewType = ViewType.EMPTY; | ||
| 249 | - // return; | ||
| 250 | - // } | ||
| 251 | - Logger.debug(TAG, 'getPageUrlData ' + pageInfo.id); | ||
| 252 | - // pageInfo.groups.forEach(async (group) => { 不能按顺序加载用for...of替代 | ||
| 253 | - for (const group of pageInfo.groups) { | ||
| 254 | - this.pageDto = await PageViewModel.getLivePageData(this.pageModel.pageId, `${group.id}`, this.pageModel.channelId, group.groupStrategy | ||
| 255 | - , this.pageModel.currentPage, this.pageModel.pageSize, getContext(this)) | ||
| 256 | - this.pageModel.timestamp = DateTimeUtils.getTimeStamp().toString() | ||
| 257 | - if (this.pageDto && this.pageDto.compList && this.pageDto.compList.length > 0) { | ||
| 258 | - this.pageDto.compList.forEach((comp) => { | ||
| 259 | - if (comp.compStyle === CompStyle.Zh_Grid_Layout_02 && this.liveReviewDTO && this.liveReviewDTO.list && this.liveReviewDTO.list.length > 0) { | ||
| 260 | - comp.operDataList.push(...this.liveReviewDTO.list) | ||
| 261 | - } | ||
| 262 | - }) | ||
| 263 | - | ||
| 264 | - this.pageModel.viewType = ViewType.LOADED; | ||
| 265 | - this.pageModel.compList.push(...this.pageDto.compList) | ||
| 266 | - if (this.pageDto.compList.length === this.pageModel.pageSize) { | ||
| 267 | - this.pageModel.currentPage++; | ||
| 268 | - this.pageModel.hasMore = true; | ||
| 269 | - } else { | ||
| 270 | - this.pageModel.hasMore = false; | ||
| 271 | - } | ||
| 272 | - // 二次请求,批查互动数据 | ||
| 273 | - PageViewModel.getInteractData(this.pageDto.compList).then((data: CompDTO[]) => { | ||
| 274 | - // 刷新,替换所有数据 | ||
| 275 | - this.pageModel.compList.replaceAll(...data) | ||
| 276 | - this.pageModel.timestamp = DateTimeUtils.getTimeStamp().toString() | ||
| 277 | - }) | ||
| 278 | - this.isFirstIn = false | ||
| 279 | - } else { | ||
| 280 | - Logger.debug(TAG, 'aboutToAppear, data response page ' + this.pageId + ', comp list is empty.'); | ||
| 281 | - this.pageModel.viewType = ViewType.EMPTY; | ||
| 282 | - } | ||
| 283 | - } | ||
| 284 | - } | ||
| 285 | - | ||
| 286 | - async getPreviewData() { | ||
| 287 | - this.liveReviewDTO = await PageViewModel.getLiveReviewUrl(this.pageNum, this.pageModel.pageSize) | ||
| 288 | - Logger.debug(TAG, 'aboutToAppear, getPreviewData ' + this.liveReviewDTO.hasNext); | ||
| 289 | - this.getData(); | 129 | + this.pageModel.pageInfo = pageInfo; |
| 130 | + this.pageModel.loadStrategy = 1 | ||
| 131 | + PageHelper.parseGroup(this.pageModel) | ||
| 290 | } | 132 | } |
| 291 | } | 133 | } |
| 292 | 134 |
| 1 | +export class PageUIReqBean { | ||
| 2 | + // 页面数据 | ||
| 3 | + pageId: string = ''; | ||
| 4 | + groupId: string = ''; | ||
| 5 | + channelId: string = ''; | ||
| 6 | + isRecGroup: boolean = false; | ||
| 7 | + /** | ||
| 8 | + * 首次加载:loadStrategy= 1 | ||
| 9 | + * 下拉刷新:loadStrategy= 2 | ||
| 10 | + * 上推刷新:loadStrategy= 3 | ||
| 11 | + */ | ||
| 12 | + loadStrategy: number = 1; | ||
| 13 | + currentPage: number = 1; | ||
| 14 | + pageSize: number = 0; | ||
| 15 | + /** | ||
| 16 | + * 楼层类型: | ||
| 17 | + * 推荐:1 | ||
| 18 | + * 普通:2 | ||
| 19 | + */ | ||
| 20 | + groupStrategy: number = 2; | ||
| 21 | +} |
| @@ -23,6 +23,8 @@ import { | @@ -23,6 +23,8 @@ import { | ||
| 23 | postInteractAccentionOperateParams, | 23 | postInteractAccentionOperateParams, |
| 24 | postRecommendListParams | 24 | postRecommendListParams |
| 25 | } from 'wdBean'; | 25 | } from 'wdBean'; |
| 26 | +import { PageUIReqBean } from '../components/page/bean/PageUIReqBean'; | ||
| 27 | +import { LiveReviewDTO } from 'wdBean/src/main/ets/bean/component/LiveReviewDTO'; | ||
| 26 | 28 | ||
| 27 | const TAG = 'HttpRequest'; | 29 | const TAG = 'HttpRequest'; |
| 28 | 30 | ||
| @@ -46,31 +48,70 @@ export class PageRepository { | @@ -46,31 +48,70 @@ export class PageRepository { | ||
| 46 | return url; | 48 | return url; |
| 47 | } | 49 | } |
| 48 | 50 | ||
| 49 | - static getCompInfoUrl(pageId: string, groupId: string, channelId: string, groupStrategy: number, currentPage: number, pageSize: number) { | ||
| 50 | - let url = HttpUrlUtils.getHost(); | ||
| 51 | - if (1 == groupStrategy) { | ||
| 52 | - //推荐 | ||
| 53 | - url = url + HttpUrlUtils.COMP_REC_PATH; | 51 | + static getCompInfoUrl(pageBean: PageUIReqBean) { |
| 52 | + let url = HttpUrlUtils.getHost() + HttpUrlUtils.COMP_PATH; | ||
| 53 | + // first_load、pull_down、push_up | ||
| 54 | + let loadStrategy = '' | ||
| 55 | + if (pageBean.loadStrategy == 2) { | ||
| 56 | + loadStrategy = 'pull_down' | ||
| 57 | + } else if (pageBean.loadStrategy == 3) { | ||
| 58 | + loadStrategy = 'push_up' | ||
| 54 | } else { | 59 | } else { |
| 55 | - //非推荐 | ||
| 56 | - url = url + HttpUrlUtils.COMP_PATH; | 60 | + loadStrategy = 'first_load' |
| 57 | } | 61 | } |
| 58 | - // TODO 暂定只请求第一页,后续对接分页加载,参数再调整 first_load? | ||
| 59 | - url = url + "?channelStrategy=2&loadStrategy=first_load" | 62 | + url = url + "?channelStrategy=" + pageBean.groupStrategy |
| 63 | + + "&loadStrategy=" + loadStrategy | ||
| 60 | + "&districtCode=" + HttpUrlUtils.getDistrictCode() | 64 | + "&districtCode=" + HttpUrlUtils.getDistrictCode() |
| 61 | + "&provinceCode=" + HttpUrlUtils.getProvinceCode() | 65 | + "&provinceCode=" + HttpUrlUtils.getProvinceCode() |
| 62 | + "&cityCode=" + HttpUrlUtils.getCityCode() | 66 | + "&cityCode=" + HttpUrlUtils.getCityCode() |
| 63 | + "&refreshTime=" + DateTimeUtils.getTimeStamp() | 67 | + "&refreshTime=" + DateTimeUtils.getTimeStamp() |
| 64 | - + "&pageId=" + pageId | ||
| 65 | - + "&groupId=" + groupId | ||
| 66 | - + "&channelId=" + channelId | ||
| 67 | - + "&pageSize=" + pageSize | ||
| 68 | - + "&pageNum=" + currentPage; | 68 | + + "&pageId=" + pageBean.pageId |
| 69 | + + "&groupId=" + pageBean.groupId | ||
| 70 | + + "&channelId=" + pageBean.channelId | ||
| 71 | + + "&pageSize=" + pageBean.pageSize | ||
| 72 | + + "&pageNum=" + pageBean.currentPage; | ||
| 73 | + // Logger.debug("TAG", 'getCompInfoUrl url: '+url); | ||
| 74 | + Logger.info(TAG, "getCompInfoUrl url = " + url) | ||
| 75 | + return url; | ||
| 76 | + } | ||
| 77 | + | ||
| 78 | + static getRecCompInfoUrl(pageBean: PageUIReqBean) { | ||
| 79 | + let url = HttpUrlUtils.getHost() + HttpUrlUtils.COMP_REC_PATH; | ||
| 80 | + /** | ||
| 81 | + * 首次加载:loadStrategy= first_load | ||
| 82 | + * 上推刷新:loadStrategy= push_up | ||
| 83 | + * 下拉刷新:loadStrategy= pull_down | ||
| 84 | + */ | ||
| 85 | + let loadStrategy = '' | ||
| 86 | + if (pageBean.loadStrategy == 2) { | ||
| 87 | + loadStrategy = 'pull_down' | ||
| 88 | + } else if (pageBean.loadStrategy == 3) { | ||
| 89 | + loadStrategy = 'push_up' | ||
| 90 | + } else { | ||
| 91 | + loadStrategy = 'first_load' | ||
| 92 | + } | ||
| 93 | + url = url + "?channelStrategy=" + pageBean.groupStrategy | ||
| 94 | + + "&loadStrategy=" + loadStrategy | ||
| 95 | + + "&districtCode=" + HttpUrlUtils.getDistrictCode() | ||
| 96 | + + "&provinceCode=" + HttpUrlUtils.getProvinceCode() | ||
| 97 | + + "&cityCode=" + HttpUrlUtils.getCityCode() | ||
| 98 | + + "&refreshTime=" + DateTimeUtils.getTimeStamp() | ||
| 99 | + + "&pageId=" + pageBean.pageId | ||
| 100 | + + "&groupId=" + pageBean.groupId | ||
| 101 | + + "&channelId=" + pageBean.channelId | ||
| 102 | + + "&pageSize=" + pageBean.pageSize | ||
| 103 | + + "&pageNum=" + pageBean.currentPage; | ||
| 69 | // Logger.debug("TAG", 'getCompInfoUrl url: '+url); | 104 | // Logger.debug("TAG", 'getCompInfoUrl url: '+url); |
| 70 | Logger.info(TAG, "getCompInfoUrl url = " + url) | 105 | Logger.info(TAG, "getCompInfoUrl url = " + url) |
| 71 | return url; | 106 | return url; |
| 72 | } | 107 | } |
| 73 | 108 | ||
| 109 | + static getLiveReviewUrl(pageNum: number = 1, pageSize: number = 20) { | ||
| 110 | + let url = HttpUrlUtils.getHost() + HttpUrlUtils.LIVE_REVIEW_PATH + "?pageNum=" + pageNum + "&pageSize=" + pageSize; | ||
| 111 | + Logger.info(TAG, "getLiveReviewUrl url = " + url) | ||
| 112 | + return url; | ||
| 113 | + } | ||
| 114 | + | ||
| 74 | static getDetailInfoUrl(relId: string, contentId: string, relType: string) { | 115 | static getDetailInfoUrl(relId: string, contentId: string, relType: string) { |
| 75 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.DETAIL_PATH; | 116 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.DETAIL_PATH; |
| 76 | url = url + "?relId=" + relId | 117 | url = url + "?relId=" + relId |
| @@ -194,14 +235,14 @@ export class PageRepository { | @@ -194,14 +235,14 @@ export class PageRepository { | ||
| 194 | return WDHttp.get<ResponseDTO<PageInfoDTO>>(url, headers) | 235 | return WDHttp.get<ResponseDTO<PageInfoDTO>>(url, headers) |
| 195 | }; | 236 | }; |
| 196 | 237 | ||
| 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) | 238 | + static fetchCompData(pageBean: PageUIReqBean) { |
| 239 | + let url = PageRepository.getCompInfoUrl(pageBean) | ||
| 199 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | 240 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); |
| 200 | return WDHttp.get<ResponseDTO<PageDTO>>(url, headers) | 241 | return WDHttp.get<ResponseDTO<PageDTO>>(url, headers) |
| 201 | }; | 242 | }; |
| 202 | 243 | ||
| 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) | 244 | + static fetchRecCompData(pageBean: PageUIReqBean) { |
| 245 | + let url = PageRepository.getRecCompInfoUrl(pageBean) | ||
| 205 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | 246 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); |
| 206 | return WDHttp.get<ResponseDTO<PageDTO>>(url, headers) | 247 | return WDHttp.get<ResponseDTO<PageDTO>>(url, headers) |
| 207 | }; | 248 | }; |
| @@ -5,6 +5,7 @@ import { PageDTO, CompDTO } from 'wdBean'; | @@ -5,6 +5,7 @@ import { PageDTO, CompDTO } from 'wdBean'; | ||
| 5 | import PageModel from '../viewmodel/PageModel'; | 5 | import PageModel from '../viewmodel/PageModel'; |
| 6 | import PageViewModel from '../viewmodel/PageViewModel'; | 6 | import PageViewModel from '../viewmodel/PageViewModel'; |
| 7 | import { DateTimeUtils } from 'wdKit'; | 7 | import { DateTimeUtils } from 'wdKit'; |
| 8 | +import PageHelper from '../viewmodel/PageHelper'; | ||
| 8 | 9 | ||
| 9 | export function listTouchEvent(pageModel: PageModel, event: TouchEvent) { | 10 | export function listTouchEvent(pageModel: PageModel, event: TouchEvent) { |
| 10 | switch (event.type) { | 11 | switch (event.type) { |
| @@ -71,31 +72,32 @@ export function touchUpPullRefresh(pageModel: PageModel) { | @@ -71,31 +72,32 @@ export function touchUpPullRefresh(pageModel: PageModel) { | ||
| 71 | pageModel.currentPage = 1; | 72 | pageModel.currentPage = 1; |
| 72 | setTimeout(() => { | 73 | setTimeout(() => { |
| 73 | let self: PageModel = pageModel; | 74 | let self: PageModel = pageModel; |
| 74 | - PageViewModel.getPageData(self, getContext()) | ||
| 75 | - .then((data: PageDTO) => { | ||
| 76 | - self.timestamp = DateTimeUtils.getTimeStamp().toString() | ||
| 77 | - if (data == null || data.compList == null || data.compList.length == 0) { | ||
| 78 | - self.hasMore = false; | ||
| 79 | - } else { | ||
| 80 | - if (data.compList.length == self.pageSize) { | ||
| 81 | - self.currentPage++; | ||
| 82 | - self.hasMore = true; | ||
| 83 | - } else { | ||
| 84 | - self.hasMore = false; | ||
| 85 | - } | ||
| 86 | - // 刷新,替换所有数据 | ||
| 87 | - self.compList.replaceAll(...data.compList) | ||
| 88 | - PageViewModel.getInteractData(data.compList).then((data: CompDTO[]) => { | ||
| 89 | - // 刷新,替换所有数据 | ||
| 90 | - self.compList.replaceAll(...data) | ||
| 91 | - self.timestamp = DateTimeUtils.getTimeStamp().toString() | ||
| 92 | - }) | ||
| 93 | - } | ||
| 94 | - closeRefresh(self, true); | ||
| 95 | - }).catch((err: string | Resource) => { | ||
| 96 | - promptAction.showToast({ message: err }); | ||
| 97 | - closeRefresh(self, false); | ||
| 98 | - }); | 75 | + PageHelper.refreshUI(self) |
| 76 | + // PageViewModel.getPageData(self.bizCopy(2)) | ||
| 77 | + // .then((data: PageDTO) => { | ||
| 78 | + // self.timestamp = DateTimeUtils.getTimeStamp().toString() | ||
| 79 | + // if (data == null || data.compList == null || data.compList.length == 0) { | ||
| 80 | + // self.hasMore = false; | ||
| 81 | + // } else { | ||
| 82 | + // if (data.compList.length == self.pageSize) { | ||
| 83 | + // self.currentPage++; | ||
| 84 | + // self.hasMore = true; | ||
| 85 | + // } else { | ||
| 86 | + // self.hasMore = false; | ||
| 87 | + // } | ||
| 88 | + // // 刷新,替换所有数据 | ||
| 89 | + // self.compList.replaceAll(...data.compList) | ||
| 90 | + // PageViewModel.getInteractData(data.compList).then((data: CompDTO[]) => { | ||
| 91 | + // // 刷新,替换所有数据 | ||
| 92 | + // self.compList.replaceAll(...data) | ||
| 93 | + // self.timestamp = DateTimeUtils.getTimeStamp().toString() | ||
| 94 | + // }) | ||
| 95 | + // } | ||
| 96 | + // closeRefresh(self, true); | ||
| 97 | + // }).catch((err: string | Resource) => { | ||
| 98 | + // promptAction.showToast({ message: err }); | ||
| 99 | + // closeRefresh(self, false); | ||
| 100 | + // }); | ||
| 99 | }, Const.DELAY_TIME); | 101 | }, Const.DELAY_TIME); |
| 100 | } else { | 102 | } else { |
| 101 | closeRefresh(pageModel, false); | 103 | closeRefresh(pageModel, false); |
| @@ -2,8 +2,9 @@ import promptAction from '@ohos.promptAction'; | @@ -2,8 +2,9 @@ import promptAction from '@ohos.promptAction'; | ||
| 2 | import PageModel from '../viewmodel/PageModel'; | 2 | import PageModel from '../viewmodel/PageModel'; |
| 3 | import { RefreshConstants as Const } from './RefreshConstants'; | 3 | import { RefreshConstants as Const } from './RefreshConstants'; |
| 4 | import PageViewModel from '../viewmodel/PageViewModel'; | 4 | import PageViewModel from '../viewmodel/PageViewModel'; |
| 5 | -import { PageDTO,CompDTO } from 'wdBean'; | 5 | +import { PageDTO, CompDTO } from 'wdBean'; |
| 6 | import { DateTimeUtils } from 'wdKit'; | 6 | import { DateTimeUtils } from 'wdKit'; |
| 7 | +import PageHelper from '../viewmodel/PageHelper'; | ||
| 7 | 8 | ||
| 8 | export function touchMoveLoadMore(model: PageModel, event: TouchEvent) { | 9 | export function touchMoveLoadMore(model: PageModel, event: TouchEvent) { |
| 9 | // list size +1 | 10 | // list size +1 |
| @@ -28,29 +29,30 @@ export function touchUpLoadMore(model: PageModel) { | @@ -28,29 +29,30 @@ export function touchUpLoadMore(model: PageModel) { | ||
| 28 | self.isLoading = true; | 29 | self.isLoading = true; |
| 29 | setTimeout(() => { | 30 | setTimeout(() => { |
| 30 | closeLoadMore(model); | 31 | closeLoadMore(model); |
| 31 | - PageViewModel.getPageData(self, getContext()) | ||
| 32 | - .then((data: PageDTO) => { | ||
| 33 | - self.timestamp = DateTimeUtils.getTimeStamp().toString() | ||
| 34 | - if (data == null || data.compList == null || data.compList.length == 0) { | ||
| 35 | - self.hasMore = false; | ||
| 36 | - } else { | ||
| 37 | - if (data.compList.length == self.pageSize) { | ||
| 38 | - self.currentPage++; | ||
| 39 | - self.hasMore = true; | ||
| 40 | - } else { | ||
| 41 | - self.hasMore = false; | ||
| 42 | - } | ||
| 43 | - let sizeBefore:number = self.compList.size(); | ||
| 44 | - self.compList.push(...data.compList) | ||
| 45 | - PageViewModel.getInteractData(data.compList).then((data: CompDTO[]) => { | ||
| 46 | - // 刷新,替换所有数据 | ||
| 47 | - self.compList.updateItems(sizeBefore, data) | ||
| 48 | - self.timestamp = DateTimeUtils.getTimeStamp().toString() | ||
| 49 | - }) | ||
| 50 | - } | ||
| 51 | - }).catch((err: string | Resource) => { | ||
| 52 | - promptAction.showToast({ message: err }); | ||
| 53 | - }) | 32 | + PageHelper.loadMore(self) |
| 33 | + // PageViewModel.getPageData(self.bizCopy()) | ||
| 34 | + // .then((data: PageDTO) => { | ||
| 35 | + // self.timestamp = DateTimeUtils.getTimeStamp().toString() | ||
| 36 | + // if (data == null || data.compList == null || data.compList.length == 0) { | ||
| 37 | + // self.hasMore = false; | ||
| 38 | + // } else { | ||
| 39 | + // if (data.compList.length == self.pageSize) { | ||
| 40 | + // self.currentPage++; | ||
| 41 | + // self.hasMore = true; | ||
| 42 | + // } else { | ||
| 43 | + // self.hasMore = false; | ||
| 44 | + // } | ||
| 45 | + // let sizeBefore: number = self.compList.size(); | ||
| 46 | + // self.compList.push(...data.compList) | ||
| 47 | + // PageViewModel.getInteractData(data.compList).then((data: CompDTO[]) => { | ||
| 48 | + // // 刷新,替换所有数据 | ||
| 49 | + // self.compList.updateItems(sizeBefore, data) | ||
| 50 | + // self.timestamp = DateTimeUtils.getTimeStamp().toString() | ||
| 51 | + // }) | ||
| 52 | + // } | ||
| 53 | + // }).catch((err: string | Resource) => { | ||
| 54 | + // promptAction.showToast({ message: err }); | ||
| 55 | + // }) | ||
| 54 | }, Const.DELAY_TIME); | 56 | }, Const.DELAY_TIME); |
| 55 | } else { | 57 | } else { |
| 56 | closeLoadMore(self); | 58 | closeLoadMore(self); |
| 1 | +import { PageDTO, CompDTO, PageInfoDTO } from 'wdBean'; | ||
| 2 | +import { ViewType } from 'wdConstant/Index'; | ||
| 3 | +import { DateTimeUtils, Logger } from 'wdKit'; | ||
| 4 | +import { closeRefresh } from '../utils/PullDownRefresh'; | ||
| 5 | +import PageModel from './PageModel'; | ||
| 6 | +import PageViewModel from './PageViewModel'; | ||
| 7 | +import { promptAction } from '@kit.ArkUI'; | ||
| 8 | + | ||
| 9 | +const TAG = 'PageHelper'; | ||
| 10 | + | ||
| 11 | +/** | ||
| 12 | + * 处理返回后的数据 | ||
| 13 | + * @deprecated | ||
| 14 | + */ | ||
| 15 | +export class PageHelper { | ||
| 16 | + async refreshUI(pageModel: PageModel) { | ||
| 17 | + pageModel.loadStrategy = 2 | ||
| 18 | + this.parseGroup(pageModel) | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + async loadMore(pageModel: PageModel) { | ||
| 22 | + pageModel.loadStrategy = 3 | ||
| 23 | + // 暂只支持comp分页加载,节目分页加载的得完善框架(如直播回看节目数据分页) | ||
| 24 | + this.compLoadMore(pageModel) | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + async parseGroup(pageModel: PageModel) { | ||
| 28 | + let pageInfo: PageInfoDTO = pageModel.pageInfo | ||
| 29 | + pageModel.groupList = [] | ||
| 30 | + pageModel.groupList.push(...pageInfo.groups) | ||
| 31 | + for (const group of pageInfo.groups) { | ||
| 32 | + pageModel.isRecGroup = group.groupStrategy === 1; | ||
| 33 | + pageModel.groupId = group.id; | ||
| 34 | + if (pageModel.isRecGroup) { | ||
| 35 | + pageModel.pageSize = 10 | ||
| 36 | + } else { | ||
| 37 | + pageModel.pageSize = 20 | ||
| 38 | + } | ||
| 39 | + pageModel.groupData = group | ||
| 40 | + // await,确保groups接口顺序执行 | ||
| 41 | + let pageDto = await PageViewModel.getPageData(pageModel.bizCopy()) | ||
| 42 | + let index = pageInfo.groups.indexOf(group) | ||
| 43 | + if (index == 0) { | ||
| 44 | + // 清空comp列表 | ||
| 45 | + pageModel.compList.clear() | ||
| 46 | + } | ||
| 47 | + this.getGroupData(pageModel, pageDto, index == pageInfo.groups.length - 1) | ||
| 48 | + } | ||
| 49 | + if (pageModel.compList.isEmpty()) { | ||
| 50 | + // 没数据,展示空页面 | ||
| 51 | + Logger.debug(TAG, 'aboutToAppear, data response page ' + pageModel.pageId + ', comp list is empty.'); | ||
| 52 | + pageModel.viewType = ViewType.EMPTY; | ||
| 53 | + } | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + private async getGroupData(pageModel: PageModel, pageDto: PageDTO, isLastGroup: boolean) { | ||
| 57 | + pageModel.timestamp = DateTimeUtils.getTimeStamp().toString() | ||
| 58 | + if (pageDto && pageDto.compList && pageDto.compList.length > 0) { | ||
| 59 | + pageModel.viewType = ViewType.LOADED; | ||
| 60 | + let sizeBefore: number = pageModel.compList.size(); | ||
| 61 | + pageModel.compList.push(...pageDto.compList) | ||
| 62 | + if (pageDto.compList.length === pageModel.pageSize) { | ||
| 63 | + pageModel.currentPage++; | ||
| 64 | + pageModel.hasMore = true; | ||
| 65 | + } else { | ||
| 66 | + pageModel.hasMore = false; | ||
| 67 | + } | ||
| 68 | + // 二次请求,批查互动数据 | ||
| 69 | + PageViewModel.getInteractData(pageDto.compList).then((data: CompDTO[]) => { | ||
| 70 | + // 刷新,替换所有数据 | ||
| 71 | + // pageModel.compList.replaceAll(...data) | ||
| 72 | + pageModel.compList.updateItems(sizeBefore, data) | ||
| 73 | + pageModel.timestamp = DateTimeUtils.getTimeStamp().toString() | ||
| 74 | + }) | ||
| 75 | + // TODO 待优化,解决content级别的展现加载 | ||
| 76 | + if (isLastGroup) { | ||
| 77 | + closeRefresh(pageModel, true); | ||
| 78 | + // // 最后一个楼层,特殊处理 | ||
| 79 | + // // 检测楼层最后一个组件业务数据是否需要通过访问接口获取 | ||
| 80 | + // let comp: CompDTO = pageDto.compList[pageDto.compList.length - 1] | ||
| 81 | + // let compSize = CollectionUtils.getListSize(comp.operDataList) | ||
| 82 | + // // 直播回放,需要二次请求数据 | ||
| 83 | + // if (compSize <= 0 && comp.dataSourceType == 'LIVE_END') { | ||
| 84 | + // let liveReviewDTO = await PageViewModel.getLiveReviewUrl(pageModel.currentPage, pageModel.pageSize) | ||
| 85 | + // // content数据回来,塞给comp | ||
| 86 | + // comp.operDataList.push(...liveReviewDTO.list) | ||
| 87 | + // } | ||
| 88 | + } | ||
| 89 | + } | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | + /** | ||
| 93 | + * 获取直播回看数据 | ||
| 94 | + */ | ||
| 95 | + private async getLiveEnd(pageModel: PageModel) { | ||
| 96 | + let liveReviewDTO = await PageViewModel.getLiveReviewUrl(pageModel.currentPage, pageModel.pageSize) | ||
| 97 | + Logger.debug(TAG, 'aboutToAppear, getPreviewData ' + liveReviewDTO.hasNext); | ||
| 98 | + } | ||
| 99 | + | ||
| 100 | + /** | ||
| 101 | + * comp加载更多,分页加载 | ||
| 102 | + */ | ||
| 103 | + private compLoadMore(pageModel: PageModel) { | ||
| 104 | + PageViewModel.getPageData(pageModel.bizCopy()) | ||
| 105 | + .then((data: PageDTO) => { | ||
| 106 | + pageModel.timestamp = DateTimeUtils.getTimeStamp().toString() | ||
| 107 | + if (data == null || data.compList == null || data.compList.length == 0) { | ||
| 108 | + pageModel.hasMore = false; | ||
| 109 | + } else { | ||
| 110 | + if (data.compList.length == pageModel.pageSize) { | ||
| 111 | + pageModel.currentPage++; | ||
| 112 | + pageModel.hasMore = true; | ||
| 113 | + } else { | ||
| 114 | + pageModel.hasMore = false; | ||
| 115 | + } | ||
| 116 | + let sizeBefore: number = pageModel.compList.size(); | ||
| 117 | + pageModel.compList.push(...data.compList) | ||
| 118 | + PageViewModel.getInteractData(data.compList).then((data: CompDTO[]) => { | ||
| 119 | + // 刷新,替换所有数据 | ||
| 120 | + pageModel.compList.updateItems(sizeBefore, data) | ||
| 121 | + pageModel.timestamp = DateTimeUtils.getTimeStamp().toString() | ||
| 122 | + }) | ||
| 123 | + } | ||
| 124 | + }).catch((err: string | Resource) => { | ||
| 125 | + promptAction.showToast({ message: err }); | ||
| 126 | + }) | ||
| 127 | + } | ||
| 128 | + | ||
| 129 | + /** | ||
| 130 | + * 节目数据分页加载 | ||
| 131 | + * TODO 待完善框架 | ||
| 132 | + */ | ||
| 133 | + private contentLoadMore() { | ||
| 134 | + | ||
| 135 | + } | ||
| 136 | +} | ||
| 137 | + | ||
| 138 | + | ||
| 139 | +let pageHelper = new PageHelper(); | ||
| 140 | + | ||
| 141 | +export default pageHelper as PageHelper; |
| 1 | -import { CompDTO } from 'wdBean'; | 1 | +import { CompDTO, GroupDTO } from 'wdBean'; |
| 2 | import { LazyDataSource } from 'wdKit'; | 2 | import { LazyDataSource } from 'wdKit'; |
| 3 | import { ViewType } from 'wdConstant/src/main/ets/enum/ViewType'; | 3 | import { ViewType } from 'wdConstant/src/main/ets/enum/ViewType'; |
| 4 | import { RefreshConstants as Const } from '../utils/RefreshConstants'; | 4 | import { RefreshConstants as Const } from '../utils/RefreshConstants'; |
| 5 | +import { PageUIReqBean } from '../components/page/bean/PageUIReqBean'; | ||
| 6 | +import { GroupInfoDTO, PageInfoDTO } from 'wdBean/src/main/ets/bean/navigation/PageInfoDTO'; | ||
| 5 | 7 | ||
| 8 | +/** | ||
| 9 | + * 页面下拉刷新、上拉加载数据bean。 | ||
| 10 | + * TODO 将业务数据拆出去 | ||
| 11 | + */ | ||
| 6 | export default class PageModel { | 12 | export default class PageModel { |
| 7 | // 页面数据 | 13 | // 页面数据 |
| 8 | pageId: string = ""; | 14 | pageId: string = ""; |
| 9 | groupId: string = ""; | 15 | groupId: string = ""; |
| 10 | channelId: string = ""; | 16 | channelId: string = ""; |
| 11 | isRecGroup: boolean = false; | 17 | isRecGroup: boolean = false; |
| 18 | + pageInfo: PageInfoDTO = {} as PageInfoDTO | ||
| 19 | + groupList: GroupInfoDTO[] = []; | ||
| 20 | + // 当前请求数据的group | ||
| 21 | + groupData: GroupInfoDTO = {} as GroupInfoDTO; | ||
| 12 | compList: LazyDataSource<CompDTO> = new LazyDataSource(); | 22 | compList: LazyDataSource<CompDTO> = new LazyDataSource(); |
| 13 | - // 页面状态,刷新、加载更多等 | 23 | + // 页面状态,刷新、加载更多等,1-首次、2-下拉、3上拉 |
| 24 | + loadStrategy: number = 1; | ||
| 14 | currentPage: number = 1; | 25 | currentPage: number = 1; |
| 15 | pageSize: number = Const.PAGE_SIZE; | 26 | pageSize: number = Const.PAGE_SIZE; |
| 16 | pullDownRefreshText: Resource = $r('app.string.pull_down_refresh_text'); | 27 | pullDownRefreshText: Resource = $r('app.string.pull_down_refresh_text'); |
| @@ -35,5 +46,20 @@ export default class PageModel { | @@ -35,5 +46,20 @@ export default class PageModel { | ||
| 35 | isCanLoadMore: boolean = false; | 46 | isCanLoadMore: boolean = false; |
| 36 | // keyGenerator相关字符串,用于刷新list布局 | 47 | // keyGenerator相关字符串,用于刷新list布局 |
| 37 | timestamp: String = '1'; | 48 | timestamp: String = '1'; |
| 38 | - groupStrategy: number = 0; | 49 | + |
| 50 | + /** | ||
| 51 | + * 简单复制业务数据 | ||
| 52 | + */ | ||
| 53 | + bizCopy(): PageUIReqBean { | ||
| 54 | + let page = new PageUIReqBean() | ||
| 55 | + page.pageId = this.pageId | ||
| 56 | + page.groupId = this.groupId | ||
| 57 | + page.channelId = this.channelId | ||
| 58 | + page.isRecGroup = this.isRecGroup | ||
| 59 | + page.currentPage = this.currentPage | ||
| 60 | + page.pageSize = this.pageSize | ||
| 61 | + page.groupStrategy = this.groupData.groupStrategy | ||
| 62 | + page.loadStrategy = this.loadStrategy | ||
| 63 | + return page | ||
| 64 | + } | ||
| 39 | } | 65 | } |
| @@ -10,8 +10,10 @@ import { | @@ -10,8 +10,10 @@ import { | ||
| 10 | PageInfoBean | 10 | PageInfoBean |
| 11 | } from 'wdBean'; | 11 | } from 'wdBean'; |
| 12 | 12 | ||
| 13 | +import { LiveReviewDTO } from 'wdBean/src/main/ets/bean/component/LiveReviewDTO'; | ||
| 13 | import { CollectionUtils, Logger, ResourcesUtils, StringUtils } from 'wdKit'; | 14 | import { CollectionUtils, Logger, ResourcesUtils, StringUtils } from 'wdKit'; |
| 14 | import { ResponseDTO, } from 'wdNetwork'; | 15 | import { ResponseDTO, } from 'wdNetwork'; |
| 16 | +import { PageUIReqBean } from '../components/page/bean/PageUIReqBean'; | ||
| 15 | import { PageRepository } from '../repository/PageRepository'; | 17 | import { PageRepository } from '../repository/PageRepository'; |
| 16 | import { BaseViewModel } from './BaseViewModel'; | 18 | import { BaseViewModel } from './BaseViewModel'; |
| 17 | import PageModel from './PageModel'; | 19 | import PageModel from './PageModel'; |
| @@ -141,16 +143,12 @@ export class PageViewModel extends BaseViewModel { | @@ -141,16 +143,12 @@ export class PageViewModel extends BaseViewModel { | ||
| 141 | return compRes.data | 143 | return compRes.data |
| 142 | } | 144 | } |
| 143 | 145 | ||
| 144 | - async getPageData(pageModel: PageModel, context?: Context): Promise<PageDTO> { | 146 | + async getPageData(pageModel: PageUIReqBean): Promise<PageDTO> { |
| 145 | Logger.debug(TAG, 'getPageData pageId: ' + pageModel.pageId); | 147 | Logger.debug(TAG, 'getPageData pageId: ' + pageModel.pageId); |
| 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); | 148 | + if (pageModel.isRecGroup) { |
| 149 | + return this.parseComp(PageRepository.fetchRecCompData(pageModel)) | ||
| 150 | + } else { | ||
| 151 | + return this.parseComp(PageRepository.fetchCompData(pageModel)) | ||
| 154 | } | 152 | } |
| 155 | return new Promise<PageDTO>((success, error) => { | 153 | return new Promise<PageDTO>((success, error) => { |
| 156 | PageRepository.fetchLivePageData(pageId, groupId, channelId, groupStrategy, currentPage, pageSize) | 154 | PageRepository.fetchLivePageData(pageId, groupId, channelId, groupStrategy, currentPage, pageSize) |
| @@ -365,6 +363,30 @@ export class PageViewModel extends BaseViewModel { | @@ -365,6 +363,30 @@ export class PageViewModel extends BaseViewModel { | ||
| 365 | }) | 363 | }) |
| 366 | }) | 364 | }) |
| 367 | } | 365 | } |
| 366 | + | ||
| 367 | + async getLiveReviewUrl(pageNum: number, pageSize: number): Promise<LiveReviewDTO> { | ||
| 368 | + return new Promise<LiveReviewDTO>((success, error) => { | ||
| 369 | + Logger.info(TAG, `getLivePreviewUrl pageInfo start`); | ||
| 370 | + PageRepository.fetchLiveReviewUrl(pageNum, pageSize).then((resDTO: ResponseDTO<LiveReviewDTO>) => { | ||
| 371 | + if (!resDTO || !resDTO.data) { | ||
| 372 | + Logger.error(TAG, 'getLivePreviewUrl then navResDTO is empty'); | ||
| 373 | + error('resDTO is empty'); | ||
| 374 | + return | ||
| 375 | + } | ||
| 376 | + if (resDTO.code != 0) { | ||
| 377 | + Logger.error(TAG, `getLivePreviewUrl then code:${resDTO.code}, message:${resDTO.message}`); | ||
| 378 | + error('resDTO Response Code is failure'); | ||
| 379 | + return | ||
| 380 | + } | ||
| 381 | + // let navResStr = JSON.stringify(navResDTO); | ||
| 382 | + Logger.info(TAG, "getLivePreviewUrl then,navResDTO.timestamp:" + resDTO.timestamp); | ||
| 383 | + success(resDTO.data); | ||
| 384 | + }).catch((err: Error) => { | ||
| 385 | + Logger.error(TAG, `getLivePreviewUrl catch, error.name : ${err.name}, error.message:${err.message}`); | ||
| 386 | + error(err); | ||
| 387 | + }) | ||
| 388 | + }) | ||
| 389 | + } | ||
| 368 | } | 390 | } |
| 369 | 391 | ||
| 370 | 392 |
-
Please register or login to post a comment