wangyong_wd

频道中”播报“添加跳转到播报页面的逻辑

@@ -11,6 +11,7 @@ const TAG = 'TopNavigationComponent'; @@ -11,6 +11,7 @@ const TAG = 'TopNavigationComponent';
11 */ 11 */
12 @Component 12 @Component
13 export struct TopNavigationComponent { 13 export struct TopNavigationComponent {
  14 + private controller: TabsController = new TabsController()
14 @Prop _currentNavIndex?: number; 15 @Prop _currentNavIndex?: number;
15 // 顶导当前选中/焦点下标 16 // 顶导当前选中/焦点下标
16 @State currentTopNavSelectedIndex: number = 0; 17 @State currentTopNavSelectedIndex: number = 0;
@@ -76,8 +77,12 @@ export struct TopNavigationComponent { @@ -76,8 +77,12 @@ export struct TopNavigationComponent {
76 }) 77 })
77 } 78 }
78 79
  80 + isBroadcast (item: TopNavDTO) {
  81 + return item.name === '播报'
  82 + }
79 build() { 83 build() {
80 Column() { 84 Column() {
  85 + // 顶部搜索、日报logo、早晚报
81 RelativeContainer() { 86 RelativeContainer() {
82 Stack({ alignContent: Alignment.Center }) { 87 Stack({ alignContent: Alignment.Center }) {
83 88
@@ -163,10 +168,10 @@ export struct TopNavigationComponent { @@ -163,10 +168,10 @@ export struct TopNavigationComponent {
163 .width('100%') 168 .width('100%')
164 .height(40) 169 .height(40)
165 .visibility(this._currentNavIndex == 0 ? Visibility.Visible : Visibility.None) 170 .visibility(this._currentNavIndex == 0 ? Visibility.Visible : Visibility.None)
166 - 171 + // 频道分类list
167 Stack({ alignContent: Alignment.TopEnd }) { 172 Stack({ alignContent: Alignment.TopEnd }) {
168 173
169 - Tabs() { 174 + Tabs({controller: this.controller}) {
170 ForEach(this.myChannelList, (navItem: TopNavDTO, index: number) => { 175 ForEach(this.myChannelList, (navItem: TopNavDTO, index: number) => {
171 TabContent() { 176 TabContent() {
172 PageComponent({ 177 PageComponent({
@@ -184,9 +189,22 @@ export struct TopNavigationComponent { @@ -184,9 +189,22 @@ export struct TopNavigationComponent {
184 .vertical(false) 189 .vertical(false)
185 .onChange((index: number) => { 190 .onChange((index: number) => {
186 Logger.info(TAG, `onChange index : ${index}`); 191 Logger.info(TAG, `onChange index : ${index}`);
187 - this.currentTopNavSelectedIndex = index; 192 + if(!this.isBroadcast(this.myChannelList[index])) {
  193 + this.currentTopNavSelectedIndex = index;
  194 + } else {
  195 + // 跳转到播报页面
  196 + let taskAction: Action = {
  197 + type: 'JUMP_INNER_NEW_PAGE',
  198 + params: {
  199 + pageID: 'BroadcastPage',
  200 + id: this.myChannelList[index].pageId
  201 + } as Params,
  202 + };
  203 + WDRouterRule.jumpWithAction(taskAction)
  204 + this.controller.changeIndex(this.currentTopNavSelectedIndex)
  205 + }
188 }) 206 })
189 - 207 + // 分类列表最右侧频道设置
190 ChannelSubscriptionLayout({ 208 ChannelSubscriptionLayout({
191 myChannelList: $myChannelList, 209 myChannelList: $myChannelList,
192 moreChannelList: $moreChannelList, 210 moreChannelList: $moreChannelList,