Merge branch 'main' of http://192.168.1.42/developOne/harmonyPool into main
* 'main' of http://192.168.1.42/developOne/harmonyPool: feat: 1)处理首页新闻tab的顶导数据源;2)处理顶导存在电子报和播报 左右切换 回归问题 feat: 1)处理首页新闻tab的顶导数据源;2)处理顶导存在电子报和播报 左右切换 回归问题 feat: 1)处理首页新闻tab的顶导数据源;2)处理顶导存在电子报和播报 左右切换 回归问题
Showing
4 changed files
with
150 additions
and
109 deletions
| @@ -2,26 +2,26 @@ | @@ -2,26 +2,26 @@ | ||
| 2 | * 顶导 | 2 | * 顶导 |
| 3 | */ | 3 | */ |
| 4 | export class TopNavDTO { | 4 | export class TopNavDTO { |
| 5 | - channelId: number = 0; | ||
| 6 | - channelStyle: number = 0; | 5 | + channelId: number = 0; //频道id |
| 6 | + channelStyle: number = 0; //频道样式;1-沉浸式;2-信息流 | ||
| 7 | channelType: number = 0; // 频道样式;1-沉浸式;2-信息流;3-特殊频道(跳转指定页面的,如版面) | 7 | channelType: number = 0; // 频道样式;1-沉浸式;2-信息流;3-特殊频道(跳转指定页面的,如版面) |
| 8 | - defaultPermitted: number = 0; | ||
| 9 | - delPermitted: number = 0; | 8 | + defaultPermitted: number = 0; //允许设置为默认首页 0:否, 1:是;【首页设置频道】 |
| 9 | + delPermitted: number = 0; //允许删除 0:否, 1:是;【撤销属性】 | ||
| 10 | fontCColor: string = ''; // 频道展示样式颜色(选中状态) | 10 | fontCColor: string = ''; // 频道展示样式颜色(选中状态) |
| 11 | fontColor: string = ''; // 频道展示样式颜色(未选中状态) | 11 | fontColor: string = ''; // 频道展示样式颜色(未选中状态) |
| 12 | - headlinesOn: number = 0; | ||
| 13 | - homeChannel: string = ''; | ||
| 14 | - iconUrlSize: string = ''; | ||
| 15 | - iconCUrlSize: string = ''; | 12 | + headlinesOn: number = 0; //头条标识 0:否, 1:是;【是否头条=是的频道,固定排序在第一位,且不可移出/移动】 |
| 13 | + homeChannel: string = ''; //必须 是否首页设置;0否,1是 | ||
| 14 | + iconUrlSize: string = ''; // 选中图片的大小 | ||
| 15 | + iconCUrlSize: string = ''; // 未选中图片的大小 | ||
| 16 | iconUrl: string = ''; // 频道图片展示样式图片相对地址(未选中状态) | 16 | iconUrl: string = ''; // 频道图片展示样式图片相对地址(未选中状态) |
| 17 | - iconCUrl: string = ''; //频道图片展示样式图片相对地址(选中状态 | ||
| 18 | - localChannel: string = ''; | ||
| 19 | - moreChannel: string = ''; | ||
| 20 | - movePermitted: number = 0; | ||
| 21 | - myChannel: string = ''; | ||
| 22 | - name: string = ''; | ||
| 23 | - num: number = 0; | ||
| 24 | - pageId: number = 0; | 17 | + iconCUrl: string = ''; //频道图片展示样式图片相对地址(选中状态) |
| 18 | + localChannel: string = ''; // 必须 是否地方频道栏目;0否,1是 | ||
| 19 | + moreChannel: string = ''; // 必须 是否更多栏目;0否,1是 | ||
| 20 | + movePermitted: number = 0; //允许移动 0:否, 1:是;【位置属性】 | ||
| 21 | + myChannel: string = '';// 必须 是否我的栏目;0否,1是 | ||
| 22 | + name: string = ''; //频道名称 | ||
| 23 | + num: number = 0; //首页设置根据这个排序20230828 | ||
| 24 | + pageId: number = 0; //频道关联页面id | ||
| 25 | pageType: string = ''; | 25 | pageType: string = ''; |
| 26 | underlineCColor: string = ''; // 选中下划线颜色 | 26 | underlineCColor: string = ''; // 选中下划线颜色 |
| 27 | } | 27 | } |
| @@ -12,8 +12,7 @@ const MORE_CHANNEL: string = '更多频道' | @@ -12,8 +12,7 @@ const MORE_CHANNEL: string = '更多频道' | ||
| 12 | const LOCAL_CHANNEL: string = '地方频道' | 12 | const LOCAL_CHANNEL: string = '地方频道' |
| 13 | 13 | ||
| 14 | const TAG: string = 'ChannelSubscriptionLayout' | 14 | const TAG: string = 'ChannelSubscriptionLayout' |
| 15 | - | ||
| 16 | -// @Entry | 15 | +export { ChannelSubscriptionLayout } |
| 17 | @Component | 16 | @Component |
| 18 | struct ChannelSubscriptionLayout { | 17 | struct ChannelSubscriptionLayout { |
| 19 | @State indexSettingArray: string [] = ['推荐', '热点'] | 18 | @State indexSettingArray: string [] = ['推荐', '热点'] |
| @@ -41,7 +40,9 @@ struct ChannelSubscriptionLayout { | @@ -41,7 +40,9 @@ struct ChannelSubscriptionLayout { | ||
| 41 | aboutToAppear() { | 40 | aboutToAppear() { |
| 42 | this.currentTopNavSelectedItem = this.myChannelList[this.currentTopNavSelectedIndex] | 41 | this.currentTopNavSelectedItem = this.myChannelList[this.currentTopNavSelectedIndex] |
| 43 | this.myChannelList.forEach(item => { | 42 | this.myChannelList.forEach(item => { |
| 44 | - this.channelIds.push(item.channelId) | 43 | + if(item != undefined && item.channelId != undefined){ |
| 44 | + this.channelIds.push(item.channelId) | ||
| 45 | + } | ||
| 45 | }) | 46 | }) |
| 46 | } | 47 | } |
| 47 | 48 | ||
| @@ -222,7 +223,6 @@ struct ChannelSubscriptionLayout { | @@ -222,7 +223,6 @@ struct ChannelSubscriptionLayout { | ||
| 222 | .padding({ bottom: 10 }) | 223 | .padding({ bottom: 10 }) |
| 223 | 224 | ||
| 224 | List() { | 225 | List() { |
| 225 | - | ||
| 226 | ListItem() { | 226 | ListItem() { |
| 227 | Row() { | 227 | Row() { |
| 228 | Text(INDEX_SETTING_TITLE) | 228 | Text(INDEX_SETTING_TITLE) |
| @@ -515,4 +515,3 @@ struct ChannelSubscriptionLayout { | @@ -515,4 +515,3 @@ struct ChannelSubscriptionLayout { | ||
| 515 | } | 515 | } |
| 516 | } | 516 | } |
| 517 | 517 | ||
| 518 | -export { ChannelSubscriptionLayout } |
| @@ -11,6 +11,9 @@ import { channelSkeleton } from '../skeleton/channelSkeleton'; | @@ -11,6 +11,9 @@ import { channelSkeleton } from '../skeleton/channelSkeleton'; | ||
| 11 | import { ParamType, TrackConstants, Tracking, TrackingButton } from 'wdTracking/Index'; | 11 | import { ParamType, TrackConstants, Tracking, TrackingButton } from 'wdTracking/Index'; |
| 12 | import DailyPaperTopicModel from '../../model/DailyPaperTopicModel'; | 12 | import DailyPaperTopicModel from '../../model/DailyPaperTopicModel'; |
| 13 | import { CompUtils } from '../../utils/CompUtils'; | 13 | import { CompUtils } from '../../utils/CompUtils'; |
| 14 | +import ChannelViewModel from '../../viewmodel/ChannelViewModel'; | ||
| 15 | +import { JSON } from '@kit.ArkTS'; | ||
| 16 | +import text from '@ohos.graphics.text'; | ||
| 14 | 17 | ||
| 15 | const TAG = 'TopNavigationComponent'; | 18 | const TAG = 'TopNavigationComponent'; |
| 16 | 19 | ||
| @@ -25,22 +28,28 @@ export struct TopNavigationComponentNew { | @@ -25,22 +28,28 @@ export struct TopNavigationComponentNew { | ||
| 25 | private topRectHeight: string = AppStorage.get<number>('topSafeHeight') + 'px'; | 28 | private topRectHeight: string = AppStorage.get<number>('topSafeHeight') + 'px'; |
| 26 | private pageName: string = '' | 29 | private pageName: string = '' |
| 27 | private pageId: number = 0 | 30 | private pageId: number = 0 |
| 31 | + readonly MAX_LINE: number = 1; // 顶部tab text最大行数 | ||
| 28 | private swiperController: SwiperController = new SwiperController() | 32 | private swiperController: SwiperController = new SwiperController() |
| 29 | private listScroller: Scroller = new Scroller() | 33 | private listScroller: Scroller = new Scroller() |
| 30 | /** | 34 | /** |
| 31 | * 首页 底导 某个tab 对象 | 35 | * 首页 底导 某个tab 对象 |
| 32 | */ | 36 | */ |
| 33 | navItem: BottomNavDTO = {} as BottomNavDTO | 37 | navItem: BottomNavDTO = {} as BottomNavDTO |
| 38 | + // 背景色 | ||
| 34 | @Consume barBackgroundColor: Color | 39 | @Consume barBackgroundColor: Color |
| 35 | - | 40 | + // 首页当前正在哪个tab的索引值 |
| 36 | @Link _currentNavIndex?: number; | 41 | @Link _currentNavIndex?: number; |
| 42 | + // 记录首页底部tab 的索引值 | ||
| 43 | + @State bottomNavIndex: number = 0 | ||
| 37 | // 顶导当前选中/焦点下标 | 44 | // 顶导当前选中/焦点下标 |
| 38 | @State @Watch('updateCurrentTopNavSelectedIndex') currentTopNavSelectedIndex: number = 0; | 45 | @State @Watch('updateCurrentTopNavSelectedIndex') currentTopNavSelectedIndex: number = 0; |
| 39 | // 顶导数据 | 46 | // 顶导数据 |
| 40 | @State @Watch('onTopNavigationDataUpdated') topNavList: TopNavDTO[] = [] | 47 | @State @Watch('onTopNavigationDataUpdated') topNavList: TopNavDTO[] = [] |
| 48 | + // | ||
| 41 | @State indexSettingChannelId: number = AppStorage.get<number>('indexSettingChannelId') || 2002 | 49 | @State indexSettingChannelId: number = AppStorage.get<number>('indexSettingChannelId') || 2002 |
| 42 | //本地缓存频道id列表 | 50 | //本地缓存频道id列表 |
| 43 | @State storageChannelIds: string = AppStorage.get<string>('channelIds') || '' | 51 | @State storageChannelIds: string = AppStorage.get<string>('channelIds') || '' |
| 52 | + // 首页设置的频道信息数组 | ||
| 44 | @State homeChannelList: TopNavDTO[] = [] | 53 | @State homeChannelList: TopNavDTO[] = [] |
| 45 | // 我的频道列表 | 54 | // 我的频道列表 |
| 46 | @State myChannelList: TopNavDTO[] = [] | 55 | @State myChannelList: TopNavDTO[] = [] |
| @@ -48,18 +57,14 @@ export struct TopNavigationComponentNew { | @@ -48,18 +57,14 @@ export struct TopNavigationComponentNew { | ||
| 48 | @State moreChannelList: TopNavDTO[] = [] | 57 | @State moreChannelList: TopNavDTO[] = [] |
| 49 | // 地方频道列表 | 58 | // 地方频道列表 |
| 50 | @State localChannelList: TopNavDTO[] = [] | 59 | @State localChannelList: TopNavDTO[] = [] |
| 51 | - readonly MAX_LINE: number = 1; | ||
| 52 | @ObjectLink @Watch('onAssignChannelChange') assignChannel: AssignChannelParam | 60 | @ObjectLink @Watch('onAssignChannelChange') assignChannel: AssignChannelParam |
| 53 | // 底导传递过来的自动刷新通知 | 61 | // 底导传递过来的自动刷新通知 |
| 54 | @Prop @Watch('onAutoRefresh') autoRefresh: number = 0 | 62 | @Prop @Watch('onAutoRefresh') autoRefresh: number = 0 |
| 55 | // 传递给page的自动刷新通知 | 63 | // 传递给page的自动刷新通知 |
| 56 | @State autoRefresh2Page: number = 0 | 64 | @State autoRefresh2Page: number = 0 |
| 57 | - // 当前底导index | ||
| 58 | - @State bottomNavIndex: number = 0 | ||
| 59 | @State animationDuration: number = 0 | 65 | @State animationDuration: number = 0 |
| 60 | @State indicatorLeftMargin: number = 0 | 66 | @State indicatorLeftMargin: number = 0 |
| 61 | @State indicatorWidth: number = 0 | 67 | @State indicatorWidth: number = 0 |
| 62 | - | ||
| 63 | @State isClickMorningEveningPaper: boolean = false | 68 | @State isClickMorningEveningPaper: boolean = false |
| 64 | 69 | ||
| 65 | build() { | 70 | build() { |
| @@ -70,7 +75,7 @@ export struct TopNavigationComponentNew { | @@ -70,7 +75,7 @@ export struct TopNavigationComponentNew { | ||
| 70 | Swiper(this.swiperController) { | 75 | Swiper(this.swiperController) { |
| 71 | ForEach(CompUtils.isNews(this.navItem) ? this.myChannelList : this.topNavList, | 76 | ForEach(CompUtils.isNews(this.navItem) ? this.myChannelList : this.topNavList, |
| 72 | (navItem: TopNavDTO, index: number) => { | 77 | (navItem: TopNavDTO, index: number) => { |
| 73 | - if (CompUtils.isRMH(this.navItem) && navItem.channelType === 3) { | 78 | + if (CompUtils.isRMH(this.navItem) && this.isSpecialChannel(navItem)) { |
| 74 | // 人民号 -- 关注tab | 79 | // 人民号 -- 关注tab |
| 75 | PeopleShipMainComponent({ | 80 | PeopleShipMainComponent({ |
| 76 | currentTopNavSelectedIndex: $currentTopNavSelectedIndex, | 81 | currentTopNavSelectedIndex: $currentTopNavSelectedIndex, |
| @@ -79,7 +84,7 @@ export struct TopNavigationComponentNew { | @@ -79,7 +84,7 @@ export struct TopNavigationComponentNew { | ||
| 79 | channelId: navItem?.channelId + '', | 84 | channelId: navItem?.channelId + '', |
| 80 | autoRefresh: this.autoRefresh2Page | 85 | autoRefresh: this.autoRefresh2Page |
| 81 | }) | 86 | }) |
| 82 | - } else | 87 | + } else { |
| 83 | if (!this.isBroadcast(navItem) && !this.isLayout(navItem)) { | 88 | if (!this.isBroadcast(navItem) && !this.isLayout(navItem)) { |
| 84 | PageComponent({ | 89 | PageComponent({ |
| 85 | currentTopNavSelectedIndex: $currentTopNavSelectedIndex, | 90 | currentTopNavSelectedIndex: $currentTopNavSelectedIndex, |
| @@ -89,7 +94,9 @@ export struct TopNavigationComponentNew { | @@ -89,7 +94,9 @@ export struct TopNavigationComponentNew { | ||
| 89 | autoRefresh: this.autoRefresh2Page | 94 | autoRefresh: this.autoRefresh2Page |
| 90 | }) | 95 | }) |
| 91 | } else { | 96 | } else { |
| 92 | - channelSkeleton() | 97 | + channelSkeleton() |
| 98 | + //Text('特殊频道').fontColor(Color.Red).fontSize(20).width('100%').height('100%') | ||
| 99 | + } | ||
| 93 | } | 100 | } |
| 94 | }) | 101 | }) |
| 95 | } | 102 | } |
| @@ -109,29 +116,45 @@ export struct TopNavigationComponentNew { | @@ -109,29 +116,45 @@ export struct TopNavigationComponentNew { | ||
| 109 | if (curIndex === index) { | 116 | if (curIndex === index) { |
| 110 | return | 117 | return |
| 111 | } | 118 | } |
| 119 | + | ||
| 112 | if (this.isBroadcastByIndex(index)) { | 120 | if (this.isBroadcastByIndex(index)) { |
| 113 | // 跳转到播报页面 | 121 | // 跳转到播报页面 |
| 114 | ProcessUtils.gotoBroadcastPage(this.myChannelList[index].pageId) | 122 | ProcessUtils.gotoBroadcastPage(this.myChannelList[index].pageId) |
| 115 | - let nextIndex = this.currentTopNavSelectedIndex > index ? index - 1 : index + 1 | ||
| 116 | - if (nextIndex < this.myChannelList.length) { | ||
| 117 | - this.changePage(nextIndex) | ||
| 118 | - } | 123 | + |
| 119 | } else if (this.isLayoutByIndex(index)) { | 124 | } else if (this.isLayoutByIndex(index)) { |
| 125 | + // 跳转到电子报页面 | ||
| 120 | ProcessUtils.gotoENewsPaper() | 126 | ProcessUtils.gotoENewsPaper() |
| 121 | - let nextIndex = this.currentTopNavSelectedIndex > index ? index - 1 : index + 1 | ||
| 122 | - if (nextIndex < this.myChannelList.length) { | ||
| 123 | - this.changePage(nextIndex) | ||
| 124 | - } | 127 | + |
| 125 | } else { | 128 | } else { |
| 126 | - this.currentTopNavSelectedIndex = index; | ||
| 127 | - this.changePage(this.currentTopNavSelectedIndex) | 129 | + this.changePage(index) |
| 128 | } | 130 | } |
| 129 | }) | 131 | }) |
| 130 | - // .onAnimationEnd((index: number)=>{ | ||
| 131 | - // Logger.info(TAG, `onAnimationEnd ${index}`); | ||
| 132 | - // }) | 132 | + .onAnimationEnd((index: number) => { |
| 133 | + Logger.info(TAG, `onAnimationEnd ${index}`); | ||
| 134 | + }) | ||
| 133 | .onChange((index) => { | 135 | .onChange((index) => { |
| 134 | Logger.info(TAG, `onChange index : ${index}`); | 136 | Logger.info(TAG, `onChange index : ${index}`); |
| 137 | + if (this.isLayoutByIndex(index) || this.isBroadcastByIndex(index)) { | ||
| 138 | + let nextIndex = this.currentTopNavSelectedIndex > index ? index - 1 : index + 1 | ||
| 139 | + if (nextIndex < this.myChannelList.length) { | ||
| 140 | + // 电子报和播报 相邻 | ||
| 141 | + if (this.isBroadcastByIndex(nextIndex) || this.isLayoutByIndex(nextIndex)) { | ||
| 142 | + nextIndex = this.currentTopNavSelectedIndex > index ? nextIndex - 1 : nextIndex + 1 | ||
| 143 | + if (nextIndex < this.myChannelList.length) { | ||
| 144 | + this.changePage(nextIndex) | ||
| 145 | + } else { | ||
| 146 | + this.changePage(this.currentTopNavSelectedIndex) | ||
| 147 | + } | ||
| 148 | + | ||
| 149 | + } else { | ||
| 150 | + this.changePage(nextIndex) | ||
| 151 | + } | ||
| 152 | + } else { | ||
| 153 | + // 极左极右有特殊频道,用旧值 | ||
| 154 | + this.changePage(this.currentTopNavSelectedIndex) | ||
| 155 | + } | ||
| 156 | + } | ||
| 157 | + | ||
| 135 | }) | 158 | }) |
| 136 | } | 159 | } |
| 137 | .width('100%') | 160 | .width('100%') |
| @@ -141,10 +164,14 @@ export struct TopNavigationComponentNew { | @@ -141,10 +164,14 @@ export struct TopNavigationComponentNew { | ||
| 141 | .margin({ top: this.topRectHeight }) | 164 | .margin({ top: this.topRectHeight }) |
| 142 | } | 165 | } |
| 143 | 166 | ||
| 167 | + /** | ||
| 168 | + * 新闻tab 头部 | ||
| 169 | + */ | ||
| 144 | @Builder | 170 | @Builder |
| 145 | topBar() { | 171 | topBar() { |
| 146 | Column() { | 172 | Column() { |
| 147 | Row() { | 173 | Row() { |
| 174 | + | ||
| 148 | FirstTabTopSearchComponent() | 175 | FirstTabTopSearchComponent() |
| 149 | 176 | ||
| 150 | Image($r('app.media.icon_ren_min_ri_bao')) | 177 | Image($r('app.media.icon_ren_min_ri_bao')) |
| @@ -173,19 +200,12 @@ export struct TopNavigationComponentNew { | @@ -173,19 +200,12 @@ export struct TopNavigationComponentNew { | ||
| 173 | .width(124) | 200 | .width(124) |
| 174 | .onClick(() => { | 201 | .onClick(() => { |
| 175 | //防止多次点击 | 202 | //防止多次点击 |
| 176 | - if(!this.isClickMorningEveningPaper) { | 203 | + if (!this.isClickMorningEveningPaper) { |
| 177 | this.isClickMorningEveningPaper = true; | 204 | this.isClickMorningEveningPaper = true; |
| 178 | let c = setInterval(() => { | 205 | let c = setInterval(() => { |
| 179 | this.isClickMorningEveningPaper = false | 206 | this.isClickMorningEveningPaper = false |
| 180 | }, 1000); | 207 | }, 1000); |
| 181 | 208 | ||
| 182 | - // 早晚报埋点 | ||
| 183 | - const params: ParamType = { | ||
| 184 | - "pageName": this.pageName, | ||
| 185 | - "pageId": this.pageId, | ||
| 186 | - } | ||
| 187 | - Tracking.event("morning_evening_news_click", params) | ||
| 188 | - | ||
| 189 | this.clickMorningEveningPaper() | 209 | this.clickMorningEveningPaper() |
| 190 | } | 210 | } |
| 191 | }) | 211 | }) |
| @@ -282,6 +302,11 @@ export struct TopNavigationComponentNew { | @@ -282,6 +302,11 @@ export struct TopNavigationComponentNew { | ||
| 282 | } | 302 | } |
| 283 | } | 303 | } |
| 284 | 304 | ||
| 305 | + /** | ||
| 306 | + * 顶部导航栏 | ||
| 307 | + * @param item | ||
| 308 | + * @param index | ||
| 309 | + */ | ||
| 285 | @Builder | 310 | @Builder |
| 286 | tabBarBuilder(item: TopNavDTO, index: number) { | 311 | tabBarBuilder(item: TopNavDTO, index: number) { |
| 287 | Column() { | 312 | Column() { |
| @@ -411,7 +436,8 @@ export struct TopNavigationComponentNew { | @@ -411,7 +436,8 @@ export struct TopNavigationComponentNew { | ||
| 411 | item.myChannel = '1' | 436 | item.myChannel = '1' |
| 412 | } | 437 | } |
| 413 | //频道分类 | 438 | //频道分类 |
| 414 | - if (item.name !== '播报') { //暂时隐藏播报 | 439 | + //TODO 暂时隐藏播报 |
| 440 | + if (item.name !== '播报') { | ||
| 415 | if (item.myChannel === '1') { | 441 | if (item.myChannel === '1') { |
| 416 | _myChannelList.push(item) | 442 | _myChannelList.push(item) |
| 417 | } | 443 | } |
| @@ -451,28 +477,46 @@ export struct TopNavigationComponentNew { | @@ -451,28 +477,46 @@ export struct TopNavigationComponentNew { | ||
| 451 | } | 477 | } |
| 452 | } | 478 | } |
| 453 | 479 | ||
| 480 | + /** | ||
| 481 | + * 频道是播报 | ||
| 482 | + * @param item | ||
| 483 | + * @returns | ||
| 484 | + */ | ||
| 454 | private isBroadcast(item?: TopNavDTO): boolean { | 485 | private isBroadcast(item?: TopNavDTO): boolean { |
| 455 | - // TODO 用id channelId = '2066' | ||
| 456 | - return item?.name === '播报' | 486 | + return item?.channelId === 2066 |
| 457 | } | 487 | } |
| 458 | 488 | ||
| 489 | + /** | ||
| 490 | + * 频道是电子报 | ||
| 491 | + * @param item | ||
| 492 | + * @returns | ||
| 493 | + */ | ||
| 459 | private isLayout(item?: TopNavDTO): boolean { | 494 | private isLayout(item?: TopNavDTO): boolean { |
| 460 | - // TODO 用id channelId = '2006' | ||
| 461 | - return item?.name === '版面' | 495 | + return item?.channelId === 2006 |
| 462 | } | 496 | } |
| 463 | 497 | ||
| 498 | + /** | ||
| 499 | + * 检测播报 | ||
| 500 | + * @param index | ||
| 501 | + * @returns | ||
| 502 | + */ | ||
| 464 | private isBroadcastByIndex(index: number): boolean { | 503 | private isBroadcastByIndex(index: number): boolean { |
| 465 | let item = this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index] | 504 | let item = this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index] |
| 466 | return this.isBroadcast(item) | 505 | return this.isBroadcast(item) |
| 467 | } | 506 | } |
| 468 | 507 | ||
| 508 | + /** | ||
| 509 | + * 检测电子报 | ||
| 510 | + * @param index | ||
| 511 | + * @returns | ||
| 512 | + */ | ||
| 469 | private isLayoutByIndex(index: number): boolean { | 513 | private isLayoutByIndex(index: number): boolean { |
| 470 | let item = this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index] | 514 | let item = this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index] |
| 471 | return this.isLayout(item) | 515 | return this.isLayout(item) |
| 472 | } | 516 | } |
| 473 | 517 | ||
| 474 | private isSpecialChannel(item?: TopNavDTO) { | 518 | private isSpecialChannel(item?: TopNavDTO) { |
| 475 | - // 版面、播报,可以用这个判断 | 519 | + // 版面、播报、关注,可以用这个判断 |
| 476 | return item?.channelType === 3 | 520 | return item?.channelType === 3 |
| 477 | } | 521 | } |
| 478 | 522 | ||
| @@ -481,7 +525,8 @@ export struct TopNavigationComponentNew { | @@ -481,7 +525,8 @@ export struct TopNavigationComponentNew { | ||
| 481 | this.topNavListHandle() | 525 | this.topNavListHandle() |
| 482 | this.changePage(this.currentTopNavSelectedIndex) | 526 | this.changePage(this.currentTopNavSelectedIndex) |
| 483 | 527 | ||
| 484 | - console.log('XY', '----TopNavigation-------aboutToAppear'+this.navItem.name) | 528 | + console.log('XY', '----TopNavigation-------aboutToAppear' + this.navItem.name) |
| 529 | + this.getTopNavList(this.navItem.id) | ||
| 485 | } | 530 | } |
| 486 | 531 | ||
| 487 | onTopNavigationDataUpdated() { | 532 | onTopNavigationDataUpdated() { |
| @@ -489,14 +534,16 @@ export struct TopNavigationComponentNew { | @@ -489,14 +534,16 @@ export struct TopNavigationComponentNew { | ||
| 489 | `onTopNavigationDataUpdated currentTopNavIndex: ${this.currentTopNavSelectedIndex},topNavList.length:${this.topNavList.length}`); | 534 | `onTopNavigationDataUpdated currentTopNavIndex: ${this.currentTopNavSelectedIndex},topNavList.length:${this.topNavList.length}`); |
| 490 | } | 535 | } |
| 491 | 536 | ||
| 537 | + /** | ||
| 538 | + * | ||
| 539 | + */ | ||
| 492 | updateCurrentTopNavSelectedIndex() { | 540 | updateCurrentTopNavSelectedIndex() { |
| 493 | - Logger.info(TAG, `this.navItem 埋点参数topStyle: ${this.navItem.topStyle}`); | ||
| 494 | 541 | ||
| 495 | - // 顶部tab埋点 | ||
| 496 | if (CompUtils.isNews(this.navItem)) { | 542 | if (CompUtils.isNews(this.navItem)) { |
| 497 | const tab = this.myChannelList[this.currentTopNavSelectedIndex] | 543 | const tab = this.myChannelList[this.currentTopNavSelectedIndex] |
| 498 | - Logger.info(TAG, `新闻tab埋点: ${JSON.stringify(tab)}`); | 544 | + //Logger.info(TAG, `新闻tab埋点: ${JSON.stringify(tab)}`); |
| 499 | 545 | ||
| 546 | + // 埋点 | ||
| 500 | const params: ParamType = { | 547 | const params: ParamType = { |
| 501 | "pageName": tab.name, | 548 | "pageName": tab.name, |
| 502 | "tabName": tab.name, | 549 | "tabName": tab.name, |
| @@ -507,6 +554,7 @@ export struct TopNavigationComponentNew { | @@ -507,6 +554,7 @@ export struct TopNavigationComponentNew { | ||
| 507 | const tab = this.topNavList[this.currentTopNavSelectedIndex] | 554 | const tab = this.topNavList[this.currentTopNavSelectedIndex] |
| 508 | Logger.info(TAG, `人民号tab埋点: ${JSON.stringify(tab)}`); | 555 | Logger.info(TAG, `人民号tab埋点: ${JSON.stringify(tab)}`); |
| 509 | 556 | ||
| 557 | + // 埋点 | ||
| 510 | const params: ParamType = { | 558 | const params: ParamType = { |
| 511 | "pageName": tab.name, | 559 | "pageName": tab.name, |
| 512 | "tabName": tab.name, | 560 | "tabName": tab.name, |
| @@ -516,12 +564,15 @@ export struct TopNavigationComponentNew { | @@ -516,12 +564,15 @@ export struct TopNavigationComponentNew { | ||
| 516 | } | 564 | } |
| 517 | } | 565 | } |
| 518 | 566 | ||
| 567 | + /** | ||
| 568 | + * 自动刷新方法 | ||
| 569 | + */ | ||
| 519 | onAutoRefresh() { | 570 | onAutoRefresh() { |
| 520 | if (this.bottomNavIndex != this._currentNavIndex) { | 571 | if (this.bottomNavIndex != this._currentNavIndex) { |
| 521 | return | 572 | return |
| 522 | } | 573 | } |
| 523 | // 通知page刷新 | 574 | // 通知page刷新 |
| 524 | - this.autoRefresh2Page++ | 575 | + this.doAutoRefresh() |
| 525 | } | 576 | } |
| 526 | 577 | ||
| 527 | private doAutoRefresh() { | 578 | private doAutoRefresh() { |
| @@ -616,49 +667,34 @@ export struct TopNavigationComponentNew { | @@ -616,49 +667,34 @@ export struct TopNavigationComponentNew { | ||
| 616 | return null | 667 | return null |
| 617 | } | 668 | } |
| 618 | 669 | ||
| 619 | - // private getTextInfo(index: number): Record<string, number> { | ||
| 620 | - // let strJson = getInspectorByKey(index.toString()) | ||
| 621 | - // try { | ||
| 622 | - // let obj: Record<string, string> = JSON.parse(strJson) | ||
| 623 | - // let rectInfo: number[][] = JSON.parse('[' + obj.$rect + ']') | ||
| 624 | - // return { 'left': px2vp(rectInfo[0][0]), 'width': px2vp(rectInfo[1][0] - rectInfo[0][0]) } | ||
| 625 | - // } catch (error) { | ||
| 626 | - // return { 'left': 0, 'width': 0 } | ||
| 627 | - // } | 670 | + // |
| 671 | + // private startAnimateTo(duration: number, leftMargin: number, width: number) { | ||
| 672 | + // animateTo({ | ||
| 673 | + // duration: duration, // 动画时长 | ||
| 674 | + // curve: Curve.Linear, // 动画曲线 | ||
| 675 | + // iterations: 1, // 播放次数 | ||
| 676 | + // playMode: PlayMode.Normal, // 动画模式 | ||
| 677 | + // onFinish: () => { | ||
| 678 | + // console.info('play end') | ||
| 679 | + // } | ||
| 680 | + // }, () => { | ||
| 681 | + // this.indicatorLeftMargin = leftMargin | ||
| 682 | + // this.indicatorWidth = width | ||
| 683 | + // }) | ||
| 628 | // } | 684 | // } |
| 629 | 685 | ||
| 630 | - // private getCurrentIndicatorInfo(index: number, event: TabsAnimationEvent): Record<string, number> { | ||
| 631 | - // let nextIndex = index | ||
| 632 | - // if (index > 0 && event.currentOffset > 0) { | ||
| 633 | - // nextIndex-- | ||
| 634 | - // } else if (index < 3 && event.currentOffset < 0) { | ||
| 635 | - // nextIndex++ | ||
| 636 | - // } | ||
| 637 | - // let indexInfo = this.getTextInfo(index) | ||
| 638 | - // let nextIndexInfo = this.getTextInfo(nextIndex) | ||
| 639 | - // let swipeRatio = Math.abs(event.currentOffset / this.tabsWidth) | ||
| 640 | - // let currentIndex = swipeRatio > 0.5 ? nextIndex : index // 页面滑动超过一半,tabBar切换到下一页。 | ||
| 641 | - // let currentLeft = indexInfo.left + (nextIndexInfo.left - indexInfo.left) * swipeRatio | ||
| 642 | - // let currentWidth = indexInfo.width + (nextIndexInfo.width - indexInfo.width) * swipeRatio | ||
| 643 | - // return { 'index': currentIndex, 'left': currentLeft, 'width': currentWidth } | ||
| 644 | - // } | 686 | + /** |
| 687 | + * 进入早晚报专题 | ||
| 688 | + */ | ||
| 689 | + clickMorningEveningPaper() { | ||
| 645 | 690 | ||
| 646 | - private startAnimateTo(duration: number, leftMargin: number, width: number) { | ||
| 647 | - animateTo({ | ||
| 648 | - duration: duration, // 动画时长 | ||
| 649 | - curve: Curve.Linear, // 动画曲线 | ||
| 650 | - iterations: 1, // 播放次数 | ||
| 651 | - playMode: PlayMode.Normal, // 动画模式 | ||
| 652 | - onFinish: () => { | ||
| 653 | - console.info('play end') | ||
| 654 | - } | ||
| 655 | - }, () => { | ||
| 656 | - this.indicatorLeftMargin = leftMargin | ||
| 657 | - this.indicatorWidth = width | ||
| 658 | - }) | ||
| 659 | - } | 691 | + // 早晚报埋点 |
| 692 | + const params: ParamType = { | ||
| 693 | + "pageName": this.pageName, | ||
| 694 | + "pageId": this.pageId, | ||
| 695 | + } | ||
| 696 | + Tracking.event("morning_evening_news_click", params) | ||
| 660 | 697 | ||
| 661 | - clickMorningEveningPaper() { | ||
| 662 | if (NetworkUtil.isNetConnected()) { | 698 | if (NetworkUtil.isNetConnected()) { |
| 663 | DailyPaperTopicModel.getDailyPaperTopic().then(dailyPaperTopicBean => { | 699 | DailyPaperTopicModel.getDailyPaperTopic().then(dailyPaperTopicBean => { |
| 664 | if (dailyPaperTopicBean && dailyPaperTopicBean.id > 0) { | 700 | if (dailyPaperTopicBean && dailyPaperTopicBean.id > 0) { |
| @@ -676,4 +712,14 @@ export struct TopNavigationComponentNew { | @@ -676,4 +712,14 @@ export struct TopNavigationComponentNew { | ||
| 676 | ToastUtils.showToast('网络出小差了,请检查网络后重试', 1000) | 712 | ToastUtils.showToast('网络出小差了,请检查网络后重试', 1000) |
| 677 | } | 713 | } |
| 678 | } | 714 | } |
| 715 | + | ||
| 716 | + //请求顶导数据 | ||
| 717 | + async getTopNavList(id: number) { | ||
| 718 | + let bottomNavDetail = await ChannelViewModel.getBottomNavDetailData(id) | ||
| 719 | + let topNavList = bottomNavDetail?.topNavChannelList || [] | ||
| 720 | + for (let topNav of topNavList) { | ||
| 721 | + console.debug(TAG, 'getTopNavList=>' + JSON.stringify(topNav)) | ||
| 722 | + | ||
| 723 | + } | ||
| 724 | + } | ||
| 679 | } | 725 | } |
| @@ -36,7 +36,7 @@ export struct BottomNavigationComponent { | @@ -36,7 +36,7 @@ export struct BottomNavigationComponent { | ||
| 36 | @State topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0 | 36 | @State topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0 |
| 37 | @State @Watch('onBottomNavigationDataUpdated') bottomNavList: BottomNavDTO[] = [] // 底导/顶导全部数据 | 37 | @State @Watch('onBottomNavigationDataUpdated') bottomNavList: BottomNavDTO[] = [] // 底导/顶导全部数据 |
| 38 | @State currentNavIndex: number = BottomNavi.NEWS; // 底导当前选中/焦点下标 | 38 | @State currentNavIndex: number = BottomNavi.NEWS; // 底导当前选中/焦点下标 |
| 39 | - @State topNavList: TopNavDTO[] = [] | 39 | + // @State topNavList: TopNavDTO[] = [] |
| 40 | // 底导TabsController | 40 | // 底导TabsController |
| 41 | private navController: TabsController = new TabsController(); | 41 | private navController: TabsController = new TabsController(); |
| 42 | readonly ASPECT_RATIO_1_1: number = 1 / 1; // 底导图片宽高比 | 42 | readonly ASPECT_RATIO_1_1: number = 1 / 1; // 底导图片宽高比 |
| @@ -52,8 +52,7 @@ export struct BottomNavigationComponent { | @@ -52,8 +52,7 @@ export struct BottomNavigationComponent { | ||
| 52 | @State assignChannel: AssignChannelParam = new AssignChannelParam() | 52 | @State assignChannel: AssignChannelParam = new AssignChannelParam() |
| 53 | // 自动刷新触发(双击tab自动刷新) | 53 | // 自动刷新触发(双击tab自动刷新) |
| 54 | @State autoRefresh: number = 0 | 54 | @State autoRefresh: number = 0 |
| 55 | - // 顶导数据,从接口获取 TODO 顶导业务逻辑没看懂,暂时不替换顶导list。频道管理数据待梳理 | ||
| 56 | - // @State topNavMap: Record<string, TopNavDTO[]> = {} | 55 | + |
| 57 | 56 | ||
| 58 | async aboutToAppear() { | 57 | async aboutToAppear() { |
| 59 | Logger.info(TAG, `aboutToAppear currentNavIndex: ${this.currentNavIndex}`); | 58 | Logger.info(TAG, `aboutToAppear currentNavIndex: ${this.currentNavIndex}`); |
| @@ -239,11 +238,7 @@ export struct BottomNavigationComponent { | @@ -239,11 +238,7 @@ export struct BottomNavigationComponent { | ||
| 239 | // 请求顶导数据(参数): | 238 | // 请求顶导数据(参数): |
| 240 | } | 239 | } |
| 241 | 240 | ||
| 242 | - //请求顶导数据 | ||
| 243 | - async getTopNavList(id: number) { | ||
| 244 | - let bottomNavDetail = await ChannelViewModel.getBottomNavDetailData(id) | ||
| 245 | - this.topNavList = bottomNavDetail?.topNavChannelList || [] | ||
| 246 | - } | 241 | + |
| 247 | 242 | ||
| 248 | onBottomNavigationDataUpdated() { | 243 | onBottomNavigationDataUpdated() { |
| 249 | Logger.error('yyyy', 'onBottomNavigationDataUpdated ' + JSON.stringify(this.bottomNavList)) | 244 | Logger.error('yyyy', 'onBottomNavigationDataUpdated ' + JSON.stringify(this.bottomNavList)) |
| @@ -366,7 +361,8 @@ export struct BottomNavigationComponent { | @@ -366,7 +361,8 @@ export struct BottomNavigationComponent { | ||
| 366 | item.pageName = 'MY'; | 361 | item.pageName = 'MY'; |
| 367 | break; | 362 | break; |
| 368 | default: | 363 | default: |
| 369 | - item.pageName = 'NEWS'; break; | 364 | + item.pageName = 'NEWS'; |
| 365 | + break; | ||
| 370 | } | 366 | } |
| 371 | }) | 367 | }) |
| 372 | this.bottomNavList = list | 368 | this.bottomNavList = list |
-
Please register or login to post a comment