liyubing

feat:

1)编辑我的频道- 频道编辑页面,第一次无地理信息,第二次有地理信息和我频道id字符串
... ... @@ -32,9 +32,10 @@ export class SpConstants{
static PUBLICVISUTORMODE_INTERESTTAGS = 'PublicVisitorMode_InterestTags'
//定位相关
static LOCATION_CITY_NAME = "location_city_name" //定位
static LOCATION_CITY_CODE = "location_city_code" //定位
static LOCATION_CITY_NAME = "location_city_name" //城市名称
static LOCATION_CITY_CODE = "location_city_code" //城市code
static LOCATION_PROVINCE_CODE = "location_province_code" //定位,省份code
static LOCATION_PROVINCE_NAME = "location_province_name" //定位,省份名称
static LOCATION_DISTRICT_CODE = "location_district_code" //定位,区县,返回9位,如:合肥-瑶海区-310115114
static LOCATION_PERMISSION_REFUSE = "location_permission_refuse" //定位
... ...
... ... @@ -68,7 +68,7 @@ struct ChannelSubscriptionLayout {
let item = this.myChannelList.splice(index, 1)[0]
this.channelIds.splice(index, 1)
AppStorage.setOrCreate('channelIds', JSON.stringify(this.channelIds))
AppStorage.setOrCreate('channelIds', this.channelIds.join(','))
/*
删除的频道信息回到原栏目中去
... ... @@ -80,7 +80,6 @@ struct ChannelSubscriptionLayout {
this.localChannelList.unshift(item)
}
// 删除频道的索引值大于 我的栏目中频道最大索引值
if (this.currentTopNavSelectedIndex > this.channelIds.length - 1) {
//使用默认频道
... ... @@ -131,8 +130,8 @@ struct ChannelSubscriptionLayout {
this.myChannelList.push(item)
AppStorage.setOrCreate('channelIds', this.channelIds.join(','))
// let storageChannelIds: string = AppStorage.get<string>('channelIds') || ''
// console.debug('TopNavigationComponent', 'addChannelItem==>' + storageChannelIds)
let storageChannelIds: string = AppStorage.get<string>('channelIds') || ''
console.debug('TopNavigationComponent', 'addChannelItem==>' + storageChannelIds)
}
itemMove(index: number, newIndex: number): void {
... ... @@ -602,7 +601,7 @@ struct ChannelSubscriptionLayout {
this.channelIds.push(item.channelId)
}
})
// console.debug('TopNavigationComponent', '--changeMyChannelData channelIds--->' + this.channelIds.join(','))
console.debug('TopNavigationComponent', '--changeMyChannelData channelIds--->' + this.channelIds.join(','))
}
}
... ...
... ... @@ -64,8 +64,8 @@ export struct TopNavigationComponentNew {
@State indicatorLeftMargin: number = 0
@State indicatorWidth: number = 0
@State isClickMorningEveningPaper: boolean = false
// 顶部导航栏是否有临时跳转频道数据不
@State haveTempTabData : boolean = false
// 顶部导航栏是否有临时跳转频道数据不
@State haveTempTabData: boolean = false
build() {
Column() {
... ... @@ -217,7 +217,7 @@ export struct TopNavigationComponentNew {
myChannelList: $myChannelList,
moreChannelList: $moreChannelList,
localChannelList: $localChannelList,
haveTempTabData:this.haveTempTabData,
haveTempTabData: this.haveTempTabData,
changeTab: (index) => {
this.channelJumpToPage(index)
}
... ... @@ -377,7 +377,6 @@ export struct TopNavigationComponentNew {
this.listScroller.scrollToIndex(index, true, ScrollAlign.CENTER)
}
/**
* 频道是播报
* @param item
... ... @@ -557,7 +556,6 @@ export struct TopNavigationComponentNew {
return -1
}
/**
* 新闻,从其他里拿数据
*/
... ... @@ -565,7 +563,7 @@ export struct TopNavigationComponentNew {
for (let i = 0; i < this.moreChannelList.length; i++) {
let topNavDTO: TopNavDTO = this.moreChannelList[i]
if (topNavDTO.channelId?.toString() === channelId) {
this.moreChannelList.splice(i,1)
this.moreChannelList.splice(i, 1)
this.haveTempTabData = true
return topNavDTO
}
... ... @@ -573,7 +571,7 @@ export struct TopNavigationComponentNew {
for (let j = 0; j < this.localChannelList.length; j++) {
let topNavDTO: TopNavDTO = this.localChannelList[j]
if (topNavDTO.channelId?.toString() === channelId) {
this.localChannelList.splice(j,1)
this.localChannelList.splice(j, 1)
this.haveTempTabData = true
return topNavDTO
}
... ... @@ -626,130 +624,47 @@ export struct TopNavigationComponentNew {
//请求顶导数据
async getTopNavList(id: number) {
Logger.debug(TAG, 'getTopNavList==>' + this.storageChannelIds)
Logger.debug(TAG, 'getTopNavList=存储=>' + this.storageChannelIds)
let bottomNavDetail = await ChannelViewModel.getBottomNavDetailData(id, this.storageChannelIds)
let topNavList = bottomNavDetail?.topNavChannelList || []
let cityName = SPHelper.default.getSync(SpConstants.LOCATION_CITY_NAME, '') as string
//let provinceName = SPHelper.default.getSync(SpConstants.LOCATION_PROVINCE_NAME, '') as string
let _myChannelList: TopNavDTO [] = []
let _storageChannelIds: string [] = [] //list1
let defaultMyChannelList: TopNavDTO[] = []
let defaultList = [...topNavList]
Logger.debug(TAG, 'cityName=>' + cityName)
// 排序
defaultList.sort((a, b) => {
return a.num - b.num;
});
//defaultMyChannelList
defaultList.forEach(item => {
if (item.defaultPermitted === 1 || item.movePermitted === 0 || item.delPermitted === 0 ||
item.headlinesOn === 1) {
defaultMyChannelList.push(item);
}
if (item.defaultPermitted === 1) {
this.homeChannelList.push(item)
}
})
//有缓存频道id
if (this.storageChannelIds) {
_storageChannelIds = this.storageChannelIds.split(',')
}
defaultMyChannelList.forEach(item => {
item.myChannel = '1'
topNavList.forEach(item => {
if (item.defaultPermitted === 1) {
item.homeChannel = '1'
}
let index = defaultList.findIndex(_item => _item.channelId === item.channelId)
if (index !== -1) {
defaultList.splice(index, 1)
console.debug('TopNavigationComponent', '--homeChannelList--->' + item.name)
this.homeChannelList.push(item)
}
})
defaultList.unshift(...defaultMyChannelList)
defaultList.forEach((item, index) => {
if (item.channelType === 2) {
if (cityName.includes(item.name)) {
item.myChannel = '1'
}
item.localChannel = '1'
}
if (index >= 11) {
if (item.channelType === 1) {
item.moreChannel = '1'
}
} else {
if (item.channelType === 1 && item.myChannel !== '1') {
item.moreChannel = '1'
}
}
if (this.storageChannelIds && _storageChannelIds.includes(String(item.channelId))) {
item.myChannel = '1'
}
//频道分类
//TODO 暂时隐藏播报
if (item.name !== '播报') {
if (item.myChannel === '1') {
_myChannelList.push(item)
}
if (item.moreChannel === '1' && item.myChannel !== '1') {
} else if (item.moreChannel === '1' && item.myChannel !== '1') {
this.moreChannelList.push(item)
}
if (item.localChannel === '1' && item.myChannel !== '1') {
} else if (item.localChannel === '1' && item.myChannel !== '1') {
this.localChannelList.push(item)
}
}
})
//根据缓存数组排序
if (this.storageChannelIds) {
// let sortedyChannelList: TopNavDTO [] = []
//
// _storageChannelIds.forEach((channelId) => {
// console.debug(TAG, 'getTopNavList=0=>' + channelId)
// for (let a of _myChannelList) {
//
// console.debug(TAG,
// 'getTopNavList=1=>' + channelId + ' ' + a.channelId + ' ' + (channelId == String(a.channelId)))
// if (channelId == String(a.channelId)) {
// sortedyChannelList.push(a)
// break;
// }
// }
//
// })
let sortedyChannelList = _myChannelList.sort((item1, item2) => {
let index1 = this.storageChannelIds.indexOf(String(item1.channelId));
let index2 = this.storageChannelIds.indexOf(String(item2.channelId));
return index1 - index2;
});
_myChannelList = sortedyChannelList
}
Logger.debug(TAG,'cityName===>'+cityName)
// if (cityName) {
// let index = _myChannelList.findIndex(ele => cityName.includes(ele.name))
// Logger.debug(TAG,'index===>'+index)
// const localChannelitem = _myChannelList.splice(index, 1)[0];
// // 将当前地区频道插入到第四个
// _myChannelList.splice(3, 0, localChannelitem);
// //_myChannelList[3] = localChannelitem
// }
this.myChannelList = _myChannelList
//缓存首页频道
let index = this.myChannelList.findIndex(_item => _item?.channelId === this.indexSettingChannelId)
if (index > -1) {
this.currentTopNavSelectedIndex = index
}
// 存储我的频道栏目中的频道id信息
let channelIds: number [] = []
this.myChannelList.forEach(item => {
if (item != undefined && item.channelId != undefined) {
channelIds.push(item.channelId)
}
})
AppStorage.setOrCreate('channelIds', channelIds.join(','))
}
}
\ No newline at end of file
... ...
... ... @@ -117,6 +117,7 @@ export class HWLocationUtils {
let code: string[] = await HWLocationUtils.getCityCode(data[0].administrativeArea, data[0].subAdministrativeArea)
if (code && code.length >= 2) {
SPHelper.default.save(SpConstants.LOCATION_CITY_NAME, cityName)
SPHelper.default.save(SpConstants.LOCATION_PROVINCE_NAME, data[0].administrativeArea)
SPHelper.default.save(SpConstants.LOCATION_PROVINCE_CODE, code[0])
SPHelper.default.save(SpConstants.LOCATION_CITY_CODE, code[1])
}
... ...