Showing
19 changed files
with
223 additions
and
117 deletions
| @@ -65,6 +65,13 @@ export class CollectionUtils { | @@ -65,6 +65,13 @@ export class CollectionUtils { | ||
| 65 | return collection.length > 0; | 65 | return collection.length > 0; |
| 66 | } | 66 | } |
| 67 | 67 | ||
| 68 | + static getElement(collection?: any[], index?: number): any { | ||
| 69 | + if (CollectionUtils.isEmpty(collection) || index === undefined) { | ||
| 70 | + return null; | ||
| 71 | + } | ||
| 72 | + return index >= 0 && index < collection.length ? collection[index] : null; | ||
| 73 | + } | ||
| 74 | + | ||
| 68 | static getListSize(collection?: any[]): number { | 75 | static getListSize(collection?: any[]): number { |
| 69 | return CollectionUtils.isEmpty(collection) ? 0 : collection.length; | 76 | return CollectionUtils.isEmpty(collection) ? 0 : collection.length; |
| 70 | } | 77 | } |
| @@ -35,6 +35,10 @@ export class HttpUrlUtils { | @@ -35,6 +35,10 @@ export class HttpUrlUtils { | ||
| 35 | */ | 35 | */ |
| 36 | static readonly COMP_PATH: string = "/api/rmrb-bff-display-zh/display/zh/c/compInfo"; | 36 | static readonly COMP_PATH: string = "/api/rmrb-bff-display-zh/display/zh/c/compInfo"; |
| 37 | /** | 37 | /** |
| 38 | + * 推荐内容的展现comp接口 | ||
| 39 | + */ | ||
| 40 | + static readonly HOTCOMP_PATH: string = "/api/rmrb-bff-display-zh/display/zh/c/rec/compInfo"; | ||
| 41 | + /** | ||
| 38 | * 详情页面详情接口 | 42 | * 详情页面详情接口 |
| 39 | */ | 43 | */ |
| 40 | static readonly DETAIL_PATH: string = "/api/rmrb-bff-display-zh/content/zh/c/content/detail"; | 44 | static readonly DETAIL_PATH: string = "/api/rmrb-bff-display-zh/content/zh/c/content/detail"; |
| @@ -131,7 +135,11 @@ export class HttpUrlUtils { | @@ -131,7 +135,11 @@ export class HttpUrlUtils { | ||
| 131 | /** | 135 | /** |
| 132 | * 我的收藏 | 136 | * 我的收藏 |
| 133 | */ | 137 | */ |
| 134 | - static readonly APPOINTMENT_MyCollectionList_PATH: string = "/api/rmrb-interact/content/zh/c/interact"; | 138 | + static readonly APPOINTMENT_MyCollectionList_PATH: string = "/api/rmrb-bff-display-zh/content/zh/c/interact"; |
| 139 | + /** | ||
| 140 | + * 收藏/取消收藏 status :收藏状态 1添加收藏 0取消收藏 | ||
| 141 | + */ | ||
| 142 | + static readonly APPOINTMENT_ExecuteCollcet_PATH: string = "/api/rmrb-interact/interact/zh/c/collect/executeCollcetRecord"; | ||
| 135 | /** | 143 | /** |
| 136 | * 个人中心 我的评论列表 | 144 | * 个人中心 我的评论列表 |
| 137 | */ | 145 | */ |
| @@ -447,7 +455,12 @@ export class HttpUrlUtils { | @@ -447,7 +455,12 @@ export class HttpUrlUtils { | ||
| 447 | } | 455 | } |
| 448 | 456 | ||
| 449 | static getMyCollectionListDataUrl() { | 457 | static getMyCollectionListDataUrl() { |
| 450 | - let url = HttpUrlUtils.HOST_SIT + HttpUrlUtils.APPOINTMENT_MyCollectionList_PATH | 458 | + let url = HttpUrlUtils._hostUrl + HttpUrlUtils.APPOINTMENT_MyCollectionList_PATH |
| 459 | + return url | ||
| 460 | + } | ||
| 461 | + | ||
| 462 | + static getExecuteCollcetUrl() { | ||
| 463 | + let url = HttpUrlUtils._hostUrl + HttpUrlUtils.APPOINTMENT_ExecuteCollcet_PATH | ||
| 451 | return url | 464 | return url |
| 452 | } | 465 | } |
| 453 | 466 |
| @@ -5,6 +5,8 @@ export { BottomNavDTO } from './src/main/ets/bean/navigation/BottomNavDTO'; | @@ -5,6 +5,8 @@ export { BottomNavDTO } from './src/main/ets/bean/navigation/BottomNavDTO'; | ||
| 5 | 5 | ||
| 6 | export { TopNavDTO } from './src/main/ets/bean/navigation/TopNavDTO'; | 6 | export { TopNavDTO } from './src/main/ets/bean/navigation/TopNavDTO'; |
| 7 | 7 | ||
| 8 | +export { PageInfoDTO } from './src/main/ets/bean/navigation/PageInfoDTO'; | ||
| 9 | + | ||
| 8 | // entity | 10 | // entity |
| 9 | export { ItemDTO } from './src/main/ets/bean/ItemDTO'; | 11 | export { ItemDTO } from './src/main/ets/bean/ItemDTO'; |
| 10 | 12 |
| @@ -29,5 +29,4 @@ export interface CompDTO { | @@ -29,5 +29,4 @@ 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 | - isSelect: boolean; | ||
| 33 | } | 32 | } |
| 1 | +/** | ||
| 2 | + * page接口返回的Page数据DTO | ||
| 3 | + */ | ||
| 4 | +export interface PageInfoDTO { | ||
| 5 | + pageId: string; // 页面id | ||
| 6 | + id: number; // 楼层id | ||
| 7 | + name: string; // 名称 | ||
| 8 | + hasAdInfo: number; | ||
| 9 | + hasPopUp: number; | ||
| 10 | + baselineShow: number; | ||
| 11 | + groups: GroupInfoDTO[]; | ||
| 12 | + channelInfo: ChannelInfoDTO; | ||
| 13 | +} | ||
| 14 | + | ||
| 15 | +export interface ChannelInfoDTO { | ||
| 16 | + channelId: string; | ||
| 17 | + channelLevel: string; | ||
| 18 | + channelName: string; | ||
| 19 | + channelStrategy: string; | ||
| 20 | + channelStyle: string; | ||
| 21 | + pageId: string; | ||
| 22 | +} | ||
| 23 | + | ||
| 24 | +export interface GroupInfoDTO { | ||
| 25 | + blockDesc: string; | ||
| 26 | + groupStrategy: number; | ||
| 27 | + id: string; | ||
| 28 | + showType: number; | ||
| 29 | + sortValue: number; | ||
| 30 | +} |
| @@ -6,13 +6,14 @@ import { EmptyComponent } from '../view/EmptyComponent' | @@ -6,13 +6,14 @@ import { EmptyComponent } from '../view/EmptyComponent' | ||
| 6 | import { ErrorComponent } from '../view/ErrorComponent' | 6 | import { ErrorComponent } from '../view/ErrorComponent' |
| 7 | import RefreshLayout from './RefreshLayout' | 7 | import RefreshLayout from './RefreshLayout' |
| 8 | import { RefreshLayoutBean } from './RefreshLayoutBean'; | 8 | import { RefreshLayoutBean } from './RefreshLayoutBean'; |
| 9 | -import { CompDTO } from 'wdBean' | 9 | +import { CompDTO, ContentDTO } from 'wdBean' |
| 10 | import LoadMoreLayout from './LoadMoreLayout' | 10 | import LoadMoreLayout from './LoadMoreLayout' |
| 11 | import NoMoreLayout from './NoMoreLayout' | 11 | import NoMoreLayout from './NoMoreLayout' |
| 12 | import { CompParser } from '../CompParser' | 12 | import { CompParser } from '../CompParser' |
| 13 | import CustomRefreshLoadLayout from './CustomRefreshLoadLayout'; | 13 | import CustomRefreshLoadLayout from './CustomRefreshLoadLayout'; |
| 14 | import { CustomSelectUI } from '../view/CustomSelectUI'; | 14 | import { CustomSelectUI } from '../view/CustomSelectUI'; |
| 15 | import { CustomBottomFuctionUI } from '../view/CustomBottomFuctionUI'; | 15 | import { CustomBottomFuctionUI } from '../view/CustomBottomFuctionUI'; |
| 16 | +import { BigPicCardComponent } from '../view/BigPicCardComponent'; | ||
| 16 | 17 | ||
| 17 | @Entry | 18 | @Entry |
| 18 | @Component | 19 | @Component |
| @@ -20,8 +21,8 @@ struct BrowsingHistoryPage { | @@ -20,8 +21,8 @@ struct BrowsingHistoryPage { | ||
| 20 | @State private browSingModel: PageModel = new PageModel() | 21 | @State private browSingModel: PageModel = new PageModel() |
| 21 | isloading : boolean = false | 22 | isloading : boolean = false |
| 22 | @Provide isEditState:boolean = false | 23 | @Provide isEditState:boolean = false |
| 23 | - @State allDatas :CompDTO[] = []; | ||
| 24 | - @State selectDatas :CompDTO[] = []; | 24 | + @State allDatas :ContentDTO[] = []; |
| 25 | + @State selectDatas :ContentDTO[] = []; | ||
| 25 | @Provide deleteNum :number = 0; | 26 | @Provide deleteNum :number = 0; |
| 26 | @Provide isAllSelect:boolean = false | 27 | @Provide isAllSelect:boolean = false |
| 27 | aboutToAppear(){ | 28 | aboutToAppear(){ |
| @@ -72,7 +73,7 @@ struct BrowsingHistoryPage { | @@ -72,7 +73,7 @@ struct BrowsingHistoryPage { | ||
| 72 | }) | 73 | }) |
| 73 | } | 74 | } |
| 74 | 75 | ||
| 75 | - ForEach(this.allDatas, (compDTO: CompDTO, compIndex: number) => { | 76 | + ForEach(this.allDatas, (compDTO: ContentDTO, compIndex: number) => { |
| 76 | ListItem() { | 77 | ListItem() { |
| 77 | this.newCompParser(compDTO,compIndex) | 78 | this.newCompParser(compDTO,compIndex) |
| 78 | } | 79 | } |
| @@ -94,7 +95,7 @@ struct BrowsingHistoryPage { | @@ -94,7 +95,7 @@ struct BrowsingHistoryPage { | ||
| 94 | } | 95 | } |
| 95 | 96 | ||
| 96 | @Builder | 97 | @Builder |
| 97 | - newCompParser(compDTO: CompDTO, compIndex: number){ | 98 | + newCompParser(compDTO: ContentDTO, compIndex: number){ |
| 98 | Row(){ | 99 | Row(){ |
| 99 | if (this.isEditState){ | 100 | if (this.isEditState){ |
| 100 | CustomSelectUI({ | 101 | CustomSelectUI({ |
| @@ -106,7 +107,7 @@ struct BrowsingHistoryPage { | @@ -106,7 +107,7 @@ struct BrowsingHistoryPage { | ||
| 106 | .margin({left:16}) | 107 | .margin({left:16}) |
| 107 | } | 108 | } |
| 108 | Column() { | 109 | Column() { |
| 109 | - CompParser({ compDTO: compDTO, compIndex: compIndex }) | 110 | + BigPicCardComponent({contentDTO:compDTO}) |
| 110 | } | 111 | } |
| 111 | } | 112 | } |
| 112 | } | 113 | } |
| @@ -118,11 +119,11 @@ struct BrowsingHistoryPage { | @@ -118,11 +119,11 @@ struct BrowsingHistoryPage { | ||
| 118 | 119 | ||
| 119 | async getData() { | 120 | async getData() { |
| 120 | this.browSingModel.currentPage = 1 | 121 | this.browSingModel.currentPage = 1 |
| 121 | - MyCollectionViewModel.newFetchMyCollectList(2,'1',this.browSingModel.currentPage,getContext(this)).then(pageDto => { | ||
| 122 | - if (pageDto && pageDto.compList && pageDto.compList.length > 0) { | 122 | + MyCollectionViewModel.fetchMyCollectList(2,'1',this.browSingModel.currentPage,getContext(this)).then(collectionItem => { |
| 123 | + if (collectionItem && collectionItem.list && collectionItem.list.length > 0) { | ||
| 123 | this.browSingModel.viewType = ViewType.LOADED; | 124 | this.browSingModel.viewType = ViewType.LOADED; |
| 124 | - this.allDatas.push(...pageDto.compList) | ||
| 125 | - if (pageDto.compList.length === this.browSingModel.pageSize) { | 125 | + this.allDatas.push(...collectionItem.list) |
| 126 | + if (collectionItem.list.length === this.browSingModel.pageSize) { | ||
| 126 | this.browSingModel.currentPage++; | 127 | this.browSingModel.currentPage++; |
| 127 | this.browSingModel.hasMore = true; | 128 | this.browSingModel.hasMore = true; |
| 128 | } else { | 129 | } else { |
| @@ -136,7 +137,7 @@ struct BrowsingHistoryPage { | @@ -136,7 +137,7 @@ struct BrowsingHistoryPage { | ||
| 136 | 137 | ||
| 137 | //数据处理 | 138 | //数据处理 |
| 138 | //单个选择 | 139 | //单个选择 |
| 139 | - addCompDTO(isOn:boolean , compDTO: CompDTO){ | 140 | + addCompDTO(isOn:boolean , compDTO: ContentDTO){ |
| 140 | compDTO.isSelect = isOn; | 141 | compDTO.isSelect = isOn; |
| 141 | if (isOn === true){ | 142 | if (isOn === true){ |
| 142 | this.selectDatas.push(compDTO) | 143 | this.selectDatas.push(compDTO) |
| @@ -150,7 +151,7 @@ struct BrowsingHistoryPage { | @@ -150,7 +151,7 @@ struct BrowsingHistoryPage { | ||
| 150 | 151 | ||
| 151 | //全选 | 152 | //全选 |
| 152 | allSelectDatas(isOn:boolean){ | 153 | allSelectDatas(isOn:boolean){ |
| 153 | - let datas: CompDTO[] = []; | 154 | + let datas: ContentDTO[] = []; |
| 154 | for (let index = 0; index < this.allDatas.length; index++) { | 155 | for (let index = 0; index < this.allDatas.length; index++) { |
| 155 | const compDTO = this.allDatas[index]; | 156 | const compDTO = this.allDatas[index]; |
| 156 | compDTO.isSelect = isOn | 157 | compDTO.isSelect = isOn |
| @@ -42,7 +42,7 @@ struct EditUserInfoPage { | @@ -42,7 +42,7 @@ struct EditUserInfoPage { | ||
| 42 | build() { | 42 | build() { |
| 43 | Row() { | 43 | Row() { |
| 44 | Column() { | 44 | Column() { |
| 45 | - CustomTitleUI({titleName:'资料编辑'}) | 45 | + CustomTitleUI({titleName:'编辑资料'}) |
| 46 | Image(this.headerImg) | 46 | Image(this.headerImg) |
| 47 | .alt($r('app.media.default_head')) | 47 | .alt($r('app.media.default_head')) |
| 48 | .backgroundColor(Color.Gray) | 48 | .backgroundColor(Color.Gray) |
| @@ -6,13 +6,15 @@ import { EmptyComponent } from '../view/EmptyComponent' | @@ -6,13 +6,15 @@ import { EmptyComponent } from '../view/EmptyComponent' | ||
| 6 | import { ErrorComponent } from '../view/ErrorComponent' | 6 | import { ErrorComponent } from '../view/ErrorComponent' |
| 7 | import RefreshLayout from './RefreshLayout' | 7 | import RefreshLayout from './RefreshLayout' |
| 8 | import { RefreshLayoutBean } from './RefreshLayoutBean'; | 8 | import { RefreshLayoutBean } from './RefreshLayoutBean'; |
| 9 | -import { CompDTO } from 'wdBean' | 9 | +import { CompDTO, ContentDTO } from 'wdBean' |
| 10 | import LoadMoreLayout from './LoadMoreLayout' | 10 | import LoadMoreLayout from './LoadMoreLayout' |
| 11 | import NoMoreLayout from './NoMoreLayout' | 11 | import NoMoreLayout from './NoMoreLayout' |
| 12 | import { CompParser } from '../CompParser' | 12 | import { CompParser } from '../CompParser' |
| 13 | import CustomRefreshLoadLayout from './CustomRefreshLoadLayout'; | 13 | import CustomRefreshLoadLayout from './CustomRefreshLoadLayout'; |
| 14 | import { CustomSelectUI } from '../view/CustomSelectUI'; | 14 | import { CustomSelectUI } from '../view/CustomSelectUI'; |
| 15 | import { CustomBottomFuctionUI } from '../view/CustomBottomFuctionUI'; | 15 | import { CustomBottomFuctionUI } from '../view/CustomBottomFuctionUI'; |
| 16 | +import { BigPicCardComponent } from '../view/BigPicCardComponent'; | ||
| 17 | +import { contentListItemParams } from '../../model/MyCollectionModel'; | ||
| 16 | 18 | ||
| 17 | @Entry | 19 | @Entry |
| 18 | @Component | 20 | @Component |
| @@ -20,8 +22,8 @@ struct MyCollectionListPage { | @@ -20,8 +22,8 @@ struct MyCollectionListPage { | ||
| 20 | @State private browSingModel: PageModel = new PageModel() | 22 | @State private browSingModel: PageModel = new PageModel() |
| 21 | isloading : boolean = false | 23 | isloading : boolean = false |
| 22 | @Provide isEditState:boolean = false | 24 | @Provide isEditState:boolean = false |
| 23 | - @State allDatas :CompDTO[] = []; | ||
| 24 | - @State selectDatas :CompDTO[] = []; | 25 | + @State allDatas :ContentDTO[] = []; |
| 26 | + @State selectDatas :ContentDTO[] = []; | ||
| 25 | @Provide deleteNum :number = 0; | 27 | @Provide deleteNum :number = 0; |
| 26 | @Provide isAllSelect:boolean = false | 28 | @Provide isAllSelect:boolean = false |
| 27 | aboutToAppear(){ | 29 | aboutToAppear(){ |
| @@ -72,7 +74,7 @@ struct MyCollectionListPage { | @@ -72,7 +74,7 @@ struct MyCollectionListPage { | ||
| 72 | }) | 74 | }) |
| 73 | } | 75 | } |
| 74 | 76 | ||
| 75 | - ForEach(this.allDatas, (compDTO: CompDTO, compIndex: number) => { | 77 | + ForEach(this.allDatas, (compDTO: ContentDTO, compIndex: number) => { |
| 76 | ListItem() { | 78 | ListItem() { |
| 77 | this.newCompParser(compDTO,compIndex) | 79 | this.newCompParser(compDTO,compIndex) |
| 78 | } | 80 | } |
| @@ -94,7 +96,7 @@ struct MyCollectionListPage { | @@ -94,7 +96,7 @@ struct MyCollectionListPage { | ||
| 94 | } | 96 | } |
| 95 | 97 | ||
| 96 | @Builder | 98 | @Builder |
| 97 | - newCompParser(compDTO: CompDTO, compIndex: number){ | 99 | + newCompParser(compDTO: ContentDTO, compIndex: number){ |
| 98 | Row(){ | 100 | Row(){ |
| 99 | if (this.isEditState){ | 101 | if (this.isEditState){ |
| 100 | CustomSelectUI({ | 102 | CustomSelectUI({ |
| @@ -106,7 +108,7 @@ struct MyCollectionListPage { | @@ -106,7 +108,7 @@ struct MyCollectionListPage { | ||
| 106 | .margin({left:16}) | 108 | .margin({left:16}) |
| 107 | } | 109 | } |
| 108 | Column() { | 110 | Column() { |
| 109 | - CompParser({ compDTO: compDTO, compIndex: compIndex }) | 111 | + BigPicCardComponent({contentDTO:compDTO}) |
| 110 | } | 112 | } |
| 111 | } | 113 | } |
| 112 | } | 114 | } |
| @@ -118,11 +120,11 @@ struct MyCollectionListPage { | @@ -118,11 +120,11 @@ struct MyCollectionListPage { | ||
| 118 | 120 | ||
| 119 | async getData() { | 121 | async getData() { |
| 120 | this.browSingModel.currentPage = 1 | 122 | this.browSingModel.currentPage = 1 |
| 121 | - MyCollectionViewModel.newFetchMyCollectList(1,'1',this.browSingModel.currentPage,getContext(this)).then(pageDto => { | ||
| 122 | - if (pageDto && pageDto.compList && pageDto.compList.length > 0) { | 123 | + MyCollectionViewModel.fetchMyCollectList(1,'1',this.browSingModel.currentPage,getContext(this)).then(collectionItem => { |
| 124 | + if (collectionItem && collectionItem.list && collectionItem.list.length > 0) { | ||
| 123 | this.browSingModel.viewType = ViewType.LOADED; | 125 | this.browSingModel.viewType = ViewType.LOADED; |
| 124 | - this.allDatas.push(...pageDto.compList) | ||
| 125 | - if (pageDto.compList.length === this.browSingModel.pageSize) { | 126 | + this.allDatas.push(...collectionItem.list) |
| 127 | + if (collectionItem.list.length === this.browSingModel.pageSize) { | ||
| 126 | this.browSingModel.currentPage++; | 128 | this.browSingModel.currentPage++; |
| 127 | this.browSingModel.hasMore = true; | 129 | this.browSingModel.hasMore = true; |
| 128 | } else { | 130 | } else { |
| @@ -136,7 +138,7 @@ struct MyCollectionListPage { | @@ -136,7 +138,7 @@ struct MyCollectionListPage { | ||
| 136 | 138 | ||
| 137 | //数据处理 | 139 | //数据处理 |
| 138 | //单个选择 | 140 | //单个选择 |
| 139 | - addCompDTO(isOn:boolean , compDTO: CompDTO){ | 141 | + addCompDTO(isOn:boolean , compDTO: ContentDTO){ |
| 140 | compDTO.isSelect = isOn; | 142 | compDTO.isSelect = isOn; |
| 141 | if (isOn === true){ | 143 | if (isOn === true){ |
| 142 | this.selectDatas.push(compDTO) | 144 | this.selectDatas.push(compDTO) |
| @@ -150,7 +152,7 @@ struct MyCollectionListPage { | @@ -150,7 +152,7 @@ struct MyCollectionListPage { | ||
| 150 | 152 | ||
| 151 | //全选 | 153 | //全选 |
| 152 | allSelectDatas(isOn:boolean){ | 154 | allSelectDatas(isOn:boolean){ |
| 153 | - let datas: CompDTO[] = []; | 155 | + let datas: ContentDTO[] = []; |
| 154 | for (let index = 0; index < this.allDatas.length; index++) { | 156 | for (let index = 0; index < this.allDatas.length; index++) { |
| 155 | const compDTO = this.allDatas[index]; | 157 | const compDTO = this.allDatas[index]; |
| 156 | compDTO.isSelect = isOn | 158 | compDTO.isSelect = isOn |
| @@ -169,13 +171,22 @@ struct MyCollectionListPage { | @@ -169,13 +171,22 @@ struct MyCollectionListPage { | ||
| 169 | 171 | ||
| 170 | //删除 | 172 | //删除 |
| 171 | deleteDatas(){ | 173 | deleteDatas(){ |
| 174 | + let deleteDatas:contentListItemParams[] = []; | ||
| 172 | for (let index = 0; index < this.selectDatas.length; index++) { | 175 | for (let index = 0; index < this.selectDatas.length; index++) { |
| 173 | - const compDTO = this.allDatas[index]; | ||
| 174 | - this.allDatas.splice(this.selectDatas.indexOf(compDTO),1) | 176 | + const compDTO = this.selectDatas[index]; |
| 177 | + this.allDatas.splice(this.allDatas.indexOf(compDTO),1) | ||
| 178 | + deleteDatas.push({contentId:compDTO.objectId,contentType:compDTO.objectType,relType:compDTO.relType,contentRelId:compDTO.relId}) | ||
| 175 | } | 179 | } |
| 176 | 180 | ||
| 181 | + MyCollectionViewModel.executeCollcet({ | ||
| 182 | + delAll:this.isAllSelect === true?1:0, | ||
| 183 | + status:0, | ||
| 184 | + contentList:deleteDatas | ||
| 185 | + }) | ||
| 186 | + | ||
| 177 | //重置删除状态 | 187 | //重置删除状态 |
| 178 | this.isEditState = false | 188 | this.isEditState = false |
| 179 | this.isAllSelect = false | 189 | this.isAllSelect = false |
| 180 | } | 190 | } |
| 191 | + | ||
| 181 | } | 192 | } |
| 1 | import { CommonConstants, ViewType } from 'wdConstant'; | 1 | import { CommonConstants, ViewType } from 'wdConstant'; |
| 2 | -import { Logger, DateTimeUtils } from 'wdKit'; | 2 | +import { Logger, DateTimeUtils, CollectionUtils } 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,8 @@ import NoMoreLayout from './NoMoreLayout'; | @@ -11,7 +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 { CompDTO } from 'wdBean'; | 14 | +import { CompDTO,PageInfoDTO } from 'wdBean'; |
| 15 | +import { GroupInfoDTO } from 'wdBean/src/main/ets/bean/navigation/PageInfoDTO'; | ||
| 15 | 16 | ||
| 16 | const TAG = 'PageComponent'; | 17 | const TAG = 'PageComponent'; |
| 17 | 18 | ||
| @@ -118,8 +119,19 @@ export struct PageComponent { | @@ -118,8 +119,19 @@ export struct PageComponent { | ||
| 118 | this.pageModel.groupId = this.pageId; | 119 | this.pageModel.groupId = this.pageId; |
| 119 | this.pageModel.channelId = this.channelId; | 120 | this.pageModel.channelId = this.channelId; |
| 120 | this.pageModel.currentPage = 1; | 121 | this.pageModel.currentPage = 1; |
| 121 | - let pageDto = await PageViewModel.getPageData(this.pageModel.pageId, this.pageModel.pageId, this.pageModel.channelId | ||
| 122 | - , this.pageModel.currentPage, this.pageModel.pageSize, getContext(this)) | 122 | + let pageInfo = await PageViewModel.getPageInfo(this.pageModel.pageId); |
| 123 | + if (pageInfo == null) { | ||
| 124 | + this.pageModel.viewType = ViewType.EMPTY; | ||
| 125 | + return; | ||
| 126 | + } | ||
| 127 | + | ||
| 128 | + let groupInfo: GroupInfoDTO = CollectionUtils.getElement(pageInfo.groups, 0); | ||
| 129 | + if (groupInfo != null) { | ||
| 130 | + this.pageModel.isRecGroup = groupInfo.groupStrategy === 1; | ||
| 131 | + this.pageModel.groupId = groupInfo.id; | ||
| 132 | + } | ||
| 133 | + | ||
| 134 | + let pageDto = await PageViewModel.getPageData(this.pageModel, getContext(this)) | ||
| 123 | this.pageModel.timestamp = DateTimeUtils.getTimeStamp().toString() | 135 | this.pageModel.timestamp = DateTimeUtils.getTimeStamp().toString() |
| 124 | if (pageDto && pageDto.compList && pageDto.compList.length > 0) { | 136 | if (pageDto && pageDto.compList && pageDto.compList.length > 0) { |
| 125 | this.pageModel.viewType = ViewType.LOADED; | 137 | this.pageModel.viewType = ViewType.LOADED; |
| @@ -19,9 +19,11 @@ export struct BigPicCardComponent { | @@ -19,9 +19,11 @@ export struct BigPicCardComponent { | ||
| 19 | 19 | ||
| 20 | aboutToAppear() { | 20 | aboutToAppear() { |
| 21 | // 取第一个数据 | 21 | // 取第一个数据 |
| 22 | + if (this.compDTO.operDataList) { | ||
| 22 | this.contentDTO = this.compDTO.operDataList[0]; | 23 | this.contentDTO = this.compDTO.operDataList[0]; |
| 23 | this.contentDTO.appStyle = "2"; | 24 | this.contentDTO.appStyle = "2"; |
| 24 | } | 25 | } |
| 26 | + } | ||
| 25 | 27 | ||
| 26 | build() { | 28 | build() { |
| 27 | this.cardBuild(); | 29 | this.cardBuild(); |
| 1 | -import { Logger } from 'wdKit'; | ||
| 2 | import { AreaListManageModel, AreaListModel } from '../../../model/AreaListModel'; | 1 | import { AreaListManageModel, AreaListModel } from '../../../model/AreaListModel'; |
| 3 | -import EditInfoViewModel from '../../../viewmodel/EditInfoViewModel'; | ||
| 4 | import { FirstLevelComponent } from './FirstLevelComponent'; | 2 | import { FirstLevelComponent } from './FirstLevelComponent'; |
| 5 | import { SecondLevelComponent } from './SecondLevelComponent'; | 3 | import { SecondLevelComponent } from './SecondLevelComponent'; |
| 6 | import { ThirdLevelComponent } from './ThirdLevelComponent'; | 4 | import { ThirdLevelComponent } from './ThirdLevelComponent'; |
| 7 | @CustomDialog | 5 | @CustomDialog |
| 6 | + | ||
| 8 | export struct AreaPickerDialog { | 7 | export struct AreaPickerDialog { |
| 9 | @Provide currentFirst: AreaListManageModel = new AreaListManageModel('','','',[]) | 8 | @Provide currentFirst: AreaListManageModel = new AreaListManageModel('','','',[]) |
| 10 | @Provide currentSecondBean: AreaListManageModel = new AreaListManageModel('','','',[]) | 9 | @Provide currentSecondBean: AreaListManageModel = new AreaListManageModel('','','',[]) |
| 1 | +import { ContentDTO } from 'wdBean/Index'; | ||
| 1 | 2 | ||
| 2 | // { | 3 | // { |
| 3 | // "hasNext": 0, | 4 | // "hasNext": 0, |
| @@ -22,24 +23,38 @@ export class MyCollectionModel{ | @@ -22,24 +23,38 @@ export class MyCollectionModel{ | ||
| 22 | } | 23 | } |
| 23 | } | 24 | } |
| 24 | 25 | ||
| 25 | -@Observed | ||
| 26 | export class MyCollectionItem{ | 26 | export class MyCollectionItem{ |
| 27 | pageNum:number = 0 | 27 | pageNum:number = 0 |
| 28 | pageSize:number = 0 | 28 | pageSize:number = 0 |
| 29 | totalCount:number = 0 | 29 | totalCount:number = 0 |
| 30 | hasNext:number = 0 | 30 | hasNext:number = 0 |
| 31 | - list:MyCollectionModel[] = [] | 31 | + list:ContentDTO[] = [] |
| 32 | + | ||
| 33 | + constructor(list?:ContentDTO[],pageNum?: number,pageSize?: number,totalCount?: number,hasNext?:number) { | ||
| 34 | + } | ||
| 32 | } | 35 | } |
| 33 | 36 | ||
| 37 | +export interface MyCollectionListModel{ | ||
| 38 | + data: MyCollectionItem | ||
| 39 | + code: number | ||
| 40 | + message: string | ||
| 41 | + success: string | ||
| 42 | + timestamp: number | ||
| 43 | +} | ||
| 34 | 44 | ||
| 35 | -export class MyCollectionListModel{ | ||
| 36 | - list:MyCollectionModel[] = [] | ||
| 37 | 45 | ||
| 38 | - pageNum: number = 0 | ||
| 39 | - pageSize: number = 20 | ||
| 40 | - totalCount: number = 0 | ||
| 41 | 46 | ||
| 42 | - constructor(list?:MyCollectionModel[],pageNum?: number,pageSize?: number,totalCount?: number) { | ||
| 43 | - } | 47 | +export interface contentListItemParams{ |
| 48 | + contentId?:string; | ||
| 49 | + contentType?:string; | ||
| 50 | + relType?:string; | ||
| 51 | + contentRelId?:string; | ||
| 44 | } | 52 | } |
| 45 | 53 | ||
| 54 | +export interface collcetRecordParams { | ||
| 55 | + delAll?: number; | ||
| 56 | + | ||
| 57 | + status?: number; | ||
| 58 | + | ||
| 59 | + contentList?: contentListItemParams[]; | ||
| 60 | +} |
| @@ -17,7 +17,8 @@ import { | @@ -17,7 +17,8 @@ import { | ||
| 17 | postExecuteLikeParams, | 17 | postExecuteLikeParams, |
| 18 | postExecuteCollectRecordParams, | 18 | postExecuteCollectRecordParams, |
| 19 | contentListParams, | 19 | contentListParams, |
| 20 | - postInteractAccentionOperateParams | 20 | + postInteractAccentionOperateParams, |
| 21 | + PageInfoDTO | ||
| 21 | } from 'wdBean'; | 22 | } from 'wdBean'; |
| 22 | 23 | ||
| 23 | const TAG = 'HttpRequest'; | 24 | const TAG = 'HttpRequest'; |
| @@ -59,6 +60,23 @@ export class PageRepository { | @@ -59,6 +60,23 @@ export class PageRepository { | ||
| 59 | Logger.info(TAG, "getCompInfoUrl url = " + url) | 60 | Logger.info(TAG, "getCompInfoUrl url = " + url) |
| 60 | return url; | 61 | return url; |
| 61 | } | 62 | } |
| 63 | + static getRecCompInfoUrl(pageId: string, groupId: string, channelId: string, currentPage: number, pageSize: number) { | ||
| 64 | + let url = HttpUrlUtils.getHost() + HttpUrlUtils.HOTCOMP_PATH; | ||
| 65 | + // TODO 暂定只请求第一页,后续对接分页加载,参数再调整 first_load? | ||
| 66 | + url = url + "?channelStrategy=1&loadStrategy=first_load" | ||
| 67 | + + "&districtCode=" + HttpUrlUtils.getDistrictCode() | ||
| 68 | + + "&provinceCode=" + HttpUrlUtils.getProvinceCode() | ||
| 69 | + + "&cityCode=" + HttpUrlUtils.getCityCode() | ||
| 70 | + + "&refreshTime=" + DateTimeUtils.getTimeStamp() | ||
| 71 | + + "&pageId=" + pageId | ||
| 72 | + + "&groupId=" + groupId | ||
| 73 | + + "&channelId=" + channelId | ||
| 74 | + + "&pageSize=" + pageSize | ||
| 75 | + + "&pageNum=" + currentPage; | ||
| 76 | + // Logger.debug("TAG", 'getCompInfoUrl url: '+url); | ||
| 77 | + Logger.info(TAG, "getCompInfoUrl url = " + url) | ||
| 78 | + return url; | ||
| 79 | + } | ||
| 62 | 80 | ||
| 63 | static getDetailInfoUrl(relId: string, contentId: string, relType: string) { | 81 | static getDetailInfoUrl(relId: string, contentId: string, relType: string) { |
| 64 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.DETAIL_PATH; | 82 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.DETAIL_PATH; |
| @@ -156,12 +174,24 @@ export class PageRepository { | @@ -156,12 +174,24 @@ export class PageRepository { | ||
| 156 | return WDHttp.get<ResponseDTO<MorningEveningPaperDTO>>(url, headers) | 174 | return WDHttp.get<ResponseDTO<MorningEveningPaperDTO>>(url, headers) |
| 157 | }; | 175 | }; |
| 158 | 176 | ||
| 159 | - static fetchPageData(pageId: string, groupId: string, channelId: string, currentPage: number, pageSize: number) { | 177 | + static fetchPageData(pageId: string) { |
| 178 | + let url = PageRepository.getPageInfoUrl(pageId) | ||
| 179 | + let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | ||
| 180 | + return WDHttp.get<ResponseDTO<PageInfoDTO>>(url, headers) | ||
| 181 | + }; | ||
| 182 | + | ||
| 183 | + static fetchCompData(pageId: string, groupId: string, channelId: string, currentPage: number, pageSize: number) { | ||
| 160 | let url = PageRepository.getCompInfoUrl(pageId, groupId, channelId, currentPage, pageSize) | 184 | let url = PageRepository.getCompInfoUrl(pageId, groupId, channelId, currentPage, pageSize) |
| 161 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | 185 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); |
| 162 | return WDHttp.get<ResponseDTO<PageDTO>>(url, headers) | 186 | return WDHttp.get<ResponseDTO<PageDTO>>(url, headers) |
| 163 | }; | 187 | }; |
| 164 | 188 | ||
| 189 | + static fetchRecCompData(pageId: string, groupId: string, channelId: string, currentPage: number, pageSize: number) { | ||
| 190 | + let url = PageRepository.getRecCompInfoUrl(pageId, groupId, channelId, currentPage, pageSize) | ||
| 191 | + let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | ||
| 192 | + return WDHttp.get<ResponseDTO<PageDTO>>(url, headers) | ||
| 193 | + }; | ||
| 194 | + | ||
| 165 | static fetchDetailData(relId: string, contentId: string, relType: string) { | 195 | static fetchDetailData(relId: string, contentId: string, relType: string) { |
| 166 | let url = PageRepository.getDetailInfoUrl(relId, contentId, relType) | 196 | let url = PageRepository.getDetailInfoUrl(relId, contentId, relType) |
| 167 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | 197 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); |
| @@ -72,7 +72,7 @@ export function touchUpPullRefresh(pageModel: PageModel) { | @@ -72,7 +72,7 @@ export function touchUpPullRefresh(pageModel: PageModel) { | ||
| 72 | setTimeout(() => { | 72 | setTimeout(() => { |
| 73 | let self: PageModel = pageModel; | 73 | let self: PageModel = pageModel; |
| 74 | 74 | ||
| 75 | - PageViewModel.getPageData(self.pageId, self.groupId, self.channelId, self.currentPage, self.pageSize, getContext()) | 75 | + PageViewModel.getPageData(self, getContext()) |
| 76 | .then((data: PageDTO) => { | 76 | .then((data: PageDTO) => { |
| 77 | self.timestamp = DateTimeUtils.getTimeStamp().toString() | 77 | self.timestamp = DateTimeUtils.getTimeStamp().toString() |
| 78 | if (data == null || data.compList == null || data.compList.length == 0) { | 78 | if (data == null || data.compList == null || data.compList.length == 0) { |
| @@ -28,7 +28,7 @@ export function touchUpLoadMore(model: PageModel) { | @@ -28,7 +28,7 @@ export function touchUpLoadMore(model: PageModel) { | ||
| 28 | self.isLoading = true; | 28 | self.isLoading = true; |
| 29 | setTimeout(() => { | 29 | setTimeout(() => { |
| 30 | closeLoadMore(model); | 30 | closeLoadMore(model); |
| 31 | - PageViewModel.getPageData(self.pageId, self.groupId, self.channelId, self.currentPage, self.pageSize, getContext()) | 31 | + PageViewModel.getPageData(self, getContext()) |
| 32 | .then((data: PageDTO) => { | 32 | .then((data: PageDTO) => { |
| 33 | self.timestamp = DateTimeUtils.getTimeStamp().toString() | 33 | self.timestamp = DateTimeUtils.getTimeStamp().toString() |
| 34 | if (data == null || data.compList == null || data.compList.length == 0) { | 34 | if (data == null || data.compList == null || data.compList.length == 0) { |
| 1 | -import { MyCollectionListModel } from '../model/MyCollectionModel'; | 1 | +import { collcetRecordParams, MyCollectionItem, MyCollectionListModel } from '../model/MyCollectionModel'; |
| 2 | import HashMap from '@ohos.util.HashMap'; | 2 | import HashMap from '@ohos.util.HashMap'; |
| 3 | import { HttpUrlUtils, ResponseDTO, WDHttp } from 'wdNetwork'; | 3 | import { HttpUrlUtils, ResponseDTO, WDHttp } from 'wdNetwork'; |
| 4 | import { Logger, ResourcesUtils } from 'wdKit'; | 4 | import { Logger, ResourcesUtils } from 'wdKit'; |
| 5 | import { PageDTO } from 'wdBean'; | 5 | import { PageDTO } from 'wdBean'; |
| 6 | +import promptAction from '@ohos.promptAction'; | ||
| 6 | 7 | ||
| 7 | const TAG = "MyCollectionViewModel" | 8 | const TAG = "MyCollectionViewModel" |
| 8 | 9 | ||
| 9 | class MyCollectionViewModel { | 10 | class MyCollectionViewModel { |
| 10 | private static instance:MyCollectionViewModel | 11 | private static instance:MyCollectionViewModel |
| 11 | - | ||
| 12 | /** | 12 | /** |
| 13 | * 单例模式 | 13 | * 单例模式 |
| 14 | * @returns | 14 | * @returns |
| @@ -20,84 +20,48 @@ class MyCollectionViewModel { | @@ -20,84 +20,48 @@ class MyCollectionViewModel { | ||
| 20 | return MyCollectionViewModel.instance; | 20 | return MyCollectionViewModel.instance; |
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | - BaseGetRequest(type:number,tagId:string,pageNum:string){ | ||
| 24 | - let url = HttpUrlUtils.getMyCollectionListDataUrl()+ `?type=${type}&operateTag=${1}&pageSize=${20}&pageNum=${pageNum}` | ||
| 25 | - if (tagId.length > 0) { | ||
| 26 | - url = url + `&tagId=${tagId}` | ||
| 27 | - } | 23 | + //Type 1 收藏 2 浏览历史 |
| 24 | + //tagId 收藏界面 标签筛选 | ||
| 25 | + BaseGetRequest(type:number,tagId:string,pageNum:number){ | ||
| 26 | + let url = HttpUrlUtils.getMyCollectionListDataUrl()+ `?type=${type}&operateTag=${2}&pageSize=${20}&pageNum=${pageNum.toString()}` | ||
| 27 | + // if (tagId.length > 0) { | ||
| 28 | + // url = url + `&tagId=${tagId}` | ||
| 29 | + // } | ||
| 28 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders() | 30 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders() |
| 29 | - return WDHttp.get<ResponseDTO<MyCollectionListModel>>(url, headers) | 31 | + return WDHttp.get<MyCollectionListModel>(url, headers) |
| 30 | } | 32 | } |
| 31 | 33 | ||
| 32 | - async getAppointmentListDataLocal(context: Context): Promise<MyCollectionListModel> { | ||
| 33 | - Logger.info(TAG, `getBottomNavDataMock start`); | ||
| 34 | - let compRes: ResponseDTO<MyCollectionListModel> | null = await ResourcesUtils.getResourcesJson<ResponseDTO<MyCollectionListModel>>(context,'browsingHistory_list_data.json' ); | ||
| 35 | - if (!compRes || !compRes.data) { | ||
| 36 | - Logger.info(TAG, `getAppointmentListDataLocal compRes is empty`); | ||
| 37 | - return new MyCollectionListModel() | ||
| 38 | - } | ||
| 39 | - Logger.info(TAG, `getAppointmentListDataLocal getResourcesJsonSync compRes : ${JSON.stringify(compRes)}`); | ||
| 40 | - return compRes.data | ||
| 41 | - } | ||
| 42 | 34 | ||
| 43 | - //Type 1 收藏 2 浏览历史 | ||
| 44 | - //tagId 收藏界面 标签筛选 | ||
| 45 | - fetchMyCollectList(type:number,tagId:string,pageNum:string,context: Context):Promise<MyCollectionListModel>{ | ||
| 46 | - return new Promise<MyCollectionListModel>((success,error) => { | ||
| 47 | - this.BaseGetRequest(type,tagId,pageNum).then((navResDTO: ResponseDTO<MyCollectionListModel>) => { | 35 | + fetchMyCollectList(type:number,tagId:string,pageNum:number,context: Context):Promise<MyCollectionItem>{ |
| 36 | + return new Promise((success,error) => { | ||
| 37 | + this.BaseGetRequest(type,tagId,pageNum).then((navResDTO: MyCollectionListModel) => { | ||
| 48 | if (!navResDTO || navResDTO.code != 0) { | 38 | if (!navResDTO || navResDTO.code != 0) { |
| 49 | - success(this.getAppointmentListDataLocal(context)) | ||
| 50 | return | 39 | return |
| 51 | } | 40 | } |
| 52 | - Logger.info(TAG, "getAppointmentList then,AppointmentResDTO.timeStamp:" + navResDTO.timestamp); | ||
| 53 | - let listData = navResDTO.data as MyCollectionListModel | ||
| 54 | - success(listData) | 41 | + Logger.info(TAG, "fetchMyCollectList then,navResDTO.timeStamp:" + navResDTO.timestamp); |
| 42 | + success(navResDTO.data) | ||
| 55 | }).catch((err: Error) => { | 43 | }).catch((err: Error) => { |
| 56 | - Logger.error(TAG, `fetchAppointmentListDataApi catch, error.name : ${err.name}, error.message:${err.message}`); | 44 | + Logger.error(TAG, `fetchMyCollectList catch, error.name : ${err.name}, error.message:${err.message}`); |
| 57 | error("page data invalid"); | 45 | error("page data invalid"); |
| 58 | }) | 46 | }) |
| 59 | }) | 47 | }) |
| 60 | } | 48 | } |
| 61 | 49 | ||
| 62 | - | ||
| 63 | - newBaseGetRequest(type:number,tagId:string,pageNum:number){ | ||
| 64 | - let url = HttpUrlUtils.getMyCollectionListDataUrl()+ `?type=${type}&operateTag=${1}&pageSize=${20}&pageNum=${pageNum.toString()}` | ||
| 65 | - if (tagId.length > 0) { | ||
| 66 | - url = url + `&tagId=${tagId}` | ||
| 67 | - } | 50 | + //收藏/取消收藏 status :收藏状态 1添加收藏 0取消收藏 |
| 51 | + executeCollcet(params: collcetRecordParams):Promise<ResponseDTO>{ | ||
| 52 | + return new Promise(() => { | ||
| 68 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders() | 53 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders() |
| 69 | - return WDHttp.get<ResponseDTO<PageDTO>>(url, headers) | 54 | + WDHttp.post<ResponseDTO>(HttpUrlUtils.getExecuteCollcetUrl(),params,headers).then((navResDTO: ResponseDTO) => { |
| 55 | + if (navResDTO.code == 0) { | ||
| 56 | + promptAction.showToast({ message: '删除成功' }) | ||
| 70 | } | 57 | } |
| 71 | - | ||
| 72 | - newFetchMyCollectList(type:number,tagId:string,pageNum:number,context: Context):Promise<PageDTO>{ | ||
| 73 | - return new Promise<PageDTO>((success,error) => { | ||
| 74 | - success(this.newGetAppointmentListDataLocal(type,context)) | ||
| 75 | - return | ||
| 76 | - this.newBaseGetRequest(type,tagId,pageNum).then((navResDTO: ResponseDTO<PageDTO>) => { | ||
| 77 | - if (!navResDTO || navResDTO.code != 0) { | ||
| 78 | - success(this.newGetAppointmentListDataLocal(type,context)) | ||
| 79 | - return | ||
| 80 | - } | ||
| 81 | - Logger.info(TAG, "getAppointmentList then,AppointmentResDTO.timeStamp:" + navResDTO.timestamp); | ||
| 82 | - let listData = navResDTO.data as PageDTO | ||
| 83 | - success(listData) | ||
| 84 | - }).catch((err: Error) => { | ||
| 85 | - Logger.error(TAG, `fetchAppointmentListDataApi catch, error.name : ${err.name}, error.message:${err.message}`); | ||
| 86 | - error("page data invalid"); | 58 | + }) |
| 59 | + .catch((error: Error) => { | ||
| 60 | + Logger.info(TAG,'executeCollcet','ResponseDTO') | ||
| 87 | }) | 61 | }) |
| 88 | }) | 62 | }) |
| 89 | } | 63 | } |
| 90 | 64 | ||
| 91 | - async newGetAppointmentListDataLocal(type:number, context: Context): Promise<PageDTO> { | ||
| 92 | - Logger.info(TAG, `getBottomNavDataMock start`); | ||
| 93 | - let compRes: ResponseDTO<PageDTO> | null = await ResourcesUtils.getResourcesJson<ResponseDTO<PageDTO>>(context,type == 1?'MyCollection_list_data.json':'browsingHistory_list_data.json'); | ||
| 94 | - if (!compRes || !compRes.data) { | ||
| 95 | - Logger.info(TAG, `getAppointmentListDataLocal compRes is empty`); | ||
| 96 | - return {} as PageDTO | ||
| 97 | - } | ||
| 98 | - Logger.info(TAG, `getAppointmentListDataLocal getResourcesJsonSync compRes : ${JSON.stringify(compRes)}`); | ||
| 99 | - return compRes.data | ||
| 100 | - } | ||
| 101 | } | 65 | } |
| 102 | 66 | ||
| 103 | const collectionViewModel = MyCollectionViewModel.getInstance(); | 67 | const collectionViewModel = MyCollectionViewModel.getInstance(); |
| @@ -8,6 +8,7 @@ export default class PageModel { | @@ -8,6 +8,7 @@ export default class PageModel { | ||
| 8 | pageId: string = ""; | 8 | pageId: string = ""; |
| 9 | groupId: string = ""; | 9 | groupId: string = ""; |
| 10 | channelId: string = ""; | 10 | channelId: string = ""; |
| 11 | + isRecGroup: boolean = false; | ||
| 11 | compList: LazyDataSource<CompDTO> = new LazyDataSource(); | 12 | compList: LazyDataSource<CompDTO> = new LazyDataSource(); |
| 12 | // 页面状态,刷新、加载更多等 | 13 | // 页面状态,刷新、加载更多等 |
| 13 | currentPage: number = 1; | 14 | currentPage: number = 1; |
| 1 | import { NavigationBodyDTO, PageDTO,InteractDataDTO,ContentBean, InteractParam,CompDTO, | 1 | import { NavigationBodyDTO, PageDTO,InteractDataDTO,ContentBean, InteractParam,CompDTO, |
| 2 | - MorningEveningPaperDTO } from 'wdBean'; | 2 | + MorningEveningPaperDTO,PageInfoDTO} from 'wdBean'; |
| 3 | import { CollectionUtils, Logger, ResourcesUtils, StringUtils } from 'wdKit'; | 3 | import { CollectionUtils, Logger, ResourcesUtils, StringUtils } from 'wdKit'; |
| 4 | import { ResponseDTO, } from 'wdNetwork'; | 4 | import { ResponseDTO, } from 'wdNetwork'; |
| 5 | import { PageRepository } from '../repository/PageRepository'; | 5 | import { PageRepository } from '../repository/PageRepository'; |
| 6 | import { BaseViewModel } from './BaseViewModel'; | 6 | import { BaseViewModel } from './BaseViewModel'; |
| 7 | +import PageModel from './PageModel'; | ||
| 7 | 8 | ||
| 8 | const TAG = 'PageViewModel'; | 9 | const TAG = 'PageViewModel'; |
| 9 | /** | 10 | /** |
| @@ -130,14 +131,18 @@ export class PageViewModel extends BaseViewModel { | @@ -130,14 +131,18 @@ export class PageViewModel extends BaseViewModel { | ||
| 130 | return compRes.data | 131 | return compRes.data |
| 131 | } | 132 | } |
| 132 | 133 | ||
| 133 | - async getPageData(pageId: string, groupId: string, channelId: string, currentPage: number | ||
| 134 | - , pageSize: number, context: Context): Promise<PageDTO> { | ||
| 135 | - Logger.debug(TAG, 'getPageData pageId: ' + pageId); | ||
| 136 | - if (mock_switch) { | ||
| 137 | - return this.getPageData1(currentPage, context); | 134 | + async getPageData(pageModel: PageModel, context?: Context): Promise<PageDTO> { |
| 135 | + Logger.debug(TAG, 'getPageData pageId: ' + pageModel.pageId); | ||
| 136 | + if (pageModel.isRecGroup) { | ||
| 137 | + return this.parseComp(PageRepository.fetchRecCompData(pageModel.pageId, pageModel.groupId, pageModel.channelId, pageModel.currentPage, pageModel.pageSize)) | ||
| 138 | + } else { | ||
| 139 | + return this.parseComp(PageRepository.fetchCompData(pageModel.pageId, pageModel.groupId, pageModel.channelId, pageModel.currentPage, pageModel.pageSize)) | ||
| 138 | } | 140 | } |
| 141 | + } | ||
| 142 | + | ||
| 143 | + private parseComp(getData: Promise<ResponseDTO<PageDTO>>): Promise<PageDTO> { | ||
| 139 | return new Promise<PageDTO>((success, error) => { | 144 | return new Promise<PageDTO>((success, error) => { |
| 140 | - PageRepository.fetchPageData(pageId, groupId, channelId, currentPage, pageSize) | 145 | + getData |
| 141 | .then((resDTO: ResponseDTO<PageDTO>) => { | 146 | .then((resDTO: ResponseDTO<PageDTO>) => { |
| 142 | if (!resDTO || !resDTO.data) { | 147 | if (!resDTO || !resDTO.data) { |
| 143 | Logger.error(TAG, 'getNavData then resDTO is empty'); | 148 | Logger.error(TAG, 'getNavData then resDTO is empty'); |
| @@ -276,6 +281,20 @@ export class PageViewModel extends BaseViewModel { | @@ -276,6 +281,20 @@ export class PageViewModel extends BaseViewModel { | ||
| 276 | }) | 281 | }) |
| 277 | return param; | 282 | return param; |
| 278 | } | 283 | } |
| 284 | + | ||
| 285 | + | ||
| 286 | + async getPageInfo(pageId: string): Promise<PageInfoDTO> { | ||
| 287 | + return new Promise<PageInfoDTO>((success, error) => { | ||
| 288 | + PageRepository.fetchPageData(pageId).then((resDTO: ResponseDTO<PageInfoDTO>) => { | ||
| 289 | + if (this.isRespondsInvalid(resDTO, 'getPageInfo')) { | ||
| 290 | + error("getPageInfo data invalid"); | ||
| 291 | + return | ||
| 292 | + } | ||
| 293 | + Logger.info(TAG, "getPageInfo then,resDTO.timeStamp:" + resDTO.timestamp); | ||
| 294 | + success(resDTO.data as PageInfoDTO); | ||
| 295 | + }); | ||
| 296 | + }); | ||
| 297 | + } | ||
| 279 | } | 298 | } |
| 280 | 299 | ||
| 281 | 300 |
-
Please register or login to post a comment