Showing
4 changed files
with
161 additions
and
103 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 | } |
| @@ -114,22 +121,55 @@ export struct TopNavigationComponentNew { | @@ -114,22 +121,55 @@ export struct TopNavigationComponentNew { | ||
| 114 | ProcessUtils.gotoBroadcastPage(this.myChannelList[index].pageId) | 121 | ProcessUtils.gotoBroadcastPage(this.myChannelList[index].pageId) |
| 115 | let nextIndex = this.currentTopNavSelectedIndex > index ? index - 1 : index + 1 | 122 | let nextIndex = this.currentTopNavSelectedIndex > index ? index - 1 : index + 1 |
| 116 | if (nextIndex < this.myChannelList.length) { | 123 | if (nextIndex < this.myChannelList.length) { |
| 117 | - this.changePage(nextIndex) | 124 | + // 电子报和播报 相邻 |
| 125 | + if (this.isLayoutByIndex(nextIndex)) { | ||
| 126 | + nextIndex = this.currentTopNavSelectedIndex > index ? nextIndex - 1 : nextIndex + 1 | ||
| 127 | + if (nextIndex < this.myChannelList.length) { | ||
| 128 | + this.changePage(nextIndex) | ||
| 129 | + } else { | ||
| 130 | + this.changePage(curIndex) | ||
| 131 | + } | ||
| 132 | + | ||
| 133 | + } else { | ||
| 134 | + this.changePage(nextIndex) | ||
| 135 | + } | ||
| 136 | + } else { | ||
| 137 | + // 极左极右有特殊频道,用旧值 | ||
| 138 | + this.changePage(curIndex) | ||
| 118 | } | 139 | } |
| 119 | } else if (this.isLayoutByIndex(index)) { | 140 | } else if (this.isLayoutByIndex(index)) { |
| 141 | + // 跳转到电子报页面 | ||
| 120 | ProcessUtils.gotoENewsPaper() | 142 | ProcessUtils.gotoENewsPaper() |
| 143 | + // 特殊频道遇到则跳转到下一个 | ||
| 121 | let nextIndex = this.currentTopNavSelectedIndex > index ? index - 1 : index + 1 | 144 | let nextIndex = this.currentTopNavSelectedIndex > index ? index - 1 : index + 1 |
| 145 | + | ||
| 146 | + Logger.info(TAG, `电子报 :${nextIndex} ${this.myChannelList.length}`); | ||
| 122 | if (nextIndex < this.myChannelList.length) { | 147 | if (nextIndex < this.myChannelList.length) { |
| 123 | - this.changePage(nextIndex) | 148 | + |
| 149 | + // 电子报和播报 相邻 | ||
| 150 | + if (this.isBroadcastByIndex(nextIndex)) { | ||
| 151 | + nextIndex = this.currentTopNavSelectedIndex > index ? nextIndex - 1 : nextIndex + 1 | ||
| 152 | + if (nextIndex < this.myChannelList.length) { | ||
| 153 | + this.changePage(nextIndex) | ||
| 154 | + } else { | ||
| 155 | + this.changePage(curIndex) | ||
| 156 | + } | ||
| 157 | + | ||
| 158 | + } else { | ||
| 159 | + this.changePage(nextIndex) | ||
| 160 | + } | ||
| 161 | + | ||
| 162 | + } else { | ||
| 163 | + // 极左极右有特殊频道,用旧值 | ||
| 164 | + this.changePage(curIndex) | ||
| 124 | } | 165 | } |
| 125 | } else { | 166 | } else { |
| 126 | - this.currentTopNavSelectedIndex = index; | ||
| 127 | - this.changePage(this.currentTopNavSelectedIndex) | 167 | + this.changePage(index) |
| 128 | } | 168 | } |
| 129 | }) | 169 | }) |
| 130 | - // .onAnimationEnd((index: number)=>{ | ||
| 131 | - // Logger.info(TAG, `onAnimationEnd ${index}`); | ||
| 132 | - // }) | 170 | + .onAnimationEnd((index: number) => { |
| 171 | + Logger.info(TAG, `onAnimationEnd ${index}`); | ||
| 172 | + }) | ||
| 133 | .onChange((index) => { | 173 | .onChange((index) => { |
| 134 | Logger.info(TAG, `onChange index : ${index}`); | 174 | Logger.info(TAG, `onChange index : ${index}`); |
| 135 | }) | 175 | }) |
| @@ -141,10 +181,14 @@ export struct TopNavigationComponentNew { | @@ -141,10 +181,14 @@ export struct TopNavigationComponentNew { | ||
| 141 | .margin({ top: this.topRectHeight }) | 181 | .margin({ top: this.topRectHeight }) |
| 142 | } | 182 | } |
| 143 | 183 | ||
| 184 | + /** | ||
| 185 | + * 新闻tab 头部 | ||
| 186 | + */ | ||
| 144 | @Builder | 187 | @Builder |
| 145 | topBar() { | 188 | topBar() { |
| 146 | Column() { | 189 | Column() { |
| 147 | Row() { | 190 | Row() { |
| 191 | + | ||
| 148 | FirstTabTopSearchComponent() | 192 | FirstTabTopSearchComponent() |
| 149 | 193 | ||
| 150 | Image($r('app.media.icon_ren_min_ri_bao')) | 194 | Image($r('app.media.icon_ren_min_ri_bao')) |
| @@ -173,19 +217,12 @@ export struct TopNavigationComponentNew { | @@ -173,19 +217,12 @@ export struct TopNavigationComponentNew { | ||
| 173 | .width(124) | 217 | .width(124) |
| 174 | .onClick(() => { | 218 | .onClick(() => { |
| 175 | //防止多次点击 | 219 | //防止多次点击 |
| 176 | - if(!this.isClickMorningEveningPaper) { | 220 | + if (!this.isClickMorningEveningPaper) { |
| 177 | this.isClickMorningEveningPaper = true; | 221 | this.isClickMorningEveningPaper = true; |
| 178 | let c = setInterval(() => { | 222 | let c = setInterval(() => { |
| 179 | this.isClickMorningEveningPaper = false | 223 | this.isClickMorningEveningPaper = false |
| 180 | }, 1000); | 224 | }, 1000); |
| 181 | 225 | ||
| 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() | 226 | this.clickMorningEveningPaper() |
| 190 | } | 227 | } |
| 191 | }) | 228 | }) |
| @@ -282,6 +319,11 @@ export struct TopNavigationComponentNew { | @@ -282,6 +319,11 @@ export struct TopNavigationComponentNew { | ||
| 282 | } | 319 | } |
| 283 | } | 320 | } |
| 284 | 321 | ||
| 322 | + /** | ||
| 323 | + * 顶部导航栏 | ||
| 324 | + * @param item | ||
| 325 | + * @param index | ||
| 326 | + */ | ||
| 285 | @Builder | 327 | @Builder |
| 286 | tabBarBuilder(item: TopNavDTO, index: number) { | 328 | tabBarBuilder(item: TopNavDTO, index: number) { |
| 287 | Column() { | 329 | Column() { |
| @@ -411,7 +453,8 @@ export struct TopNavigationComponentNew { | @@ -411,7 +453,8 @@ export struct TopNavigationComponentNew { | ||
| 411 | item.myChannel = '1' | 453 | item.myChannel = '1' |
| 412 | } | 454 | } |
| 413 | //频道分类 | 455 | //频道分类 |
| 414 | - if (item.name !== '播报') { //暂时隐藏播报 | 456 | + //TODO 暂时隐藏播报 |
| 457 | + if (item.name !== '播报') { | ||
| 415 | if (item.myChannel === '1') { | 458 | if (item.myChannel === '1') { |
| 416 | _myChannelList.push(item) | 459 | _myChannelList.push(item) |
| 417 | } | 460 | } |
| @@ -451,28 +494,46 @@ export struct TopNavigationComponentNew { | @@ -451,28 +494,46 @@ export struct TopNavigationComponentNew { | ||
| 451 | } | 494 | } |
| 452 | } | 495 | } |
| 453 | 496 | ||
| 497 | + /** | ||
| 498 | + * 频道是播报 | ||
| 499 | + * @param item | ||
| 500 | + * @returns | ||
| 501 | + */ | ||
| 454 | private isBroadcast(item?: TopNavDTO): boolean { | 502 | private isBroadcast(item?: TopNavDTO): boolean { |
| 455 | - // TODO 用id channelId = '2066' | ||
| 456 | - return item?.name === '播报' | 503 | + return item?.channelId === 2066 |
| 457 | } | 504 | } |
| 458 | 505 | ||
| 506 | + /** | ||
| 507 | + * 频道是电子报 | ||
| 508 | + * @param item | ||
| 509 | + * @returns | ||
| 510 | + */ | ||
| 459 | private isLayout(item?: TopNavDTO): boolean { | 511 | private isLayout(item?: TopNavDTO): boolean { |
| 460 | - // TODO 用id channelId = '2006' | ||
| 461 | - return item?.name === '版面' | 512 | + return item?.channelId === 2006 |
| 462 | } | 513 | } |
| 463 | 514 | ||
| 515 | + /** | ||
| 516 | + * 检测播报 | ||
| 517 | + * @param index | ||
| 518 | + * @returns | ||
| 519 | + */ | ||
| 464 | private isBroadcastByIndex(index: number): boolean { | 520 | private isBroadcastByIndex(index: number): boolean { |
| 465 | let item = this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index] | 521 | let item = this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index] |
| 466 | return this.isBroadcast(item) | 522 | return this.isBroadcast(item) |
| 467 | } | 523 | } |
| 468 | 524 | ||
| 525 | + /** | ||
| 526 | + * 检测电子报 | ||
| 527 | + * @param index | ||
| 528 | + * @returns | ||
| 529 | + */ | ||
| 469 | private isLayoutByIndex(index: number): boolean { | 530 | private isLayoutByIndex(index: number): boolean { |
| 470 | let item = this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index] | 531 | let item = this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index] |
| 471 | return this.isLayout(item) | 532 | return this.isLayout(item) |
| 472 | } | 533 | } |
| 473 | 534 | ||
| 474 | private isSpecialChannel(item?: TopNavDTO) { | 535 | private isSpecialChannel(item?: TopNavDTO) { |
| 475 | - // 版面、播报,可以用这个判断 | 536 | + // 版面、播报、关注,可以用这个判断 |
| 476 | return item?.channelType === 3 | 537 | return item?.channelType === 3 |
| 477 | } | 538 | } |
| 478 | 539 | ||
| @@ -481,7 +542,8 @@ export struct TopNavigationComponentNew { | @@ -481,7 +542,8 @@ export struct TopNavigationComponentNew { | ||
| 481 | this.topNavListHandle() | 542 | this.topNavListHandle() |
| 482 | this.changePage(this.currentTopNavSelectedIndex) | 543 | this.changePage(this.currentTopNavSelectedIndex) |
| 483 | 544 | ||
| 484 | - console.log('XY', '----TopNavigation-------aboutToAppear'+this.navItem.name) | 545 | + console.log('XY', '----TopNavigation-------aboutToAppear' + this.navItem.name) |
| 546 | + this.getTopNavList(this.navItem.id) | ||
| 485 | } | 547 | } |
| 486 | 548 | ||
| 487 | onTopNavigationDataUpdated() { | 549 | onTopNavigationDataUpdated() { |
| @@ -489,14 +551,16 @@ export struct TopNavigationComponentNew { | @@ -489,14 +551,16 @@ export struct TopNavigationComponentNew { | ||
| 489 | `onTopNavigationDataUpdated currentTopNavIndex: ${this.currentTopNavSelectedIndex},topNavList.length:${this.topNavList.length}`); | 551 | `onTopNavigationDataUpdated currentTopNavIndex: ${this.currentTopNavSelectedIndex},topNavList.length:${this.topNavList.length}`); |
| 490 | } | 552 | } |
| 491 | 553 | ||
| 554 | + /** | ||
| 555 | + * | ||
| 556 | + */ | ||
| 492 | updateCurrentTopNavSelectedIndex() { | 557 | updateCurrentTopNavSelectedIndex() { |
| 493 | - Logger.info(TAG, `this.navItem 埋点参数topStyle: ${this.navItem.topStyle}`); | ||
| 494 | 558 | ||
| 495 | - // 顶部tab埋点 | ||
| 496 | if (CompUtils.isNews(this.navItem)) { | 559 | if (CompUtils.isNews(this.navItem)) { |
| 497 | const tab = this.myChannelList[this.currentTopNavSelectedIndex] | 560 | const tab = this.myChannelList[this.currentTopNavSelectedIndex] |
| 498 | - Logger.info(TAG, `新闻tab埋点: ${JSON.stringify(tab)}`); | 561 | + //Logger.info(TAG, `新闻tab埋点: ${JSON.stringify(tab)}`); |
| 499 | 562 | ||
| 563 | + // 埋点 | ||
| 500 | const params: ParamType = { | 564 | const params: ParamType = { |
| 501 | "pageName": tab.name, | 565 | "pageName": tab.name, |
| 502 | "tabName": tab.name, | 566 | "tabName": tab.name, |
| @@ -507,6 +571,7 @@ export struct TopNavigationComponentNew { | @@ -507,6 +571,7 @@ export struct TopNavigationComponentNew { | ||
| 507 | const tab = this.topNavList[this.currentTopNavSelectedIndex] | 571 | const tab = this.topNavList[this.currentTopNavSelectedIndex] |
| 508 | Logger.info(TAG, `人民号tab埋点: ${JSON.stringify(tab)}`); | 572 | Logger.info(TAG, `人民号tab埋点: ${JSON.stringify(tab)}`); |
| 509 | 573 | ||
| 574 | + // 埋点 | ||
| 510 | const params: ParamType = { | 575 | const params: ParamType = { |
| 511 | "pageName": tab.name, | 576 | "pageName": tab.name, |
| 512 | "tabName": tab.name, | 577 | "tabName": tab.name, |
| @@ -516,12 +581,15 @@ export struct TopNavigationComponentNew { | @@ -516,12 +581,15 @@ export struct TopNavigationComponentNew { | ||
| 516 | } | 581 | } |
| 517 | } | 582 | } |
| 518 | 583 | ||
| 584 | + /** | ||
| 585 | + * 自动刷新方法 | ||
| 586 | + */ | ||
| 519 | onAutoRefresh() { | 587 | onAutoRefresh() { |
| 520 | if (this.bottomNavIndex != this._currentNavIndex) { | 588 | if (this.bottomNavIndex != this._currentNavIndex) { |
| 521 | return | 589 | return |
| 522 | } | 590 | } |
| 523 | // 通知page刷新 | 591 | // 通知page刷新 |
| 524 | - this.autoRefresh2Page++ | 592 | + this.doAutoRefresh() |
| 525 | } | 593 | } |
| 526 | 594 | ||
| 527 | private doAutoRefresh() { | 595 | private doAutoRefresh() { |
| @@ -616,49 +684,34 @@ export struct TopNavigationComponentNew { | @@ -616,49 +684,34 @@ export struct TopNavigationComponentNew { | ||
| 616 | return null | 684 | return null |
| 617 | } | 685 | } |
| 618 | 686 | ||
| 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 | - // } | 687 | + // |
| 688 | + // private startAnimateTo(duration: number, leftMargin: number, width: number) { | ||
| 689 | + // animateTo({ | ||
| 690 | + // duration: duration, // 动画时长 | ||
| 691 | + // curve: Curve.Linear, // 动画曲线 | ||
| 692 | + // iterations: 1, // 播放次数 | ||
| 693 | + // playMode: PlayMode.Normal, // 动画模式 | ||
| 694 | + // onFinish: () => { | ||
| 695 | + // console.info('play end') | ||
| 696 | + // } | ||
| 697 | + // }, () => { | ||
| 698 | + // this.indicatorLeftMargin = leftMargin | ||
| 699 | + // this.indicatorWidth = width | ||
| 700 | + // }) | ||
| 628 | // } | 701 | // } |
| 629 | 702 | ||
| 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 | - // } | 703 | + /** |
| 704 | + * 进入早晚报专题 | ||
| 705 | + */ | ||
| 706 | + clickMorningEveningPaper() { | ||
| 645 | 707 | ||
| 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 | - } | 708 | + // 早晚报埋点 |
| 709 | + const params: ParamType = { | ||
| 710 | + "pageName": this.pageName, | ||
| 711 | + "pageId": this.pageId, | ||
| 712 | + } | ||
| 713 | + Tracking.event("morning_evening_news_click", params) | ||
| 660 | 714 | ||
| 661 | - clickMorningEveningPaper() { | ||
| 662 | if (NetworkUtil.isNetConnected()) { | 715 | if (NetworkUtil.isNetConnected()) { |
| 663 | DailyPaperTopicModel.getDailyPaperTopic().then(dailyPaperTopicBean => { | 716 | DailyPaperTopicModel.getDailyPaperTopic().then(dailyPaperTopicBean => { |
| 664 | if (dailyPaperTopicBean && dailyPaperTopicBean.id > 0) { | 717 | if (dailyPaperTopicBean && dailyPaperTopicBean.id > 0) { |
| @@ -676,4 +729,14 @@ export struct TopNavigationComponentNew { | @@ -676,4 +729,14 @@ export struct TopNavigationComponentNew { | ||
| 676 | ToastUtils.showToast('网络出小差了,请检查网络后重试', 1000) | 729 | ToastUtils.showToast('网络出小差了,请检查网络后重试', 1000) |
| 677 | } | 730 | } |
| 678 | } | 731 | } |
| 732 | + | ||
| 733 | + //请求顶导数据 | ||
| 734 | + async getTopNavList(id: number) { | ||
| 735 | + let bottomNavDetail = await ChannelViewModel.getBottomNavDetailData(id) | ||
| 736 | + let topNavList = bottomNavDetail?.topNavChannelList || [] | ||
| 737 | + for (let topNav of topNavList) { | ||
| 738 | + console.debug(TAG, 'getTopNavList=>' + JSON.stringify(topNav)) | ||
| 739 | + | ||
| 740 | + } | ||
| 741 | + } | ||
| 679 | } | 742 | } |
| @@ -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