liyubing

feat:

1)频道编辑页面,删除的频道留存的索引值无法指引顶导频道时,使用默认频道
@@ -19,10 +19,15 @@ struct ChannelSubscriptionLayout { @@ -19,10 +19,15 @@ struct ChannelSubscriptionLayout {
19 //当前选中的频道 19 //当前选中的频道
20 @Link currentTopNavSelectedIndex: number; 20 @Link currentTopNavSelectedIndex: number;
21 @Prop homeChannelList: TopNavDTO [] 21 @Prop homeChannelList: TopNavDTO []
  22 + // 我的频道栏目的频道信息数组
22 @Link myChannelList: TopNavDTO [] 23 @Link myChannelList: TopNavDTO []
  24 + // 更多频道栏目频道信息数组
23 @Link moreChannelList: TopNavDTO [] 25 @Link moreChannelList: TopNavDTO []
  26 + // 地方频道栏目频道信息数组
24 @Link localChannelList: TopNavDTO [] 27 @Link localChannelList: TopNavDTO []
  28 + // 收集到的我的频道栏目中的频道id
25 @State channelIds: number [] = [] 29 @State channelIds: number [] = []
  30 +
26 @State isShow: boolean = false 31 @State isShow: boolean = false
27 @State dragItem: number = -1 32 @State dragItem: number = -1
28 private dragRefOffsetX: number = 0 33 private dragRefOffsetX: number = 0
@@ -33,12 +38,12 @@ struct ChannelSubscriptionLayout { @@ -33,12 +38,12 @@ struct ChannelSubscriptionLayout {
33 private FIX_VP_Y: number = 48 38 private FIX_VP_Y: number = 48
34 @State indexSettingChannelId: number = AppStorage.get<number>('indexSettingChannelId') || 2002 39 @State indexSettingChannelId: number = AppStorage.get<number>('indexSettingChannelId') || 2002
35 @State isEditIng: boolean = false 40 @State isEditIng: boolean = false
36 - @State currentTopNavSelectedItem: TopNavDTO = {} as TopNavDTO 41 + // @State currentTopNavSelectedItem: TopNavDTO = {} as TopNavDTO
37 changeTab: (index: number) => void = () => { 42 changeTab: (index: number) => void = () => {
38 } 43 }
39 44
40 aboutToAppear() { 45 aboutToAppear() {
41 - this.currentTopNavSelectedItem = this.myChannelList[this.currentTopNavSelectedIndex] 46 + // this.currentTopNavSelectedItem = this.myChannelList[this.currentTopNavSelectedIndex]
42 this.myChannelList.forEach(item => { 47 this.myChannelList.forEach(item => {
43 if(item != undefined && item.channelId != undefined){ 48 if(item != undefined && item.channelId != undefined){
44 this.channelIds.push(item.channelId) 49 this.channelIds.push(item.channelId)
@@ -57,15 +62,32 @@ struct ChannelSubscriptionLayout { @@ -57,15 +62,32 @@ struct ChannelSubscriptionLayout {
57 62
58 //删除频道 63 //删除频道
59 delChannelItem(index: number) { 64 delChannelItem(index: number) {
  65 +
60 let item = this.myChannelList.splice(index, 1)[0] 66 let item = this.myChannelList.splice(index, 1)[0]
61 this.channelIds.splice(index, 1) 67 this.channelIds.splice(index, 1)
62 AppStorage.setOrCreate('channelIds', JSON.stringify(this.channelIds)) 68 AppStorage.setOrCreate('channelIds', JSON.stringify(this.channelIds))
  69 +
  70 + /*
  71 + 删除的频道信息回到原栏目中去
  72 + */
63 if (item.moreChannel === '1') { 73 if (item.moreChannel === '1') {
64 this.moreChannelList.unshift(item) 74 this.moreChannelList.unshift(item)
65 } 75 }
66 if (item.localChannel === '1') { 76 if (item.localChannel === '1') {
67 this.localChannelList.unshift(item) 77 this.localChannelList.unshift(item)
68 } 78 }
  79 +
  80 +
  81 + // 删除频道的索引值大于 我的栏目中频道最大索引值
  82 + if(this.currentTopNavSelectedIndex > this.channelIds.length-1){
  83 + //使用默认频道
  84 + //缓存首页频道
  85 + let index = this.myChannelList.findIndex(_item => _item?.channelId === this.indexSettingChannelId)
  86 + console.debug('TopNavigationComponent','index='+index)
  87 + if (index > -1) {
  88 + this.currentTopNavSelectedIndex = index
  89 + }
  90 + }
69 } 91 }
70 92
71 // 添加频道 93 // 添加频道
@@ -12,8 +12,6 @@ import { ParamType, TrackConstants, Tracking, TrackingButton } from 'wdTracking/ @@ -12,8 +12,6 @@ import { ParamType, TrackConstants, Tracking, TrackingButton } from 'wdTracking/
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'; 14 import ChannelViewModel from '../../viewmodel/ChannelViewModel';
15 -import { JSON } from '@kit.ArkTS';  
16 -import text from '@ohos.graphics.text';  
17 15
18 const TAG = 'TopNavigationComponent'; 16 const TAG = 'TopNavigationComponent';
19 17
@@ -95,7 +93,6 @@ export struct TopNavigationComponentNew { @@ -95,7 +93,6 @@ export struct TopNavigationComponentNew {
95 }) 93 })
96 } else { 94 } else {
97 channelSkeleton() 95 channelSkeleton()
98 - //Text('特殊频道').fontColor(Color.Red).fontSize(20).width('100%').height('100%')  
99 } 96 }
100 } 97 }
101 }) 98 })
@@ -153,6 +150,8 @@ export struct TopNavigationComponentNew { @@ -153,6 +150,8 @@ export struct TopNavigationComponentNew {
153 // 极左极右有特殊频道,用旧值 150 // 极左极右有特殊频道,用旧值
154 this.changePage(this.currentTopNavSelectedIndex) 151 this.changePage(this.currentTopNavSelectedIndex)
155 } 152 }
  153 + } else {
  154 + //this.currentTopNavSelectedIndex = index
156 } 155 }
157 156
158 }) 157 })
@@ -369,6 +368,7 @@ export struct TopNavigationComponentNew { @@ -369,6 +368,7 @@ export struct TopNavigationComponentNew {
369 * @param index 频道所在的序列号 368 * @param index 频道所在的序列号
370 */ 369 */
371 private changePage(index: number) { 370 private changePage(index: number) {
  371 + Logger.info(TAG, `修改页面 changePage index : ${index}`);
372 this.currentTopNavSelectedIndex = index 372 this.currentTopNavSelectedIndex = index
373 this.swiperController.changeIndex(index) 373 this.swiperController.changeIndex(index)
374 this.listScroller.scrollToIndex(index, true, ScrollAlign.CENTER) 374 this.listScroller.scrollToIndex(index, true, ScrollAlign.CENTER)
@@ -521,7 +521,6 @@ export struct TopNavigationComponentNew { @@ -521,7 +521,6 @@ export struct TopNavigationComponentNew {
521 this.topNavListHandle() 521 this.topNavListHandle()
522 this.changePage(this.currentTopNavSelectedIndex) 522 this.changePage(this.currentTopNavSelectedIndex)
523 523
524 - console.log('XY', '----TopNavigation-------aboutToAppear' + this.navItem.name)  
525 this.getTopNavList(this.navItem.id) 524 this.getTopNavList(this.navItem.id)
526 } 525 }
527 526
@@ -534,11 +533,9 @@ export struct TopNavigationComponentNew { @@ -534,11 +533,9 @@ export struct TopNavigationComponentNew {
534 * 533 *
535 */ 534 */
536 updateCurrentTopNavSelectedIndex() { 535 updateCurrentTopNavSelectedIndex() {
537 - 536 + console.debug(TAG, 'updateCurrentTopNavSelectedIndex=>' + this.currentTopNavSelectedIndex)
538 if (CompUtils.isNews(this.navItem)) { 537 if (CompUtils.isNews(this.navItem)) {
539 const tab = this.myChannelList[this.currentTopNavSelectedIndex] 538 const tab = this.myChannelList[this.currentTopNavSelectedIndex]
540 - //Logger.info(TAG, `新闻tab埋点: ${JSON.stringify(tab)}`);  
541 -  
542 // 埋点 539 // 埋点
543 const params: ParamType = { 540 const params: ParamType = {
544 "pageName": tab.name, 541 "pageName": tab.name,
@@ -548,8 +545,6 @@ export struct TopNavigationComponentNew { @@ -548,8 +545,6 @@ export struct TopNavigationComponentNew {
548 Tracking.event("home_page_tab_click", params) 545 Tracking.event("home_page_tab_click", params)
549 } else if (CompUtils.isRMH(this.navItem)) { 546 } else if (CompUtils.isRMH(this.navItem)) {
550 const tab = this.topNavList[this.currentTopNavSelectedIndex] 547 const tab = this.topNavList[this.currentTopNavSelectedIndex]
551 - Logger.info(TAG, `人民号tab埋点: ${JSON.stringify(tab)}`);  
552 -  
553 // 埋点 548 // 埋点
554 const params: ParamType = { 549 const params: ParamType = {
555 "pageName": tab.name, 550 "pageName": tab.name,
@@ -663,21 +658,6 @@ export struct TopNavigationComponentNew { @@ -663,21 +658,6 @@ export struct TopNavigationComponentNew {
663 return null 658 return null
664 } 659 }
665 660
666 - //  
667 - // private startAnimateTo(duration: number, leftMargin: number, width: number) {  
668 - // animateTo({  
669 - // duration: duration, // 动画时长  
670 - // curve: Curve.Linear, // 动画曲线  
671 - // iterations: 1, // 播放次数  
672 - // playMode: PlayMode.Normal, // 动画模式  
673 - // onFinish: () => {  
674 - // console.info('play end')  
675 - // }  
676 - // }, () => {  
677 - // this.indicatorLeftMargin = leftMargin  
678 - // this.indicatorWidth = width  
679 - // })  
680 - // }  
681 661
682 /** 662 /**
683 * 进入早晚报专题 663 * 进入早晚报专题
@@ -717,9 +697,9 @@ export struct TopNavigationComponentNew { @@ -717,9 +697,9 @@ export struct TopNavigationComponentNew {
717 async getTopNavList(id: number) { 697 async getTopNavList(id: number) {
718 let bottomNavDetail = await ChannelViewModel.getBottomNavDetailData(id) 698 let bottomNavDetail = await ChannelViewModel.getBottomNavDetailData(id)
719 let topNavList = bottomNavDetail?.topNavChannelList || [] 699 let topNavList = bottomNavDetail?.topNavChannelList || []
720 - for (let topNav of topNavList) {  
721 - console.debug(TAG, 'getTopNavList=>' + JSON.stringify(topNav))  
722 -  
723 - } 700 + // for (let topNav of topNavList) {
  701 + // console.debug(TAG, 'getTopNavList=>' + JSON.stringify(topNav))
  702 + //
  703 + // }
724 } 704 }
725 } 705 }
@@ -24,17 +24,17 @@ export class Tracking { @@ -24,17 +24,17 @@ export class Tracking {
24 // Logger.error('yyyy','event track failed') 24 // Logger.error('yyyy','event track failed')
25 // }) 25 // })
26 26
27 - let publicParams = new PublicParams()  
28 - publicParams.getPublicParams().then((pubParams) => {  
29 -  
30 - if (params) {  
31 - for (const obj of Object.entries(params)) {  
32 - // Logger.info(TAG, ` ${obj[0]} => ` + `${obj[1]}`);  
33 - pubParams[obj[0]] = obj[1]  
34 - }  
35 - }  
36 - sensors.track(eventId, pubParams)  
37 - }) 27 + // let publicParams = new PublicParams()
  28 + // publicParams.getPublicParams().then((pubParams) => {
  29 + //
  30 + // if (params) {
  31 + // for (const obj of Object.entries(params)) {
  32 + // // Logger.info(TAG, ` ${obj[0]} => ` + `${obj[1]}`);
  33 + // pubParams[obj[0]] = obj[1]
  34 + // }
  35 + // }
  36 + // sensors.track(eventId, pubParams)
  37 + // })
38 } 38 }
39 } 39 }
40 40