Showing
4 changed files
with
93 additions
and
25 deletions
| @@ -29,6 +29,7 @@ export struct BottomNavigationComponent { | @@ -29,6 +29,7 @@ export struct BottomNavigationComponent { | ||
| 29 | @State topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0 | 29 | @State topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0 |
| 30 | @State @Watch('onBottomNavigationDataUpdated') bottomNavList: BottomNavDTO[] = [] // 底导/顶导全部数据 | 30 | @State @Watch('onBottomNavigationDataUpdated') bottomNavList: BottomNavDTO[] = [] // 底导/顶导全部数据 |
| 31 | @State currentNavIndex: number = BottomNavi.NEWS; // 底导当前选中/焦点下标 | 31 | @State currentNavIndex: number = BottomNavi.NEWS; // 底导当前选中/焦点下标 |
| 32 | + @State topNavList: TopNavDTO[] = [] | ||
| 32 | // 底导TabsController | 33 | // 底导TabsController |
| 33 | private navController: TabsController = new TabsController(); | 34 | private navController: TabsController = new TabsController(); |
| 34 | readonly ASPECT_RATIO_1_1: number = 1 / 1; // 底导图片宽高比 | 35 | readonly ASPECT_RATIO_1_1: number = 1 / 1; // 底导图片宽高比 |
| @@ -54,6 +55,7 @@ export struct BottomNavigationComponent { | @@ -54,6 +55,7 @@ export struct BottomNavigationComponent { | ||
| 54 | bottomNav.bottomNavList = bottomNav.bottomNavList.filter(item => item.name !== '服务'); | 55 | bottomNav.bottomNavList = bottomNav.bottomNavList.filter(item => item.name !== '服务'); |
| 55 | this.bottomNavList = bottomNav.bottomNavList | 56 | this.bottomNavList = bottomNav.bottomNavList |
| 56 | } | 57 | } |
| 58 | + this.getTopNavList(this.bottomNavList[0]?.id) | ||
| 57 | HomeChannelUtils.setBottomNavData(bottomNav) | 59 | HomeChannelUtils.setBottomNavData(bottomNav) |
| 58 | 60 | ||
| 59 | EmitterUtils.receiveEvent(EmitterEventId.JUMP_HOME_CHANNEL, (str?: string) => { | 61 | EmitterUtils.receiveEvent(EmitterEventId.JUMP_HOME_CHANNEL, (str?: string) => { |
| @@ -127,6 +129,15 @@ export struct BottomNavigationComponent { | @@ -127,6 +129,15 @@ export struct BottomNavigationComponent { | ||
| 127 | .height($r('app.float.bottom_navigation_barHeight')) | 129 | .height($r('app.float.bottom_navigation_barHeight')) |
| 128 | .hoverEffect(HoverEffect.Highlight) | 130 | .hoverEffect(HoverEffect.Highlight) |
| 129 | .onClick(() => { | 131 | .onClick(() => { |
| 132 | + Logger.info(TAG, `onChange, index: ${index}`); | ||
| 133 | + this.onBottomNavigationIndexChange(navItem,index) | ||
| 134 | + }) | ||
| 135 | + | ||
| 136 | + } | ||
| 137 | + | ||
| 138 | + // 底导切换函数 | ||
| 139 | + async onBottomNavigationIndexChange(navItem:BottomNavDTO,index:number) { | ||
| 140 | + Logger.info(TAG, `onBottomNavigationIndexChange this.currentNavIndex: ${this.currentNavIndex}`); | ||
| 130 | if (navItem.name === '我的') { | 141 | if (navItem.name === '我的') { |
| 131 | this.barBackgroundColor = Color.White | 142 | this.barBackgroundColor = Color.White |
| 132 | this.currentBottomNavInfo = {} as BottomNavDTO | 143 | this.currentBottomNavInfo = {} as BottomNavDTO |
| @@ -139,23 +150,18 @@ export struct BottomNavigationComponent { | @@ -139,23 +150,18 @@ export struct BottomNavigationComponent { | ||
| 139 | this.currentBottomNavInfo = navItem | 150 | this.currentBottomNavInfo = navItem |
| 140 | } | 151 | } |
| 141 | } | 152 | } |
| 142 | - | ||
| 143 | this.currentNavIndex = index; | 153 | this.currentNavIndex = index; |
| 144 | - Logger.info(TAG, `onChange, index: ${index}`); | ||
| 145 | - | ||
| 146 | - }) | ||
| 147 | - | ||
| 148 | - } | ||
| 149 | 154 | ||
| 150 | - // 底导切换函数 | ||
| 151 | - onBottomNavigationIndexChange() { | ||
| 152 | - Logger.info(TAG, `onBottomNavigationIndexChange this.currentNavIndex: ${this.currentNavIndex}`); | ||
| 153 | // 请求顶导数据(参数): | 155 | // 请求顶导数据(参数): |
| 154 | } | 156 | } |
| 157 | + //请求顶导数据 | ||
| 158 | + async getTopNavList(id:number){ | ||
| 159 | + let bottomNavDetail = await PageViewModel.getBottomNavDetailData(id) | ||
| 160 | + this.topNavList = bottomNavDetail?.topNavChannelList || [] | ||
| 161 | + } | ||
| 155 | 162 | ||
| 156 | onBottomNavigationDataUpdated() { | 163 | onBottomNavigationDataUpdated() { |
| 157 | // Logger.info(TAG, `onBottomNavigationDataUpdated currentNavIndex: ${this.currentNavIndex},length:${this.bottomNavItemList.length}`); | 164 | // Logger.info(TAG, `onBottomNavigationDataUpdated currentNavIndex: ${this.currentNavIndex},length:${this.bottomNavItemList.length}`); |
| 158 | - this.onBottomNavigationIndexChange() | ||
| 159 | } | 165 | } |
| 160 | 166 | ||
| 161 | /** | 167 | /** |
| 1 | import { BottomNavDTO, CompDTO, TopNavDTO } from 'wdBean'; | 1 | import { BottomNavDTO, CompDTO, TopNavDTO } from 'wdBean'; |
| 2 | -import { LazyDataSource, Logger } from 'wdKit'; | 2 | +import { LazyDataSource, Logger,SPHelper } from 'wdKit'; |
| 3 | +import { SpConstants } from 'wdConstant'; | ||
| 3 | import { ProcessUtils } from 'wdRouter'; | 4 | import { ProcessUtils } from 'wdRouter'; |
| 4 | import { PageComponent } from './PageComponent'; | 5 | import { PageComponent } from './PageComponent'; |
| 5 | import { ChannelSubscriptionLayout } from './ChannelSubscriptionLayout'; | 6 | import { ChannelSubscriptionLayout } from './ChannelSubscriptionLayout'; |
| @@ -66,7 +67,6 @@ export struct TopNavigationComponent { | @@ -66,7 +67,6 @@ export struct TopNavigationComponent { | ||
| 66 | private tabsWidth: number = 0 | 67 | private tabsWidth: number = 0 |
| 67 | //定时器延时处理切换至版面、播报tab时 返回上一个tab | 68 | //定时器延时处理切换至版面、播报tab时 返回上一个tab |
| 68 | @State tabTimmer: number = 0 | 69 | @State tabTimmer: number = 0 |
| 69 | - | ||
| 70 | topOrBottomNavChange() { | 70 | topOrBottomNavChange() { |
| 71 | if (this.currentBottomNavName === this.currentBottomNavInfo?.name) { | 71 | if (this.currentBottomNavName === this.currentBottomNavInfo?.name) { |
| 72 | this.setBarBackgroundColor() | 72 | this.setBarBackgroundColor() |
| @@ -84,6 +84,8 @@ export struct TopNavigationComponent { | @@ -84,6 +84,8 @@ export struct TopNavigationComponent { | ||
| 84 | 84 | ||
| 85 | //处理新闻tab顶导频道数据 | 85 | //处理新闻tab顶导频道数据 |
| 86 | topNavListHandle() { | 86 | topNavListHandle() { |
| 87 | + let cityName = SPHelper.default.getSync(SpConstants.LOCATION_CITY_NAME, '') as string | ||
| 88 | + | ||
| 87 | let _channelIds: number [] = [] | 89 | let _channelIds: number [] = [] |
| 88 | let _myChannelList: TopNavDTO [] = [] | 90 | let _myChannelList: TopNavDTO [] = [] |
| 89 | let _storageChannelIds: string [] = [] //list1 | 91 | let _storageChannelIds: string [] = [] //list1 |
| @@ -126,6 +128,9 @@ export struct TopNavigationComponent { | @@ -126,6 +128,9 @@ export struct TopNavigationComponent { | ||
| 126 | item.myChannel = '1' | 128 | item.myChannel = '1' |
| 127 | } | 129 | } |
| 128 | if (item.channelType === 2) { | 130 | if (item.channelType === 2) { |
| 131 | + if(cityName.includes(item.name)){ | ||
| 132 | + item.myChannel = '1' | ||
| 133 | + } | ||
| 129 | item.localChannel = '1' | 134 | item.localChannel = '1' |
| 130 | } | 135 | } |
| 131 | if (index >= 11) { | 136 | if (index >= 11) { |
| @@ -145,13 +150,20 @@ export struct TopNavigationComponent { | @@ -145,13 +150,20 @@ export struct TopNavigationComponent { | ||
| 145 | _channelIds.push(item.channelId) | 150 | _channelIds.push(item.channelId) |
| 146 | } else if (item.moreChannel === '1') { | 151 | } else if (item.moreChannel === '1') { |
| 147 | this.moreChannelList.push(item) | 152 | this.moreChannelList.push(item) |
| 148 | - } else if (item.localChannel === '1') { | 153 | + } else if (item.localChannel === '1' && item.myChannel !== '1') { |
| 149 | this.localChannelList.push(item) | 154 | this.localChannelList.push(item) |
| 150 | } | 155 | } |
| 151 | } | 156 | } |
| 152 | 157 | ||
| 153 | }) | 158 | }) |
| 154 | 159 | ||
| 160 | + if(cityName){ | ||
| 161 | + let index = _myChannelList.findIndex(ele=> cityName.includes(ele.name)) | ||
| 162 | + const localChannelitem = _myChannelList.splice(index, 1)[0]; | ||
| 163 | + // 将当前地区频道插入到第四个 | ||
| 164 | + _myChannelList.splice(3, 0, localChannelitem); | ||
| 165 | + } | ||
| 166 | + | ||
| 155 | this.channelIds = _channelIds | 167 | this.channelIds = _channelIds |
| 156 | this.myChannelList = _myChannelList | 168 | this.myChannelList = _myChannelList |
| 157 | 169 |
| @@ -11,6 +11,7 @@ import { | @@ -11,6 +11,7 @@ import { | ||
| 11 | LiveReviewDTO, | 11 | LiveReviewDTO, |
| 12 | MorningEveningPaperDTO, | 12 | MorningEveningPaperDTO, |
| 13 | NavigationBodyDTO, | 13 | NavigationBodyDTO, |
| 14 | + NavigationDetailDTO, | ||
| 14 | NewspaperListBean, | 15 | NewspaperListBean, |
| 15 | NewspaperTimeInfoBean, | 16 | NewspaperTimeInfoBean, |
| 16 | PageDTO, | 17 | PageDTO, |
| @@ -30,10 +31,17 @@ const TAG = 'HttpRequest'; | @@ -30,10 +31,17 @@ const TAG = 'HttpRequest'; | ||
| 30 | 31 | ||
| 31 | export class PageRepository { | 32 | export class PageRepository { |
| 32 | static getBottomNavGroupUrl() { | 33 | static getBottomNavGroupUrl() { |
| 34 | + //http://192.168.1.3:3300/project/3802/interface/api/189229 | ||
| 33 | // https: //pd-apis-uat.pdnews.cn/api/rmrb-bff-display-zh/display/zh/c/bottomNavGroup | 35 | // https: //pd-apis-uat.pdnews.cn/api/rmrb-bff-display-zh/display/zh/c/bottomNavGroup |
| 34 | return HttpUrlUtils.getHost() + HttpUrlUtils.BOTTOM_NAV_PATH; | 36 | return HttpUrlUtils.getHost() + HttpUrlUtils.BOTTOM_NAV_PATH; |
| 35 | } | 37 | } |
| 36 | 38 | ||
| 39 | + static getBottomNavGroupDetailUrl() { | ||
| 40 | + // http://192.168.1.3:3300/project/3802/interface/api/189231 | ||
| 41 | + // https: //pd-apis-uat.pdnews.cn/api/rmrb-bff-display-zh/display/zh/c/bottomNavGroup/detail | ||
| 42 | + return HttpUrlUtils.getHost() + HttpUrlUtils.BOTTOM_NAV_DETAIL_PATH; | ||
| 43 | + } | ||
| 44 | + | ||
| 37 | static getPageInfoUrl(pageId: string) { | 45 | static getPageInfoUrl(pageId: string) { |
| 38 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.PAGE_INFO_PATH + "?pageId=" + pageId; | 46 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.PAGE_INFO_PATH + "?pageId=" + pageId; |
| 39 | // Logger.info(TAG, "getPageInfoUrl url = " + url) | 47 | // Logger.info(TAG, "getPageInfoUrl url = " + url) |
| @@ -105,7 +113,9 @@ export class PageRepository { | @@ -105,7 +113,9 @@ export class PageRepository { | ||
| 105 | } | 113 | } |
| 106 | 114 | ||
| 107 | static getLiveMoreUrl(type: number, pageNum: number = 1, pageSize: number = 20) { | 115 | static getLiveMoreUrl(type: number, pageNum: number = 1, pageSize: number = 20) { |
| 108 | - let url = HttpUrlUtils.getHost() + HttpUrlUtils.LIVE_MORE_PATH + "?type=" + type + "&pageNum=" + pageNum + "&pageSize=" + pageSize; | 116 | + let url = |
| 117 | + HttpUrlUtils.getHost() + HttpUrlUtils.LIVE_MORE_PATH + "?type=" + type + "&pageNum=" + pageNum + "&pageSize=" + | ||
| 118 | + pageSize; | ||
| 109 | Logger.info(TAG, "getLiveMoreUrl url = " + url) | 119 | Logger.info(TAG, "getLiveMoreUrl url = " + url) |
| 110 | return url; | 120 | return url; |
| 111 | } | 121 | } |
| @@ -120,11 +130,11 @@ export class PageRepository { | @@ -120,11 +130,11 @@ export class PageRepository { | ||
| 120 | return url; | 130 | return url; |
| 121 | } | 131 | } |
| 122 | 132 | ||
| 123 | - static getInteractDataV2Url(contentId: string, contentType: string, contentRelId: string,rmhPlatform:number) { | 133 | + static getInteractDataV2Url(contentId: string, contentType: string, contentRelId: string, rmhPlatform: number) { |
| 124 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_V2_DATA_PATH; | 134 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_V2_DATA_PATH; |
| 125 | url = url + "?contentId=" + contentId | 135 | url = url + "?contentId=" + contentId |
| 126 | + "&contentType=" + contentType | 136 | + "&contentType=" + contentType |
| 127 | - if(!StringUtils.isEmpty(contentRelId)){ | 137 | + if (!StringUtils.isEmpty(contentRelId)) { |
| 128 | url = url + "&contentRelId=" + contentRelId; | 138 | url = url + "&contentRelId=" + contentRelId; |
| 129 | } | 139 | } |
| 130 | url = url + "&rmhPlatform=" + rmhPlatform; | 140 | url = url + "&rmhPlatform=" + rmhPlatform; |
| @@ -199,7 +209,8 @@ export class PageRepository { | @@ -199,7 +209,8 @@ export class PageRepository { | ||
| 199 | * channelStrategy:频道策略 | 209 | * channelStrategy:频道策略 |
| 200 | * topicId:专题id | 210 | * topicId:专题id |
| 201 | * */ | 211 | * */ |
| 202 | - static getMorningEveningCompInfoUrl(pageId: number, groupId: number, refreshTime: string, topicId: string, pageNum: number, pageSize: number) { | 212 | + static getMorningEveningCompInfoUrl(pageId: number, groupId: number, refreshTime: string, topicId: string, |
| 213 | + pageNum: number, pageSize: number) { | ||
| 203 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.COMP_PATH; | 214 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.COMP_PATH; |
| 204 | url = url + "?loadStrategy=first_load&pageNum=" + pageNum + "&refreshTime=" + refreshTime + "&pageId=" | 215 | url = url + "?loadStrategy=first_load&pageNum=" + pageNum + "&refreshTime=" + refreshTime + "&pageId=" |
| 205 | + pageId + "&channelStrategy=2&groupId=" + groupId + "&topicId=" + topicId + "&pageSize=" + pageSize; | 216 | + pageId + "&channelStrategy=2&groupId=" + groupId + "&topicId=" + topicId + "&pageSize=" + pageSize; |
| @@ -212,6 +223,11 @@ export class PageRepository { | @@ -212,6 +223,11 @@ export class PageRepository { | ||
| 212 | return WDHttp.get<ResponseDTO<NavigationBodyDTO>>(url) | 223 | return WDHttp.get<ResponseDTO<NavigationBodyDTO>>(url) |
| 213 | }; | 224 | }; |
| 214 | 225 | ||
| 226 | + static fetchNavigationDetailDataApi(id:number = 210) { | ||
| 227 | + let url = PageRepository.getBottomNavGroupDetailUrl() + `?id=${id}`; | ||
| 228 | + return WDHttp.get<ResponseDTO<NavigationDetailDTO>>(url) | ||
| 229 | + }; | ||
| 230 | + | ||
| 215 | /** | 231 | /** |
| 216 | * 获取早晚报数据 | 232 | * 获取早晚报数据 |
| 217 | * @param pageId | 233 | * @param pageId |
| @@ -251,8 +267,8 @@ export class PageRepository { | @@ -251,8 +267,8 @@ export class PageRepository { | ||
| 251 | return WDHttp.get<ResponseDTO<ContentDetailDTO[]>>(url) | 267 | return WDHttp.get<ResponseDTO<ContentDetailDTO[]>>(url) |
| 252 | }; | 268 | }; |
| 253 | 269 | ||
| 254 | - static fetchInteractDataV2(contentId: string, contentType: string, contentRelId: string,rmhPlatform:number) { | ||
| 255 | - let url = PageRepository.getInteractDataV2Url(contentId, contentType, contentRelId,rmhPlatform) | 270 | + static fetchInteractDataV2(contentId: string, contentType: string, contentRelId: string, rmhPlatform: number) { |
| 271 | + let url = PageRepository.getInteractDataV2Url(contentId, contentType, contentRelId, rmhPlatform) | ||
| 256 | return WDHttp.get<ResponseDTO<InteractDataDTO>>(url) | 272 | return WDHttp.get<ResponseDTO<InteractDataDTO>>(url) |
| 257 | }; | 273 | }; |
| 258 | 274 | ||
| @@ -318,6 +334,7 @@ export class PageRepository { | @@ -318,6 +334,7 @@ export class PageRepository { | ||
| 318 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_ACCENTION_OPERATION | 334 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_ACCENTION_OPERATION |
| 319 | return WDHttp.post(url, params) | 335 | return WDHttp.post(url, params) |
| 320 | } | 336 | } |
| 337 | + | ||
| 321 | /** | 338 | /** |
| 322 | * 关注号主 | 339 | * 关注号主 |
| 323 | */ | 340 | */ |
| @@ -335,7 +352,8 @@ export class PageRepository { | @@ -335,7 +352,8 @@ export class PageRepository { | ||
| 335 | success(resDTO); | 352 | success(resDTO); |
| 336 | }) | 353 | }) |
| 337 | .catch((err: Error) => { | 354 | .catch((err: Error) => { |
| 338 | - Logger.error(TAG, `postInteractAccentionOperate catch, error.name : ${err.name}, error.message:${err.message}`); | 355 | + Logger.error(TAG, |
| 356 | + `postInteractAccentionOperate catch, error.name : ${err.name}, error.message:${err.message}`); | ||
| 339 | error(err); | 357 | error(err); |
| 340 | }) | 358 | }) |
| 341 | }) | 359 | }) |
| @@ -362,7 +380,8 @@ export class PageRepository { | @@ -362,7 +380,8 @@ export class PageRepository { | ||
| 362 | /** | 380 | /** |
| 363 | * 获取早晚报compInfo | 381 | * 获取早晚报compInfo |
| 364 | * */ | 382 | * */ |
| 365 | - static fetchMorningEveningCompInfo(pageId: number, groupId: number, refreshTime: string, topicId: string, pageNum: number, pageSize: number) { | 383 | + static fetchMorningEveningCompInfo(pageId: number, groupId: number, refreshTime: string, topicId: string, |
| 384 | + pageNum: number, pageSize: number) { | ||
| 366 | let url = PageRepository.getMorningEveningCompInfoUrl(pageId, groupId, refreshTime, topicId, pageNum, pageSize) | 385 | let url = PageRepository.getMorningEveningCompInfoUrl(pageId, groupId, refreshTime, topicId, pageNum, pageSize) |
| 367 | return WDHttp.get<ResponseDTO<CompInfoBean>>(url) | 386 | return WDHttp.get<ResponseDTO<CompInfoBean>>(url) |
| 368 | }; | 387 | }; |
| @@ -392,7 +411,8 @@ export class PageRepository { | @@ -392,7 +411,8 @@ export class PageRepository { | ||
| 392 | static fetchBroadcastCompInfo(pageId: number, groupId: number, refreshTime: string, topicId: | 411 | static fetchBroadcastCompInfo(pageId: number, groupId: number, refreshTime: string, topicId: |
| 393 | string, channelId: string) { | 412 | string, channelId: string) { |
| 394 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.COMP_PATH; | 413 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.COMP_PATH; |
| 395 | - url = `${url}?topicId=${topicId}&channelStrategy=2&groupId=${groupId}&refreshTime=${refreshTime}&pageSize=50&recommend=0&pageId=${pageId}&loadStrategy=first_load&pageNum=1&channelId=${channelId}` | 414 | + url = |
| 415 | + `${url}?topicId=${topicId}&channelStrategy=2&groupId=${groupId}&refreshTime=${refreshTime}&pageSize=50&recommend=0&pageId=${pageId}&loadStrategy=first_load&pageNum=1&channelId=${channelId}` | ||
| 396 | Logger.info(TAG, "getMorningEveningCompInfoUrl url = " + url) | 416 | Logger.info(TAG, "getMorningEveningCompInfoUrl url = " + url) |
| 397 | return WDHttp.get<ResponseDTO<CompInfoBean>>(url) | 417 | return WDHttp.get<ResponseDTO<CompInfoBean>>(url) |
| 398 | }; | 418 | }; |
| @@ -408,8 +428,8 @@ export class PageRepository { | @@ -408,8 +428,8 @@ export class PageRepository { | ||
| 408 | /** | 428 | /** |
| 409 | * 获取更多直播/预约 | 429 | * 获取更多直播/预约 |
| 410 | * */ | 430 | * */ |
| 411 | - static fetchLiveMoreUrl(type: number,pageNum: number, pageSize: number) { | ||
| 412 | - let url = PageRepository.getLiveMoreUrl(type,pageNum, pageSize) | 431 | + static fetchLiveMoreUrl(type: number, pageNum: number, pageSize: number) { |
| 432 | + let url = PageRepository.getLiveMoreUrl(type, pageNum, pageSize) | ||
| 413 | return WDHttp.get<ResponseDTO<LiveReviewDTO>>(url) | 433 | return WDHttp.get<ResponseDTO<LiveReviewDTO>>(url) |
| 414 | }; | 434 | }; |
| 415 | 435 |
| @@ -9,7 +9,8 @@ import { | @@ -9,7 +9,8 @@ import { | ||
| 9 | PageDTO, | 9 | PageDTO, |
| 10 | PageInfoBean, | 10 | PageInfoBean, |
| 11 | PageInfoDTO, | 11 | PageInfoDTO, |
| 12 | - GoldenPositionExtraBean | 12 | + GoldenPositionExtraBean, |
| 13 | + NavigationDetailDTO | ||
| 13 | } from 'wdBean'; | 14 | } from 'wdBean'; |
| 14 | 15 | ||
| 15 | import { CollectionUtils, Logger, ResourcesUtils, StringUtils } from 'wdKit'; | 16 | import { CollectionUtils, Logger, ResourcesUtils, StringUtils } from 'wdKit'; |
| @@ -46,6 +47,11 @@ export class PageViewModel extends BaseViewModel { | @@ -46,6 +47,11 @@ export class PageViewModel extends BaseViewModel { | ||
| 46 | return this.getNavData(); | 47 | return this.getNavData(); |
| 47 | } | 48 | } |
| 48 | 49 | ||
| 50 | + async getBottomNavDetailData(id:number): Promise<NavigationDetailDTO> { | ||
| 51 | + Logger.info(TAG, `getBottomNavDetailData start`); | ||
| 52 | + return this.getNavDetailData(id); | ||
| 53 | + } | ||
| 54 | + | ||
| 49 | async getBottomNavDataMock(context: Context): Promise<NavigationBodyDTO> { | 55 | async getBottomNavDataMock(context: Context): Promise<NavigationBodyDTO> { |
| 50 | Logger.info(TAG, `getBottomNavDataMock start`); | 56 | Logger.info(TAG, `getBottomNavDataMock start`); |
| 51 | let compRes: ResponseDTO<NavigationBodyDTO> | null = await ResourcesUtils.getResourcesJson<ResponseDTO<NavigationBodyDTO>>(context, 'bottom_nav.json'); | 57 | let compRes: ResponseDTO<NavigationBodyDTO> | null = await ResourcesUtils.getResourcesJson<ResponseDTO<NavigationBodyDTO>>(context, 'bottom_nav.json'); |
| @@ -81,6 +87,30 @@ export class PageViewModel extends BaseViewModel { | @@ -81,6 +87,30 @@ export class PageViewModel extends BaseViewModel { | ||
| 81 | }) | 87 | }) |
| 82 | } | 88 | } |
| 83 | 89 | ||
| 90 | + private getNavDetailData(id:number): Promise<NavigationDetailDTO> { | ||
| 91 | + return new Promise<NavigationDetailDTO>((success, error) => { | ||
| 92 | + Logger.info(TAG, `getNavData start`); | ||
| 93 | + PageRepository.fetchNavigationDetailDataApi(id).then((navResDTO: ResponseDTO<NavigationDetailDTO>) => { | ||
| 94 | + if (!navResDTO || !navResDTO.data) { | ||
| 95 | + Logger.error(TAG, 'getNavData then navResDTO is empty'); | ||
| 96 | + error('navResDTO is empty'); | ||
| 97 | + return | ||
| 98 | + } | ||
| 99 | + if (navResDTO.code != 0) { | ||
| 100 | + Logger.error(TAG, `getNavData then code:${navResDTO.code}, message:${navResDTO.message}`); | ||
| 101 | + error('navResDTO Response Code is failure'); | ||
| 102 | + return | ||
| 103 | + } | ||
| 104 | + // let navResStr = JSON.stringify(navResDTO); | ||
| 105 | + Logger.info(TAG, "getNavData then,navResDTO.timestamp:" + navResDTO.timestamp); | ||
| 106 | + success(navResDTO.data); | ||
| 107 | + }).catch((err: Error) => { | ||
| 108 | + Logger.error(TAG, `fetchNavigationDataApi catch, error.name : ${err.name}, error.message:${err.message}`); | ||
| 109 | + error(err); | ||
| 110 | + }) | ||
| 111 | + }) | ||
| 112 | + } | ||
| 113 | + | ||
| 84 | /** | 114 | /** |
| 85 | * Get PageDTO data. | 115 | * Get PageDTO data. |
| 86 | * | 116 | * |
-
Please register or login to post a comment