Toggle navigation
Toggle navigation
This project
Loading...
Sign in
developOne
/
harmonyPool
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
yuzhilin
2024-05-09 14:04:46 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
db0538095aa4eeb428cc7c26d15cb6d6cd8eab39
db053809
1 parent
fa2cc06e
fix:17016 功能缺陷--开机启动设置定位后,第四个频道预期是上海,实际没有展示上海tab,看图
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
100 additions
and
32 deletions
sight_harmony/features/wdComponent/src/main/ets/components/page/BottomNavigationComponent.ets
sight_harmony/features/wdComponent/src/main/ets/components/page/TopNavigationComponent.ets
sight_harmony/features/wdComponent/src/main/ets/repository/PageRepository.ets
sight_harmony/features/wdComponent/src/main/ets/viewmodel/PageViewModel.ets
sight_harmony/features/wdComponent/src/main/ets/components/page/BottomNavigationComponent.ets
View file @
db05380
...
...
@@ -29,6 +29,7 @@ export struct BottomNavigationComponent {
@State topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0
@State @Watch('onBottomNavigationDataUpdated') bottomNavList: BottomNavDTO[] = [] // 底导/顶导全部数据
@State currentNavIndex: number = BottomNavi.NEWS; // 底导当前选中/焦点下标
@State topNavList: TopNavDTO[] = []
// 底导TabsController
private navController: TabsController = new TabsController();
readonly ASPECT_RATIO_1_1: number = 1 / 1; // 底导图片宽高比
...
...
@@ -54,6 +55,7 @@ export struct BottomNavigationComponent {
bottomNav.bottomNavList = bottomNav.bottomNavList.filter(item => item.name !== '服务');
this.bottomNavList = bottomNav.bottomNavList
}
this.getTopNavList(this.bottomNavList[0]?.id)
HomeChannelUtils.setBottomNavData(bottomNav)
EmitterUtils.receiveEvent(EmitterEventId.JUMP_HOME_CHANNEL, (str?: string) => {
...
...
@@ -127,35 +129,39 @@ export struct BottomNavigationComponent {
.height($r('app.float.bottom_navigation_barHeight'))
.hoverEffect(HoverEffect.Highlight)
.onClick(() => {
if (navItem.name === '我的') {
this.barBackgroundColor = Color.White
this.currentBottomNavInfo = {} as BottomNavDTO
} else {
if (this.currentNavIndex === index) {
// 当前tab,单击事件
this.autoRefresh++
} else {
// 切换tab
this.currentBottomNavInfo = navItem
}
}
this.currentNavIndex = index;
Logger.info(TAG, `onChange, index: ${index}`);
this.onBottomNavigationIndexChange(navItem,index)
})
}
// 底导切换函数
onBottomNavigationIndexChange(
) {
async onBottomNavigationIndexChange(navItem:BottomNavDTO,index:number
) {
Logger.info(TAG, `onBottomNavigationIndexChange this.currentNavIndex: ${this.currentNavIndex}`);
if (navItem.name === '我的') {
this.barBackgroundColor = Color.White
this.currentBottomNavInfo = {} as BottomNavDTO
} else {
if (this.currentNavIndex === index) {
// 当前tab,单击事件
this.autoRefresh++
} else {
// 切换tab
this.currentBottomNavInfo = navItem
}
}
this.currentNavIndex = index;
// 请求顶导数据(参数):
}
//请求顶导数据
async getTopNavList(id:number){
let bottomNavDetail = await PageViewModel.getBottomNavDetailData(id)
this.topNavList = bottomNavDetail?.topNavChannelList || []
}
onBottomNavigationDataUpdated() {
// Logger.info(TAG, `onBottomNavigationDataUpdated currentNavIndex: ${this.currentNavIndex},length:${this.bottomNavItemList.length}`);
this.onBottomNavigationIndexChange()
}
/**
...
...
sight_harmony/features/wdComponent/src/main/ets/components/page/TopNavigationComponent.ets
View file @
db05380
import { BottomNavDTO, CompDTO, TopNavDTO } from 'wdBean';
import { LazyDataSource, Logger } from 'wdKit';
import { LazyDataSource, Logger,SPHelper } from 'wdKit';
import { SpConstants } from 'wdConstant';
import { ProcessUtils } from 'wdRouter';
import { PageComponent } from './PageComponent';
import { ChannelSubscriptionLayout } from './ChannelSubscriptionLayout';
...
...
@@ -66,7 +67,6 @@ export struct TopNavigationComponent {
private tabsWidth: number = 0
//定时器延时处理切换至版面、播报tab时 返回上一个tab
@State tabTimmer: number = 0
topOrBottomNavChange() {
if (this.currentBottomNavName === this.currentBottomNavInfo?.name) {
this.setBarBackgroundColor()
...
...
@@ -84,6 +84,8 @@ export struct TopNavigationComponent {
//处理新闻tab顶导频道数据
topNavListHandle() {
let cityName = SPHelper.default.getSync(SpConstants.LOCATION_CITY_NAME, '') as string
let _channelIds: number [] = []
let _myChannelList: TopNavDTO [] = []
let _storageChannelIds: string [] = [] //list1
...
...
@@ -126,6 +128,9 @@ export struct TopNavigationComponent {
item.myChannel = '1'
}
if (item.channelType === 2) {
if(cityName.includes(item.name)){
item.myChannel = '1'
}
item.localChannel = '1'
}
if (index >= 11) {
...
...
@@ -145,13 +150,20 @@ export struct TopNavigationComponent {
_channelIds.push(item.channelId)
} else if (item.moreChannel === '1') {
this.moreChannelList.push(item)
} else if (item.localChannel === '1') {
} else if (item.localChannel === '1'
&& item.myChannel !== '1'
) {
this.localChannelList.push(item)
}
}
})
if(cityName){
let index = _myChannelList.findIndex(ele=> cityName.includes(ele.name))
const localChannelitem = _myChannelList.splice(index, 1)[0];
// 将当前地区频道插入到第四个
_myChannelList.splice(3, 0, localChannelitem);
}
this.channelIds = _channelIds
this.myChannelList = _myChannelList
...
...
sight_harmony/features/wdComponent/src/main/ets/repository/PageRepository.ets
View file @
db05380
...
...
@@ -11,6 +11,7 @@ import {
LiveReviewDTO,
MorningEveningPaperDTO,
NavigationBodyDTO,
NavigationDetailDTO,
NewspaperListBean,
NewspaperTimeInfoBean,
PageDTO,
...
...
@@ -30,10 +31,17 @@ const TAG = 'HttpRequest';
export class PageRepository {
static getBottomNavGroupUrl() {
//http://192.168.1.3:3300/project/3802/interface/api/189229
// https: //pd-apis-uat.pdnews.cn/api/rmrb-bff-display-zh/display/zh/c/bottomNavGroup
return HttpUrlUtils.getHost() + HttpUrlUtils.BOTTOM_NAV_PATH;
}
static getBottomNavGroupDetailUrl() {
// http://192.168.1.3:3300/project/3802/interface/api/189231
// https: //pd-apis-uat.pdnews.cn/api/rmrb-bff-display-zh/display/zh/c/bottomNavGroup/detail
return HttpUrlUtils.getHost() + HttpUrlUtils.BOTTOM_NAV_DETAIL_PATH;
}
static getPageInfoUrl(pageId: string) {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.PAGE_INFO_PATH + "?pageId=" + pageId;
// Logger.info(TAG, "getPageInfoUrl url = " + url)
...
...
@@ -105,7 +113,9 @@ export class PageRepository {
}
static getLiveMoreUrl(type: number, pageNum: number = 1, pageSize: number = 20) {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.LIVE_MORE_PATH + "?type=" + type + "&pageNum=" + pageNum + "&pageSize=" + pageSize;
let url =
HttpUrlUtils.getHost() + HttpUrlUtils.LIVE_MORE_PATH + "?type=" + type + "&pageNum=" + pageNum + "&pageSize=" +
pageSize;
Logger.info(TAG, "getLiveMoreUrl url = " + url)
return url;
}
...
...
@@ -120,11 +130,11 @@ export class PageRepository {
return url;
}
static getInteractDataV2Url(contentId: string, contentType: string, contentRelId: string,
rmhPlatform:
number) {
static getInteractDataV2Url(contentId: string, contentType: string, contentRelId: string,
rmhPlatform:
number) {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_V2_DATA_PATH;
url = url + "?contentId=" + contentId
+ "&contentType=" + contentType
if
(!StringUtils.isEmpty(contentRelId))
{
if
(!StringUtils.isEmpty(contentRelId))
{
url = url + "&contentRelId=" + contentRelId;
}
url = url + "&rmhPlatform=" + rmhPlatform;
...
...
@@ -199,7 +209,8 @@ export class PageRepository {
* channelStrategy:频道策略
* topicId:专题id
* */
static getMorningEveningCompInfoUrl(pageId: number, groupId: number, refreshTime: string, topicId: string, pageNum: number, pageSize: number) {
static getMorningEveningCompInfoUrl(pageId: number, groupId: number, refreshTime: string, topicId: string,
pageNum: number, pageSize: number) {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.COMP_PATH;
url = url + "?loadStrategy=first_load&pageNum=" + pageNum + "&refreshTime=" + refreshTime + "&pageId="
+ pageId + "&channelStrategy=2&groupId=" + groupId + "&topicId=" + topicId + "&pageSize=" + pageSize;
...
...
@@ -212,6 +223,11 @@ export class PageRepository {
return WDHttp.get<ResponseDTO<NavigationBodyDTO>>(url)
};
static fetchNavigationDetailDataApi(id:number = 210) {
let url = PageRepository.getBottomNavGroupDetailUrl() + `?id=${id}`;
return WDHttp.get<ResponseDTO<NavigationDetailDTO>>(url)
};
/**
* 获取早晚报数据
* @param pageId
...
...
@@ -251,8 +267,8 @@ export class PageRepository {
return WDHttp.get<ResponseDTO<ContentDetailDTO[]>>(url)
};
static fetchInteractDataV2(contentId: string, contentType: string, contentRelId: string,rmhPlatform:number) {
let url = PageRepository.getInteractDataV2Url(contentId, contentType, contentRelId,rmhPlatform)
static fetchInteractDataV2(contentId: string, contentType: string, contentRelId: string, rmhPlatform: number) {
let url = PageRepository.getInteractDataV2Url(contentId, contentType, contentRelId, rmhPlatform)
return WDHttp.get<ResponseDTO<InteractDataDTO>>(url)
};
...
...
@@ -318,6 +334,7 @@ export class PageRepository {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_ACCENTION_OPERATION
return WDHttp.post(url, params)
}
/**
* 关注号主
*/
...
...
@@ -335,7 +352,8 @@ export class PageRepository {
success(resDTO);
})
.catch((err: Error) => {
Logger.error(TAG, `postInteractAccentionOperate catch, error.name : ${err.name}, error.message:${err.message}`);
Logger.error(TAG,
`postInteractAccentionOperate catch, error.name : ${err.name}, error.message:${err.message}`);
error(err);
})
})
...
...
@@ -362,7 +380,8 @@ export class PageRepository {
/**
* 获取早晚报compInfo
* */
static fetchMorningEveningCompInfo(pageId: number, groupId: number, refreshTime: string, topicId: string, pageNum: number, pageSize: number) {
static fetchMorningEveningCompInfo(pageId: number, groupId: number, refreshTime: string, topicId: string,
pageNum: number, pageSize: number) {
let url = PageRepository.getMorningEveningCompInfoUrl(pageId, groupId, refreshTime, topicId, pageNum, pageSize)
return WDHttp.get<ResponseDTO<CompInfoBean>>(url)
};
...
...
@@ -392,7 +411,8 @@ export class PageRepository {
static fetchBroadcastCompInfo(pageId: number, groupId: number, refreshTime: string, topicId:
string, channelId: string) {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.COMP_PATH;
url = `${url}?topicId=${topicId}&channelStrategy=2&groupId=${groupId}&refreshTime=${refreshTime}&pageSize=50&recommend=0&pageId=${pageId}&loadStrategy=first_load&pageNum=1&channelId=${channelId}`
url =
`${url}?topicId=${topicId}&channelStrategy=2&groupId=${groupId}&refreshTime=${refreshTime}&pageSize=50&recommend=0&pageId=${pageId}&loadStrategy=first_load&pageNum=1&channelId=${channelId}`
Logger.info(TAG, "getMorningEveningCompInfoUrl url = " + url)
return WDHttp.get<ResponseDTO<CompInfoBean>>(url)
};
...
...
@@ -408,8 +428,8 @@ export class PageRepository {
/**
* 获取更多直播/预约
* */
static fetchLiveMoreUrl(type: number,pageNum: number, pageSize: number) {
let url = PageRepository.getLiveMoreUrl(type,pageNum, pageSize)
static fetchLiveMoreUrl(type: number, pageNum: number, pageSize: number) {
let url = PageRepository.getLiveMoreUrl(type, pageNum, pageSize)
return WDHttp.get<ResponseDTO<LiveReviewDTO>>(url)
};
...
...
sight_harmony/features/wdComponent/src/main/ets/viewmodel/PageViewModel.ets
View file @
db05380
...
...
@@ -9,7 +9,8 @@ import {
PageDTO,
PageInfoBean,
PageInfoDTO,
GoldenPositionExtraBean
GoldenPositionExtraBean,
NavigationDetailDTO
} from 'wdBean';
import { CollectionUtils, Logger, ResourcesUtils, StringUtils } from 'wdKit';
...
...
@@ -46,6 +47,11 @@ export class PageViewModel extends BaseViewModel {
return this.getNavData();
}
async getBottomNavDetailData(id:number): Promise<NavigationDetailDTO> {
Logger.info(TAG, `getBottomNavDetailData start`);
return this.getNavDetailData(id);
}
async getBottomNavDataMock(context: Context): Promise<NavigationBodyDTO> {
Logger.info(TAG, `getBottomNavDataMock start`);
let compRes: ResponseDTO<NavigationBodyDTO> | null = await ResourcesUtils.getResourcesJson<ResponseDTO<NavigationBodyDTO>>(context, 'bottom_nav.json');
...
...
@@ -81,6 +87,30 @@ export class PageViewModel extends BaseViewModel {
})
}
private getNavDetailData(id:number): Promise<NavigationDetailDTO> {
return new Promise<NavigationDetailDTO>((success, error) => {
Logger.info(TAG, `getNavData start`);
PageRepository.fetchNavigationDetailDataApi(id).then((navResDTO: ResponseDTO<NavigationDetailDTO>) => {
if (!navResDTO || !navResDTO.data) {
Logger.error(TAG, 'getNavData then navResDTO is empty');
error('navResDTO is empty');
return
}
if (navResDTO.code != 0) {
Logger.error(TAG, `getNavData then code:${navResDTO.code}, message:${navResDTO.message}`);
error('navResDTO Response Code is failure');
return
}
// let navResStr = JSON.stringify(navResDTO);
Logger.info(TAG, "getNavData then,navResDTO.timestamp:" + navResDTO.timestamp);
success(navResDTO.data);
}).catch((err: Error) => {
Logger.error(TAG, `fetchNavigationDataApi catch, error.name : ${err.name}, error.message:${err.message}`);
error(err);
})
})
}
/**
* Get PageDTO data.
*
...
...
Please
register
or
login
to post a comment