yuzhilin

底导切换修复

... ... @@ -16,7 +16,7 @@ PersistentStorage.persistProp('indexSettingChannelId', 0);
@Component
export struct TopNavigationComponent {
private tabsController: TabsController = new TabsController()
@Prop _currentNavIndex: number;
@Prop _currentNavIndex?: number;
// 顶导当前选中/焦点下标
@State currentTopNavSelectedIndex: number = 0;
// 顶导数据
... ... @@ -35,7 +35,6 @@ export struct TopNavigationComponent {
// 地方频道列表
@State localChannelList: TopNavDTO[] = []
readonly MAX_LINE: number = 1;
//处理新闻tab顶导频道数据
topNavListHandle() {
let _channelIds: number [] = []
... ... @@ -111,9 +110,11 @@ export struct TopNavigationComponent {
AppStorage.set('indexSettingChannelId', this.homeChannelList[0].channelId)
} else {
let index = this.myChannelList.findIndex(_item => _item.channelId === this.indexSettingChannelId)
if (index > -1) {
this.currentTopNavSelectedIndex = index
}
}
}
isBroadcast(item: TopNavDTO) {
return item.name === '播报'
... ... @@ -122,8 +123,8 @@ export struct TopNavigationComponent {
build() {
Column() {
// 顶部搜索、日报logo、早晚报
Column(){
Row(){
Column() {
Row() {
FirstTabTopSearchComponent()
Image($r('app.media.icon_ren_min_ri_bao'))
... ... @@ -168,7 +169,8 @@ export struct TopNavigationComponent {
})
}.width('100%')
.justifyContent(FlexAlign.SpaceBetween)
}.height('73lpx')
}
.height('73lpx')
.width('100%')
.justifyContent(FlexAlign.End)
.backgroundColor($r('app.color.white'))
... ... @@ -266,10 +268,8 @@ export struct TopNavigationComponent {
aboutToAppear() {
//处理新闻tab顶导频道数据
if (this._currentNavIndex === 0) {
this.topNavListHandle()
}
}
aboutToDisappear() {
AppStorage.set('channelIds', this.channelIds.join(','))
... ...