Showing
1 changed file
with
67 additions
and
55 deletions
| @@ -72,68 +72,70 @@ export struct TopNavigationComponentNew { | @@ -72,68 +72,70 @@ export struct TopNavigationComponentNew { | ||
| 72 | private tabsWidth: number = 0 | 72 | private tabsWidth: number = 0 |
| 73 | 73 | ||
| 74 | build() { | 74 | build() { |
| 75 | - // 频道分类list | ||
| 76 | - RelativeContainer() { | ||
| 77 | - this.tabBar() | ||
| 78 | - Swiper(this.swiperController) { | ||
| 79 | - ForEach(this.currentBottomNavName === '新闻' ? this.myChannelList : this.topNavList, | ||
| 80 | - (navItem: TopNavDTO, index: number) => { | ||
| 81 | - if (this.currentBottomNavName === '人民号' && navItem.name === '关注') { | ||
| 82 | - PeopleShipMainComponent({ | ||
| 83 | - currentTopNavSelectedIndex: $currentTopNavSelectedIndex, | ||
| 84 | - navIndex: index, | ||
| 85 | - pageId: navItem.pageId + '', | ||
| 86 | - channelId: navItem.channelId + '', | ||
| 87 | - }) | ||
| 88 | - } else | ||
| 89 | - if (!this.isBroadcast(navItem) && !this.isLayout(navItem)) { | ||
| 90 | - PageComponent({ | 75 | + Column() { |
| 76 | + // 频道分类list | ||
| 77 | + RelativeContainer() { | ||
| 78 | + this.tabBar() | ||
| 79 | + Swiper(this.swiperController) { | ||
| 80 | + ForEach(this.currentBottomNavName === '新闻' ? this.myChannelList : this.topNavList, | ||
| 81 | + (navItem: TopNavDTO, index: number) => { | ||
| 82 | + if (this.currentBottomNavName === '人民号' && navItem.name === '关注') { | ||
| 83 | + PeopleShipMainComponent({ | ||
| 91 | currentTopNavSelectedIndex: $currentTopNavSelectedIndex, | 84 | currentTopNavSelectedIndex: $currentTopNavSelectedIndex, |
| 92 | navIndex: index, | 85 | navIndex: index, |
| 93 | pageId: navItem.pageId + '', | 86 | pageId: navItem.pageId + '', |
| 94 | channelId: navItem.channelId + '', | 87 | channelId: navItem.channelId + '', |
| 95 | - autoRefresh: this.autoRefresh2Page | ||
| 96 | }) | 88 | }) |
| 97 | - } else { | ||
| 98 | - channelSkeleton() | 89 | + } else |
| 90 | + if (!this.isBroadcast(navItem) && !this.isLayout(navItem)) { | ||
| 91 | + PageComponent({ | ||
| 92 | + currentTopNavSelectedIndex: $currentTopNavSelectedIndex, | ||
| 93 | + navIndex: index, | ||
| 94 | + pageId: navItem.pageId + '', | ||
| 95 | + channelId: navItem.channelId + '', | ||
| 96 | + autoRefresh: this.autoRefresh2Page | ||
| 97 | + }) | ||
| 98 | + } else { | ||
| 99 | + channelSkeleton() | ||
| 100 | + } | ||
| 101 | + }) | ||
| 102 | + } | ||
| 103 | + .loop(false) | ||
| 104 | + .indicator(false) | ||
| 105 | + .effectMode(EdgeEffect.None) | ||
| 106 | + .index(this.currentTopNavSelectedIndex) | ||
| 107 | + .cachedCount(0) | ||
| 108 | + .id('pageContent') | ||
| 109 | + .alignRules({ | ||
| 110 | + 'top': { 'anchor': 'tabList', 'align': VerticalAlign.Bottom }, | ||
| 111 | + 'middle': { 'anchor': '__container__', 'align': HorizontalAlign.Center }, | ||
| 112 | + 'bottom': { 'anchor': '__container__', 'align': VerticalAlign.Bottom } | ||
| 113 | + }) | ||
| 114 | + .onChange((index) => { | ||
| 115 | + Logger.info(TAG, `onChange index : ${index}`); | ||
| 116 | + if (this.isBroadcastByIndex(index)) { | ||
| 117 | + // 跳转到播报页面 | ||
| 118 | + ProcessUtils.gotoBroadcastPage(this.myChannelList[index].pageId) | ||
| 119 | + let nextIndex = this.currentTopNavSelectedIndex > index ? index - 1 : index + 1 | ||
| 120 | + if (nextIndex < this.myChannelList.length) { | ||
| 121 | + this.changePage(nextIndex) | ||
| 99 | } | 122 | } |
| 100 | - }) | ||
| 101 | - } | ||
| 102 | - .loop(false) | ||
| 103 | - .indicator(false) | ||
| 104 | - .effectMode(EdgeEffect.None) | ||
| 105 | - .index(this.currentTopNavSelectedIndex) | ||
| 106 | - .cachedCount(0) | ||
| 107 | - .id('pageContent') | ||
| 108 | - .alignRules({ | ||
| 109 | - 'top': { 'anchor': 'tabList', 'align': VerticalAlign.Bottom }, | ||
| 110 | - 'middle': { 'anchor': '__container__', 'align': HorizontalAlign.Center }, | ||
| 111 | - 'bottom': { 'anchor': '__container__', 'align': VerticalAlign.Bottom } | ||
| 112 | - }) | ||
| 113 | - .onChange((index) => { | ||
| 114 | - Logger.info(TAG, `onChange index : ${index}`); | ||
| 115 | - if (this.isBroadcastByIndex(index)) { | ||
| 116 | - // 跳转到播报页面 | ||
| 117 | - ProcessUtils.gotoBroadcastPage(this.myChannelList[index].pageId) | ||
| 118 | - let nextIndex = this.currentTopNavSelectedIndex > index ? index - 1 : index + 1 | ||
| 119 | - if (nextIndex < this.myChannelList.length) { | ||
| 120 | - this.changePage(nextIndex) | ||
| 121 | - } | ||
| 122 | - } else if (this.isLayoutByIndex(index)) { | ||
| 123 | - ProcessUtils.gotoENewsPaper() | ||
| 124 | - let nextIndex = this.currentTopNavSelectedIndex > index ? index - 1 : index + 1 | ||
| 125 | - if (nextIndex < this.myChannelList.length) { | ||
| 126 | - this.changePage(nextIndex) | 123 | + } else if (this.isLayoutByIndex(index)) { |
| 124 | + ProcessUtils.gotoENewsPaper() | ||
| 125 | + let nextIndex = this.currentTopNavSelectedIndex > index ? index - 1 : index + 1 | ||
| 126 | + if (nextIndex < this.myChannelList.length) { | ||
| 127 | + this.changePage(nextIndex) | ||
| 128 | + } | ||
| 129 | + } else { | ||
| 130 | + this.currentTopNavSelectedIndex = index; | ||
| 131 | + this.changePage(this.currentTopNavSelectedIndex) | ||
| 127 | } | 132 | } |
| 128 | - } else { | ||
| 129 | - this.currentTopNavSelectedIndex = index; | ||
| 130 | - this.changePage(this.currentTopNavSelectedIndex) | ||
| 131 | - } | ||
| 132 | 133 | ||
| 133 | - }) | 134 | + }) |
| 135 | + } | ||
| 136 | + .width('100%') | ||
| 137 | + .height('100%') | ||
| 134 | } | 138 | } |
| 135 | - .width('100%') | ||
| 136 | - .height('100%') | ||
| 137 | } | 139 | } |
| 138 | 140 | ||
| 139 | @Builder | 141 | @Builder |
| @@ -316,7 +318,7 @@ export struct TopNavigationComponentNew { | @@ -316,7 +318,7 @@ export struct TopNavigationComponentNew { | ||
| 316 | bottom: 2, | 318 | bottom: 2, |
| 317 | }) | 319 | }) |
| 318 | .id(`col_tabBar${index}`) | 320 | .id(`col_tabBar${index}`) |
| 319 | - .margin({ right: this.myChannelList.length === index + 1 ? 36 : 0 }) | 321 | + // .margin({ right: this.myChannelList.length === index + 1 ? 36 : 0 }) |
| 320 | .onClick(() => { | 322 | .onClick(() => { |
| 321 | Logger.debug(TAG, `onClick, index: ${index}`); | 323 | Logger.debug(TAG, `onClick, index: ${index}`); |
| 322 | if (this.currentTopNavSelectedIndex === index) { | 324 | if (this.currentTopNavSelectedIndex === index) { |
| @@ -487,9 +489,19 @@ export struct TopNavigationComponentNew { | @@ -487,9 +489,19 @@ export struct TopNavigationComponentNew { | ||
| 487 | } | 489 | } |
| 488 | 490 | ||
| 489 | /** | 491 | /** |
| 492 | + * 判断是否当前页面处理逻辑,如消息通知,只需要切换到当前底导的处理,过滤掉非当前。 | ||
| 493 | + */ | ||
| 494 | + private isCurrentPage(): boolean { | ||
| 495 | + return this._currentNavIndex === this.bottomNavIndex | ||
| 496 | + } | ||
| 497 | + | ||
| 498 | + /** | ||
| 490 | * 频道id变化,即指定频道跳转场景 | 499 | * 频道id变化,即指定频道跳转场景 |
| 491 | */ | 500 | */ |
| 492 | onAssignChannelChange() { | 501 | onAssignChannelChange() { |
| 502 | + if (!this.isCurrentPage()) { | ||
| 503 | + return | ||
| 504 | + } | ||
| 493 | let channelId = this.assignChannel.channelId | 505 | let channelId = this.assignChannel.channelId |
| 494 | let index = -1 | 506 | let index = -1 |
| 495 | if (this._currentNavIndex === 0) { | 507 | if (this._currentNavIndex === 0) { |
| @@ -537,7 +549,7 @@ export struct TopNavigationComponentNew { | @@ -537,7 +549,7 @@ export struct TopNavigationComponentNew { | ||
| 537 | private getChannelByMine(channelId: string) { | 549 | private getChannelByMine(channelId: string) { |
| 538 | for (let i = 0; i < this.myChannelList.length; i++) { | 550 | for (let i = 0; i < this.myChannelList.length; i++) { |
| 539 | let topNavDTO: TopNavDTO = this.myChannelList[i] | 551 | let topNavDTO: TopNavDTO = this.myChannelList[i] |
| 540 | - if (topNavDTO.channelId?.toString() === channelId) { | 552 | + if (topNavDTO?.channelId?.toString() === channelId) { |
| 541 | return i | 553 | return i |
| 542 | } | 554 | } |
| 543 | } | 555 | } |
-
Please register or login to post a comment