张善主

Merge remote-tracking branch 'origin/main'

Showing 39 changed files with 979 additions and 540 deletions
... ... @@ -84,4 +84,9 @@ export const enum CompStyle {
Card_Comp_Adv = 'card_comp_adv', // 信息流广告稿件
Card_Comp_Zh_Grid_Layout_02 = 'Card_Comp_Zh_Grid_Layout-02', // 一行两列卡业务内容
Card_Comp_Live_Big_Image_01 = 'card_comp_live_sub_big_image_01', // 直播预约大图卡
Card_Comp_Live_Big_Image_02 = 'card_comp_live_sub_big_image_02' // 直播大图卡
}
... ...
... ... @@ -163,7 +163,8 @@ export class ProcessUtils {
extra: {
relType: content?.relType,
relId: content?.relId,
} as ExtraDTO
} as ExtraDTO,
targetLayout: content.customParamTargetLayout
} as Params,
};
WDRouterRule.jumpWithAction(taskAction)
... ... @@ -232,7 +233,8 @@ export class ProcessUtils {
relId: content?.relId,
channelId: content?.channelId,
pageId: content?.pageId
} as ExtraDTO
} as ExtraDTO,
targetLayout: content.customParamTargetLayout
} as Params,
};
WDRouterRule.jumpWithAction(taskAction)
... ... @@ -300,7 +302,8 @@ export class ProcessUtils {
channelId: content?.channelId,
sourcePage: '5',
commentId: content?.commentInfo?.commentId
} as ExtraDTO
} as ExtraDTO,
targetLayout: content.customParamTargetLayout
} as Params,
};
WDRouterRule.jumpWithAction(taskAction)
... ... @@ -316,7 +319,8 @@ export class ProcessUtils {
extra: {
relType: content?.relType,
relId: content?.relId,
} as ExtraDTO
} as ExtraDTO,
targetLayout: content.customParamTargetLayout
} as Params,
};
WDRouterRule.jumpWithAction(taskAction)
... ... @@ -352,7 +356,8 @@ export class ProcessUtils {
extra: {
relType: content?.relType,
relId: content?.relId,
} as ExtraDTO
} as ExtraDTO,
targetLayout: content.customParamTargetLayout
} as Params,
};
WDRouterRule.jumpWithAction(taskAction)
... ... @@ -394,7 +399,8 @@ export class ProcessUtils {
extra: {
relType: content?.relType,
relId: content?.relId,
} as ExtraDTO
} as ExtraDTO,
targetLayout: content.customParamTargetLayout
} as Params,
};
WDRouterRule.jumpWithAction(taskAction)
... ...
... ... @@ -116,6 +116,9 @@ export class ContentDTO implements BaseDTO {
timeBlurred:number = 0
top:number = 0
// 自定义参数,用于跳转对应页面时 传递targetLayout参数用
customParamTargetLayout?: string
static clone(old: ContentDTO): ContentDTO {
let content = new ContentDTO();
content.liveType = old.liveType;
... ...
... ... @@ -24,4 +24,6 @@ export interface Params {
videoCoverUrl?: string;
pageId?: string;
backVisibility?: boolean; //展示顶部返回栏
targetLayout?: string; // "comment" 表示进入对应页面后,跳转至评论区
}
... ...
... ... @@ -18,6 +18,7 @@ import { Card21Component } from './cardview/Card21Component';
import { SearchContentComponent } from './cardview/SearchContentComponent';
import { DateTimeUtils } from 'wdKit/Index';
import { TrackConstants, TrackingPageBrowse } from 'wdTracking/Index';
import { LiveBigImage02Component } from './cardview/LiveBigImage02Component';
/**
* card适配器,卡片样式汇总,依据ContentDTO#appStyle
... ... @@ -89,7 +90,9 @@ export struct CardParser {
Card20Component({ contentDTO, compDTO: this.compDTO, pageId: this.pageId, pageName: this.pageName })
} else if (contentDTO.appStyle === CompStyle.Card_21) {
Card21Component({ contentDTO, compDTO: this.compDTO, pageId: this.pageId, pageName: this.pageName })
} else {
} else if (contentDTO.appStyle === CompStyle.Card_Comp_Live_Big_Image_02) {
LiveBigImage02Component({ contentDTO:contentDTO, compDTO: this.compDTO, pageId: this.pageId, pageName: this.pageName })
}else {
// todo:组件未实现 / Component Not Implemented
// Text(contentDTO.appStyle)
// .width(CommonConstants.FULL_PARENT)
... ...
... ... @@ -60,7 +60,7 @@ export struct CarderInteraction {
})
}
if(this.contentDetailData?.openComment == 1){
if(this.contentDetailData?.openComment == 1 || router.getState().name === 'PeopleShipHomePage'){
this.commentLayout()
}
this.builderLike()
... ...
... ... @@ -79,8 +79,6 @@ export struct CompParser {
@Builder
componentBuilder() {
//CardParser({ contentDTO: this.compDTO.operDataList[0], compDTO:this.compDTO })
if (this.compDTO.operDataList[0]?.objectType !== '3' &&
this.compDTO.operDataList[0]?.objectType !== '13') { //暂时屏蔽活动和音频详情入口
if (this.compDTO.compStyle === CompStyle.Label_03) {
... ... @@ -171,7 +169,7 @@ export struct CompParser {
AdvCardParser({ pageModel: this.pageModel, compDTO: this.compDTO })
//Text(`compIndex = ${compIndex}`).width('100%').fontSize('12fp').fontColor(Color.Red).padding({ left: 0, right: 0 })
Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
} else if (!Number.isNaN(Number(this.compDTO.compStyle))) {
} else if (!Number.isNaN(Number(this.compDTO.compStyle)) || this.compDTO.compType === 'appStyle') {
CardParser({ contentDTO: this.compDTO.operDataList[0], compDTO: this.compDTO, pageId: this.pageId, pageName: this.pageName });
Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
} else {
... ...
... ... @@ -17,6 +17,7 @@ import {
batchLikeAndCollectResult,
RmhInfoDTO,
InteractDataDTO,
Action,
} from 'wdBean';
import media from '@ohos.multimedia.media';
import { OperRowListView } from './view/OperRowListView';
... ... @@ -56,9 +57,7 @@ const PATTERN_DATE_CN_RN: string = 'yyyy年MM月dd日 HH:mm';
@Component
export struct DynamicDetailComponent {
//入参
private relId: string = ''
private contentId: string = ''
private relType: string = ''
action: Action = {} as Action
//出参
@Provide contentDetailData: ContentDetailDTO = {} as ContentDetailDTO
//UI
... ... @@ -82,6 +81,8 @@ export struct DynamicDetailComponent {
@State openLikes: boolean = false // 是否可以点赞 1:可以 0:不可以
pageParam: ParamType = {}
commentListAreaInfo?: Area
lastTimeoutId?: number
// @Provide bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0
@Provide topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0
... ... @@ -553,6 +554,12 @@ export struct DynamicDetailComponent {
CommentComponent({
publishCommentModel: this.publishCommentModel
})
.id("comment")
.onAreaChange((oldValue: Area, newValue: Area) => {
this.commentListAreaInfo = newValue
this.checkToScrollCommentArea()
})
}
Blank().layoutWeight(1)
}
... ... @@ -587,7 +594,10 @@ export struct DynamicDetailComponent {
private async getContentDetailData() {
this.isNetConnected = NetworkUtil.isNetConnected()
try {
let data = await MultiPictureDetailViewModel.getDetailData(this.relId, this.contentId, this.relType)
const relId = this.action.params?.extra?.relId || '';
const relType = this.action.params?.extra?.relType || '';
const contentId = this.action.params?.contentID || '';
let data = await MultiPictureDetailViewModel.getDetailData(relId, contentId, relType)
this.isPageEnd = true;
this.contentDetailData = data[0];
let dateTime =
... ... @@ -774,13 +784,13 @@ export struct DynamicDetailComponent {
return
}
const params: postExecuteLikeParams = {
status: this.newsStatusOfUser?.likeStatus === '1' ? 0 : 1,
status: this.newsStatusOfUser?.likeStatus == '1' ? 0 : 1,
contentId: this.contentDetailData?.newsId + '',
contentType: this.contentDetailData?.newsType + '',
}
ContentDetailRequest.postExecuteLike(params).then(res => {
this.newsStatusOfUser.likeStatus = this.newsStatusOfUser?.likeStatus === '1' ? '0' : '1'
if (this.newsStatusOfUser.likeStatus === '1') {
this.newsStatusOfUser.likeStatus = this.newsStatusOfUser?.likeStatus == '1' ? '0' : '1'
if (this.newsStatusOfUser.likeStatus == '1') {
this.interactDataDTO.likeNum = Number(this.interactDataDTO.likeNum) + 1
} else {
this.interactDataDTO.likeNum = Number(this.interactDataDTO.likeNum) - 1
... ... @@ -788,7 +798,7 @@ export struct DynamicDetailComponent {
console.log('点赞、取消点赞==', this.newsStatusOfUser?.likeStatus, this.interactDataDTO?.likeNum)
//内容点赞、取消点赞Tracking 1点赞 0取消点赞
TrackingContent.like(this.newsStatusOfUser?.likeStatus === '1', TrackConstants.PageName.DynamicDetail, TrackConstants.PageName.DynamicDetail,
TrackingContent.like(this.newsStatusOfUser?.likeStatus == '1', TrackConstants.PageName.DynamicDetail, TrackConstants.PageName.DynamicDetail,
{
'contentType': `${this.contentDetailData.newsType}`,
'contentId': `${this.contentDetailData.newsId}`,
... ... @@ -804,6 +814,29 @@ export struct DynamicDetailComponent {
let context = getContext(this) as common.UIAbilityContext;
viewBlogItemInsightIntentShare(context,this.contentDetailData, this.interactDataDTO)
}
checkToScrollCommentArea() {
if (!this.commentListAreaInfo) {
// 需要评论区位置,调用前 请确保它有值
return
}
if (this.action.params?.targetLayout && this.action.params.targetLayout == "comment") {
if (this.lastTimeoutId) {
clearTimeout(this.lastTimeoutId)
}
this.lastTimeoutId = setTimeout(() => {
let offSetY = this.commentListAreaInfo?.globalPosition.y as number
Logger.debug(TAG, "即将滚动至yOffset: " + (offSetY - 100))
//头部距离48
this.scroller.scrollTo({
yOffset: offSetY - 100,
xOffset: 0,
animation: { duration: 1000, curve: Curve.Ease }
})
this.action.params!.targetLayout = undefined
}, 600)
}
}
}
interface radiusType {
... ...
... ... @@ -66,6 +66,7 @@ export struct ImageAndTextPageComponent {
@State offsetY: number = 0
pageShowTime:number = 0;
pageHideTime:number = 0;
lastTimeoutId?: number
onPageShow() {
this.pageShowTime = DateTimeUtils.getTimeStamp()
... ... @@ -152,6 +153,8 @@ export struct ImageAndTextPageComponent {
.onAreaChange((oldValue: Area, newValue: Area) => {
this.info = newValue
this.checkToScrollCommentArea()
})
// .onMeasureSize()
... ... @@ -370,8 +373,11 @@ export struct ImageAndTextPageComponent {
status: this.newsStatusOfUser?.likeStatus == '1' ? '0' : '1',
contentId: this.contentDetailData?.newsId + '',
contentType: this.contentDetailData?.newsType + '',
contentRelId: this.contentDetailData?.reLInfo?.relId || '' + '',
}
console.log(TAG, '点赞、取消点赞params', JSON.stringify(params))
PageRepository.postExecuteLike(params).then(res => {
console.log(TAG, '点赞、res', JSON.stringify(res))
console.log(TAG, '点赞、取消点赞', 'toggleLikeStatus==',)
if (this.newsStatusOfUser) {
//内容点赞、取消点赞Tracking 1点赞 0取消点赞
... ... @@ -413,6 +419,7 @@ export struct ImageAndTextPageComponent {
if (this.info) {
// let height = DisplayUtils.getDeviceHeight() / 2
let offSetY = this.info?.globalPosition.y as number
Logger.debug(TAG, "滚动至yOffset: " + (offSetY - 100))
//头部距离48
this.scroller.scrollTo({
yOffset: offSetY - 100,
... ... @@ -427,4 +434,27 @@ export struct ImageAndTextPageComponent {
aboutToDisappear() {
}
checkToScrollCommentArea() {
if (!this.info) {
// 需要评论区位置,调用前 请确保它有值
return
}
if (this.action.params?.targetLayout && this.action.params.targetLayout == "comment") {
if (this.lastTimeoutId) {
clearTimeout(this.lastTimeoutId)
}
this.lastTimeoutId = setTimeout(() => {
let offSetY = this.info?.globalPosition.y as number
Logger.debug(TAG, "即将滚动至yOffset: " + (offSetY - 100))
//头部距离48
this.scroller.scrollTo({
yOffset: offSetY - 100,
xOffset: 0,
animation: { duration: 1000, curve: Curve.Ease }
})
this.action.params!.targetLayout = undefined
}, 600)
}
}
}
... ...
import { CompDTO, ContentDTO } from 'wdBean';
import { ProcessUtils } from 'wdRouter';
import { onlyWifiLoadImg } from '../../utils/lazyloadImg';
import { hasClicked, persistentStorage } from '../../utils/persistentStorage';
import { SearchShowRed, textItem, titleInitRes } from '../../utils/searchShowRed';
import { DateTimeUtils } from 'wdKit/Index';
import { LottieView } from '../lottie/LottieView';
import { router } from '@kit.ArkUI';
const TAG: string = 'Card6Component-Card13Component';
/**
* 本地样式卡:直播大图卡
*/
@Component
export struct LiveBigImage02Component {
@ObjectLink compDTO: CompDTO
@State pageId: string = '';
@State pageName: string = '';
@State contentDTO: ContentDTO = new ContentDTO();
@State loadImg: boolean = false;
@State clicked: boolean = false;
async aboutToAppear() {
const curRouter = router.getState().name;
this.clicked = hasClicked(this.contentDTO.objectId,curRouter)
this.loadImg = await onlyWifiLoadImg();
}
build() {
Column() {
Text(this.contentDTO.newsTitle)
.fontSize(18)
.maxLines(2)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.margin({ top: 16, bottom: 8 })
.alignSelf(ItemAlign.Start)
.fontColor(this.clicked ? 0x848484 : $r('app.color.color_222222'))
Stack() {
if (this.contentDTO.fullColumnImgUrls && this.contentDTO.fullColumnImgUrls.length > 0) {
Image(this.contentDTO.fullColumnImgUrls[0].url)//
.backgroundColor(this.loadImg ? $r('app.color.color_B0B0B0') : 0xf5f5f5)
.width('100%')
.aspectRatio(16 / 9)
.borderRadius(4)
.borderWidth(0.5)
.borderColor($r('app.color.color_0D000000'))
}
this.LiveImage(this.contentDTO)
}
.alignContent(Alignment.BottomEnd)
Row() {
if (this.contentDTO.rmhInfo && this.contentDTO.rmhInfo.rmhName) {
Text(this.contentDTO.rmhInfo.rmhName)
.fontSize(12)
.fontWeight(400)
.fontColor($r('app.color.color_B0B0B0'))
.fontFamily('PingFang SC-Medium')
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.align(Alignment.Start)
Image($r('app.media.point_live_icon'))
.objectFit(ImageFit.Auto)
.interpolation(ImageInterpolation.High)
.width(16)
.height(16)
.margin(2)
}
Text(DateTimeUtils.getCommentTime(Number.parseFloat(this.contentDTO.publishTimestamp)))
.fontSize(12)
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.align(Alignment.Start)
.width('100%')
.fontColor($r('app.color.color_B0B0B0'))
}
.margin({ top: 8, bottom: 8 })
}
.width('100%')
.padding({
left: $r('app.float.card_comp_pagePadding_lf'),
right: $r('app.float.card_comp_pagePadding_lf'),
})
.onClick(() => {
this.clicked = true;
persistentStorage(this.contentDTO.objectId);
ProcessUtils.processPage(this.contentDTO)
})
}
@Builder
LiveImage(item: ContentDTO) {
Row() {
LottieView({
name: 'live_status_wait',
path: "lottie/live_detail_living.json",
lottieWidth: 14,
lottieHeight: 14,
autoplay: true,
loop: true,
title: item.newsTitle
})
.margin({
right: '2vp'
})
Text('直播中')
.fontSize('12vp')
.fontWeight(400)
.fontColor(Color.White)
.textShadow({
radius: 2,
color: 'rgba(0,0,0,0.3)',
offsetX: 0,
offsetY: 2
})
.margin({
right: '5vp'
})
Image($r('app.media.icon_comp_line_live')).height('11vp').width('1.5vp')
if (this.getLiveRoomNumber(this.compDTO.operDataList[0]).length > 0) {
Text(this.getLiveRoomNumber(this.compDTO.operDataList[0]))
.fontSize('12vp')
.fontWeight(400)
.textShadow({
radius: 2,
color: 'rgba(0,0,0,0.3)',
offsetX: 0,
offsetY: 2
})
.fontColor(Color.White)
.margin({
left: '5vp'
})
}
}
.justifyContent(FlexAlign.End)
.margin({ right: 8, bottom: 8 })
}
// 判断是否预约
getLiveRoomNumber(item: ContentDTO): string {
const objc = item.liveRoomDataBean
if (objc && objc.pv && objc.pv > 0) {
return this.computeShowNum(objc.pv)
}
return ''
}
private computeShowNum(count: number): string {
if (count >= 10000) {
let num = (count / 10000).toFixed(1)
if (Number(num.substring(num.length - 1)) == 0) {
num = num.substring(0, num.length - 2)
}
return num + '万人参加'
}
return `${count}人参加`
}
}
\ No newline at end of file
... ...
... ... @@ -30,14 +30,15 @@ export struct MoreComponent {
Card9Component({ compDTO: new CompDTO, contentDTO:item, pageId: "", pageName: "" })
}
})
Divider()
.width('100%')
.color($r('app.color.color_F5F5F5'))
.strokeWidth(4)
} else {
Column() {
Divider()
.width('100%')
.color($r('app.color.color_F5F5F5'))
.strokeWidth(5)
Row() {
Text('点击展开更多相似')
.fontSize(16)
... ...
... ... @@ -34,7 +34,7 @@ export struct SearchContentComponent {
}
titleInit() {
const titleInitRes:titleInitRes = SearchShowRed.titleInit(this.contentDTO.title);
const titleInitRes:titleInitRes = SearchShowRed.titleInit(this.contentDTO.contentText || '');
// this.titleMarked = titleInitRes.titleMarked;
this.textArr = titleInitRes.textArr;
}
... ...
... ... @@ -498,6 +498,7 @@ struct QualityCommentItem {
content.relType = this.item.targetRelType;
content.pageId = this.item.pageId;
content.linkUrl = this.item.h5Url;
content.customParamTargetLayout = "comment"
ProcessUtils.processPage(content)
}
... ...
... ... @@ -79,15 +79,17 @@ export struct ZhGridLayout03 {
.onClick((event: ClickEvent) => {
console.log('333rt',JSON.stringify(item))
InfomationCardClick.track(this.compDTO, item, this.pageId, this.pageName)
if (item.objectType === '11') {
ProcessUtils.jumpExternalWebPage
ProcessUtils.jumpChannelTab(item.objectId, item.pageId, item.newsTitle)
} else if(item.objectType === '6'){
ProcessUtils.jumpExternalWebPage(item.linkUrl)
//ProcessUtils.gotoWeb(item);
}else{
ProcessUtils.processPage(item)
}
ProcessUtils.processPage(item)
// if (item.objectType === '11') {
// ProcessUtils.jumpExternalWebPage
// ProcessUtils.jumpChannelTab(item.objectId, item.pageId, item.newsTitle)
// } else if(item.objectType === '6'){
// ProcessUtils.jumpExternalWebPage(item.linkUrl)
// //ProcessUtils.gotoWeb(item);
// }else{
// ProcessUtils.processPage(item)
// }
})
}
}
... ...
... ... @@ -93,6 +93,7 @@ export struct HomePageBottomCommentComponent {
.onClick(()=>{
let content = getParams(item)
TrackingContent.common(TrackConstants.EventType.Click,TrackConstants.PageName.Main_Personal,TrackConstants.PageName.Main_Personal,TrackParamConvert.program(content))
content.customParamTargetLayout = "comment"
ProcessUtils.processPage(content)
})
.onVisibleAreaChange([0.0, 1.0], (isVisible: boolean, currentRatio: number) => {
... ...
import { router } from '@kit.ArkUI'
/**
* 常见的标题
*/
@Component
export default struct CommonPageTitle {
// 标题名称
@State title:string = ''
build() {
RelativeContainer() {
//标题栏目
Image($r('app.media.icon_arrow_left'))
.width(24)
.height(24)
.objectFit(ImageFit.Auto)
.id("back_icon")
.alignRules({
center: { anchor: "__container__", align: VerticalAlign.Center },
left: { anchor: "__container__", align: HorizontalAlign.Start }
})
.onClick(() => {
router.back()
})
Text(this.title)
.maxLines(1)
.id("title")
.fontSize('18vp')
.fontWeight(400)
.fontColor($r('app.color.color_222222'))
.lineHeight('22vp')
.alignRules({
center: { anchor: "__container__", align: VerticalAlign.Center },
middle: { anchor: "__container__", align: HorizontalAlign.Center }
})
}
.height(44)
.padding({
left: $r('app.float.card_comp_pagePadding_lf'),
right: $r('app.float.card_comp_pagePadding_lf'),
})
.width('100%')
}
}
\ No newline at end of file
... ...
import { ContentDTO, LiveRoomDataBean } from 'wdBean';
import { ProcessUtils } from 'wdRouter';
import PageViewModel from '../../viewmodel/PageViewModel';
import { DateTimeUtils, LazyDataSource, Logger, NetworkUtil } from 'wdKit/Index';
import { router } from '@kit.ArkUI';
import { ViewType } from 'wdConstant/src/main/ets/enum/ViewType';
import { CustomPullToRefresh } from '../reusable/CustomPullToRefresh';
import { PeopleShipNoMoreData } from '../reusable/PeopleShipNoMoreData';
import { EmptyComponent, WDViewDefaultType } from '../view/EmptyComponent';
import { ErrorComponent } from '../view/ErrorComponent';
import LoadMoreLayout from '../page/LoadMoreLayout';
import { LottieView } from '../../components/lottie/LottieView';
import dataPreferences from '@ohos.data.preferences';
import { BusinessError } from '@ohos.base';
import { onlyWifiLoadImg } from '../../utils/lazyloadImg';
import { channelSkeleton } from '../skeleton/channelSkeleton';
import CommonPageTitle from './CommonPageTitle';
import TemplatePageComponent from './template/TemplatePageComponent';
import { TemplatePageConstant } from './template/TemplatePageConstant';
const TAG: string = 'LiveMorePage';
const PREFERENCES_NAME = 'rmrLiveMorePage.db'
let preferenceTheme: dataPreferences.Preferences | null = null
/**
* 直播更多:
* type=1 直播
* type=2 预约
* 卡片结构:上下结构
* 卡片宽度:充满父窗口
* 卡片高度,仅包含横板图片:图片高度由图片的宽度及宽高比决定,图片宽度占父窗口'100%',宽高比为16:9:
* 直播列表
*/
@Entry
@Component
struct LiveMorePage {
@State data: LazyDataSource<ContentDTO> = new LazyDataSource();
@State topSafeHeight: number = AppStorage.get<number>('topSafeHeight') as number;
@State bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0
type: number = 1;
pageSize: number = 20;
operDataList: ContentDTO[] = [];
title: string = '直播列表'
@State contentDTO: ContentDTO = new ContentDTO();
@State private hasMore: boolean = true
@State private currentPage: number = 1
@State private isLoading: boolean = false
private scroller: Scroller = new Scroller()
@State liveRoomList: LiveRoomDataBean[] = []
// 点击过的数据
@State clickDatas: Array<string> = []
@State loadImg: boolean = false;
@State viewType: ViewType = ViewType.LOADING
emptyType: WDViewDefaultType = WDViewDefaultType.WDViewDefaultType_Default
async aboutToAppear(): Promise<void> {
await this.getPreferencesFromStorage()
this.loadImg = await onlyWifiLoadImg();
this.getLivMoreClickPreference()
Logger.debug(TAG, '数据:' + JSON.stringify(this.clickDatas))
this.currentPage = 1
this.getData()
}
title: string = '直播列表'
build() {
Column() {
this.TabbarNormal()
if (this.viewType == ViewType.LOADING) {
this.LoadingLayout()
} else if (this.viewType == ViewType.EMPTY || this.viewType == ViewType.ERROR) {
EmptyComponent({
emptyType: this.emptyType,
emptyButton: true,
retry: () => {
this.getData()
}
})
} else {
CustomPullToRefresh({
alldata: this.data,
scroller: this.scroller,
hasMore: false,
customList: () => {
this.ListLayout()
},
onRefresh: (resolve) => {
this.currentPage = 1
this.getData(resolve)
},
})
}
//常见标题
CommonPageTitle({ title: this.title })
// 通用模板组件
TemplatePageComponent({ pageDataSourceType: TemplatePageConstant.LIVE_HORIZONTAL_CARD })
}
.height('100%')
.backgroundColor(Color.White)
.padding({
left: $r('app.float.card_comp_pagePadding_lf'),
right: $r('app.float.card_comp_pagePadding_lf'),
top: px2vp(this.topSafeHeight),
bottom: px2vp(this.bottomSafeHeight)
})
}
@Builder
LoadingLayout() {
channelSkeleton()
}
@Builder
ListLayout() {
List({ scroller: this.scroller }) {
// 下拉刷新
LazyForEach(this.data, (contentDTO: ContentDTO) => {
ListItem() {
this.buildItem(contentDTO)
}
},
(contentDTO: ContentDTO, contentIndex: number) => contentDTO.pageId + contentIndex.toString()
)
// 加载更多
ListItem() {
if (this.hasMore && this.data && this.data.totalCount() > 0) {
LoadMoreLayout({ isVisible: this.hasMore })
} else if (!this.hasMore && !this.isLoading) {
PeopleShipNoMoreData()
}
}
}
.scrollBar(BarState.Off)
.edgeEffect(EdgeEffect.None)
.cachedCount(3)
.height('calc(100% - 44vp)')
.onReachEnd(() => {
Logger.debug(TAG, "触底了");
if (!this.isLoading && this.hasMore) {
//加载分页数据
this.currentPage++;
this.getData()
}
})
}
/**
* 组件项
*
* @param programmeBean item 组件项, 上面icon,下面标题
*/
@Builder
buildItem(item: ContentDTO) {
Column() {
Text(item.newsTitle)
.fontSize(18)
.maxLines(2)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.margin({ top: 16, bottom: 8 })
.alignSelf(ItemAlign.Start)
.fontColor(this.isClicked(item.objectId) ? $r('app.color.color_848484') : $r('app.color.color_222222'))
Stack() {
if (item.fullColumnImgUrls && item.fullColumnImgUrls.length > 0) {
Image(this.loadImg ? item.fullColumnImgUrls[0].url : '')
.backgroundColor(this.loadImg ? $r('app.color.color_B0B0B0') : 0xf5f5f5)
.width('100%')
.aspectRatio(16 / 9)
.borderRadius(4)
}
this.LiveImage(item)
}
.alignContent(Alignment.BottomEnd)
Row() {
if (item.rmhInfo && item.rmhInfo.rmhName) {
Text(item.rmhInfo.rmhName)
.fontSize(12)
.fontWeight(400)
.fontColor($r('app.color.color_B0B0B0'))
.fontFamily('PingFang SC-Medium')
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.align(Alignment.Start)
Image($r('app.media.point_live_icon'))
.objectFit(ImageFit.Auto)
.interpolation(ImageInterpolation.High)
.width(16)
.height(16)
.margin(2)
}
Text(DateTimeUtils.getCommentTime(Number.parseFloat(item.publishTimestamp)))
.fontSize(12)
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.align(Alignment.Start)
.width('100%')
.fontColor($r('app.color.color_B0B0B0'))
}
.margin({ top: 8, bottom: 8 })
Divider()
.strokeWidth(1)
.margin({ top: 6 })
.width('100%')
.color('#f5f5f5')
}
.width('100%')
.onClick(() => {
this.clickRowBuildItem(item)
ProcessUtils.processPage(item)
})
}
/*导航栏*/
@Builder
TabbarNormal() {
RelativeContainer() {
//标题栏目
Image($r('app.media.icon_arrow_left'))
.width(24)
.height(24)
.objectFit(ImageFit.Auto)
.id("back_icon")
.alignRules({
center: { anchor: "__container__", align: VerticalAlign.Center },
left: { anchor: "__container__", align: HorizontalAlign.Start }
})
.onClick(() => {
router.back()
})
Text(this.title)
.maxLines(1)
.id("title")
.fontSize('18vp')
.fontWeight(400)
.fontColor($r('app.color.color_222222'))
.lineHeight('22vp')
.alignRules({
center: { anchor: "__container__", align: VerticalAlign.Center },
middle: { anchor: "__container__", align: HorizontalAlign.Center }
})
}
.height(44)
.width('100%')
}
@Builder
LiveImage(item: ContentDTO) {
Row() {
LottieView({
name: 'live_status_wait',
path: "lottie/live_detail_living.json",
lottieWidth: 14,
lottieHeight: 14,
autoplay: true,
loop: true,
title: item.newsTitle
})
.margin({
right: '2vp'
})
Text('直播中')
.fontSize('12vp')
.fontWeight(400)
.fontColor(Color.White)
.textShadow({
radius: 2,
color: 'rgba(0,0,0,0.3)',
offsetX: 0,
offsetY: 2
})
.margin({
right: '5vp'
})
Image($r('app.media.icon_comp_line_live')).height('11vp').width('1.5vp')
if (this.getLiveRoomNumber(item).length > 0) {
Text(this.getLiveRoomNumber(item))
.fontSize('12vp')
.fontWeight(400)
.textShadow({
radius: 2,
color: 'rgba(0,0,0,0.3)',
offsetX: 0,
offsetY: 2
})
.fontColor(Color.White)
.margin({
left: '5vp'
})
}
}
.justifyContent(FlexAlign.End)
.margin({ right: 8, bottom: 8 })
}
private async getData(resolve?: (value: string | PromiseLike<string>) => void) {
if (this.isLoading) {
if (resolve) {
resolve('已更新至最新')
}
return
}
// 检测网络
let netStatus = NetworkUtil.isNetConnected()
if (!netStatus) {
this.emptyType = WDViewDefaultType.WDViewDefaultType_NoNetwork
this.viewType = ViewType.ERROR
return
}
this.isLoading = true
try {
const liveReviewDTO = await PageViewModel.getLiveMoreUrl(this.type, this.currentPage, this.pageSize)
if (liveReviewDTO && liveReviewDTO.list && liveReviewDTO.list.length > 0) {
if (liveReviewDTO.list.length === this.pageSize) {
this.hasMore = true;
} else {
this.hasMore = false;
}
if (this.currentPage == 1) {
this.data.clear()
}
this.data.push(...liveReviewDTO.list)
this.getLiveRoomDataInfo(liveReviewDTO.list)
} else {
this.hasMore = false;
}
this.resolveEnd(true, resolve)
if (liveReviewDTO.list.length == 0 && this.currentPage == 1) {
this.viewType = ViewType.EMPTY
this.emptyType = WDViewDefaultType.WDViewDefaultType_NoListContent
}
} catch (exception) {
this.resolveEnd(false, resolve)
}
}
private resolveEnd(isTop: boolean, resolve?: (value: string | PromiseLike<string>) => void) {
if (resolve) {
if (this.currentPage == 1 && isTop) {
resolve('已更新至最新')
} else {
resolve('')
}
}
if (this.currentPage == 1 && !isTop) {
this.viewType = ViewType.ERROR
this.emptyType = WDViewDefaultType.WDViewDefaultType_NoListContent
} else {
this.viewType = ViewType.LOADED
}
this.isLoading = false
}
private getLiveDetailIds(list: ContentDTO[]): string {
let idList: string[] = []
list.forEach(item => {
idList.push(item.objectId)
});
return idList.join(',')
}
// 获取评论数
async getLiveRoomDataInfo(list: ContentDTO[]) {
const reserveIds = this.getLiveDetailIds(list)
Logger.debug(TAG, '是否预约数据:' + ` ${reserveIds}`)
PageViewModel.getLiveRoomBatchInfo(reserveIds).then((result) => {
Logger.debug(TAG, '是否预约数据:' + ` ${JSON.stringify(result)}`)
if (result && result.length > 0) {
this.liveRoomList.push(...result)
this.data.reloadData()
}
}).catch(() => {
// this.data.push(...list)
})
}
// 判断是否预约
getLiveRoomNumber(item: ContentDTO): string {
const objc = this.liveRoomList.find((element: LiveRoomDataBean) => {
return element.liveId.toString() == item.objectId
})
if (objc && objc.pv && objc.pv > 0) {
return this.computeShowNum(objc.pv)
}
return ''
}
private computeShowNum(count: number): string {
if (count >= 10000) {
let num = (count / 10000).toFixed(1)
if (Number(num.substring(num.length - 1)) == 0) {
num = num.substring(0, num.length - 2)
}
return num + '万人参加'
}
return `${count}人参加`
}
isClicked(objectId: string) {
return this.clickDatas.includes(objectId)
}
clickRowBuildItem(item: ContentDTO) {
if (item.objectId && !this.clickDatas.includes(item.objectId)) {
Logger.debug(TAG, '数据:' + JSON.stringify(this.clickDatas))
this.clickDatas.push(item.objectId.toString())
this.putLiveMoreClickPreference()
}
}
async getPreferencesFromStorage() {
let context = getContext(this) as Context
preferenceTheme = await dataPreferences.getPreferences(context, PREFERENCES_NAME)
}
putLiveMoreClickPreference() {
Logger.info(TAG, `Put begin` + JSON.stringify(this.clickDatas))
if (preferenceTheme !== null && this.clickDatas.length > 0) {
// await
const arr: Array<string> = []
arr.push(...this.clickDatas)
preferenceTheme.put('liveMorePage', arr).then(() => {
Logger.debug(TAG, "Succeeded in putting value of 'startup'.");
}).catch((err: BusinessError) => {
Logger.debug(TAG, "Failed to put value of 'startup'. code =" + err.code + ", message =" + err.message);
})
// await preferenceTheme.flush()
preferenceTheme.flush((err: BusinessError) => {
if (err) {
Logger.debug(TAG, "Failed to flush. code =" + err.code + ", message =" + err.message);
return;
}
})
}
}
getLivMoreClickPreference() {
Logger.info(TAG, `Get begin`)
if (preferenceTheme !== null) {
preferenceTheme.get('liveMorePage', []).then((data: dataPreferences.ValueType) => {
if (data instanceof Array) {
this.clickDatas = data as Array<string>
}
}).catch((err: BusinessError) => {
console.error("Failed to get value of 'startup'. code =" + err.code + ", message =" + err.message);
})
}
}
}
\ No newline at end of file
... ...
import { BottomNavDTO, CompDTO, TopNavDTO } from 'wdBean';
import { BottomNavDTO, TopNavDTO } from 'wdBean';
import { SpConstants } from 'wdConstant';
import { DisplayUtils, LazyDataSource, Logger, NetworkUtil, SPHelper, ToastUtils } from 'wdKit';
import { Logger, NetworkUtil, SPHelper, ToastUtils } from 'wdKit';
import { ProcessUtils, WDRouterPage, WDRouterRule } from 'wdRouter';
import { PageComponent } from './PageComponent';
import { ChannelSubscriptionLayout } from './ChannelSubscriptionLayout';
... ... @@ -8,9 +8,8 @@ import { FirstTabTopSearchComponent } from '../search/FirstTabTopSearchComponent
import { AssignChannelParam } from 'wdRouter/src/main/ets/utils/HomeChannelUtils';
import { PeopleShipMainComponent } from '../peopleShip/PeopleShipMainComponent';
import { channelSkeleton } from '../skeleton/channelSkeleton';
import { TrackConstants, TrackingButton } from 'wdTracking/Index';
import DailyPaperTopicModel from '../../model/DailyPaperTopicModel'
import { ParamType, Tracking } from 'wdTracking/Index';
import { ParamType, TrackConstants, Tracking, TrackingButton } from 'wdTracking/Index';
import DailyPaperTopicModel from '../../model/DailyPaperTopicModel';
import { CompUtils } from '../../utils/CompUtils';
const TAG = 'TopNavigationComponent';
... ...
import { ArrayList } from '@kit.ArkTS'
import { CompDTO, ContentDTO, LiveRoomDataBean } from 'wdBean/Index'
import { DateTimeUtils, Logger } from 'wdKit/Index'
import PageViewModel from '../../../viewmodel/PageViewModel'
const TAG: string = 'BaseTemplateHelp'
export class BasePageHelp {
/**
* 请求获取直播房间的动态数据
* @param list
*/
/**
* 直播回看的批查数据
* @param list
* @param compList
*/
getLiveRoomDataInfo(compList: CompDTO[]) {
let list: ContentDTO[] = []
compList.forEach((comp: CompDTO) => {
list.push(...comp.operDataList)
})
let time = DateTimeUtils.getTimeStamp().toString()
let reserveIds = this.getLiveDetailIds(list)
PageViewModel.getLiveRoomBatchInfo(reserveIds).then((result) => {
if (result && result.length > 0) {
result.forEach((bean: LiveRoomDataBean) => {
for (let item of list) {
if (item.objectId == bean.liveId.toString()) {
item.liveRoomDataBean = bean
outer: for (let compBean of compList) {
for (let contentBean of compBean.operDataList) {
if (contentBean === item) {
compBean.timestamp = time
break outer
}
}
}
break
}
}
})
}
}).catch(() => {
})
}
/**
* 获取业务内容 objectId 集合穿 如1,2,3
* @param pageContentList
* @returns
*/
private getLiveDetailIds(pageContentList: ContentDTO[]): string {
let idList: string[] = []
pageContentList.forEach(item => {
idList.push(item.objectId)
});
return idList.join(',')
}
}
\ No newline at end of file
... ...
import { CompDTO, ContentDTO } from 'wdBean/Index'
import { LazyDataSource, Logger } from 'wdKit/Index'
import { CompParser } from '../../CompParser'
import { CustomPullToRefresh } from '../../reusable/CustomPullToRefresh'
import { PeopleShipNoMoreData } from '../../reusable/PeopleShipNoMoreData'
import { channelSkeleton } from '../../skeleton/channelSkeleton'
import { EmptyComponent } from '../../view/EmptyComponent'
import LoadMoreLayout from '../LoadMoreLayout'
import TemplatePageHelp from './TemplatePageHelp'
import TemplatePageModel from './TemplatePageModel'
import { TemplatePageStateType } from './TemplatePageStateType'
const TAG: string = 'TemplatePageComponent';
/**
* @Description: 处理通用信息展示页面,1)业务数据加载;2)异常状况处理;3)展位信息处理
* @Author:
* @Email: liyubing@wondertek.com.cn
* @CreateDate:
* @UpdateRemark: 更新说明
* @Version: 1.0
*/
@Component
export default struct TemplatePageComponent {
// 模板页面的数据驱动对象
@State private templatePage: TemplatePageModel = new TemplatePageModel
// 此内容主要因CustomPullToRefresh需要,目前没任何业务意义要求
@State pageData: LazyDataSource<ContentDTO> = new LazyDataSource();
// 滚动
private templateScroller: Scroller = new Scroller()
//识别不同页面的业务类型
pageDataSourceType: string = ''
// 埋点字段
pageId: string = ''
pageName: string = ''
async aboutToAppear() {
Logger.debug(TAG, 'aboutToAppear')
this.requestPageData()
}
aboutToDisappear(): void {
}
build() {
if (this.templatePage.pageCompType === TemplatePageStateType.LOADING) {
this.LoadingLayout()
} else if (this.templatePage.pageCompType === TemplatePageStateType.LOADED) {
CustomPullToRefresh({
alldata: this.pageData,
scroller: this.templateScroller,
hasMore: false,
customList: () => {
this.ListLayout()
},
onRefresh: (resolve) => {
this.templatePage.currentPage = 1
this.templatePage.resolve = resolve
this.requestPageData(resolve)
},
})
} else {
EmptyComponent({
emptyType: this.templatePage.noNormalState,
emptyButton: true,
retry: () => {
this.requestPageData()
}
})
}
}
@Builder
LoadingLayout() {
channelSkeleton()
}
@Builder
ListLayout() {
List({ scroller: this.templateScroller }) {
// 下拉刷新
LazyForEach(this.templatePage.compList, (compDTO: CompDTO, index: number) => {
ListItem() {
Column() {
CompParser({
compDTO: compDTO,
compIndex: index,
pageId: this.pageId,
pageName: this.pageName
});
}
}
},
(contentDTO: CompDTO, contentIndex: number) => JSON.stringify(contentDTO))
// 加载更多
ListItem() {
if (this.templatePage.hasMore && this.templatePage.compList && this.templatePage.compList.totalCount() > 0) {
LoadMoreLayout({ isVisible: this.templatePage.hasMore })
} else if (!this.templatePage.hasMore && !this.templatePage.isLoading) {
PeopleShipNoMoreData()
}
}
}
.scrollBar(BarState.Off)
.edgeEffect(EdgeEffect.None)
.cachedCount(3)
.height('calc(100% - 44vp)')
.onReachEnd(() => {
Logger.debug(TAG, "触底了");
if (!this.templatePage.isLoading && this.templatePage.hasMore) {
//加载分页数据
this.templatePage.currentPage++;
this.requestPageData()
}
})
}
/**
* 请求业务数据
*/
async requestPageData(resolve?: (value: string | PromiseLike<string>) => void) {
if (this.templatePage.isLoading) {
if (resolve) {
resolve('已更新至最新')
}
return
}
this.templatePage.pageDataSourceType = this.pageDataSourceType
TemplatePageHelp.requestPageData(this.templatePage)
}
}
\ No newline at end of file
... ...
/**
* @Description: 模板页面的常量
* @Author:
* @Email: liyubing@wondertek.com.cn
* @CreateDate:
* @UpdateRemark: 更新说明
* @Version: 1.0
*/
export class TemplatePageConstant {
/**
* 直播中
*/
public static LIVE_HORIZONTAL_CARD: string = "LIVE_HORIZONTAL_CARD"
}
\ No newline at end of file
... ...
import { CompDTO } from 'wdBean/Index';
import { CompStyle } from 'wdConstant/Index';
import { NetworkUtil } from 'wdKit/Index';
import PageViewModel from '../../../viewmodel/PageViewModel';
import { WDViewDefaultType } from '../../view/EmptyComponent';
import { BasePageHelp } from './BasePageHelp';
import { TemplatePageConstant } from './TemplatePageConstant';
import TemplatePageModel from './TemplatePageModel';
import { TemplatePageStateType } from './TemplatePageStateType';
const TAG: string = 'TemplatePageHelp';
/**
* @Description: 完成不同页面业务数据获取并加工
* @Author:
* @Email: liyubing@wondertek.com.cn
* @CreateDate:
* @UpdateRemark: 更新说明
* @Version: 1.0
*/
export class TemplatePageHelp extends BasePageHelp {
private pageModel: TemplatePageModel = new TemplatePageModel
constructor() {
super();
}
/**
* 请求业务数据
* @param pageModel
*/
async requestPageData(pageModel: TemplatePageModel) {
this.pageModel = pageModel
// 检测网络
let netStatus = NetworkUtil.isNetConnected()
if (netStatus) {
this.treatDiffBusinessDataSource()
} else if (pageModel.compList.size() > 0) {
// 加载缓存数据了,不用无网络提示
} else {
// 无网情况
pageModel.pageCompType = TemplatePageStateType.OTHER;
pageModel.noNormalState = WDViewDefaultType.WDViewDefaultType_NoNetwork
}
}
/**
* 区分不同业务数据源
*/
private treatDiffBusinessDataSource() {
if (this.pageModel.pageDataSourceType === TemplatePageConstant.LIVE_HORIZONTAL_CARD) {
// 直播列表
this.requestLiveListData(this.pageModel.resolve)
}
}
/**
* 请求直播列表数据
*/
private async requestLiveListData(resolve?: (value: string | PromiseLike<string>) => void) {
this.pageModel.isLoading = true
const liveReviewDTO = await PageViewModel.getLiveMoreUrl(1, this.pageModel.currentPage, this.pageModel.pageSize)
if (liveReviewDTO && liveReviewDTO.list && liveReviewDTO.list.length > 0) {
if (liveReviewDTO.list.length === this.pageModel.pageSize) {
this.pageModel.hasMore = true
} else {
this.pageModel.hasMore = false
}
// 依据业务请求获取的数据,转换成compDTO数据
let pageContentList: CompDTO[] = [] // 收集页面组件、稿件和本地组件容器
for (let contentDto of liveReviewDTO.list) {
let compDTO: CompDTO = new CompDTO()
compDTO.compType = 'appStyle'
contentDto.appStyle = CompStyle.Card_Comp_Live_Big_Image_02
compDTO.operDataList.push(contentDto)
pageContentList.push(compDTO)
}
// 推送数据到懒加载机制
this.pushDataToPage(pageContentList)
// 完成业务请求加载
this.pageModel.isLoading = false
// 批查
this.allCompBatchRequest(pageContentList)
} else {
this.pageModel.hasMore = false
if (this.pageModel.currentPage === 1) {
// 无业务数据
this.pageNoHaveData()
}
}
this.resolveEnd(resolve)
}
/**
* 处理页面批查业务方法
* @param list
*/
private allCompBatchRequest(compList: CompDTO[]) {
// 获取直播房间的动态数据
this.getLiveRoomDataInfo(compList)
// 测试数据
// setTimeout(() => {
// let time = DateTimeUtils.getTimeStamp().toString()
// let index = 1
// let compBean = compList[index] as CompDTO
// let contentBean = compBean.operDataList[0]
// contentBean.newsTitle = '熬阿斯蒂芬'
// //comp.operDataList[0].newsTitle = '测试111'
// let liveRoomBean: LiveRoomDataBean = {} as LiveRoomDataBean;
// liveRoomBean.pv = 6555
// contentBean.liveRoomDataBean = liveRoomBean
// compBean.timestamp = time
// Logger.debug("ZZZXXXXX",
// "-----setTimeout--------->" + time)
// }, 4 * 1000)
}
/**
* 推数据到页面
* @param list
*/
private pushDataToPage(pageContentList: CompDTO[]) {
// 请求第一页数据,需要清理pageData数据
if (this.pageModel.currentPage == 1) {
this.pageModel.compList.clear()
}
// 懒加载,推送数据
for (let contentDto of pageContentList) {
this.pageModel.compList.push(contentDto)
}
//完成业务数据请求
this.pageModel.pageCompType = TemplatePageStateType.LOADED
}
/**
* 页面没有数据
*/
private pageNoHaveData() {
this.pageModel.pageCompType = TemplatePageStateType.OTHER
this.pageModel.noNormalState = WDViewDefaultType.WDViewDefaultType_NoNetwork
}
/**
* 解析结束
* @param resolve
*/
private resolveEnd(resolve?: (value: string | PromiseLike<string>) => void) {
if (resolve) {
if (this.pageModel.currentPage == 1) {
resolve('已更新至最新')
} else {
resolve('')
}
}
}
}
let templatePageHelp = new TemplatePageHelp();
export default templatePageHelp as TemplatePageHelp;
\ No newline at end of file
... ...
import { ContentDTO } from 'wdBean/Index';
import { BaseDTO } from 'wdBean/src/main/ets/bean/component/BaseDTO';
import { LazyDataSource } from 'wdKit/Index';
import { WDViewDefaultType } from '../../view/EmptyComponent';
import { TemplatePageStateType } from './TemplatePageStateType';
/**
* @Description: 与TemplatePageCompent结合使用,处理业务、异常等数据
* @Author:
* @Email: liyubing@wondertek.com.cn
* @CreateDate:
* @UpdateRemark: 更新说明
* @Version: 1.0
*/
export default class TemplatePageModel {
/**
* 不用的页面所展示的业务数据都转换CompDTO对象
*/
compList: LazyDataSource<BaseDTO> = new LazyDataSource();
/**
* 识别不同页面的业务类型
*/
pageDataSourceType: string = ''
// 页码
currentPage: number = 1
// 一页最多信息量
pageSize: number = 20
// 是否支持加载更多数据
hasMore:boolean = false
// 是否正在请求数据
isLoading: boolean = false
/**
* 此字段可驱动组件展示不同业务的组件,
*/
pageCompType: number = TemplatePageStateType.LOADING
/**
* 异常状态 ——> 记录在获取数据中的不同状态,如无数据、无网络等情况
*/
noNormalState: WDViewDefaultType = WDViewDefaultType.WDViewDefaultType_Default
resolve?: (value: string | PromiseLike<string>) => void
}
\ No newline at end of file
... ...
/**
*
* 组件加载数据的不同状态
*
*/
export const enum TemplatePageStateType {
// 已初始化,但尚未发出请求
INITIAL = 0,
// 加载中:已发出请求,但请求尚未返回;
LOADING,
//
OTHER,
// 已加载结束/非失败/非空/可以是仅一页数据,即楼层数据列表PAGE_GROUP_LIST/
LOADED,
}
\ No newline at end of file
... ...
... ... @@ -48,19 +48,26 @@ export struct PeopleShipHomeArticleListComponent {
} else if (this.viewType == 2) {
ErrorComponent()
} else {
this.ListLayout()
// CustomPullToRefresh({
// alldata:this.arr,
// scroller:this.scroller,
// hasMore: false,
// customList:()=>{
// this.ListLayout()
// },
// onRefresh:(resolve)=>{
// this.currentPage = 1
// this.getPeopleShipPageArticleList(resolve)
// },
// })
CustomPullToRefresh({
alldata:this.arr,
scroller:this.scroller,
hasMore:this.hasMore,
customList:()=>{
this.ListLayout()
},
onRefresh:(resolve)=>{
this.currentPage = 1
this.getPeopleShipPageArticleList(resolve)
},
onLoadMore:(resolve)=> {
if (this.hasMore === false) {
if(resolve) resolve('')
return
}
this.currentPage++
this.getPeopleShipPageArticleList(resolve)
}
})
}
}
... ... @@ -90,14 +97,16 @@ export struct PeopleShipHomeArticleListComponent {
// 加载更多
ListItem() {
if (this.hasMore && this.arr && this.arr.length > 0) {
LoadMoreLayout({ isVisible: this.hasMore })
} else if (!this.hasMore && !this.isLoading) {
// if (this.hasMore && this.arr && this.arr.length > 0) {
// LoadMoreLayout({ isVisible: this.hasMore })
// } else
if (!this.hasMore && !this.isLoading) {
PeopleShipNoMoreData()
}
}
}
.cachedCount(4)
.scrollBar(BarState.Off)
.backgroundColor(Color.Transparent)
.width("100%")
.height("100%")
... ...
... ... @@ -291,6 +291,12 @@ export struct SearchResultContentComponent {
Divider().strokeWidth(5).color('#f5f5f5').padding({ left: 0, right: 0 })
}
} else {
if(this.data.get(index + 1).sameContentListSize > 0) {
Divider()
.width('100%')
.color($r('app.color.color_F5F5F5'))
.strokeWidth(4)
}
CardParser({compDTO:new CompDTO, contentDTO: item })
}
if (index != this.data.totalCount() - 1) {
... ...
... ... @@ -134,7 +134,7 @@ export struct HorizontalStrokeCardThreeTwoRadioForMoreComponent {
.aspectRatio(1.5)
.width(this.compDTO.operDataList.length == 2 ? 210 : 150)
.borderRadius(4)
.objectFit(ImageFit.Cover)
.objectFit(ImageFit.Contain)
CardMediaInfo({
livePeopleNum:false,
contentDTO: item
... ... @@ -153,7 +153,7 @@ export struct HorizontalStrokeCardThreeTwoRadioForMoreComponent {
.width(this.compDTO.operDataList.length == 2 ? 210 : 150)
.lineHeight(21)
}
.height(this.compDTO.operDataList.length == 2 ? 190 : 150)
.height(this.compDTO.operDataList.length == 2 ? 180 : 148)
.padding({ right: 16 })
// .offset({x:16})
.onClick(() => {
... ... @@ -167,7 +167,7 @@ export struct HorizontalStrokeCardThreeTwoRadioForMoreComponent {
Row() {
Ellipse()
.width(2* (this.moreWidth - this.initMoreWidth - 1))
.height(this.compDTO.operDataList.length == 2 ? 180 : 146)
.height(this.compDTO.operDataList.length == 2 ? 180 : 148)
.fill(0xf1f3f4)
.position({ left: -(this.moreWidth - this.initMoreWidth - 3) * 0.8 })
... ... @@ -181,7 +181,7 @@ export struct HorizontalStrokeCardThreeTwoRadioForMoreComponent {
}
.justifyContent(FlexAlign.Center)
.align(Alignment.Center)
.height(this.compDTO.operDataList.length == 2 ? 180 : 146)
.height(this.compDTO.operDataList.length == 2 ? 180 : 148)
.width(this.initMoreWidth)
.backgroundColor(0xf1f3f4)
.borderRadius({ topLeft: 5, bottomLeft: 5 })
... ... @@ -213,6 +213,7 @@ export struct HorizontalStrokeCardThreeTwoRadioForMoreComponent {
}
}
})
.height(this.compDTO.operDataList.length == 2 ? 180 : 148)
// .width('100%')
// .backgroundColor($r("app.color.color_FE4B05"))
... ...
... ... @@ -170,7 +170,7 @@ export struct LiveHorizontalCardComponent {
.width(this.compDTO.operDataList.length == 2 ? 210 : 150)
.lineHeight(21)
}
.height(this.compDTO.operDataList.length == 2 ? 190 : 150)
.height(this.compDTO.operDataList.length == 2 ? 180 : 148)
.padding({ right: 16 })
.onClick(() => {
InfomationCardClick.track(this.compDTO, item, this.pageId, this.pageName)
... ... @@ -232,7 +232,7 @@ export struct LiveHorizontalCardComponent {
}
})
.width(CommonConstants.FULL_WIDTH)
.height(this.compDTO.operDataList.length == 2 ? 180 : 136)
.height(this.compDTO.operDataList.length == 2 ? 180 : 148)
} else if (this.compDTO.operDataList.length) {
// 一个
LiveHorizontalCardForOneComponent({ contentDTO: this.compDTO.operDataList[0] })
... ...
... ... @@ -263,6 +263,13 @@ export class PageViewModel extends BaseViewModel {
})
}
/**
*
* @param type 1:正在直播,2:预告
* @param pageNum
* @param pageSize
* @returns
*/
async getLiveMoreUrl(type: number, pageNum: number, pageSize: number): Promise<LiveReviewDTO> {
return new Promise<LiveReviewDTO>((success, error) => {
Logger.info(TAG, `getLiveMoreUrl pageInfo start`);
... ... @@ -363,21 +370,22 @@ export class PageViewModel extends BaseViewModel {
async getPageGroupCacheData(pageModel: PageUIReqBean): Promise<PageDTO | null> {
Logger.debug(TAG, 'getPageData pageId: ' + pageModel.pageId);
return new Promise<PageDTO | null>((success) => {
CacheData.getLocalCacheData(CacheData.compGroupInfoDataCacheKey + pageModel.pageId + pageModel.groupId).then((data) => {
// Logger.debug(TAG, 'getPageGroupCacheData 333 ' + JSON.stringify(data));
if (data) {
let navBean = JSON.parse(CacheData.getNetworkData(data)) as PageDTO
success(navBean)
} else {
CacheData.getLocalCacheData(CacheData.compGroupInfoDataCacheKey + pageModel.pageId + pageModel.groupId)
.then((data) => {
// Logger.debug(TAG, 'getPageGroupCacheData 333 ' + JSON.stringify(data));
if (data) {
let navBean = JSON.parse(CacheData.getNetworkData(data)) as PageDTO
success(navBean)
} else {
success(null)
}
})
.catch((err: object) => {
Logger.error(TAG, 'getPageGroupCacheData catch err: ' + JSON.stringify(err));
success(null)
}
}).catch((err: object) => {
Logger.error(TAG, 'getPageGroupCacheData catch err: ' + JSON.stringify(err));
success(null)
})
})
});
}
}
... ...
... ... @@ -33,6 +33,7 @@ export interface recommentVideoListParams {
interface contentListItem {
contentId: string;
contentType: number;
contentRelId?:string
}
export interface contentListParams {
... ...
... ... @@ -17,6 +17,7 @@ import { componentUtils, window } from '@kit.ArkUI';
import { PlayerFullScreenView } from '../view/PlayerFullScreenView';
import { OperRowListView, publishCommentModel } from 'wdComponent/Index';
import { ParamType, TrackConstants } from 'wdTracking/Index';
import { onlyWifiLoadVideo } from 'wdComponent/src/main/ets/utils/lazyloadImg';
const TAG = 'DetailPlayShortVideoPage';
... ... @@ -55,6 +56,8 @@ export struct DetailPlayShortVideoPage {
@State playerHeight: number | string = px2vp(this.windowHeight)
pageParam: ParamType = {}
PageName: string = ''
@State toastText: ResourceStr = "正在使用非WI-FI网络,播放将产生流量费用"
@Consume onlyWifiLoadVideo: boolean
/**
* 页面显示重查用户关注、点赞等信息
... ... @@ -62,7 +65,7 @@ export struct DetailPlayShortVideoPage {
async pageShowChange() {
if (this.currentIndex === this.index) {
this.queryNewsInfoOfUser()
if (this.switchVideoStatus && this.isPlay) {
if (this.switchVideoStatus && this.isPlay && this.onlyWifiLoadVideo) {
await this.playerController.play()
this.imageVisible = false
}
... ... @@ -75,7 +78,7 @@ export struct DetailPlayShortVideoPage {
*/
async videoStatusChange() {
if (this.currentIndex === this.index) {
if (this.switchVideoStatus && this.isPlay) {
if (this.switchVideoStatus && this.isPlay && this.onlyWifiLoadVideo) {
await this.playerController.play()
this.imageVisible = false
} else {
... ... @@ -99,9 +102,18 @@ export struct DetailPlayShortVideoPage {
if (!this.playerController.getPlayer()) {
this.playerController.firstPlay(this.contentDetailData?.videoInfo[0]?.videoUrl || '', this.PageName,
this.PageName, this.pageParam);
this.playerController.onCanplay = async () => {
this.ratio = this.playerController.videoWidth / this.playerController.videoHeight
await this.playerController.play()
this.imageVisible = false
}
} else {
await this.playerController.play()
this.imageVisible = false
if (!this.onlyWifiLoadVideo) {
await this.playerController.pause()
} else {
await this.playerController.play()
this.imageVisible = false
}
}
}
}
... ... @@ -156,15 +168,22 @@ export struct DetailPlayShortVideoPage {
}
aboutToAppear() {
async aboutToAppear() {
if(await onlyWifiLoadVideo()){
this.onlyWifiLoadVideo = true
}
this.videoLandScape = this.contentDetailData.videoInfo[0]?.videoLandScape
this.ratio = (this.contentDetailData.videoInfo[0]?.resolutionWidth || 16) /
(this.contentDetailData.videoInfo[0]?.resolutionHeight || 9)
this.playerController.onCanplay = async () => {
this.ratio = this.playerController.videoWidth / this.playerController.videoHeight
if ((this.index == 0 || this.currentIndex === this.index) && this.switchVideoStatus) {
await this.playerController.play()
this.imageVisible = false
if (!this.onlyWifiLoadVideo) {
await this.playerController.pause()
} else {
await this.playerController.play()
this.imageVisible = false
}
}
}
this.playerController.onTimeUpdate = (position, duration) => {
... ... @@ -261,12 +280,17 @@ export struct DetailPlayShortVideoPage {
playerController: this.playerController
})
if (!this.onlyWifiLoadVideo) {
this.buildContent()
}
}
.width('100%')
.layoutWeight(1)
.onClick(() => {
this.playerController?.switchPlayOrPause();
this.playerController.onStatusChange = (status: number) => {
this.status = status
if (status === PlayerConstants.STATUS_PAUSE) {
this.isPlay = false
} else if(status === PlayerConstants.STATUS_START) {
... ... @@ -303,6 +327,51 @@ export struct DetailPlayShortVideoPage {
}
@Builder
buildContent() {
Row() {
Column(){
Column(){
Text(this.toastText)
.fontFamily('PingFang SC-Regular')
.fontWeight(FontWeight.Regular)
.fontColor('#FFFFFF')
.fontSize(14)
.lineHeight(20)
.textAlign(TextAlign.Center)
}
Column() {
Text("使用流量播放")
.fontFamily('PingFang SC-Regular')
.fontWeight(FontWeight.Regular)
.fontColor(Color.White)
.fontSize(12)
}
.border({ width: 1, color: '#4DFFFFFF', radius: 4 })
.height(28)
.width(88)
.alignItems(HorizontalAlign.Center)
.justifyContent(FlexAlign.Center)
.margin({
top: 16
})
.onClick(() => {
this.onlyWifiLoadVideo = true
this.playerController?.play()
this.imageVisible = false
})
}
.width('100%')
.height(64)
}
.width('100%')
.height('100%')
.alignItems(VerticalAlign.Center)
.justifyContent(FlexAlign.Center)
.backgroundColor('#222222')
.opacity(0.7)
}
/**
* 视频首帧图,用于快速显示
* 竖屏封面顶部仍然有点偏移,待处理
... ...
... ... @@ -39,6 +39,7 @@ export struct DetailVideoListPage {
@State interactDataList: InteractDataDTO[] = []
pageShowTime:number = 0;
pageHideTime:number = 0;
@Provide onlyWifiLoadVideo: boolean = false
async aboutToAppear(): Promise<void> {
// 注册监听网络连接
... ...
... ... @@ -9,12 +9,11 @@ import {
contentListParams,
getRecCompInfoParams
} from 'wdDetailPlayApi/src/main/ets/request/ContentDetailRequest';
import { Logger, WindowModel } from 'wdKit/Index';
import { Logger, WindowModel, DateTimeUtils } from 'wdKit/Index';
import { PictureLoading } from './PictureLoading';
import { DisplayDirection } from 'wdConstant/Index';
import { window } from '@kit.ArkUI';
import { EmptyComponent, WDViewDefaultType } from 'wdComponent/Index';
import { DateTimeUtils } from 'wdKit/Index';
import { TrackConstants, TrackingPageBrowse } from 'wdTracking/Index';
interface loadMoreData {
... ... @@ -65,6 +64,7 @@ export struct VideoChannelDetail {
@State isRequesting: boolean = false
pageShowTime: number = 0;
pageHideTime: number = 0;
@Provide onlyWifiLoadVideo: boolean = false
autoRefreshChange() {
if (this.topNavIndex === 0 && !this.isRequesting) {
... ...
... ... @@ -13,6 +13,7 @@ export struct PlayerBottomView {
@Consume isDragging?: boolean
@Consume contentDetailData: ContentDetailDTO
@Consume displayDirection: DisplayDirection
@Consume onlyWifiLoadVideo: boolean
aboutToAppear(): void {
... ...
... ... @@ -14,11 +14,9 @@ export struct PlayerProgressView {
@State loadingTop: number = 10
@State loadingWidth: number | string = 1
@State showLoading: boolean = false
@Consume onlyWifiLoadVideo: boolean
aboutToAppear() {
if (this.playerController) {
this.playerController.onStatusChange = (status: number) => {
this.status = status
}
this.playerController.onSeekDone = (status: number) => {
this.playerController?.play()
}
... ... @@ -26,7 +24,9 @@ export struct PlayerProgressView {
this.playerController.onLoaded = (loaded: number) => {
if(loaded == 1) {
this.loadingWidth = '95%'
this.showLoading = true
if (this.onlyWifiLoadVideo) {
this.showLoading = true
}
} else {
this.loadingWidth = 1
this.showLoading = false
... ...
... ... @@ -249,6 +249,8 @@ export struct PlayerRightView {
pageID: ''
}
WDRouterRule.jumpWithPage(WDRouterPage.peopleShipHomePage, params)
} else {
ToastUtils.showToast("暂时无法查看该创作者主页", 2000);
}
})
... ...
... ... @@ -14,7 +14,7 @@ interface obj {
@Observed
export class WDPlayerController {
private initPromise: Promise<void>;
private avPlayer?: media.AVPlayer;
private avPlayer?: media.AVPlayer | null;
private duration: number = 0;
private status: number = PlayerConstants.STATUS_IDLE;
private loop: boolean = true;
... ... @@ -196,6 +196,7 @@ export class WDPlayerController {
}
if (this.avPlayer == null) {
console.log("等待")
this.initPromise = this.createAVPlayer();
await this.initPromise;
} else {
if (this.avPlayer.state != AVPlayerStatus.IDLE) {
... ... @@ -225,7 +226,7 @@ export class WDPlayerController {
return
}
this.avPlayer.release()
this.avPlayer = undefined
this.avPlayer = null
}
... ...
... ... @@ -9,35 +9,25 @@ const TAG = 'DynamicDetailPage';
@Component
struct DynamicDetailPage {
pageShowTime:number = 0;
@State relId: string = ''
@State contentId: string = ''
@State relType: string = ''
@Provide pageName: string = TrackConstants.PageName.DynamicDetail
@Provide pageId: string = TrackConstants.PageName.DynamicDetail
build() {
Column() {
DynamicDetailComponent({
relId: this.relId,
contentId: this.contentId,
relType: this.relType
})
DynamicDetailComponent({action: router.getParams() as Action })
}
.height('100%')
.width('100%')
.backgroundColor('#20272E')
}
aboutToAppear() {
let par:Action = router.getParams() as Action;
let params = par?.params;
this.relId = params?.extra?.relId || '';
this.relType = params?.extra?.relType || '';
this.contentId = params?.contentID || '';
}
onPageShow() {
this.pageShowTime = DateTimeUtils.getTimeStamp()
}
onPageHide() {
//页面浏览
TrackingPageBrowse.trackCommonPageExposureEnd(TrackConstants.PageName.DynamicDetail,TrackConstants.PageName.DynamicDetail,Math.floor((DateTimeUtils.getTimeStamp() - this.pageShowTime)/1000))
... ...
... ... @@ -7,7 +7,6 @@ import LaunchDataModel, { defaultLaunchModel } from '../viewModel/LaunchDataMode
import { ParamType, TrackConstants, TrackingButton, TrackingContent } from 'wdTracking/Index';
import { ContentDTO } from 'wdBean/Index';
import { Core } from '@ohos/hypium';
@Entry
... ... @@ -19,6 +18,8 @@ struct LaunchAdvertisingPage {
@State defaultModel:defaultLaunchModel = new defaultLaunchModel()
private controller:VideoController | undefined;
enter() {
WDRouterRule.jumpWithReplacePage(WDRouterPage.mainPage)
clearInterval(this.timer)
... ... @@ -60,6 +61,14 @@ struct LaunchAdvertisingPage {
Column(){
if(this.defaultModel.showType === '1'){
//显示视频播放
Video({
src: this.defaultModel.bootVideoUrl,
previewUri: this.defaultModel.bootVideoScreenUrl,
controller: this.controller
})
.objectFit(ImageFit.Contain) //设置视频适配模式
.width('100%')
.height('100%')
}else {
//显示图片
Image(this.defaultModel.bootScreenUrl)
... ... @@ -104,8 +113,8 @@ struct LaunchAdvertisingPage {
.margin({top:'10lpx',right:'19lpx'})
.backgroundColor('#80000000')
.onClick(() => {
this.enter()
this.trackingLaunchJumpOver()
this.enter()
}).margin({right:16})
}.margin({top:50}).width('100%').height('56lpx')
... ...