wangyong_wd

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

... ... @@ -11,6 +11,7 @@ const TAG = 'TopNavigationComponent';
*/
@Component
export struct TopNavigationComponent {
private controller: TabsController = new TabsController()
@Prop _currentNavIndex?: number;
// 顶导当前选中/焦点下标
@State currentTopNavSelectedIndex: number = 0;
... ... @@ -76,8 +77,12 @@ export struct TopNavigationComponent {
})
}
isBroadcast (item: TopNavDTO) {
return item.name === '播报'
}
build() {
Column() {
// 顶部搜索、日报logo、早晚报
RelativeContainer() {
Stack({ alignContent: Alignment.Center }) {
... ... @@ -163,10 +168,10 @@ export struct TopNavigationComponent {
.width('100%')
.height(40)
.visibility(this._currentNavIndex == 0 ? Visibility.Visible : Visibility.None)
// 频道分类list
Stack({ alignContent: Alignment.TopEnd }) {
Tabs() {
Tabs({controller: this.controller}) {
ForEach(this.myChannelList, (navItem: TopNavDTO, index: number) => {
TabContent() {
PageComponent({
... ... @@ -184,9 +189,22 @@ export struct TopNavigationComponent {
.vertical(false)
.onChange((index: number) => {
Logger.info(TAG, `onChange index : ${index}`);
if(!this.isBroadcast(this.myChannelList[index])) {
this.currentTopNavSelectedIndex = index;
} else {
// 跳转到播报页面
let taskAction: Action = {
type: 'JUMP_INNER_NEW_PAGE',
params: {
pageID: 'BroadcastPage',
id: this.myChannelList[index].pageId
} as Params,
};
WDRouterRule.jumpWithAction(taskAction)
this.controller.changeIndex(this.currentTopNavSelectedIndex)
}
})
// 分类列表最右侧频道设置
ChannelSubscriptionLayout({
myChannelList: $myChannelList,
moreChannelList: $moreChannelList,
... ...