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
zhenghy
2024-04-16 16:38:31 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
703a4d09eb8a881aee410307738020df11441164
703a4d09
1 parent
8d3ec253
视频频道入口修改与接口调用
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
300 additions
and
123 deletions
sight_harmony/commons/wdKit/src/main/ets/utils/WindowModel.ets
sight_harmony/commons/wdNetwork/src/main/ets/http/HttpUrlUtils.ets
sight_harmony/features/wdComponent/src/main/ets/components/page/BottomNavigationComponent.ets
sight_harmony/features/wdComponent/src/main/ets/components/page/PageComponent.ets
sight_harmony/features/wdComponent/src/main/ets/components/page/TopNavigationComponent.ets
sight_harmony/features/wdDetailPlayApi/src/main/ets/request/ContentDetailRequest.ets
sight_harmony/features/wdDetailPlayShortVideo/src/main/ets/pages/VideoChannelDetail.ets
sight_harmony/features/wdDetailPlayShortVideo/src/main/ets/view/PlayerTitleComment.ets
sight_harmony/features/wdPlayer/src/main/ets/controller/WDPlayerController.ets
sight_harmony/commons/wdKit/src/main/ets/utils/WindowModel.ets
View file @
703a4d0
import window from '@ohos.window';
import { BusinessError } from '@ohos.base';
import {
AsyncCallback,
BusinessError } from '@ohos.base';
import deviceInfo from '@ohos.deviceInfo'
import display from '@ohos.display';
interface SystemBarProperties {
statusBarColor?: string;
isStatusBarLightIcon?: boolean;
statusBarContentColor?: string;
navigationBarColor?: string;
isNavigationBarLightIcon?: boolean;
navigationBarContentColor?: string;
}
export class Size {
width: number = 0
height: number = 0
...
...
@@ -15,17 +25,23 @@ export class Size {
export class WindowModel {
private windowStage?: window.WindowStage;
private windowClass?: window.Window;
static shared: WindowModel = new WindowModel()
static TAG = "WindowModel";
setWindowStage(windowStage: window.WindowStage) {
this.windowStage = windowStage;
this.windowClass = windowStage.getMainWindowSync();
}
getWindowStage(): window.WindowStage {
return this.windowStage as window.WindowStage
}
getWindowClass(): window.Window {
return this.windowClass as window.Window
}
setMainWindowFullScreen(fullScreen: boolean) {
if (deviceInfo.deviceType != "phone") {
return
...
...
@@ -103,5 +119,17 @@ export class WindowModel {
});
})
}
/**
* 设置窗口全屏模式时窗口内导航栏、状态栏的属性,使用callback异步回调。
* @param systemBarProperties
* @param callback
*/
setWindowSystemBarProperties(systemBarProperties: SystemBarProperties, callback?: AsyncCallback<void>): void {
this.windowClass?.setWindowSystemBarProperties(systemBarProperties, (err: BusinessError) => {
callback && callback(err)
})
}
}
...
...
sight_harmony/commons/wdNetwork/src/main/ets/http/HttpUrlUtils.ets
View file @
703a4d0
...
...
@@ -46,6 +46,10 @@ export class HttpUrlUtils {
* 批查接口,查询互动相关数据,如收藏数、评论数等
*/
static readonly INTERACT_DATA_PATH: string = "/api/rmrb-contact/contact/zh/c/content/interactData";
/**
* 查询视频频道推荐楼层
*/
static readonly DISPLAY_REC_COMPINFO: string = "/api/rmrb-bff-display-zh/display/zh/c/rec/compInfo";
// 多图(图集)详情页
/**
* 批量查询内容当前用户点赞、收藏状态
...
...
@@ -196,7 +200,6 @@ export class HttpUrlUtils {
* 搜索联想词
*/
static readonly RELATED_SEARCH_CONTENT_DATA_PATH: string = "/api/rmrb-search-api/zh/c/suggestions/";
/**
* 直播详情
*/
...
...
@@ -205,7 +208,6 @@ export class HttpUrlUtils {
* 直播详情-直播间列表
*/
static readonly LIVE_LIST_PATH: string = "/api/live-center-message/zh/a/live/message/video/list";
/**
* 直播详情-大家聊列表
*/
...
...
@@ -215,7 +217,6 @@ export class HttpUrlUtils {
* 搜索结果 显示tab 数
*/
static readonly SEARCH_RESULT_COUNT_DATA_PATH: string = "/api/rmrb-search-api/zh/c/count?keyword=";
/**
* 早晚报列表
* 根据页面id获取页面楼层列表
...
...
sight_harmony/features/wdComponent/src/main/ets/components/page/BottomNavigationComponent.ets
View file @
703a4d0
...
...
@@ -60,6 +60,7 @@ export struct BottomNavigationComponent {
MinePageComponent()
} else {
TopNavigationComponent({
groupId: navItem.id,
topNavList: navItem.topNavChannelList,
_currentNavIndex: this.currentNavIndex,
changeBarBackgroundColor: (color: Color) => {
...
...
sight_harmony/features/wdComponent/src/main/ets/components/page/PageComponent.ets
View file @
703a4d0
...
...
@@ -12,7 +12,6 @@ import LoadMoreLayout from './LoadMoreLayout';
import CustomRefreshLoadLayout from './CustomRefreshLoadLayout';
import { CompParser } from '../CompParser';
import { GroupInfoDTO } from 'wdBean/src/main/ets/bean/navigation/PageInfoDTO';
import { VideoChannelDetail } from 'wdDetailPlayShortVideo/Index';
import { CompDTO, LiveReviewDTO, PageDTO, PageInfoBean } from 'wdBean';
...
...
@@ -40,7 +39,6 @@ export struct PageComponent {
totalCount: 0,
list: []
};
name: string = "";
@Link @Watch('onChange') currentTopNavSelectedIndex: number
build() {
...
...
@@ -71,42 +69,35 @@ export struct PageComponent {
@Builder
ListLayout() {
List() {
if (this.name !== '视频') {
// 下拉刷新
ListItem() {
RefreshLayout({
refreshBean: new RefreshLayoutBean(this.pageModel.isVisiblePullDown, this.pageModel.pullDownRefreshImage,
this.pageModel.pullDownRefreshText, this.pageModel.pullDownRefreshHeight)
})
}
}
if (this.name === '视频') {
VideoChannelDetail()
} else {
LazyForEach(this.pageModel.compList, (compDTO: CompDTO, compIndex: number) => {
ListItem() {
Column() {
CompParser({ compDTO: compDTO, compIndex: compIndex });
}
}
},
(compDTO: CompDTO, compIndex: number) => compDTO.id + compIndex.toString() + this.pageModel.timestamp
)
// 下拉刷新
ListItem() {
RefreshLayout({
refreshBean: new RefreshLayoutBean(this.pageModel.isVisiblePullDown, this.pageModel.pullDownRefreshImage,
this.pageModel.pullDownRefreshText, this.pageModel.pullDownRefreshHeight)
})
}
if (this.name !== '视频') {
// 加载更多
LazyForEach(this.pageModel.compList, (compDTO: CompDTO, compIndex: number) => {
ListItem() {
if (this.pageModel.hasMore) {
LoadMoreLayout({
refreshBean: new RefreshLayoutBean(this.pageModel.isVisiblePullUpLoad, this.pageModel.pullUpLoadImage,
this.pageModel.pullUpLoadText, this.pageModel.pullUpLoadHeight)
})
} else {
NoMoreLayout()
Column() {
CompParser({ compDTO: compDTO, compIndex: compIndex });
}
}
},
(compDTO: CompDTO, compIndex: number) => compDTO.id + compIndex.toString() + this.pageModel.timestamp
)
// 加载更多
ListItem() {
if (this.pageModel.hasMore) {
LoadMoreLayout({
refreshBean: new RefreshLayoutBean(this.pageModel.isVisiblePullUpLoad, this.pageModel.pullUpLoadImage,
this.pageModel.pullUpLoadText, this.pageModel.pullUpLoadHeight)
})
} else {
NoMoreLayout()
}
}
}
...
...
sight_harmony/features/wdComponent/src/main/ets/components/page/TopNavigationComponent.ets
View file @
703a4d0
...
...
@@ -6,6 +6,7 @@ import { ChannelSubscriptionLayout } from './ChannelSubscriptionLayout';
import { FirstTabTopSearchComponent } from '../search/FirstTabTopSearchComponent';
import window from '@ohos.window';
import { WindowModel } from 'wdKit';
import { VideoChannelDetail } from 'wdDetailPlayShortVideo/Index';
const TAG = 'TopNavigationComponent';
...
...
@@ -20,6 +21,7 @@ const storage = LocalStorage.getShared();
@Entry(storage)
@Component
export struct TopNavigationComponent {
private groupId: number = 0
private tabsController: TabsController = new TabsController()
private changeBarBackgroundColor: (color: Color) => void = () => {
}
...
...
@@ -236,15 +238,23 @@ export struct TopNavigationComponent {
Tabs({ index: this.currentTopNavSelectedIndex, controller: this.tabsController }) {
ForEach(this._currentNavIndex === 0 ? this.myChannelList : this.topNavList, (navItem: TopNavDTO, index: number) => {
TabContent() {
if (!this.isBroadcast(navItem) && !this.isLayout(navItem)) {
PageComponent({
currentTopNavSelectedIndex: $currentTopNavSelectedIndex,
navIndex: index,
if (this._currentNavIndex === 2 && navItem.name === '视频') {
VideoChannelDetail({
bottomNavIndex: this._currentNavIndex,
topNavIndex: this.currentTopNavSelectedIndex,
groupId: this.groupId + '',
pageId: navItem.pageId + '',
channelId: navItem.channelId + '',
name: navItem.name
})
}
} else
if (!this.isBroadcast(navItem) && !this.isLayout(navItem)) {
PageComponent({
currentTopNavSelectedIndex: $currentTopNavSelectedIndex,
navIndex: index,
pageId: navItem.pageId + '',
channelId: navItem.channelId + '',
})
}
}
.tabBar(this.tabBarBuilder(navItem, index))
...
...
sight_harmony/features/wdDetailPlayApi/src/main/ets/request/ContentDetailRequest.ets
View file @
703a4d0
...
...
@@ -2,6 +2,7 @@ import { Logger, ResourcesUtils } from 'wdKit';
import { HttpUrlUtils, ResponseDTO, WDHttp } from 'wdNetwork';
import { ContentDetailDTO, InteractDataDTO } from 'wdBean';
import HashMap from '@ohos.util.HashMap';
import { HttpRequest } from 'wdNetwork/src/main/ets/http/HttpRequest';
const TAG = 'ContentDetailRequest';
...
...
@@ -13,6 +14,18 @@ export interface ContentDetailRequestParams {
relType: string
}
export interface contentsItem {
contentId: string;
contentRelId: string;
contentType: number;
relId: string;
relType: string;
}
export interface batchContentDetailParams {
contents: contentsItem[]
}
export interface recommentVideoListParams {
pageSize: number;
refreshCnt: number;
...
...
@@ -27,6 +40,47 @@ export interface contentListParams {
contentList: contentListItem[];
}
export interface getRecCompInfoParams {
groupId: string;
pageId: string;
channelId: string;
loadStrategy: string;
channelStrategy: string;
pageNum: number;
pageSize: number;
refreshTime: number;
}
// 为空的值不声明,需要时再加
export interface operDataListItem {
objectId: string;
objectType: string;
relId: string;
relType: string;
channelId: string;
}
export interface compListItem {
compStyle: string;
compType: string;
hasMore: number;
recommend: number;
operDataList: operDataListItem[];
}
export interface getRecCompInfoResult {
blockDesc: string;
id: number;
name: string;
pageId: string;
pageNum: number;
pageSize: number;
recommend: number;
totalCount: number;
compList: compListItem[]
}
export interface IStatusContentList {
contentId: string;
...
...
@@ -159,7 +213,33 @@ export class ContentDetailRequest {
}
/**
*
* 查询沉浸式视频频道推荐楼层数据
* @returns
*/
static getRecCompInfo(params: getRecCompInfoParams): Promise<ResponseDTO<getRecCompInfoResult>> {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.DISPLAY_REC_COMPINFO
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return WDHttp.request({ url, method: 'GET', params, headers: HttpRequest.buildHeaderWithGlobalHeader(headers) })
}
/**
* 批量查询沉浸式视频详情
* @returns
*/
static batchContentDetail(params: batchContentDetailParams): Promise<ResponseDTO<ContentDetailDTO[]>> {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.DETAIL_PATH
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return WDHttp.request({
url,
method: 'POST',
data: params,
headers: HttpRequest.buildHeaderWithGlobalHeader(headers)
})
}
/**
* 批量查询作品点赞、收藏、分享、阅读、评论数量
* @returns
*/
static getContentInteract(params: contentListParams): Promise<ResponseDTO<InteractDataDTO[]>> {
...
...
sight_harmony/features/wdDetailPlayShortVideo/src/main/ets/pages/VideoChannelDetail.ets
View file @
703a4d0
...
...
@@ -5,104 +5,164 @@ import { DetailPlayShortVideoPage } from './DetailPlayShortVideoPage'
import { Test } from './Test'
import router from '@ohos.router';
import window from '@ohos.window';
import { contentListParams } from 'wdDetailPlayApi/src/main/ets/request/ContentDetailRequest';
import {
batchContentDetailParams,
compListItem,
contentListParams,
contentsItem,
getRecCompInfoParams
} from 'wdDetailPlayApi/src/main/ets/request/ContentDetailRequest';
import { WindowModel } from 'wdKit/Index';
import { BusinessError } from '@kit.BasicServicesKit';
interface loadMoreData {
pageNum: number;
refreshTime: number;
loadStrategy: string;
}
@Entry
@Component
export struct VideoChannelDetail {
private contentId: string = ''
private relId: string = ''
private relType: string = ''
private groupId: string = '' // 楼层id
private pageId: string = '' //页面id
private pageNum: number = 1
private pageSize: number = 10
private loadStrategy: string = 'first_load' // 首次加载: first_load, 上推刷新: push_up, 下拉刷新: pull_down
private refreshTime: number = new Date().getTime() // 第一页刷新时间,用于频道分页排序时过滤,查询时携带【首刷、下拉取当前最新时间;其他的都使用首刷的时间】
private channelId: string = '' // 频道id
private channelStrategy: string = '1' // 频道策略 1-推荐;2-时间线
// private topicId?: string = '' // 专题id
// private recommend?: string = '' // 0.非推荐,1.推荐;
@State @Watch('navIndexChange') bottomNavIndex: number = 0
@State @Watch('navIndexChange') topNavIndex: number = 0
private swiperController: SwiperController = new SwiperController()
@Provide showComment: boolean = false
@State data: ContentDetailDTO[] = []
@State currentIndex: number = 0
@State interactDataList: InteractDataDTO[] = []
@State totalCount: number = 0
async aboutToAppear(): Promise<void> {
// let data: ContentDetailDTO[] = []
// let action: Action = router.getParams() as Action
// if (action) {
// this.contentId = action.params?.contentID || ''
// if (action.params && action.params.extra) {
// this.relId = action.params.extra.relId || ''
// this.relType = action.params.extra.relType || ''
// }
// await ContentDetailRequest.getContentDetail({
// contentId: this.contentId,
// relId: this.relId,
// relType: this.relType
// }).then((resDTO: ResponseDTO<ContentDetailDTO[]>) => {
// console.error('resDTO==', JSON.stringify(resDTO.data))
// if (resDTO.data) {
// this.data.push(resDTO.data[0])
// }
//
// })
// }
await this.queryVideoList()
// await ContentDetailRequest.postRecommendVideoList({
// pageSize: 5,
// refreshCnt: 1
// }).then(res => {
// if (res.data) {
// data = data.concat(res.data)
// }
// console.log('res1===', JSON.stringify(res))
// console.log('res==' + this.data)
// })
if (this.data.length > 0) {
const params: contentListParams = {
contentList: []
}
this.data.map(item => {
params.contentList.push({
contentId: item.newsId + '',
contentType: item.newsType
})
})
// 批量查询内容当前用户点赞、收藏状态
await ContentDetailRequest.getContentInteract(params).then(res => {
if (res.data) {
this.interactDataList = res.data || []
}
console.log('获取互动点赞等数据===', JSON.stringify(res))
})
// 查询各类型内容动态数据接口V2
/**
* 监听视频频道激活或失活
*/
navIndexChange() {
if (this.bottomNavIndex === 2 && this.topNavIndex === 0) {
// 如果视频在暂停则播放视频
} else {
// 如果视频在播放则暂停视频
}
}
// this.data = data
console.error('aboutToAppear===', this.data.length)
async aboutToAppear(): Promise<void> {
const windowStage = WindowModel.shared.getWindowStage() as window.WindowStage
const windowClass: window.Window = windowStage.getMainWindowSync();
windowClass.setWindowSystemBarProperties({
statusBarContentColor: '#ffffff',
})
console.error('aboutToAppear groupId', this.groupId)
console.error('aboutToAppear pageId', this.pageId)
console.error('aboutToAppear channelId', this.channelId)
// 根据视频频道传参查询视频楼层信息
this.getRecCompInfo()
}
aboutToDisappear(): void {
const windowStage = WindowModel.shared.getWindowStage() as window.WindowStage
const windowClass: window.Window = windowStage.getMainWindowSync();
windowClass.setWindowSystemBarProperties({
statusBarContentColor: '#000000',
})
console.error('aboutToDisappear videoChanel')
}
onPageHide(): void {
console.error('onPageHide videoChanel')
}
onPageShow(): void {
console.error('onPageShow videoChanel')
}
/**
*
查询视频列表用于翻页
*
根据视频频道传参查询视频楼层信息
*/
async queryVideoList() {
await ContentDetailRequest.postRecommendVideoList({
pageSize: 5,
refreshCnt: 1
}).then(res => {
if (res.data) {
this.data = this.data.concat(res.data)
async getRecCompInfo() {
if (this.data.length > 0 && this.data.length === this.totalCount) {
AlertDialog.show({ message: '没有更多视频了~' })
return
}
const params: getRecCompInfoParams = {
groupId: this.groupId,
pageId: this.pageId,
channelId: this.channelId,
loadStrategy: this.loadStrategy,
channelStrategy: this.channelStrategy,
pageNum: this.pageNum,
pageSize: this.pageSize,
refreshTime: this.refreshTime,
}
await ContentDetailRequest.getRecCompInfo(params).then(res => {
console.log('根据视频频道传参查询视频楼层信息', res.data?.totalCount)
console.log('根据视频频道传参查询视频楼层信息', JSON.stringify(res.data?.compList))
this.totalCount = res.data?.totalCount || 0
const list1: batchContentDetailParams = {
contents: []
}
const list2: contentListParams = {
contentList: []
}
console.log('queryVideoList===', JSON.stringify(this.data))
})
}
aboutToDisappear(): void {
if (res.data?.compList.length) {
res.data?.compList.map((item: compListItem) => {
list1.contents.push({
contentId: item.operDataList[0].objectId,
contentRelId: item.operDataList[0].relId,
contentType: Number(item.operDataList[0].objectType),
relId: item.operDataList[0].relId,
relType: item.operDataList[0].relType,
})
list2.contentList.push({
contentId: item.operDataList[0].objectId,
contentType: Number(item.operDataList[0].objectType),
})
})
}
this.batchContentDetail(list1)
this.getContentInteract(list2)
}).catch((e: BusinessError) => {
console.error('eeeeeeeeeeeeee', e)
})
}
onPageHide(): void {
/**
* 根据视频楼层信息批量查询视频列表
*/
async batchContentDetail(list: batchContentDetailParams) {
if (list.contents.length > 0) {
await ContentDetailRequest.batchContentDetail(list).then(res => {
console.log('根据视频楼层信息批量查询视频列表', JSON.stringify(res.data))
this.data = this.data.concat(res.data as [])
})
}
}
/**
* 根据视频信息批量查询点赞、收藏状态
*/
async getContentInteract(list: contentListParams) {
if (list.contentList.length > 0) {
await ContentDetailRequest.getContentInteract(list).then(res => {
this.interactDataList = res.data || []
console.log('根据视频信息批量查询点赞、收藏状态', JSON.stringify(res))
})
}
}
build() {
...
...
@@ -133,7 +193,10 @@ export struct VideoChannelDetail {
console.info('onChange==', index.toString())
if (this.currentIndex === this.data.length - 1) {
this.queryVideoList()
this.pageNum++
this.refreshTime = new Date().getTime()
this.loadStrategy = 'push_up'
this.getRecCompInfo()
}
})
...
...
sight_harmony/features/wdDetailPlayShortVideo/src/main/ets/view/PlayerTitleComment.ets
View file @
703a4d0
...
...
@@ -144,7 +144,7 @@ export struct PlayerTitleComment {
Column() {
Slider({
value: this.progressVal,
step: 1,
step:
0.0
1,
// style: SliderStyle.OutSet
})
.blockColor(this.status === PlayerConstants.STATUS_START ? Color.Transparent : $r('app.color.play_block_color'))
...
...
@@ -159,7 +159,7 @@ export struct PlayerTitleComment {
.width('100%')
.height(19)
.onChange((value: number, mode: SliderChangeMode) => {
this.playerController?.setSeekTime(
value
, mode);
this.playerController?.setSeekTime(
Math.floor(value)
, mode);
})
if (this.showComment) {
...
...
sight_harmony/features/wdPlayer/src/main/ets/controller/WDPlayerController.ets
View file @
703a4d0
...
...
@@ -120,6 +120,9 @@ export class WDPlayerController {
this.avPlayer?.on(Events.ERROR, (error) => {
this.playError(error.message);
})
this.avPlayer?.on('seekDone', (time: number) => {
this.initProgress(time);
})
this.avPlayer?.on(Events.VIDEO_SIZE_CHANGE, (width: number, height: number) => {
if (this.onVideoSizeChange) {
this.onVideoSizeChange(width, height);
...
...
@@ -248,8 +251,8 @@ export class WDPlayerController {
// 100 / 1000));
}
if (mode === SliderChangeMode.End) {
this.seekTime = value * this.duration;
this.avPlayer?.seek(this.seekTime, media.SeekMode.SEEK_PREV_SYNC);
this.seekTime = Math.floor(value * this.duration / 100);
this.avPlayer?.seek(this.seekTime);
}
}
...
...
@@ -269,7 +272,7 @@ export class WDPlayerController {
let nowSeconds = Math.floor(time / 1000);
let totalSeconds = Math.floor(this.duration / 1000);
if (this.onTimeUpdate) {
this.onTimeUpdate(
nowSeconds, totalSeconds
);
this.onTimeUpdate(
time, this.duration
);
}
}
...
...
Please
register
or
login
to post a comment