zhangbo1_wd

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

@@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
4 export interface TopNavDTO { 4 export interface TopNavDTO {
5 channelId: number; 5 channelId: number;
6 channelStyle: number; 6 channelStyle: number;
7 - channelType: number; 7 + channelType: number; // 频道样式;1-沉浸式;2-信息流;3-特殊频道(跳转指定页面的,如版面)
8 defaultPermitted: number; 8 defaultPermitted: number;
9 delPermitted: number; 9 delPermitted: number;
10 fontCColor: string; // 频道展示样式颜色(选中状态) 10 fontCColor: string; // 频道展示样式颜色(选中状态)
@@ -66,6 +66,8 @@ export struct TopNavigationComponent { @@ -66,6 +66,8 @@ export struct TopNavigationComponent {
66 private tabsWidth: number = 0 66 private tabsWidth: number = 0
67 //定时器延时处理切换至版面、播报tab时 返回上一个tab 67 //定时器延时处理切换至版面、播报tab时 返回上一个tab
68 @State tabTimmer: number = 0 68 @State tabTimmer: number = 0
  69 + // 标识,是否为点击触发的tab切换,临时变量
  70 + private changeByClick: boolean = false
69 71
70 //处理新闻tab顶导频道数据 72 //处理新闻tab顶导频道数据
71 topNavListHandle() { 73 topNavListHandle() {
@@ -170,13 +172,20 @@ export struct TopNavigationComponent { @@ -170,13 +172,20 @@ export struct TopNavigationComponent {
170 } 172 }
171 173
172 isBroadcast(item: TopNavDTO) { 174 isBroadcast(item: TopNavDTO) {
  175 + // TODO 用id channelId = '2066'
173 return item.name === '播报' 176 return item.name === '播报'
174 } 177 }
175 178
176 isLayout(item: TopNavDTO) { 179 isLayout(item: TopNavDTO) {
  180 + // TODO 用id channelId = '2006'
177 return item.name === '版面' 181 return item.name === '版面'
178 } 182 }
179 183
  184 + isSpecialChannel(item: TopNavDTO) {
  185 + // 版面、播报,可以用这个判断
  186 + return item.channelType === 3
  187 + }
  188 +
180 build() { 189 build() {
181 Column() { 190 Column() {
182 // 顶部搜索、日报logo、早晚报 191 // 顶部搜索、日报logo、早晚报
@@ -287,7 +296,15 @@ export struct TopNavigationComponent { @@ -287,7 +296,15 @@ export struct TopNavigationComponent {
287 if (this.isLayout(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index])) { 296 if (this.isLayout(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index])) {
288 ProcessUtils.gotoENewsPaper() 297 ProcessUtils.gotoENewsPaper()
289 this.tabTimmer = setTimeout(() => { 298 this.tabTimmer = setTimeout(() => {
290 - this.tabsController.changeIndex(this.currentTopNavSelectedIndex) 299 + if (!this.changeByClick) {
  300 + // 识别左滑右滑,跳过版面,到下一个
  301 + let nextIndex = this.currentTopNavSelectedIndex > index ? index - 1 : index + 1
  302 + this.tabsController.changeIndex(nextIndex)
  303 + } else {
  304 + this.tabsController.changeIndex(this.currentTopNavSelectedIndex)
  305 + // 重置标识
  306 + this.changeByClick = false
  307 + }
291 }, 100) 308 }, 100)
292 } 309 }
293 }) 310 })
@@ -406,6 +423,7 @@ export struct TopNavigationComponent { @@ -406,6 +423,7 @@ export struct TopNavigationComponent {
406 // 当前tab,单击事件 423 // 当前tab,单击事件
407 this.doAutoRefresh() 424 this.doAutoRefresh()
408 } else { 425 } else {
  426 + this.changeByClick = true
409 this.tabsController.changeIndex(index) 427 this.tabsController.changeIndex(index)
410 } 428 }
411 }) 429 })