zhenghy

视频缺省图

Showing 25 changed files with 114 additions and 85 deletions
import {
NetworkUtil,
Logger,
NetworkType,
SPHelper,
} from 'wdKit';
import { NetworkUtil, Logger, NetworkType, SPHelper, } from 'wdKit';
import { ResponseDTO } from 'wdNetwork';
import {
ContentDetailDTO,
... ... @@ -68,7 +63,7 @@ export struct MultiPictureDetailPageComponent {
})
// 注册监听网络连接
let netStatus = NetworkUtil.isNetConnected()
if(netStatus) {
if (netStatus) {
// 有网络
this.getContentDetailData()
} else {
... ... @@ -270,8 +265,12 @@ export struct MultiPictureDetailPageComponent {
.height(px2vp(this.titleHeight) + 64)
}
if(this.netStatus !== undefined) {
EmptyComponent({ emptyType: $netStatus, emptyButton:true, retry: () => {this.getContentDetailData()}})
if (this.netStatus !== undefined) {
EmptyComponent({
emptyType: this.netStatus, emptyButton: true, retry: () => {
this.getContentDetailData()
}
})
.id('e_empty_content')
.alignRules({
center: { anchor: "__container__", align: VerticalAlign.Center },
... ... @@ -307,35 +306,37 @@ export struct MultiPictureDetailPageComponent {
getContentDetailData() {
try {
PageRepository.fetchDetailData(this.relId, this.contentId, this.relType).then(async (resDTO: ResponseDTO<ContentDetailDTO[]>) => {
if (!resDTO || !resDTO.data) {
Logger.error(TAG, 'fetchDetailData is empty');
return
}
if (resDTO.code != 0) {
Logger.error(TAG, `fetchDetailData then code:${resDTO.code}, message:${resDTO.message}`);
return
}
this.netStatus = undefined
this.contentDetailData = resDTO.data?.[0];
// this.contentDetailData.photoList = []
if(this.contentDetailData?.photoList && this.contentDetailData?.photoList?.length === 0) {
// 暂无内容
this.netStatus = 0
Logger.info(TAG, `this.netStatus:${JSON.stringify(this.netStatus)}`)
}
Logger.info(TAG, `contentDetailData:${JSON.stringify(this.contentDetailData)}`)
// 未登录,跳转登录
const user_id = await SPHelper.default.get(SpConstants.USER_ID, '')
if (user_id) {
this.getInteractBrowsOperate()
this.getBatchAttentionStatus()
}
}).catch((err: Error) => {
Logger.info(TAG, `fetchDetailData then,err: ${JSON.stringify(err)}`);
// 内容获取失败
this.netStatus = 9
})
PageRepository.fetchDetailData(this.relId, this.contentId, this.relType)
.then(async (resDTO: ResponseDTO<ContentDetailDTO[]>) => {
if (!resDTO || !resDTO.data) {
Logger.error(TAG, 'fetchDetailData is empty');
return
}
if (resDTO.code != 0) {
Logger.error(TAG, `fetchDetailData then code:${resDTO.code}, message:${resDTO.message}`);
return
}
this.netStatus = undefined
this.contentDetailData = resDTO.data?.[0];
// this.contentDetailData.photoList = []
if (this.contentDetailData?.photoList && this.contentDetailData?.photoList?.length === 0) {
// 暂无内容
this.netStatus = 0
Logger.info(TAG, `this.netStatus:${JSON.stringify(this.netStatus)}`)
}
Logger.info(TAG, `contentDetailData:${JSON.stringify(this.contentDetailData)}`)
// 未登录,跳转登录
const user_id = await SPHelper.default.get(SpConstants.USER_ID, '')
if (user_id) {
this.getInteractBrowsOperate()
this.getBatchAttentionStatus()
}
})
.catch((err: Error) => {
Logger.info(TAG, `fetchDetailData then,err: ${JSON.stringify(err)}`);
// 内容获取失败
this.netStatus = 9
})
} catch (exception) {
}
... ...
... ... @@ -46,13 +46,13 @@ export const enum WDViewDefaultType {
/**
* 空数据/无数据
*/
@Preview
// @Preview
@Component
export struct EmptyComponent {
// private emptySize: SizeOptions = {};
@State emptyWidth: string | number = CommonConstants.FULL_PARENT;
@State emptyHeight: string | number = CommonConstants.FULL_PARENT;
@Link emptyType: number
@State emptyType: number = WDViewDefaultType.WDViewDefaultType_Default
@State emptyButton: boolean = false
@State timeNum: number = 10
/**
... ...
import { LiveDetailsBean } from 'wdBean/Index';
import { WDPlayerController, WDPlayerRenderVLiveView, WDPlayerRenderView } from 'wdPlayer/Index';
import componentUtils from '@ohos.arkui.componentUtils';
const TAG = 'PlayerComponent'
@Component
export struct PlayerComponent {
private playerController?: WDPlayerController;
// playerController: WDPlayerController = new WDPlayerController();
@Consume @Watch('updateData') liveDetailsBean: LiveDetailsBean
@Consume @Watch('pageShowChange') pageShow: number
@Consume @Watch('pageHideChange') pageHide: number
@State bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0
@State topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0
@State imgUrl: string = ''
... ... @@ -16,6 +16,14 @@ export struct PlayerComponent {
@State liveStreamType: number | null = -1
@State playUrl: string = ''
pageShowChange() {
this.playerController?.play()
}
pageHideChange() {
this.playerController?.pause()
}
aboutToAppear(): void {
console.log(TAG, 'aboutToAppear')
if (this.playerController) {
... ...
import { Action, ContentDetailDTO, InteractDataDTO } from 'wdBean/Index';
import { ContentDetailDTO, InteractDataDTO } from 'wdBean/Index';
import { ContentDetailRequest } from 'wdDetailPlayApi/Index'
import { ResponseDTO } from 'wdNetwork/Index';
import { DetailPlayShortVideoPage } from './DetailPlayShortVideoPage'
// import { Test } from './Test'
import router from '@ohos.router';
import window from '@ohos.window';
import {
WDViewDefaultType,
EmptyComponent
} from '../../../../../wdComponent/src/main/ets/components/view/EmptyComponent'
import {
batchContentDetailParams,
compListItem,
contentListParams,
contentsItem,
getRecCompInfoParams
} from 'wdDetailPlayApi/src/main/ets/request/ContentDetailRequest';
import { Logger, WindowModel } from 'wdKit/Index';
import { BusinessError } from '@kit.BasicServicesKit';
import { PictureLoading } from './PictureLoading';
interface loadMoreData {
... ... @@ -23,8 +21,6 @@ interface loadMoreData {
}
const TAG = 'VideoChannelDetail'
let timer: number = -1
const storage = LocalStorage.getShared();
@Entry(storage)
... ... @@ -54,6 +50,7 @@ export struct VideoChannelDetail {
@State interactDataList: InteractDataDTO[] = []
@State totalCount: number = 0
@State isMouted: boolean = false
@State isRequestError: boolean = false
pageShowChange() {
if (this.bottomNavIndex === 2 && this.topNavIndex === 0) {
... ... @@ -149,6 +146,7 @@ export struct VideoChannelDetail {
}
await ContentDetailRequest.getRecCompInfo(params).then(res => {
this.isRequestError = false
console.log('根据视频频道传参查询视频楼层信息totalCount', res.data?.totalCount + '')
this.totalCount = res.data?.totalCount || 0
... ... @@ -182,6 +180,9 @@ export struct VideoChannelDetail {
this.isMouted = true
}, 500)
}).catch(() => {
// 获取内容失败请重试
this.isRequestError = true
})
}
... ... @@ -211,41 +212,52 @@ export struct VideoChannelDetail {
build() {
Column() {
PictureLoading().visibility(this.isMouted ? Visibility.None : Visibility.Visible)
Swiper(this.swiperController) {
ForEach(this.data, (item: ContentDetailDTO, index: number) => {
Column() {
DetailPlayShortVideoPage({
contentDetailData: item,
currentIndex: this.currentIndex,
index: index,
interactData: this.interactDataList[index]
})
}.width('100%')
.height('100%')
}, (item: ContentDetailDTO) => item.newsId + '')
}
.visibility(this.isMouted ? Visibility.Visible : Visibility.None)
.cachedCount(-1)
.indicator(false)
.vertical(true)
.loop(false)
.width('100%')
.height('100%')
// 扩展至所有非安全区域
.expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM])
.onChange((index: number) => {
this.currentIndex = index
console.info('onChange==', index.toString())
if (this.currentIndex === this.data.length - 1) {
this.pageNum++
this.refreshTime = new Date().getTime()
this.loadStrategy = 'push_up'
this.getRecCompInfo()
if (this.isRequestError) {
EmptyComponent({
emptyType: WDViewDefaultType.WDViewDefaultType_NoVideo,
emptyButton: true,
retry: () => {
this.getRecCompInfo()
}
})
} else {
PictureLoading().visibility(this.isMouted ? Visibility.None : Visibility.Visible)
Swiper(this.swiperController) {
ForEach(this.data, (item: ContentDetailDTO, index: number) => {
Column() {
DetailPlayShortVideoPage({
contentDetailData: item,
currentIndex: this.currentIndex,
index: index,
interactData: this.interactDataList[index]
})
}.width('100%')
.height('100%')
}, (item: ContentDetailDTO) => item.newsId + '')
}
})
.visibility(this.isMouted ? Visibility.Visible : Visibility.None)
.cachedCount(-1)
.indicator(false)
.vertical(true)
.loop(false)
.width('100%')
.height('100%')
// 扩展至所有非安全区域
.expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM])
.onChange((index: number) => {
this.currentIndex = index
console.info('onChange==', index.toString())
if (this.currentIndex === this.data.length - 1) {
this.pageNum++
this.refreshTime = new Date().getTime()
this.loadStrategy = 'push_up'
this.getRecCompInfo()
}
})
}
}
.width('100%')
.height('100%')
... ...
... ... @@ -9,6 +9,14 @@
"value": "14fp"
},
{
"name": "font_size_12",
"value": "12fp"
},
{
"name": "normal_text_size",
"value": "16fp"
},
{
"name": "title_popup_image_size",
"value": "24vp"
},
... ...