zhangbo1_wd

手势滑动触发版面跳转,tab选中修改,【跳过版面,到下一个】

... ... @@ -4,7 +4,7 @@
export interface TopNavDTO {
channelId: number;
channelStyle: number;
channelType: number;
channelType: number; // 频道样式;1-沉浸式;2-信息流;3-特殊频道(跳转指定页面的,如版面)
defaultPermitted: number;
delPermitted: number;
fontCColor: string; // 频道展示样式颜色(选中状态)
... ...
... ... @@ -66,6 +66,8 @@ export struct TopNavigationComponent {
private tabsWidth: number = 0
//定时器延时处理切换至版面、播报tab时 返回上一个tab
@State tabTimmer: number = 0
// 标识,是否为点击触发的tab切换,临时变量
private changeByClick: boolean = false
//处理新闻tab顶导频道数据
topNavListHandle() {
... ... @@ -170,13 +172,20 @@ export struct TopNavigationComponent {
}
isBroadcast(item: TopNavDTO) {
// TODO 用id channelId = '2066'
return item.name === '播报'
}
isLayout(item: TopNavDTO) {
// TODO 用id channelId = '2006'
return item.name === '版面'
}
isSpecialChannel(item: TopNavDTO) {
// 版面、播报,可以用这个判断
return item.channelType === 3
}
build() {
Column() {
// 顶部搜索、日报logo、早晚报
... ... @@ -287,7 +296,15 @@ export struct TopNavigationComponent {
if (this.isLayout(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index])) {
ProcessUtils.gotoENewsPaper()
this.tabTimmer = setTimeout(() => {
if (!this.changeByClick) {
// 识别左滑右滑,跳过版面,到下一个
let nextIndex = this.currentTopNavSelectedIndex > index ? index - 1 : index + 1
this.tabsController.changeIndex(nextIndex)
} else {
this.tabsController.changeIndex(this.currentTopNavSelectedIndex)
// 重置标识
this.changeByClick = false
}
}, 100)
}
})
... ... @@ -406,6 +423,7 @@ export struct TopNavigationComponent {
// 当前tab,单击事件
this.doAutoRefresh()
} else {
this.changeByClick = true
this.tabsController.changeIndex(index)
}
})
... ...