Showing
4 changed files
with
28 additions
and
112 deletions
| @@ -32,9 +32,10 @@ export class SpConstants{ | @@ -32,9 +32,10 @@ export class SpConstants{ | ||
| 32 | static PUBLICVISUTORMODE_INTERESTTAGS = 'PublicVisitorMode_InterestTags' | 32 | static PUBLICVISUTORMODE_INTERESTTAGS = 'PublicVisitorMode_InterestTags' |
| 33 | 33 | ||
| 34 | //定位相关 | 34 | //定位相关 |
| 35 | - static LOCATION_CITY_NAME = "location_city_name" //定位 | ||
| 36 | - static LOCATION_CITY_CODE = "location_city_code" //定位 | 35 | + static LOCATION_CITY_NAME = "location_city_name" //城市名称 |
| 36 | + static LOCATION_CITY_CODE = "location_city_code" //城市code | ||
| 37 | static LOCATION_PROVINCE_CODE = "location_province_code" //定位,省份code | 37 | static LOCATION_PROVINCE_CODE = "location_province_code" //定位,省份code |
| 38 | + static LOCATION_PROVINCE_NAME = "location_province_name" //定位,省份名称 | ||
| 38 | static LOCATION_DISTRICT_CODE = "location_district_code" //定位,区县,返回9位,如:合肥-瑶海区-310115114 | 39 | static LOCATION_DISTRICT_CODE = "location_district_code" //定位,区县,返回9位,如:合肥-瑶海区-310115114 |
| 39 | static LOCATION_PERMISSION_REFUSE = "location_permission_refuse" //定位 | 40 | static LOCATION_PERMISSION_REFUSE = "location_permission_refuse" //定位 |
| 40 | 41 |
| @@ -68,7 +68,7 @@ struct ChannelSubscriptionLayout { | @@ -68,7 +68,7 @@ struct ChannelSubscriptionLayout { | ||
| 68 | 68 | ||
| 69 | let item = this.myChannelList.splice(index, 1)[0] | 69 | let item = this.myChannelList.splice(index, 1)[0] |
| 70 | this.channelIds.splice(index, 1) | 70 | this.channelIds.splice(index, 1) |
| 71 | - AppStorage.setOrCreate('channelIds', JSON.stringify(this.channelIds)) | 71 | + AppStorage.setOrCreate('channelIds', this.channelIds.join(',')) |
| 72 | 72 | ||
| 73 | /* | 73 | /* |
| 74 | 删除的频道信息回到原栏目中去 | 74 | 删除的频道信息回到原栏目中去 |
| @@ -80,7 +80,6 @@ struct ChannelSubscriptionLayout { | @@ -80,7 +80,6 @@ struct ChannelSubscriptionLayout { | ||
| 80 | this.localChannelList.unshift(item) | 80 | this.localChannelList.unshift(item) |
| 81 | } | 81 | } |
| 82 | 82 | ||
| 83 | - | ||
| 84 | // 删除频道的索引值大于 我的栏目中频道最大索引值 | 83 | // 删除频道的索引值大于 我的栏目中频道最大索引值 |
| 85 | if (this.currentTopNavSelectedIndex > this.channelIds.length - 1) { | 84 | if (this.currentTopNavSelectedIndex > this.channelIds.length - 1) { |
| 86 | //使用默认频道 | 85 | //使用默认频道 |
| @@ -131,8 +130,8 @@ struct ChannelSubscriptionLayout { | @@ -131,8 +130,8 @@ struct ChannelSubscriptionLayout { | ||
| 131 | this.myChannelList.push(item) | 130 | this.myChannelList.push(item) |
| 132 | AppStorage.setOrCreate('channelIds', this.channelIds.join(',')) | 131 | AppStorage.setOrCreate('channelIds', this.channelIds.join(',')) |
| 133 | 132 | ||
| 134 | - // let storageChannelIds: string = AppStorage.get<string>('channelIds') || '' | ||
| 135 | - // console.debug('TopNavigationComponent', 'addChannelItem==>' + storageChannelIds) | 133 | + let storageChannelIds: string = AppStorage.get<string>('channelIds') || '' |
| 134 | + console.debug('TopNavigationComponent', 'addChannelItem==>' + storageChannelIds) | ||
| 136 | } | 135 | } |
| 137 | 136 | ||
| 138 | itemMove(index: number, newIndex: number): void { | 137 | itemMove(index: number, newIndex: number): void { |
| @@ -602,7 +601,7 @@ struct ChannelSubscriptionLayout { | @@ -602,7 +601,7 @@ struct ChannelSubscriptionLayout { | ||
| 602 | this.channelIds.push(item.channelId) | 601 | this.channelIds.push(item.channelId) |
| 603 | } | 602 | } |
| 604 | }) | 603 | }) |
| 605 | - // console.debug('TopNavigationComponent', '--changeMyChannelData channelIds--->' + this.channelIds.join(',')) | 604 | + console.debug('TopNavigationComponent', '--changeMyChannelData channelIds--->' + this.channelIds.join(',')) |
| 606 | 605 | ||
| 607 | } | 606 | } |
| 608 | } | 607 | } |
| @@ -65,7 +65,7 @@ export struct TopNavigationComponentNew { | @@ -65,7 +65,7 @@ export struct TopNavigationComponentNew { | ||
| 65 | @State indicatorWidth: number = 0 | 65 | @State indicatorWidth: number = 0 |
| 66 | @State isClickMorningEveningPaper: boolean = false | 66 | @State isClickMorningEveningPaper: boolean = false |
| 67 | // 顶部导航栏是否有临时跳转频道数据不 | 67 | // 顶部导航栏是否有临时跳转频道数据不 |
| 68 | - @State haveTempTabData : boolean = false | 68 | + @State haveTempTabData: boolean = false |
| 69 | 69 | ||
| 70 | build() { | 70 | build() { |
| 71 | Column() { | 71 | Column() { |
| @@ -217,7 +217,7 @@ export struct TopNavigationComponentNew { | @@ -217,7 +217,7 @@ export struct TopNavigationComponentNew { | ||
| 217 | myChannelList: $myChannelList, | 217 | myChannelList: $myChannelList, |
| 218 | moreChannelList: $moreChannelList, | 218 | moreChannelList: $moreChannelList, |
| 219 | localChannelList: $localChannelList, | 219 | localChannelList: $localChannelList, |
| 220 | - haveTempTabData:this.haveTempTabData, | 220 | + haveTempTabData: this.haveTempTabData, |
| 221 | changeTab: (index) => { | 221 | changeTab: (index) => { |
| 222 | this.channelJumpToPage(index) | 222 | this.channelJumpToPage(index) |
| 223 | } | 223 | } |
| @@ -377,7 +377,6 @@ export struct TopNavigationComponentNew { | @@ -377,7 +377,6 @@ export struct TopNavigationComponentNew { | ||
| 377 | this.listScroller.scrollToIndex(index, true, ScrollAlign.CENTER) | 377 | this.listScroller.scrollToIndex(index, true, ScrollAlign.CENTER) |
| 378 | } | 378 | } |
| 379 | 379 | ||
| 380 | - | ||
| 381 | /** | 380 | /** |
| 382 | * 频道是播报 | 381 | * 频道是播报 |
| 383 | * @param item | 382 | * @param item |
| @@ -557,7 +556,6 @@ export struct TopNavigationComponentNew { | @@ -557,7 +556,6 @@ export struct TopNavigationComponentNew { | ||
| 557 | return -1 | 556 | return -1 |
| 558 | } | 557 | } |
| 559 | 558 | ||
| 560 | - | ||
| 561 | /** | 559 | /** |
| 562 | * 新闻,从其他里拿数据 | 560 | * 新闻,从其他里拿数据 |
| 563 | */ | 561 | */ |
| @@ -565,7 +563,7 @@ export struct TopNavigationComponentNew { | @@ -565,7 +563,7 @@ export struct TopNavigationComponentNew { | ||
| 565 | for (let i = 0; i < this.moreChannelList.length; i++) { | 563 | for (let i = 0; i < this.moreChannelList.length; i++) { |
| 566 | let topNavDTO: TopNavDTO = this.moreChannelList[i] | 564 | let topNavDTO: TopNavDTO = this.moreChannelList[i] |
| 567 | if (topNavDTO.channelId?.toString() === channelId) { | 565 | if (topNavDTO.channelId?.toString() === channelId) { |
| 568 | - this.moreChannelList.splice(i,1) | 566 | + this.moreChannelList.splice(i, 1) |
| 569 | this.haveTempTabData = true | 567 | this.haveTempTabData = true |
| 570 | return topNavDTO | 568 | return topNavDTO |
| 571 | } | 569 | } |
| @@ -573,7 +571,7 @@ export struct TopNavigationComponentNew { | @@ -573,7 +571,7 @@ export struct TopNavigationComponentNew { | ||
| 573 | for (let j = 0; j < this.localChannelList.length; j++) { | 571 | for (let j = 0; j < this.localChannelList.length; j++) { |
| 574 | let topNavDTO: TopNavDTO = this.localChannelList[j] | 572 | let topNavDTO: TopNavDTO = this.localChannelList[j] |
| 575 | if (topNavDTO.channelId?.toString() === channelId) { | 573 | if (topNavDTO.channelId?.toString() === channelId) { |
| 576 | - this.localChannelList.splice(j,1) | 574 | + this.localChannelList.splice(j, 1) |
| 577 | this.haveTempTabData = true | 575 | this.haveTempTabData = true |
| 578 | return topNavDTO | 576 | return topNavDTO |
| 579 | } | 577 | } |
| @@ -626,130 +624,47 @@ export struct TopNavigationComponentNew { | @@ -626,130 +624,47 @@ export struct TopNavigationComponentNew { | ||
| 626 | //请求顶导数据 | 624 | //请求顶导数据 |
| 627 | async getTopNavList(id: number) { | 625 | async getTopNavList(id: number) { |
| 628 | 626 | ||
| 629 | - Logger.debug(TAG, 'getTopNavList==>' + this.storageChannelIds) | 627 | + Logger.debug(TAG, 'getTopNavList=存储=>' + this.storageChannelIds) |
| 630 | 628 | ||
| 631 | let bottomNavDetail = await ChannelViewModel.getBottomNavDetailData(id, this.storageChannelIds) | 629 | let bottomNavDetail = await ChannelViewModel.getBottomNavDetailData(id, this.storageChannelIds) |
| 632 | let topNavList = bottomNavDetail?.topNavChannelList || [] | 630 | let topNavList = bottomNavDetail?.topNavChannelList || [] |
| 633 | 631 | ||
| 634 | - let cityName = SPHelper.default.getSync(SpConstants.LOCATION_CITY_NAME, '') as string | 632 | + //let provinceName = SPHelper.default.getSync(SpConstants.LOCATION_PROVINCE_NAME, '') as string |
| 635 | let _myChannelList: TopNavDTO [] = [] | 633 | let _myChannelList: TopNavDTO [] = [] |
| 636 | - let _storageChannelIds: string [] = [] //list1 | ||
| 637 | - let defaultMyChannelList: TopNavDTO[] = [] | ||
| 638 | - let defaultList = [...topNavList] | ||
| 639 | - | ||
| 640 | - Logger.debug(TAG, 'cityName=>' + cityName) | ||
| 641 | - // 排序 | ||
| 642 | - defaultList.sort((a, b) => { | ||
| 643 | - return a.num - b.num; | ||
| 644 | - }); | ||
| 645 | - | ||
| 646 | - //defaultMyChannelList | ||
| 647 | - defaultList.forEach(item => { | ||
| 648 | - if (item.defaultPermitted === 1 || item.movePermitted === 0 || item.delPermitted === 0 || | ||
| 649 | - item.headlinesOn === 1) { | ||
| 650 | - defaultMyChannelList.push(item); | ||
| 651 | - } | ||
| 652 | - if (item.defaultPermitted === 1) { | ||
| 653 | - this.homeChannelList.push(item) | ||
| 654 | - } | ||
| 655 | - }) | ||
| 656 | 634 | ||
| 657 | - //有缓存频道id | ||
| 658 | - if (this.storageChannelIds) { | ||
| 659 | - _storageChannelIds = this.storageChannelIds.split(',') | ||
| 660 | - | ||
| 661 | - } | ||
| 662 | - | ||
| 663 | - defaultMyChannelList.forEach(item => { | ||
| 664 | - item.myChannel = '1' | 635 | + topNavList.forEach(item => { |
| 665 | if (item.defaultPermitted === 1) { | 636 | if (item.defaultPermitted === 1) { |
| 666 | - item.homeChannel = '1' | ||
| 667 | - } | ||
| 668 | - let index = defaultList.findIndex(_item => _item.channelId === item.channelId) | ||
| 669 | - if (index !== -1) { | ||
| 670 | - defaultList.splice(index, 1) | 637 | + console.debug('TopNavigationComponent', '--homeChannelList--->' + item.name) |
| 638 | + this.homeChannelList.push(item) | ||
| 671 | } | 639 | } |
| 672 | - }) | ||
| 673 | - defaultList.unshift(...defaultMyChannelList) | ||
| 674 | 640 | ||
| 675 | - defaultList.forEach((item, index) => { | ||
| 676 | - if (item.channelType === 2) { | ||
| 677 | - if (cityName.includes(item.name)) { | ||
| 678 | - item.myChannel = '1' | ||
| 679 | - } | ||
| 680 | - item.localChannel = '1' | ||
| 681 | - } | ||
| 682 | - if (index >= 11) { | ||
| 683 | - if (item.channelType === 1) { | ||
| 684 | - item.moreChannel = '1' | ||
| 685 | - } | ||
| 686 | - } else { | ||
| 687 | - if (item.channelType === 1 && item.myChannel !== '1') { | ||
| 688 | - item.moreChannel = '1' | ||
| 689 | - } | ||
| 690 | - } | ||
| 691 | - if (this.storageChannelIds && _storageChannelIds.includes(String(item.channelId))) { | ||
| 692 | - item.myChannel = '1' | ||
| 693 | - } | ||
| 694 | - //频道分类 | ||
| 695 | //TODO 暂时隐藏播报 | 641 | //TODO 暂时隐藏播报 |
| 696 | if (item.name !== '播报') { | 642 | if (item.name !== '播报') { |
| 697 | if (item.myChannel === '1') { | 643 | if (item.myChannel === '1') { |
| 698 | _myChannelList.push(item) | 644 | _myChannelList.push(item) |
| 699 | - } | ||
| 700 | - if (item.moreChannel === '1' && item.myChannel !== '1') { | 645 | + } else if (item.moreChannel === '1' && item.myChannel !== '1') { |
| 701 | this.moreChannelList.push(item) | 646 | this.moreChannelList.push(item) |
| 702 | - } | ||
| 703 | - if (item.localChannel === '1' && item.myChannel !== '1') { | 647 | + } else if (item.localChannel === '1' && item.myChannel !== '1') { |
| 704 | this.localChannelList.push(item) | 648 | this.localChannelList.push(item) |
| 705 | } | 649 | } |
| 706 | } | 650 | } |
| 707 | }) | 651 | }) |
| 708 | 652 | ||
| 709 | - //根据缓存数组排序 | ||
| 710 | - if (this.storageChannelIds) { | ||
| 711 | - | ||
| 712 | - // let sortedyChannelList: TopNavDTO [] = [] | ||
| 713 | - // | ||
| 714 | - // _storageChannelIds.forEach((channelId) => { | ||
| 715 | - // console.debug(TAG, 'getTopNavList=0=>' + channelId) | ||
| 716 | - // for (let a of _myChannelList) { | ||
| 717 | - // | ||
| 718 | - // console.debug(TAG, | ||
| 719 | - // 'getTopNavList=1=>' + channelId + ' ' + a.channelId + ' ' + (channelId == String(a.channelId))) | ||
| 720 | - // if (channelId == String(a.channelId)) { | ||
| 721 | - // sortedyChannelList.push(a) | ||
| 722 | - // break; | ||
| 723 | - // } | ||
| 724 | - // } | ||
| 725 | - // | ||
| 726 | - // }) | ||
| 727 | - | ||
| 728 | - let sortedyChannelList = _myChannelList.sort((item1, item2) => { | ||
| 729 | - let index1 = this.storageChannelIds.indexOf(String(item1.channelId)); | ||
| 730 | - let index2 = this.storageChannelIds.indexOf(String(item2.channelId)); | ||
| 731 | - return index1 - index2; | ||
| 732 | - }); | ||
| 733 | - _myChannelList = sortedyChannelList | ||
| 734 | - } | ||
| 735 | - | ||
| 736 | - Logger.debug(TAG,'cityName===>'+cityName) | ||
| 737 | - // if (cityName) { | ||
| 738 | - // let index = _myChannelList.findIndex(ele => cityName.includes(ele.name)) | ||
| 739 | - // Logger.debug(TAG,'index===>'+index) | ||
| 740 | - // const localChannelitem = _myChannelList.splice(index, 1)[0]; | ||
| 741 | - // // 将当前地区频道插入到第四个 | ||
| 742 | - // _myChannelList.splice(3, 0, localChannelitem); | ||
| 743 | - // //_myChannelList[3] = localChannelitem | ||
| 744 | - // } | ||
| 745 | - | ||
| 746 | this.myChannelList = _myChannelList | 653 | this.myChannelList = _myChannelList |
| 747 | 654 | ||
| 748 | - | ||
| 749 | //缓存首页频道 | 655 | //缓存首页频道 |
| 750 | let index = this.myChannelList.findIndex(_item => _item?.channelId === this.indexSettingChannelId) | 656 | let index = this.myChannelList.findIndex(_item => _item?.channelId === this.indexSettingChannelId) |
| 751 | if (index > -1) { | 657 | if (index > -1) { |
| 752 | this.currentTopNavSelectedIndex = index | 658 | this.currentTopNavSelectedIndex = index |
| 753 | } | 659 | } |
| 660 | + | ||
| 661 | + // 存储我的频道栏目中的频道id信息 | ||
| 662 | + let channelIds: number [] = [] | ||
| 663 | + this.myChannelList.forEach(item => { | ||
| 664 | + if (item != undefined && item.channelId != undefined) { | ||
| 665 | + channelIds.push(item.channelId) | ||
| 666 | + } | ||
| 667 | + }) | ||
| 668 | + AppStorage.setOrCreate('channelIds', channelIds.join(',')) | ||
| 754 | } | 669 | } |
| 755 | } | 670 | } |
| @@ -117,6 +117,7 @@ export class HWLocationUtils { | @@ -117,6 +117,7 @@ export class HWLocationUtils { | ||
| 117 | let code: string[] = await HWLocationUtils.getCityCode(data[0].administrativeArea, data[0].subAdministrativeArea) | 117 | let code: string[] = await HWLocationUtils.getCityCode(data[0].administrativeArea, data[0].subAdministrativeArea) |
| 118 | if (code && code.length >= 2) { | 118 | if (code && code.length >= 2) { |
| 119 | SPHelper.default.save(SpConstants.LOCATION_CITY_NAME, cityName) | 119 | SPHelper.default.save(SpConstants.LOCATION_CITY_NAME, cityName) |
| 120 | + SPHelper.default.save(SpConstants.LOCATION_PROVINCE_NAME, data[0].administrativeArea) | ||
| 120 | SPHelper.default.save(SpConstants.LOCATION_PROVINCE_CODE, code[0]) | 121 | SPHelper.default.save(SpConstants.LOCATION_PROVINCE_CODE, code[0]) |
| 121 | SPHelper.default.save(SpConstants.LOCATION_CITY_CODE, code[1]) | 122 | SPHelper.default.save(SpConstants.LOCATION_CITY_CODE, code[1]) |
| 122 | } | 123 | } |
-
Please register or login to post a comment