Showing
4 changed files
with
71 additions
and
43 deletions
| @@ -11,6 +11,7 @@ import { channelSkeleton } from '../skeleton/channelSkeleton'; | @@ -11,6 +11,7 @@ import { channelSkeleton } from '../skeleton/channelSkeleton'; | ||
| 11 | import { TrackConstants, TrackingButton } from 'wdTracking/Index'; | 11 | import { TrackConstants, TrackingButton } from 'wdTracking/Index'; |
| 12 | import DailyPaperTopicModel from '../../model/DailyPaperTopicModel' | 12 | import DailyPaperTopicModel from '../../model/DailyPaperTopicModel' |
| 13 | import { ParamType, Tracking } from 'wdTracking/Index'; | 13 | import { ParamType, Tracking } from 'wdTracking/Index'; |
| 14 | +import { CompUtils } from '../../utils/CompUtils'; | ||
| 14 | 15 | ||
| 15 | const TAG = 'TopNavigationComponent'; | 16 | const TAG = 'TopNavigationComponent'; |
| 16 | 17 | ||
| @@ -23,27 +24,16 @@ const storage = LocalStorage.getShared(); | @@ -23,27 +24,16 @@ const storage = LocalStorage.getShared(); | ||
| 23 | @Component | 24 | @Component |
| 24 | export struct TopNavigationComponentNew { | 25 | export struct TopNavigationComponentNew { |
| 25 | private topRectHeight: string = AppStorage.get<number>('topSafeHeight') + 'px'; | 26 | private topRectHeight: string = AppStorage.get<number>('topSafeHeight') + 'px'; |
| 26 | - /** | ||
| 27 | - * @deprecated | ||
| 28 | - */ | ||
| 29 | - private groupId: number = 0 | ||
| 30 | - /** | ||
| 31 | - * @deprecated TODO type判断 | ||
| 32 | - */ | ||
| 33 | - private currentBottomNavName: string = '' | ||
| 34 | private pageName: string = '' | 27 | private pageName: string = '' |
| 35 | private pageId: number = 0 | 28 | private pageId: number = 0 |
| 36 | private swiperController: SwiperController = new SwiperController() | 29 | private swiperController: SwiperController = new SwiperController() |
| 37 | private listScroller: Scroller = new Scroller() | 30 | private listScroller: Scroller = new Scroller() |
| 38 | - @Consume barBackgroundColor: Color | ||
| 39 | - /** | ||
| 40 | - * @deprecated | ||
| 41 | - */ | ||
| 42 | - @State bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0 | ||
| 43 | /** | 31 | /** |
| 44 | - * @deprecated | 32 | + * 首页 底导 某个tab 对象 |
| 45 | */ | 33 | */ |
| 46 | - @State topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0 | 34 | + navItem: BottomNavDTO = {} as BottomNavDTO |
| 35 | + @Consume barBackgroundColor: Color | ||
| 36 | + | ||
| 47 | @Link _currentNavIndex?: number; | 37 | @Link _currentNavIndex?: number; |
| 48 | // 顶导当前选中/焦点下标 | 38 | // 顶导当前选中/焦点下标 |
| 49 | @State @Watch('updateCurrentTopNavSelectedIndex') currentTopNavSelectedIndex: number = 0; | 39 | @State @Watch('updateCurrentTopNavSelectedIndex') currentTopNavSelectedIndex: number = 0; |
| @@ -70,7 +60,6 @@ export struct TopNavigationComponentNew { | @@ -70,7 +60,6 @@ export struct TopNavigationComponentNew { | ||
| 70 | @State animationDuration: number = 0 | 60 | @State animationDuration: number = 0 |
| 71 | @State indicatorLeftMargin: number = 0 | 61 | @State indicatorLeftMargin: number = 0 |
| 72 | @State indicatorWidth: number = 0 | 62 | @State indicatorWidth: number = 0 |
| 73 | - private tabsWidth: number = 0 | ||
| 74 | 63 | ||
| 75 | build() { | 64 | build() { |
| 76 | Column() { | 65 | Column() { |
| @@ -78,9 +67,10 @@ export struct TopNavigationComponentNew { | @@ -78,9 +67,10 @@ export struct TopNavigationComponentNew { | ||
| 78 | RelativeContainer() { | 67 | RelativeContainer() { |
| 79 | this.tabBar() | 68 | this.tabBar() |
| 80 | Swiper(this.swiperController) { | 69 | Swiper(this.swiperController) { |
| 81 | - ForEach(this.currentBottomNavName === '新闻' ? this.myChannelList : this.topNavList, | 70 | + ForEach(CompUtils.isNews(this.navItem) ? this.myChannelList : this.topNavList, |
| 82 | (navItem: TopNavDTO, index: number) => { | 71 | (navItem: TopNavDTO, index: number) => { |
| 83 | - if (this.currentBottomNavName === '人民号' && navItem.name === '关注') { | 72 | + if (CompUtils.isRMH(this.navItem) && navItem.channelType === 3) { |
| 73 | + // 人民号 -- 关注tab | ||
| 84 | PeopleShipMainComponent({ | 74 | PeopleShipMainComponent({ |
| 85 | currentTopNavSelectedIndex: $currentTopNavSelectedIndex, | 75 | currentTopNavSelectedIndex: $currentTopNavSelectedIndex, |
| 86 | navIndex: index, | 76 | navIndex: index, |
| @@ -203,8 +193,7 @@ export struct TopNavigationComponentNew { | @@ -203,8 +193,7 @@ export struct TopNavigationComponentNew { | ||
| 203 | 193 | ||
| 204 | @Builder | 194 | @Builder |
| 205 | tabBar() { | 195 | tabBar() { |
| 206 | - // TODO 判断是否新闻tab,修改方法(,_currentNavIndex==0 都不对,需要用type)(用topStyle) | ||
| 207 | - if (this.currentBottomNavName === '新闻') { | 196 | + if (CompUtils.isNews(this.navItem)) { |
| 208 | // 顶部搜索、日报logo、早晚报 | 197 | // 顶部搜索、日报logo、早晚报 |
| 209 | this.topBar() | 198 | this.topBar() |
| 210 | ChannelSubscriptionLayout({ | 199 | ChannelSubscriptionLayout({ |
| @@ -233,13 +222,9 @@ export struct TopNavigationComponentNew { | @@ -233,13 +222,9 @@ export struct TopNavigationComponentNew { | ||
| 233 | .listDirection(Axis.Horizontal) | 222 | .listDirection(Axis.Horizontal) |
| 234 | .scrollBar(BarState.Off) | 223 | .scrollBar(BarState.Off) |
| 235 | .edgeEffect(EdgeEffect.None) | 224 | .edgeEffect(EdgeEffect.None) |
| 236 | - .padding({ left: 8, top:0, right: 0 }) | 225 | + .padding({ left: 8, top: 0, right: 0 }) |
| 237 | .height($r('app.float.top_tab_bar_height')) | 226 | .height($r('app.float.top_tab_bar_height')) |
| 238 | .backgroundColor(this.barBackgroundColor) | 227 | .backgroundColor(this.barBackgroundColor) |
| 239 | - .onAreaChange((oldValue: Area, newValue: Area) => { | ||
| 240 | - let width = Number.parseFloat(newValue.width.toString()) | ||
| 241 | - this.tabsWidth = Number.isNaN(width) ? 0 : width | ||
| 242 | - }) | ||
| 243 | .id('tabList') | 228 | .id('tabList') |
| 244 | .alignRules({ | 229 | .alignRules({ |
| 245 | 'top': { 'anchor': 'topBar', 'align': VerticalAlign.Bottom }, | 230 | 'top': { 'anchor': 'topBar', 'align': VerticalAlign.Bottom }, |
| @@ -278,10 +263,6 @@ export struct TopNavigationComponentNew { | @@ -278,10 +263,6 @@ export struct TopNavigationComponentNew { | ||
| 278 | .listDirection(Axis.Horizontal) | 263 | .listDirection(Axis.Horizontal) |
| 279 | .scrollBar(BarState.Off) | 264 | .scrollBar(BarState.Off) |
| 280 | .edgeEffect(EdgeEffect.None) | 265 | .edgeEffect(EdgeEffect.None) |
| 281 | - .onAreaChange((oldValue: Area, newValue: Area) => { | ||
| 282 | - let width = Number.parseFloat(newValue.width.toString()) | ||
| 283 | - this.tabsWidth = Number.isNaN(width) ? 0 : width | ||
| 284 | - }) | ||
| 285 | .height($r('app.float.top_tab_bar_height_common')) | 266 | .height($r('app.float.top_tab_bar_height_common')) |
| 286 | .backgroundColor(this.barBackgroundColor) | 267 | .backgroundColor(this.barBackgroundColor) |
| 287 | .id('tabList') | 268 | .id('tabList') |
| @@ -498,10 +479,9 @@ export struct TopNavigationComponentNew { | @@ -498,10 +479,9 @@ export struct TopNavigationComponentNew { | ||
| 498 | } | 479 | } |
| 499 | 480 | ||
| 500 | updateCurrentTopNavSelectedIndex() { | 481 | updateCurrentTopNavSelectedIndex() { |
| 501 | - Logger.info(TAG, `currentTopNavSelectedIndex : ${this.currentTopNavSelectedIndex}、${this.currentBottomNavName}`); | ||
| 502 | 482 | ||
| 503 | // 顶部tab埋点 | 483 | // 顶部tab埋点 |
| 504 | - if (this.currentBottomNavName === '新闻') { | 484 | + if (CompUtils.isVideo(this.navItem)) { |
| 505 | const tab = this.myChannelList[this.currentTopNavSelectedIndex] | 485 | const tab = this.myChannelList[this.currentTopNavSelectedIndex] |
| 506 | Logger.info(TAG, `新闻tab埋点: ${JSON.stringify(tab)}`); | 486 | Logger.info(TAG, `新闻tab埋点: ${JSON.stringify(tab)}`); |
| 507 | 487 | ||
| @@ -511,7 +491,7 @@ export struct TopNavigationComponentNew { | @@ -511,7 +491,7 @@ export struct TopNavigationComponentNew { | ||
| 511 | "pageId": tab.pageId, | 491 | "pageId": tab.pageId, |
| 512 | } | 492 | } |
| 513 | Tracking.event("home_page_tab_click ", params) | 493 | Tracking.event("home_page_tab_click ", params) |
| 514 | - } else if (this.currentBottomNavName === '人民号') { | 494 | + } else if (CompUtils.isRMH(this.navItem)) { |
| 515 | const tab = this.topNavList[this.currentTopNavSelectedIndex] | 495 | const tab = this.topNavList[this.currentTopNavSelectedIndex] |
| 516 | Logger.info(TAG, `人民号tab埋点: ${JSON.stringify(tab)}`); | 496 | Logger.info(TAG, `人民号tab埋点: ${JSON.stringify(tab)}`); |
| 517 | 497 |
| @@ -32,6 +32,45 @@ export class CompUtils { | @@ -32,6 +32,45 @@ export class CompUtils { | ||
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | /** | 34 | /** |
| 35 | + * 是视频tab | ||
| 36 | + * @param navItem | ||
| 37 | + * @returns | ||
| 38 | + */ | ||
| 39 | + static isVideo(navItem: BottomNavDTO) : boolean{ | ||
| 40 | + if (navItem == null) { | ||
| 41 | + return false; | ||
| 42 | + | ||
| 43 | + } | ||
| 44 | + return navItem.topStyle === '13'; | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + /** | ||
| 48 | + * 是新闻tab | ||
| 49 | + * @param navItem | ||
| 50 | + * @returns | ||
| 51 | + */ | ||
| 52 | + static isNews(navItem: BottomNavDTO) : boolean{ | ||
| 53 | + if (navItem == null) { | ||
| 54 | + return false; | ||
| 55 | + | ||
| 56 | + } | ||
| 57 | + return navItem.topStyle === '11'; | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + /** | ||
| 61 | + * 是人民号tab | ||
| 62 | + * @param navItem | ||
| 63 | + * @returns | ||
| 64 | + */ | ||
| 65 | + static isRMH(navItem: BottomNavDTO) : boolean{ | ||
| 66 | + if (navItem == null) { | ||
| 67 | + return false; | ||
| 68 | + | ||
| 69 | + } | ||
| 70 | + return navItem.topStyle === '12'; | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | + /** | ||
| 35 | * 获取Label标题 | 74 | * 获取Label标题 |
| 36 | * | 75 | * |
| 37 | * @param component 组件bean | 76 | * @param component 组件bean |
| @@ -81,7 +81,7 @@ export struct BottomNavigationComponent { | @@ -81,7 +81,7 @@ export struct BottomNavigationComponent { | ||
| 81 | if (CompUtils.isMine(navItem)) { | 81 | if (CompUtils.isMine(navItem)) { |
| 82 | // 我的页面组件数据列表 | 82 | // 我的页面组件数据列表 |
| 83 | MinePageComponent({ isMinePage: this.currentNavIndex === this.bottomNavList.length - 1 }) | 83 | MinePageComponent({ isMinePage: this.currentNavIndex === this.bottomNavList.length - 1 }) |
| 84 | - } else if (navItem.name === '视频') { | 84 | + } else if (CompUtils.isVideo(navItem)) { |
| 85 | // 视频频道,包含视频和直播 | 85 | // 视频频道,包含视频和直播 |
| 86 | VideoChannelPage({ | 86 | VideoChannelPage({ |
| 87 | topNavList: navItem.topNavChannelList.filter(item => item.channelId != 2073), | 87 | topNavList: navItem.topNavChannelList.filter(item => item.channelId != 2073), |
| @@ -89,14 +89,14 @@ export struct BottomNavigationComponent { | @@ -89,14 +89,14 @@ export struct BottomNavigationComponent { | ||
| 89 | autoRefresh: this.autoRefresh | 89 | autoRefresh: this.autoRefresh |
| 90 | }) | 90 | }) |
| 91 | } else { | 91 | } else { |
| 92 | + // 其它带顶到的页面,如 新闻、人民号、服务 | ||
| 92 | TopNavigationComponentNew({ | 93 | TopNavigationComponentNew({ |
| 93 | - groupId: navItem.id, | ||
| 94 | topNavList: navItem.topNavChannelList.filter(item => item.channelId != 2073), | 94 | topNavList: navItem.topNavChannelList.filter(item => item.channelId != 2073), |
| 95 | _currentNavIndex: $currentNavIndex, | 95 | _currentNavIndex: $currentNavIndex, |
| 96 | bottomNavIndex: index, | 96 | bottomNavIndex: index, |
| 97 | - currentBottomNavName: navItem.name, | ||
| 98 | assignChannel: this.assignChannel, | 97 | assignChannel: this.assignChannel, |
| 99 | - autoRefresh: this.autoRefresh | 98 | + autoRefresh: this.autoRefresh, |
| 99 | + navItem: navItem | ||
| 100 | }) | 100 | }) |
| 101 | } | 101 | } |
| 102 | } | 102 | } |
| @@ -246,7 +246,7 @@ export struct BottomNavigationComponent { | @@ -246,7 +246,7 @@ export struct BottomNavigationComponent { | ||
| 246 | } | 246 | } |
| 247 | 247 | ||
| 248 | onBottomNavigationDataUpdated() { | 248 | onBottomNavigationDataUpdated() { |
| 249 | - Logger.error('yyyy','onBottomNavigationDataUpdated '+JSON.stringify(this.bottomNavList)) | 249 | + Logger.error('yyyy', 'onBottomNavigationDataUpdated ' + JSON.stringify(this.bottomNavList)) |
| 250 | // Logger.info(TAG, `onBottomNavigationDataUpdated currentNavIndex: ${this.currentNavIndex},length:${this.bottomNavItemList.length}`); | 250 | // Logger.info(TAG, `onBottomNavigationDataUpdated currentNavIndex: ${this.currentNavIndex},length:${this.bottomNavItemList.length}`); |
| 251 | } | 251 | } |
| 252 | 252 | ||
| @@ -353,11 +353,20 @@ export struct BottomNavigationComponent { | @@ -353,11 +353,20 @@ export struct BottomNavigationComponent { | ||
| 353 | list = list.filter(item => item.name !== '服务'); | 353 | list = list.filter(item => item.name !== '服务'); |
| 354 | list.forEach(item => { | 354 | list.forEach(item => { |
| 355 | switch (item.name) { | 355 | switch (item.name) { |
| 356 | - case '新闻': item.pageName = 'NEWS'; break; | ||
| 357 | - case '人民号': item.pageName = 'PEOPLE'; break; | ||
| 358 | - case '视频': item.pageName = 'VIDEOS'; break; | ||
| 359 | - case '我的': item.pageName = 'MY'; break; | ||
| 360 | - default : item.pageName = 'NEWS'; break; | 356 | + case '新闻': |
| 357 | + item.pageName = 'NEWS'; | ||
| 358 | + break; | ||
| 359 | + case '人民号': | ||
| 360 | + item.pageName = 'PEOPLE'; | ||
| 361 | + break; | ||
| 362 | + case '视频': | ||
| 363 | + item.pageName = 'VIDEOS'; | ||
| 364 | + break; | ||
| 365 | + case '我的': | ||
| 366 | + item.pageName = 'MY'; | ||
| 367 | + break; | ||
| 368 | + default: | ||
| 369 | + item.pageName = 'NEWS'; break; | ||
| 361 | } | 370 | } |
| 362 | }) | 371 | }) |
| 363 | this.bottomNavList = list | 372 | this.bottomNavList = list |
| @@ -58,7 +58,7 @@ export struct VideoChannelPage { | @@ -58,7 +58,7 @@ export struct VideoChannelPage { | ||
| 58 | * TODO:根据顶导配置获取颜色展示效果不对,待确认 | 58 | * TODO:根据顶导配置获取颜色展示效果不对,待确认 |
| 59 | */ | 59 | */ |
| 60 | getTopNavFontColor(item: TopNavDTO, index: number): Color | string { | 60 | getTopNavFontColor(item: TopNavDTO, index: number): Color | string { |
| 61 | - if (item.name === '视频' && this.currentBottomNavInfo.name === '视频') { | 61 | + if (item.channelStyle === 1) { |
| 62 | return this.currentTopNavSelectedIndex === index ? Color.White : '#949494' | 62 | return this.currentTopNavSelectedIndex === index ? Color.White : '#949494' |
| 63 | } else { | 63 | } else { |
| 64 | return this.currentTopNavSelectedIndex === index ? Color.Black : "#B2B2B2" | 64 | return this.currentTopNavSelectedIndex === index ? Color.Black : "#B2B2B2" |
-
Please register or login to post a comment