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
liyubing
2024-06-12 17:46:58 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
77d96d7c81ea719e36cc5a863c0b1c51eb3a906a
77d96d7c
1 parent
99d607b1
feat:
1)直播预告页面改造成使用通用模板组件
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
657 additions
and
643 deletions
sight_harmony/features/wdBean/src/main/ets/bean/content/ContentDTO.ets
sight_harmony/features/wdBean/src/main/ets/bean/live/ReserveItemBean.ets
sight_harmony/features/wdComponent/src/main/ets/components/CardParser.ets
sight_harmony/features/wdComponent/src/main/ets/components/CompParser.ets
sight_harmony/features/wdComponent/src/main/ets/components/cardview/LiveBigImage01Component.ets
sight_harmony/features/wdComponent/src/main/ets/components/cardview/LiveBigImage02Component.ets
sight_harmony/features/wdComponent/src/main/ets/components/page/LiveMorePage.ets
sight_harmony/features/wdComponent/src/main/ets/components/page/template/BasePageHelp.ets
sight_harmony/features/wdComponent/src/main/ets/components/page/template/TemplatePageComponent.ets
sight_harmony/features/wdComponent/src/main/ets/components/page/template/TemplatePageConstant.ets
sight_harmony/features/wdComponent/src/main/ets/components/page/template/TemplatePageHelp.ets
sight_harmony/features/wdComponent/src/main/ets/components/page/template/TemplatePageModel.ets
sight_harmony/features/wdComponent/src/main/ets/components/reserveMore/ReserveMorePage.ets
sight_harmony/features/wdComponent/src/main/ets/viewmodel/PageViewModel.ets
sight_harmony/features/wdBean/src/main/ets/bean/content/ContentDTO.ets
View file @
77d96d7
...
...
@@ -8,6 +8,7 @@ import { RmhInfoDTO } from '../detail/RmhInfoDTO';
import { commentInfo } from './commentInfo';
import { BaseDTO } from '../component/BaseDTO';
import { LiveRoomDataBean } from '../live/LiveRoomDataBean';
import { ReserveItemBean } from '../live/ReserveItemBean';
export class ContentShareInfoDTO {
shareTitle: string = ''
...
...
@@ -67,8 +68,8 @@ export class ContentDTO implements BaseDTO {
vImageUrl: string = '';
screenType: string = '';
source: string = '';
objectId: string = '';
objectType: string = '';
objectId: string = '';
objectLevel: string = '';
channelId: string = '';
relId: string = '';
...
...
@@ -115,7 +116,11 @@ export class ContentDTO implements BaseDTO {
//本地字段:时间轴专题页节点组件时间;【如果开启模糊则显示时间->左右;0:否,1:是】
timeBlurred:number = 0
top:number = 0
// 直播预约状态
reserveItemBean : ReserveItemBean = new ReserveItemBean(-1,this.relId,false)
// keyGenerator相关字符串,用于刷新list布局
timestamp: String = '1'
// 自定义参数,用于跳转对应页面时 传递targetLayout参数用
customParamTargetLayout?: string
...
...
sight_harmony/features/wdBean/src/main/ets/bean/live/ReserveItemBean.ets
View file @
77d96d7
@Observed export class ReserveItemBean {
@Observed export class
ReserveItemBean {
liveId: number
relationId: string
subscribe: boolean
...
...
sight_harmony/features/wdComponent/src/main/ets/components/CardParser.ets
View file @
77d96d7
...
...
@@ -19,6 +19,7 @@ import { SearchContentComponent } from './cardview/SearchContentComponent';
import { DateTimeUtils } from 'wdKit/Index';
import { TrackConstants, TrackingPageBrowse } from 'wdTracking/Index';
import { LiveBigImage02Component } from './cardview/LiveBigImage02Component';
import { LiveBigImage01Component } from './cardview/LiveBigImage01Component';
/**
* card适配器,卡片样式汇总,依据ContentDTO#appStyle
...
...
@@ -26,13 +27,13 @@ import { LiveBigImage02Component } from './cardview/LiveBigImage02Component';
*/
@Component
export struct CardParser {
@State pageId: string = '';
@State pageName: string = '';
@State contentDTO: ContentDTO = new ContentDTO();
@State compIndex: number = 0;
@ObjectLink compDTO: CompDTO
pageShowTime:number = 0;
pageHideTime:number = 0;
pageShowTime: number = 0;
pageHideTime: number = 0;
aboutToAppear(): void {
console.log('CardParser-', JSON.stringify(this.contentDTO))
...
...
@@ -46,8 +47,9 @@ export struct CardParser {
onPageHide(): void {
this.pageHideTime = DateTimeUtils.getTimeStamp()
let duration = 0
duration = Math.floor((this.pageHideTime - this.pageShowTime)/1000)
TrackingPageBrowse.trackCommonPageExposureEnd(TrackConstants.PageName.Customer_Personal,TrackConstants.PageName.Customer_Personal,duration)
duration = Math.floor((this.pageHideTime - this.pageShowTime) / 1000)
TrackingPageBrowse.trackCommonPageExposureEnd(TrackConstants.PageName.Customer_Personal,
TrackConstants.PageName.Customer_Personal, duration)
}
build() {
...
...
@@ -58,41 +60,136 @@ export struct CardParser {
contentBuilder(contentDTO: ContentDTO) {
// Card6Component({ compDTO: this.compDTO, contentDTO: this.contentDTO })
if (!!contentDTO.contentText) {
SearchContentComponent({ contentDTO, compDTO: this.compDTO, pageId: this.pageId, pageName: this.pageName })
SearchContentComponent({
contentDTO,
compDTO: this.compDTO,
pageId: this.pageId,
pageName: this.pageName
})
} else {
if (contentDTO.appStyle === CompStyle.Card_02) {
Card2Component({ compDTO: this.compDTO, contentDTO, pageId: this.pageId, pageName: this.pageName })
Card2Component({
compDTO: this.compDTO,
contentDTO,
pageId: this.pageId,
pageName: this.pageName
})
} else if (contentDTO.appStyle === CompStyle.Card_03) {
Card3Component({ compDTO: this.compDTO, contentDTO, pageId: this.pageId, pageName: this.pageName })
}else if (contentDTO.appStyle === CompStyle.Card_04) {
Card4Component({ compDTO: this.compDTO, contentDTO, pageId: this.pageId, pageName: this.pageName })
} else if (contentDTO.appStyle === CompStyle.Card_05) {
Card5Component({ compDTO: this.compDTO, contentDTO, titleShowPolicy: this.compDTO.titleShowPolicy, pageId: this.pageId, pageName: this.pageName})
} else if (contentDTO.appStyle === CompStyle.Card_06 || contentDTO.appStyle === CompStyle.Card_13 ) {
Card6Component({ compDTO: this.compDTO, contentDTO: this.contentDTO, pageId: this.pageId, pageName: this.pageName })
Card3Component({
compDTO: this.compDTO,
contentDTO,
pageId: this.pageId,
pageName: this.pageName
})
} else if (contentDTO.appStyle === CompStyle.Card_04) {
Card4Component({
compDTO: this.compDTO,
contentDTO,
pageId: this.pageId,
pageName: this.pageName
})
} else if (contentDTO.appStyle === CompStyle.Card_05) {
Card5Component({
compDTO: this.compDTO,
contentDTO,
titleShowPolicy: this.compDTO.titleShowPolicy,
pageId: this.pageId,
pageName: this.pageName
})
} else if (contentDTO.appStyle === CompStyle.Card_06 || contentDTO.appStyle === CompStyle.Card_13) {
Card6Component({
compDTO: this.compDTO,
contentDTO: this.contentDTO,
pageId: this.pageId,
pageName: this.pageName
})
} else if (contentDTO.appStyle === CompStyle.Card_10) {
Card10Component({ compDTO: this.compDTO, contentDTO, pageId: this.pageId, pageName: this.pageName })
Card10Component({
compDTO: this.compDTO,
contentDTO,
pageId: this.pageId,
pageName: this.pageName
})
} else if (contentDTO.appStyle === CompStyle.Card_11) {
Card11Component({ compDTO: this.compDTO, contentDTO, pageId: this.pageId, pageName: this.pageName })
Card11Component({
compDTO: this.compDTO,
contentDTO,
pageId: this.pageId,
pageName: this.pageName
})
} else if (contentDTO.appStyle === CompStyle.Card_12) {
Card12Component({ compDTO: this.compDTO, contentDTO, pageId: this.pageId, pageName: this.pageName })
Card12Component({
compDTO: this.compDTO,
contentDTO,
pageId: this.pageId,
pageName: this.pageName
})
} else if (contentDTO.appStyle === CompStyle.Card_14) {
Card14Component({ contentDTO, compDTO: this.compDTO, pageId: this.pageId, pageName: this.pageName })
Card14Component({
contentDTO,
compDTO: this.compDTO,
pageId: this.pageId,
pageName: this.pageName
})
} else if (contentDTO.appStyle === CompStyle.Card_15) {
Card15Component({ contentDTO, compDTO: this.compDTO, pageId: this.pageId, pageName: this.pageName })
Card15Component({
contentDTO,
compDTO: this.compDTO,
pageId: this.pageId,
pageName: this.pageName
})
} else if (contentDTO.appStyle === CompStyle.Card_16) {
Card16Component({ contentDTO, compDTO: this.compDTO, pageId: this.pageId, pageName: this.pageName })
Card16Component({
contentDTO,
compDTO: this.compDTO,
pageId: this.pageId,
pageName: this.pageName
})
} else if (contentDTO.appStyle === CompStyle.Card_17) {
Card17Component({ compDTO: this.compDTO, contentDTO, pageId: this.pageId, pageName: this.pageName })
Card17Component({
compDTO: this.compDTO,
contentDTO,
pageId: this.pageId,
pageName: this.pageName
})
} else if (contentDTO.appStyle === CompStyle.Card_19) {
Card19Component({ contentDTO, compDTO: this.compDTO, pageId: this.pageId, pageName: this.pageName })
Card19Component({
contentDTO,
compDTO: this.compDTO,
pageId: this.pageId,
pageName: this.pageName
})
} else if (contentDTO.appStyle === CompStyle.Card_20) {
Card20Component({ contentDTO, compDTO: this.compDTO, pageId: this.pageId, pageName: this.pageName })
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 })
Card21Component({
contentDTO,
compDTO: this.compDTO,
pageId: this.pageId,
pageName: this.pageName
})
} else if (contentDTO.appStyle === CompStyle.Card_Comp_Live_Big_Image_01) {
LiveBigImage01Component({
contentDTO: contentDTO,
compDTO: this.compDTO,
pageId: this.pageId,
pageName: this.pageName,
index: this.compIndex
})
} else if (contentDTO.appStyle === CompStyle.Card_Comp_Live_Big_Image_02) {
LiveBigImage02Component({ contentDTO:contentDTO, compDTO: this.compDTO, pageId: this.pageId, pageName: this.pageName })
}else {
LiveBigImage02Component({
contentDTO: contentDTO,
compDTO: this.compDTO,
pageId: this.pageId,
pageName: this.pageName
})
} else {
// todo:组件未实现 / Component Not Implemented
// Text(contentDTO.appStyle)
// .width(CommonConstants.FULL_PARENT)
...
...
sight_harmony/features/wdComponent/src/main/ets/components/CompParser.ets
View file @
77d96d7
...
...
@@ -58,7 +58,7 @@ export struct CompParser {
this.compDTO.operDataList = this.noneAudioItems;
}
// 金刚卡屏蔽音频类型稿件
if (this.compDTO.compStyle === CompStyle.Zh_Grid_Layout_03) {
if (this.compDTO.compStyle === CompStyle.Zh_Grid_Layout_03) {
this.audioItems = this.compDTO.operDataList.filter(item => {
return item.objectType === '13' || item.linkUrl.includes('audiotopic')
})
...
...
@@ -96,9 +96,17 @@ export struct CompParser {
Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
} else if (this.compDTO.compStyle === CompStyle.Zh_Single_Row_01 && this.compDTO.imageScale === 3) {
if (this.compDTO.operDataList.length > 1) {
HorizontalStrokeCardThreeTwoRadioForMoreComponent({ compDTO: this.compDTO, pageId: this.pageId, pageName: this.pageName })
HorizontalStrokeCardThreeTwoRadioForMoreComponent({
compDTO: this.compDTO,
pageId: this.pageId,
pageName: this.pageName
})
} else {
HorizontalStrokeCardThreeTwoRadioForOneComponent({ compDTO: this.compDTO, pageId: this.pageId, pageName: this.pageName })
HorizontalStrokeCardThreeTwoRadioForOneComponent({
compDTO: this.compDTO,
pageId: this.pageId,
pageName: this.pageName
})
}
Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
} else if (this.compDTO.compStyle === CompStyle.Zh_Single_Row_02) {
...
...
@@ -113,7 +121,12 @@ export struct CompParser {
// Divider().strokeWidth(5).color('#f5f5f5').padding({ left: 0, right: 0 })
} else if (this.compDTO.compStyle === CompStyle.Card_Comp_Zh_Grid_Layout_02) { //双列流小视频,一行两图卡
ZhGridLayout02NewsContent({ compDTO: this.compDTO, operDataList: this.compDTO.operDataList, pageId: this.pageId, pageName: this.pageName })
ZhGridLayout02NewsContent({
compDTO: this.compDTO,
operDataList: this.compDTO.operDataList,
pageId: this.pageId,
pageName: this.pageName
})
} else if (this.compDTO.compStyle === CompStyle.Zh_Grid_Layout_03) {
ZhGridLayout03({ compDTO: this.compDTO, pageId: this.pageId, pageName: this.pageName })
...
...
@@ -139,24 +152,39 @@ export struct CompParser {
Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
} else if (this.compDTO.compStyle === CompStyle.Zh_Single_Column_03) {
// 大图卡
Card2Component({ compDTO: this.compDTO, contentDTO: this.compDTO.operDataList[0], pageId: this.pageId, pageName: this.pageName })
Card2Component({
compDTO: this.compDTO,
contentDTO: this.compDTO.operDataList[0],
pageId: this.pageId,
pageName: this.pageName
})
Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
} else if (this.compDTO.compStyle === CompStyle.Card_09) {
//时间链卡
Card9Component({
compDTO: this.compDTO,
contentDTO:this.compDTO.operDataList[0],
contentDTO:
this.compDTO.operDataList[0],
pageId: this.pageId,
pageName: this.pageName
})
Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
} else if(this.compDTO.compStyle === CompStyle.Card_13){
Card6Component({ compDTO: this.compDTO, contentDTO: this.compDTO.operDataList[0], pageId: this.pageId, pageName: this.pageName })
} else if (this.compDTO.compStyle === CompStyle.Card_13) {
Card6Component({
compDTO: this.compDTO,
contentDTO: this.compDTO.operDataList[0],
pageId: this.pageId,
pageName: this.pageName
})
Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
} else if(this.compDTO.compStyle === CompStyle.Card_03){
Card3Component({ compDTO: this.compDTO, contentDTO: this.compDTO.operDataList[0], pageId: this.pageId, pageName: this.pageName })
} else if (this.compDTO.compStyle === CompStyle.Card_03) {
Card3Component({
compDTO: this.compDTO,
contentDTO: this.compDTO.operDataList[0],
pageId: this.pageId,
pageName: this.pageName
})
Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
}else if (this.compDTO.compStyle === CompStyle.Zh_Single_Column_04) {
}
else if (this.compDTO.compStyle === CompStyle.Zh_Single_Column_04) {
ZhSingleColumn04({ compDTO: this.compDTO, pageId: this.pageId, pageName: this.pageName })
Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
} else if (this.compDTO.compStyle === CompStyle.Zh_Single_Column_05) {
...
...
@@ -170,7 +198,13 @@ export struct CompParser {
//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)) || this.compDTO.compType === 'appStyle') {
CardParser({ contentDTO: this.compDTO.operDataList[0], compDTO: this.compDTO, pageId: this.pageId, pageName: this.pageName });
CardParser({
contentDTO: this.compDTO.operDataList[0],
compDTO: this.compDTO,
pageId: this.pageId,
pageName: this.pageName,
compIndex: this.compIndex
});
Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
} else {
// Text(this.compDTO.compStyle)
...
...
sight_harmony/features/wdComponent/src/main/ets/components/cardview/LiveBigImage01Component.ets
0 → 100644
View file @
77d96d7
import { CompDTO, ContentDTO } from 'wdBean';
import { ProcessUtils, WDRouterPage, WDRouterRule } from 'wdRouter';
import { onlyWifiLoadImg } from '../../utils/lazyloadImg';
import { hasClicked } from '../../utils/persistentStorage';
import { ToastUtils } from 'wdKit/Index';
import { router } from '@kit.ArkUI';
import { TrackConstants, Tracking, TrackingContent, TrackParamConvert } from 'wdTracking/Index';
import { HttpUtils } from 'wdNetwork/Index';
import { LiveModel } from '../../viewmodel/LiveModel';
const TAG: string = 'LiveBigImage01Component';
/**
* 本地样式卡:直播预约卡
*/
@Component
export struct LiveBigImage01Component {
@ObjectLink compDTO: CompDTO
@State pageId: string = '';
@State pageName: string = '';
@State contentDTO: ContentDTO = new ContentDTO();
@State loadImg: boolean = false;
@State clicked: boolean = false;
index: number = 0
@State isLoadingAttention: boolean = false
async aboutToAppear() {
const curRouter = router.getState().name;
this.clicked = hasClicked(this.contentDTO.objectId, curRouter)
this.loadImg = await onlyWifiLoadImg();
}
build() {
Column() {
Stack() {
Image(this.loadImg ? this.contentDTO.fullColumnImgUrls[0]?.url : '')
.width('100%')
.aspectRatio(16 / 9)
.backgroundColor(this.loadImg ? $r('app.color.color_B0B0B0') : $r('app.color.color_33A3A3A3'))
.objectFit(ImageFit.Contain)
.borderWidth(0.5)
.borderColor($r('app.color.color_0D000000'))
.borderRadius({
topLeft: '4vp',
topRight: '4vp'
})
this.LiveImage()
}
.alignContent(Alignment.BottomEnd)
Text(this.contentDTO.newsTitle)
.fontSize(17)
.maxLines(2)
.lineHeight(25)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.margin({ top: 4, left: 12, right: 12 })
.alignSelf(ItemAlign.Start)
Row() {
if (this.contentDTO.liveInfo && this.contentDTO.liveInfo.liveStartTime) {
Row() {
Image($r('app.media.reserve_play_icon'))
.width(20)
.height(20)
.margin({
left: 10,
top: 2,
bottom: 2,
right: 6
})
Text(this.getReserveDate(this.contentDTO.liveInfo.liveStartTime, 1))
.fontSize(12)
.fontWeight(500)
.fontColor('#ED2800')
.fontFamily('PingFang SC-Medium')
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.margin({ top: 8, bottom: 8 })
.align(Alignment.Start)
Image($r('app.media.point_icon'))
.objectFit(ImageFit.Auto)
.interpolation(ImageInterpolation.High)
.width(6)
.height(16)
.margin(2)
Text(this.getReserveDate(this.contentDTO.liveInfo.liveStartTime, 2))
.fontSize(12)
.fontWeight(500)
.fontColor('#ED2800')
.fontFamily('PingFang SC-Medium')
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.margin({ top: 8, bottom: 8, right: 10 })
.align(Alignment.Start)
}
.backgroundColor('#F5F5F5')
.margin(12)
}
// 预约
Row() {
LoadingProgress()
.width(20)
.height(20)
.color(!this.isReserved() ? $r('app.color.color_fff') : $r('app.color.color_CCCCCC'))
.visibility((this.isLoadingAttention) ? Visibility.Visible :
Visibility.None)
Text(!this.isReserved() ? '预约' : '已预约')
.fontSize($r('app.float.vp_12'))
.fontWeight(500)
.fontColor(!this.isReserved() ? $r('app.color.color_fff') : $r('app.color.color_CCCCCC'))
.width('100%')
.height('100%')
.textAlign(TextAlign.Center)
.visibility((this.isLoadingAttention) ? Visibility.None :
Visibility.Visible)
.margin({
right: '10vp'
})
.textShadow({
radius: 2,
color: 'rgba(0,0,0,0.3)',
offsetY: 2
})
.backgroundColor(!this.isReserved() ? $r('app.color.color_ED2800') : $r('app.color.color_F5F5F5'))
.borderRadius(3)
}
.onClick(() => {
this.bookAndCancel(this.contentDTO)
})
.justifyContent(FlexAlign.Center)
.alignItems(VerticalAlign.Center)
.borderRadius(3)
.width('52vp')
.height('24vp')
.margin({ right: 12 })
}
.width('100%')
.justifyContent(FlexAlign.SpaceBetween)
}
.borderRadius(4)
.backgroundColor(Color.White)
.width('calc(100% - 24vp)')
.margin({
left: '12vp',
right: '12vp',
top: this.index == 0 ? '12vp' : '8vp'
})
.onClick(() => {
// 内容点击埋点
TrackingContent.common(TrackConstants.EventType.Click,
this.pageId,
this.pageId,
TrackParamConvert.program(this.contentDTO))
ProcessUtils.processPage(this.contentDTO)
})
.onVisibleAreaChange([0, 1], (isVisiable: boolean, ratio: number) => {
if (isVisiable) {
// 内容曝光埋点
TrackingContent.common(TrackConstants.EventType.Show,
this.pageId,
this.pageId,
TrackParamConvert.program(this.contentDTO))
}
})
}
@Builder
LiveImage() {
Row() {
Image($r('app.media.reserve_new_icon'))
.width(14)
.height(14)
.margin({
right: 3
})
Text('预约')
.fontSize('12vp')
.fontWeight(400)
.fontColor(Color.White)
.textShadow({
radius: 2,
color: 'rgba(0,0,0,0.3)',
offsetY: 2
})
}
.backgroundColor(Color.Transparent)
.margin({ right: 8, bottom: 8 })
}
getReserveDate(eventDateTimeString: string, type: number): string {
// 解析事件的日期和时间
const eventDateTime = new Date(eventDateTimeString);
const currentDateTime = new Date();
// 截取事件时间的小时和分钟(假设事件时间是按照24小时制)
const eventHour = eventDateTime.getHours();
const eventMinutes = eventDateTime.getMinutes();
const eventTimeStr = `${eventHour}:${eventMinutes.toString().padStart(2, '0')}开始`; // 格式化时间,确保分钟是两位数
if (type === 1) {
// 判断是否是今天
const eventDate = eventDateTime.setHours(0, 0, 0, 0);
const currentDate = currentDateTime.setHours(0, 0, 0, 0);
if (eventDate === currentDate) {
return `今天`;
} else {
const month = eventDateTime.getMonth() + 1;
const date = eventDateTime.getDate();
return `${month}月${date}日`;
}
} else {
return `${eventTimeStr}`;
}
}
// 预约/取消预约
async bookAndCancel(item: ContentDTO) {
// 未登录,跳转登录
if (!HttpUtils.getUserId()) {
WDRouterRule.jumpWithPage(WDRouterPage.loginPage)
return
}
if (!this.isLoadingAttention) {
this.isLoadingAttention = true
const reserveItem = item.reserveItemBean
if (reserveItem) {
this.isLoadingAttention = true
try {
// 埋点
Tracking.event(!reserveItem.subscribe ? "live_subscribe_click" : "cancel_live_subscribe_click",
TrackParamConvert.program(item))
const res = await LiveModel.liveAppointment(reserveItem.relationId, reserveItem.liveId.toString(),
!reserveItem.subscribe);
if (res.code == 0) {
ToastUtils.shortToast(!reserveItem.subscribe ? '预约成功' : '取消预约成功')
reserveItem.subscribe = !reserveItem.subscribe ? true : false
}
this.isLoadingAttention = false
} catch (e) {
this.isLoadingAttention = false
}
} else {
this.isLoadingAttention = false
}
}
}
// 判断是否预约
isReserved() {
if (this.compDTO.operDataList[0].reserveItemBean == undefined) {
return false
}
return this.compDTO.operDataList[0].reserveItemBean.subscribe
}
}
\ No newline at end of file
...
...
sight_harmony/features/wdComponent/src/main/ets/components/cardview/LiveBigImage02Component.ets
View file @
77d96d7
...
...
@@ -2,12 +2,11 @@ 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-Card13
Component';
const TAG: string = '
LiveBigImage02
Component';
/**
* 本地样式卡:直播大图卡
...
...
sight_harmony/features/wdComponent/src/main/ets/components/page/LiveMorePage.ets
View file @
77d96d7
...
...
@@ -23,7 +23,7 @@ struct LiveMorePage {
//常见标题
CommonPageTitle({ title: this.title })
// 通用模板组件
TemplatePageComponent({ pageDataSourceType: TemplatePageConstant.LIVE_HORIZONTAL_
CARD
})
TemplatePageComponent({ pageDataSourceType: TemplatePageConstant.LIVE_HORIZONTAL_
PAGE
})
}
.height('100%')
...
...
sight_harmony/features/wdComponent/src/main/ets/components/page/template/BasePageHelp.ets
View file @
77d96d7
import { ArrayList } from '@kit.ArkTS'
import { CompDTO, ContentDTO, LiveRoomDataBean } from 'wdBean/Index'
import { CompDTO, ContentDTO, LiveRoomDataBean, ReserveBean, ReserveItemBean } from 'wdBean/Index'
import { DateTimeUtils, Logger } from 'wdKit/Index'
import { HttpUtils } from 'wdNetwork/Index'
import { LiveModel } from '../../../viewmodel/LiveModel'
import PageViewModel from '../../../viewmodel/PageViewModel'
const TAG: string = 'BaseTemplateHelp'
export class BasePageHelp {
/**
* 请求获取直播房间的动态数据
* @param list
* 批查直播预约数据
* @param compList
*/
async getAppointmentInfo(compList: CompDTO[]) {
if (HttpUtils.getUserId()) {
let time = DateTimeUtils.getTimeStamp().toString()
Logger.debug(TAG, 'getAppointmentInfo-->'+time)
const reserveBean = this.transformToLiveDetailsBeans(compList)
LiveModel.getAppointmentStatus(reserveBean).then((result) => {
Logger.debug(TAG, '是否预约数据:' + ` ${JSON.stringify(result)}`)
if (result && result.length > 0) {
for (let item of result) {
for (let compItem of compList) {
if (item.liveId.toString() == compItem.operDataList[0].objectId) {
compItem.operDataList[0].reserveItemBean = item
compItem.timestamp = time
break
}
}
}
}
}).catch(() => {
})
} else {
}
}
// 这个函数遍历liveReviewDTO.list并转换为LiveDetailsBean数组
transformToLiveDetailsBeans(compList: CompDTO[]): ReserveBean[] {
let list: ContentDTO[] = []
compList.forEach(compBean => {
if (compBean.operDataList && compBean.operDataList.length > 0) {
list.push(compBean.operDataList[0])
}
})
const liveDetailsBeans: ReserveBean[] = [];
list.forEach(item => {
liveDetailsBeans.push({
relationId: item.relId,
liveId: item.objectId,
});
});
return liveDetailsBeans
}
/**
* 直播回看的批查数据
* @param list
* 请求获取直播房间的动态数据
* @param compList
*/
getLiveRoomDataInfo(compList: CompDTO[]) {
getLiveRoomDataInfo(compList: CompDTO[]) {
let list: ContentDTO[] = []
compList.forEach((comp: CompDTO) => {
list.push(...comp.operDataList)
list.push(...comp.operDataList)
})
let time = DateTimeUtils.getTimeStamp().toString()
...
...
@@ -48,6 +97,7 @@ export class BasePageHelp {
}).catch(() => {
})
}
/**
* 获取业务内容 objectId 集合穿 如1,2,3
* @param pageContentList
...
...
sight_harmony/features/wdComponent/src/main/ets/components/page/template/TemplatePageComponent.ets
View file @
77d96d7
import { CompDTO, ContentDTO } from 'wdBean/Index'
import { LazyDataSource, Logger } from 'wdKit/Index'
import { CompDTO, ContentDTO, ReserveItemBean } from 'wdBean/Index'
import { DateTimeUtils, EmitterEventId, EmitterUtils, LazyDataSource, Logger } from 'wdKit/Index'
import { CompParser } from '../../CompParser'
import { CustomPullToRefresh } from '../../reusable/CustomPullToRefresh'
import { PeopleShipNoMoreData } from '../../reusable/PeopleShipNoMoreData'
...
...
@@ -23,7 +23,6 @@ const TAG: string = 'TemplatePageComponent';
*/
@Component
export default struct TemplatePageComponent {
// 模板页面的数据驱动对象
@State private templatePage: TemplatePageModel = new TemplatePageModel
// 此内容主要因CustomPullToRefresh需要,目前没任何业务意义要求
...
...
@@ -32,7 +31,7 @@ export default struct TemplatePageComponent {
private templateScroller: Scroller = new Scroller()
//识别不同页面的业务类型
pageDataSourceType: string = ''
@State listColor: Resource = $r('app.color.color_fff')
// 埋点字段
pageId: string = ''
pageName: string = ''
...
...
@@ -40,6 +39,38 @@ export default struct TemplatePageComponent {
async aboutToAppear() {
Logger.debug(TAG, 'aboutToAppear')
this.requestPageData()
// 登录成功
EmitterUtils.receiveEvent(EmitterEventId.LOGIN_SUCCESS, () => {
Logger.debug(TAG, 'receiveEvent-----LOGIN_SUCCESS----------')
this.templatePage.isEmitter = true
this.templatePage.currentPage = 1
this.requestPageData()
})
// 获取预约
EmitterUtils.receiveEvent(EmitterEventId.LIVE_ROOM_SUBSCRIBE, (str?: string) => {
Logger.debug(TAG, 'receiveEvent LIVE_ROOM_SUBSCRIBE: ' + str)
if (str) {
// 跳转指定频道场景,传参底导id、频道id
const model: ReserveItemBean = JSON.parse(str)
Logger.debug(TAG, '是否关注元数据0:' + ` ${model.liveId}`)
for (let compItem of this.templatePage.compList.getDataArray()) {
let compBean = compItem as CompDTO
if (compBean.operDataList && compBean.operDataList[0]) {
let liveStr = new String(model.liveId)
if (compBean.operDataList[0].objectId == liveStr) {
compBean.operDataList[0].reserveItemBean.subscribe = model.subscribe
let time = DateTimeUtils.getTimeStamp().toString()
compBean.timestamp = time
break
}
}
}
}
})
}
aboutToDisappear(): void {
...
...
@@ -51,6 +82,7 @@ export default struct TemplatePageComponent {
this.LoadingLayout()
} else if (this.templatePage.pageCompType === TemplatePageStateType.LOADED) {
CustomPullToRefresh({
alldata: this.pageData,
scroller: this.templateScroller,
...
...
@@ -63,7 +95,7 @@ export default struct TemplatePageComponent {
this.templatePage.resolve = resolve
this.requestPageData(resolve)
},
})
})
.backgroundColor(this.listColor)
} else {
EmptyComponent({
...
...
sight_harmony/features/wdComponent/src/main/ets/components/page/template/TemplatePageConstant.ets
View file @
77d96d7
...
...
@@ -10,7 +10,12 @@ export class TemplatePageConstant {
/**
* 直播中
*/
public static LIVE_HORIZONTAL_CARD: string = "LIVE_HORIZONTAL_CARD"
public static LIVE_HORIZONTAL_PAGE: string = "live_horizontal_page"
/**
* 直播预告
*/
public static LIVE_PORTEND_PAGE :string = 'live_portend_page'
}
\ No newline at end of file
...
...
sight_harmony/features/wdComponent/src/main/ets/components/page/template/TemplatePageHelp.ets
View file @
77d96d7
import { CompDTO } from 'wdBean/Index';
import { CompStyle } from 'wdConstant/Index';
import { NetworkUtil } from 'wdKit/Index';
import {
DateTimeUtils,
NetworkUtil } from 'wdKit/Index';
import PageViewModel from '../../../viewmodel/PageViewModel';
import { WDViewDefaultType } from '../../view/EmptyComponent';
import { BasePageHelp } from './BasePageHelp';
...
...
@@ -51,9 +51,16 @@ export class TemplatePageHelp extends BasePageHelp {
*/
private treatDiffBusinessDataSource() {
if (this.pageModel.pageDataSourceType === TemplatePageConstant.LIVE_HORIZONTAL_CARD) {
if (this.pageModel.isLoading) {
return
}
if (this.pageModel.pageDataSourceType === TemplatePageConstant.LIVE_HORIZONTAL_PAGE) {
// 直播列表
this.requestLiveListData(this.pageModel.resolve)
} else if (this.pageModel.pageDataSourceType === TemplatePageConstant.LIVE_PORTEND_PAGE) {
// 直播预告
this.requestLivePortendData(this.pageModel.resolve)
}
}
...
...
@@ -76,21 +83,22 @@ export class TemplatePageHelp extends BasePageHelp {
this.pageModel.hasMore = false
}
// 依据业务请求获取的数据,转换成compDTO数据
let time = DateTimeUtils.getTimeStamp().toString()
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
if(this.pageModel.isEmitter){
contentDto.timestamp = time
}
compDTO.operDataList.push(contentDto)
pageContentList.push(compDTO)
}
// 推送数据到懒加载机制
this.pushDataToPage(pageContentList)
// 完成业务请求加载
this.pageModel.isLoading = false
// 批查
this.allCompBatchRequest(pageContentList)
...
...
@@ -104,10 +112,66 @@ export class TemplatePageHelp extends BasePageHelp {
}
this.resolveEnd(resolve)
// 完成业务请求加载
this.pageModel.isLoading = false
}
/**
* 请求直播预告数据
*/
private async requestLivePortendData(resolve?: (value: string | PromiseLike<string>) => void) {
this.pageModel.isLoading = true
const liveReviewDTO = await PageViewModel.getLiveMoreUrl(2, 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 time = DateTimeUtils.getTimeStamp().toString()
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_01
if (this.pageModel.isEmitter) {
contentDto.timestamp = time
}
compDTO.operDataList.push(contentDto)
pageContentList.push(compDTO)
}
// 推送数据到懒加载机制
this.pushDataToPage(pageContentList)
// 批查直播预约状态
this.getAppointmentInfo(pageContentList)
} else {
this.pageModel.hasMore = false
if (this.pageModel.currentPage === 1) {
// 无业务数据
this.pageNoHaveData()
}
}
this.resolveEnd(resolve)
// 完成业务请求加载
this.pageModel.isLoading = false
}
/**
* 处理页面批查业务方法
* @param list
*/
...
...
@@ -140,16 +204,22 @@ export class TemplatePageHelp extends BasePageHelp {
*/
private pushDataToPage(pageContentList: CompDTO[]) {
console.debug(TAG, 'pushDataToPage====>' + this.pageModel.currentPage)
// 请求第一页数据,需要清理pageData数据
if (this.pageModel.currentPage == 1) {
this.pageModel.compList.clear()
}
// 懒加载,推送数据
for (let contentDto of pageContentList) {
this.pageModel.compList.push(contentDto)
}
// for (let contentDto of pageContentList) {
// this.pageModel.compList.push(contentDto)
// }
this.pageModel.compList.push(...pageContentList)
//完成业务数据请求
this.pageModel.pageCompType = TemplatePageStateType.LOADED
this.pageModel.haveDataShow = true
// }
}
...
...
sight_harmony/features/wdComponent/src/main/ets/components/page/template/TemplatePageModel.ets
View file @
77d96d7
...
...
@@ -21,16 +21,18 @@ export default class TemplatePageModel {
* 识别不同页面的业务类型
*/
pageDataSourceType: string = ''
// 页码
currentPage: number = 1
// 一页最多信息量
pageSize: number = 20
// 是否支持加载更多数据
hasMore:boolean = false
hasMore:
boolean = false
// 是否正在请求数据
isLoading: boolean = false
// 页面已有数据展示
haveDataShow: boolean = false
// 接收Emitter事件,需要刷新界面,此时就需要对展示业务进行驱动更新
isEmitter: boolean = false
/**
* 此字段可驱动组件展示不同业务的组件,
*/
...
...
@@ -39,6 +41,5 @@ export default class TemplatePageModel {
* 异常状态 ——> 记录在获取数据中的不同状态,如无数据、无网络等情况
*/
noNormalState: WDViewDefaultType = WDViewDefaultType.WDViewDefaultType_Default
resolve?: (value: string | PromiseLike<string>) => void
}
\ No newline at end of file
...
...
sight_harmony/features/wdComponent/src/main/ets/components/reserveMore/ReserveMorePage.ets
View file @
77d96d7
import { ContentDTO, ReserveBean, ReserveItemBean } from 'wdBean/Index';
import { ProcessUtils } from 'wdRouter/Index';
import PageViewModel from '../../viewmodel/PageViewModel';
import { Logger, EmitterEventId, EmitterUtils, ToastUtils } from 'wdKit/Index';
import { router } from '@kit.ArkUI';
import { LiveModel } from '../../viewmodel/LiveModel';
import { ViewType } from 'wdConstant/src/main/ets/enum/ViewType';
import { EmptyComponent } from '../view/EmptyComponent';
import { ErrorComponent } from '../view/ErrorComponent';
import { CustomPullToRefresh } from '../reusable/CustomPullToRefresh';
import { PeopleShipNoMoreData } from '../reusable/PeopleShipNoMoreData';
import { HttpUtils } from 'wdNetwork/Index';
import { WDRouterPage, WDRouterRule } from 'wdRouter'
import { LazyDataSource } from 'wdKit/Index';
import LoadMoreLayout from '../page/LoadMoreLayout'
import { onlyWifiLoadImg } from '../../utils/lazyloadImg';
import { TrackConstants, Tracking, TrackingContent, TrackingPageBrowse, TrackParamConvert } from 'wdTracking/Index';
import { TrackConstants, TrackingPageBrowse } from 'wdTracking/Index';
import CommonPageTitle from '../page/CommonPageTitle';
import TemplatePageComponent from '../page/template/TemplatePageComponent';
import { TemplatePageConstant } from '../page/template/TemplatePageConstant';
const TAG: string = 'ReserveMorePage';
...
...
@@ -29,58 +16,27 @@ const TAG: string = 'ReserveMorePage';
@Entry
@Component
struct ReserveMorePage {
@State data: LazyDataSource<ContentDTO> = new LazyDataSource();
private reserveList: ReserveItemBean[] = []
@State topSafeHeight: number = AppStorage.get<number>('topSafeHeight') as number;
@State bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0
type: number = 2;
pageSize: number = 20;
title: string = '直播预告'
//是否预约过直播
@State isAppointmentLive: boolean = false
@State contentDTO: ContentDTO = {} as ContentDTO;
@State private hasMore: boolean = true
@State private currentPage: number = 1
@State private isLoading: boolean = false
@State viewType: ViewType = ViewType.LOADING
private scroller: Scroller = new Scroller()
@State reservedIds: string[] = []
@State isShow: boolean = false
@State private liveId: string = ''
@State isLoadingAttention: boolean = false
@State loadImg: boolean = false;
private pageId: string = TrackConstants.PageName.Live_Appointment_List
private pageName: string = TrackConstants.PageName.Live_Appointment_List
private pageShowStartTime: number = 0
build() {
Column() {
this.TabbarNormal()
if (this.viewType == ViewType.LOADING) {
this.LoadingLayout()
} else if (this.viewType == ViewType.ERROR) {
ErrorComponent()
.onTouch(() => {
if (this.viewType === ViewType.ERROR) {
this.getData()
}
})
} else if (this.viewType == ViewType.EMPTY) {
EmptyComponent()
} else {
CustomPullToRefresh({
alldata: this.data,
scroller: this.scroller,
hasMore: false,
customList: () => {
this.ListLayout()
},
onRefresh: (resolve) => {
this.currentPage = 1
this.getData(resolve)
},
}).backgroundColor($r('app.color.color_F5F5F5'))
}
//常见标题
CommonPageTitle({ title: this.title })
// 通用模板组件
TemplatePageComponent({
pageDataSourceType: TemplatePageConstant.LIVE_PORTEND_PAGE,
listColor: $r('app.color.color_F5F5F5'),
pageId: this.pageId,
pageName: this.pageName
})
}.height('100%').backgroundColor('#FFFFFF').padding({
top: px2vp(this.topSafeHeight),
...
...
@@ -93,300 +49,9 @@ struct ReserveMorePage {
LoadingLayout() {
}
@Builder
ListLayout() {
List({ scroller: this.scroller }) {
// 下拉刷新
LazyForEach(this.data, (contentDTO: ContentDTO, index: number) => {
ListItem() {
this.buildItem(contentDTO, index)
}
},
(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()
}
}
}
.cachedCount(8)
.edgeEffect(EdgeEffect.None)
.scrollBar(BarState.Off)
.backgroundColor('#F5F5F5')
.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, index: number) {
Column() {
Stack() {
Image(this.loadImg ? item.fullColumnImgUrls[0]?.url : '')
.width('100%')
.aspectRatio(16 / 9)
.backgroundColor(this.loadImg ? $r('app.color.color_B0B0B0') : $r('app.color.color_33A3A3A3'))
.objectFit(ImageFit.Contain)
.borderWidth(0.5)
.borderColor($r('app.color.color_0D000000'))
.borderRadius({
topLeft: '4vp',
topRight: '4vp'
})
this.LiveImage()
}
.alignContent(Alignment.BottomEnd)
Text(item.newsTitle)
.fontSize(17)
.maxLines(2)
.lineHeight(25)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.margin({ top: 4, left: 12, right: 12 })
.alignSelf(ItemAlign.Start)
Row() {
if (item.liveInfo && item.liveInfo.liveStartTime) {
Row() {
Image($r('app.media.reserve_play_icon'))
.width(20)
.height(20)
.margin({
left: 10,
top: 2,
bottom: 2,
right: 6
})
Text(this.getReserveDate(item.liveInfo.liveStartTime, 1))
.fontSize(12)
.fontWeight(500)
.fontColor('#ED2800')
.fontFamily('PingFang SC-Medium')
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.margin({ top: 8, bottom: 8 })
.align(Alignment.Start)
Image($r('app.media.point_icon'))
.objectFit(ImageFit.Auto)
.interpolation(ImageInterpolation.High)
.width(6)
.height(16)
.margin(2)
Text(this.getReserveDate(item.liveInfo.liveStartTime, 2))
.fontSize(12)
.fontWeight(500)
.fontColor('#ED2800')
.fontFamily('PingFang SC-Medium')
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.margin({ top: 8, bottom: 8, right: 10 })
.align(Alignment.Start)
}
.backgroundColor('#F5F5F5')
.margin(12)
}
// 预约
Row() {
LoadingProgress()
.width(20)
.height(20)
.color(!this.isReserved(item) ? $r('app.color.color_fff') : $r('app.color.color_CCCCCC'))
.visibility((this.isLoadingAttention && this.liveId == item.objectId) ? Visibility.Visible :
Visibility.None)
Text(!this.isReserved(item) ? '预约' : '已预约')
.fontSize($r('app.float.vp_12'))
.fontWeight(500)
.fontColor(!this.isReserved(item) ? $r('app.color.color_fff') : $r('app.color.color_CCCCCC'))
.width('100%')
.height('100%')
.textAlign(TextAlign.Center)
.visibility((this.isLoadingAttention && this.liveId == item.objectId) ? Visibility.None :
Visibility.Visible)
.margin({
right: '10vp'
})
.textShadow({
radius: 2,
color: 'rgba(0,0,0,0.3)',
offsetY: 2
})
.backgroundColor(!this.isReserved(item) ? $r('app.color.color_ED2800') : $r('app.color.color_F5F5F5'))
.borderRadius(3)
}
.onClick(() => {
this.bookAndCancel(item)
})
.justifyContent(FlexAlign.Center)
.alignItems(VerticalAlign.Center)
.borderRadius(3)
.width('52vp')
.height('24vp')
.margin({ right: 12 })
}
.width('100%')
.justifyContent(FlexAlign.SpaceBetween)
}
.borderRadius(4)
.backgroundColor(Color.White)
.width('calc(100% - 24vp)')
.margin({
left: '12vp',
right: '12vp',
top: index == 0 ? '12vp' : '8vp'
})
.onClick(() => {
// 内容点击埋点
TrackingContent.common(TrackConstants.EventType.Click,
item.pageId,
item.pageId,
TrackParamConvert.program(item))
ProcessUtils.processPage(item)
})
.onVisibleAreaChange([0, 1], (isVisiable: boolean, ratio: number) => {
if (isVisiable) {
// 内容曝光埋点
TrackingContent.common(TrackConstants.EventType.Show,
item.pageId,
item.pageId,
TrackParamConvert.program(item))
}
})
}
/*导航栏*/
@Builder
TabbarNormal() {
RelativeContainer() {
//标题栏目
Image($r('app.media.icon_arrow_left'))
.width(24)
.height(24)
.objectFit(ImageFit.Auto)
.id("back_icon")
.margin({
left: '16vp'
})
.alignRules({
center: { anchor: "__container__", align: VerticalAlign.Center },
left: { anchor: "__container__", align: HorizontalAlign.Start }
})
.onClick(() => {
router.back()
})
Text(this.title)// .height('42lpx')
.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%').backgroundColor('#FFFFFF')
}
@Builder
LiveImage() {
Row() {
Image($r('app.media.reserve_new_icon'))
.width(14)
.height(14)
.margin({
right: 3
})
Text('预约')
.fontSize('12vp')
.fontWeight(400)
.fontColor(Color.White)
.textShadow({
radius: 2,
color: 'rgba(0,0,0,0.3)',
offsetY: 2
})
}
.backgroundColor(Color.Transparent)
.margin({ right: 8, bottom: 8 })
}
async aboutToAppear(): Promise<void> {
this.loadImg = await onlyWifiLoadImg();
// PageViewModel.get
this.currentPage = 1
this.getData()
// 登录成功
EmitterUtils.receiveEvent(EmitterEventId.LOGIN_SUCCESS, () => {
this.currentPage = 1
this.getData()
})
// 获取预约
EmitterUtils.receiveEvent(EmitterEventId.LIVE_ROOM_SUBSCRIBE, (str?: string) => {
Logger.debug(TAG, 'receiveEvent LIVE_ROOM_SUBSCRIBE: ' + str)
if (str) {
// 跳转指定频道场景,传参底导id、频道id
const model: ReserveItemBean = JSON.parse(str)
Logger.debug(TAG, '是否关注元数据0:' + ` ${model.liveId}`)
if (model && model.liveId && this.reserveList) {
// 修改源数据
this.reserveList.forEach((element) => {
if (element.liveId == model.liveId) {
if (element && element.subscribe != model.subscribe) {
Logger.debug(TAG, '是否关注元数据2:' + ` ${JSON.stringify(element.subscribe)}`)
element.subscribe = !element.subscribe
Logger.debug(TAG, '是否关注元数据3:' + ` ${JSON.stringify(element.subscribe)}`)
this.isShow = true
if (element.subscribe) {
this.reservedIds.push(element.liveId.toString())
} else {
const num = this.reservedIds.indexOf(element.liveId.toString())
if (num >= 0 && num < this.reservedIds.length) {
this.reservedIds.splice(num, 1)
}
}
}
}
})
}
}
})
}
onPageShow(): void {
this.pageShowStartTime = Date.now()
if (this.isShow) {
this.data.reloadData()
this.isShow = false
}
}
onPageHide(): void {
...
...
@@ -394,221 +59,4 @@ struct ReserveMorePage {
TrackingPageBrowse.trackCommonPageExposureEnd(this.pageId, this.pageName, duration)
}
private async getData(resolve?: (value: string | PromiseLike<string>) => void) {
if (this.isLoading) {
if (resolve) {
resolve('已更新至最新')
}
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.reserveList = []
this.reservedIds = []
}
liveReviewDTO.list.forEach((content) => {
content.pageId = this.pageId
})
this.data.push(...liveReviewDTO.list)
//批量查询关注状态
this.getAppointmentInfo(liveReviewDTO.list)
} else {
this.hasMore = false;
}
this.resolveEnd(true, resolve)
if (liveReviewDTO.list.length == 0 && this.currentPage == 1) {
this.viewType = ViewType.EMPTY
}
} catch (exception) {
this.resolveEnd(false, resolve)
}
// PageViewModel.getLiveMoreUrl(this.type, this.currentPage, this.pageSize).then(async (liveReviewDTO) => {
// // this.operDataList = []
// // this.operDataList.push(...liveReviewDTO.list)
// this.data.push(...liveReviewDTO.list)
//
// // this.getAppointmentInfo()
// })
}
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
} else {
this.viewType = ViewType.LOADED
}
this.isLoading = false
}
async getAppointmentInfo(list: ContentDTO[]) {
if (HttpUtils.getUserId()) {
const reserveBean = this.transformToLiveDetailsBeans(list)
Logger.debug(TAG, '是否预约数据:' + ` ${JSON.stringify(reserveBean)}`)
LiveModel.getAppointmentStatus(reserveBean).then((result) => {
Logger.debug(TAG, '是否预约数据:' + ` ${JSON.stringify(result)}`)
if (result && result.length > 0) {
this.reserveList.push(...result)
// this.reserveStatus = res;
result.map((item: ReserveItemBean) => {
if (item.subscribe) {
this.reservedIds.push(item.liveId.toString())
}
})
}
}).catch(() => {
// this.data.push(...list)
})
} else {
// this.data.push(...list)
}
}
// 判断是否预约
isReserved(item: ContentDTO) {
return this.reservedIds.includes(item.objectId)
}
getAttentionItem(item: ContentDTO) {
const objc = this.reserveList.find((element: ReserveItemBean) => {
return element.liveId.toString() == item.objectId
})
return objc
}
// 这个函数遍历liveReviewDTO.list并转换为LiveDetailsBean数组
transformToLiveDetailsBeans(list: ContentDTO[]): ReserveBean[] {
const liveDetailsBeans: ReserveBean[] = [];
list.forEach(item => {
liveDetailsBeans.push({
relationId: item.relId,
liveId: item.objectId,
});
});
return liveDetailsBeans
}
// 预约/取消预约
async bookAndCancel(item: ContentDTO) {
// 未登录,跳转登录
if (!HttpUtils.getUserId()) {
WDRouterRule.jumpWithPage(WDRouterPage.loginPage)
return
}
if (!this.isLoadingAttention && this.liveId.length == 0) {
this.isLoadingAttention = true
this.liveId = item.objectId
const reserveItem = this.getAttentionItem(item)
if (reserveItem) {
this.isLoadingAttention = true
this.liveId = reserveItem.liveId.toString()
try {
// 埋点
Tracking.event(!reserveItem.subscribe ? "live_subscribe_click" : "cancel_live_subscribe_click",
TrackParamConvert.program(item))
const res = await LiveModel.liveAppointment(reserveItem.relationId, reserveItem.liveId.toString(),
!reserveItem.subscribe);
if (res.code == 0) {
ToastUtils.shortToast(!reserveItem.subscribe ? '预约成功' : '取消预约成功')
// 修改源数据
this.reserveList.forEach((element) => {
if (element.liveId.toString() == item.objectId) {
Logger.debug(TAG, '是否关注元数据:' + ` ${JSON.stringify(element.subscribe)}`)
element.subscribe = !element.subscribe
Logger.debug(TAG, '是否关注元数据1:' + ` ${JSON.stringify(element.subscribe)}`)
if (element.subscribe) {
this.reservedIds.push(element.liveId.toString())
} else {
const num = this.reservedIds.indexOf(element.liveId.toString())
if (num >= 0 && num < this.reservedIds.length) {
this.reservedIds.splice(num, 1)
}
}
}
})
}
this.isLoadingAttention = false
this.liveId = ''
} catch (e) {
this.liveId = ''
this.isLoadingAttention = false
}
} else {
this.liveId = ''
this.isLoadingAttention = false
}
}
}
getReserveDate(eventDateTimeString: string, type: number): string {
// 解析事件的日期和时间
const eventDateTime = new Date(eventDateTimeString);
const currentDateTime = new Date();
// 截取事件时间的小时和分钟(假设事件时间是按照24小时制)
const eventHour = eventDateTime.getHours();
const eventMinutes = eventDateTime.getMinutes();
const eventTimeStr = `${eventHour}:${eventMinutes.toString().padStart(2, '0')}开始`; // 格式化时间,确保分钟是两位数
if (type === 1) {
// 判断是否是今天
const eventDate = eventDateTime.setHours(0, 0, 0, 0);
const currentDate = currentDateTime.setHours(0, 0, 0, 0);
if (eventDate === currentDate) {
return `今天`;
} else {
const month = eventDateTime.getMonth() + 1;
const date = eventDateTime.getDate();
return `${month}月${date}日`;
}
} else {
return `${eventTimeStr}`;
}
}
// getReserveDate(eventDateTimeString: string, type: number): string {
// // 解析事件的日期和时间
// const eventDateTime = new Date(eventDateTimeString);
// const currentDateTime = new Date();
//
// // 截取事件时间的小时和分钟(假设事件时间是按照24小时制)
// const eventHour = eventDateTime.getHours();
// const eventMinutes = eventDateTime.getMinutes();
// const eventTimeStr = `${eventHour}:${eventMinutes.toString().padStart(2, '0')}开始`; // 格式化时间,确保分钟是两位数
//
// if (type === 1) {
// // 如果是今天
// if (eventDateTime.setHours(0,0,0,0) === currentDateTime.setHours(0,0,0,0)) {
// return `今天`;
// } else {
// // 如果事件不在今天
// const month = eventDateTime.getMonth() + 1; // 月份从0开始
// const date = eventDateTime.getDate();
// return `${month}月${date}日`;
// }
// } else {
// return `${eventTimeStr}`;
// }
// }
}
\ No newline at end of file
...
...
sight_harmony/features/wdComponent/src/main/ets/viewmodel/PageViewModel.ets
View file @
77d96d7
...
...
@@ -270,18 +270,20 @@ export class PageViewModel extends BaseViewModel {
* @param pageSize
* @returns
*/
async getLiveMoreUrl(type: number, pageNum: number, pageSize: number): Promise<LiveReviewDTO> {
return new Promise<LiveReviewDTO>((success, error) => {
async getLiveMoreUrl(type: number, pageNum: number, pageSize: number): Promise<LiveReviewDTO | null> {
return new Promise<LiveReviewDTO| null>((success, error) => {
Logger.info(TAG, `getLiveMoreUrl pageInfo start`);
PageRepository.fetchLiveMoreUrl(type, pageNum, pageSize).then((resDTO: ResponseDTO<LiveReviewDTO>) => {
if (!resDTO || !resDTO.data) {
Logger.error(TAG, 'getLiveMoreUrl then navResDTO is empty');
error('resDTO is empty');
//error('resDTO is empty');
success(null);
return
}
if (resDTO.code != 0) {
Logger.error(TAG, `getLiveMoreUrl then code:${resDTO.code}, message:${resDTO.message}`);
error('resDTO Response Code is failure');
//error('resDTO Response Code is failure');
success(null);
return
}
// let navResStr = JSON.stringify(navResDTO);
...
...
@@ -289,7 +291,8 @@ export class PageViewModel extends BaseViewModel {
success(resDTO.data);
}).catch((err: Error) => {
Logger.error(TAG, `getLiveMoreUrl catch, error.name : ${err.name}, error.message:${err.message}`);
error(err);
//error(err);
success(null);
})
})
}
...
...
Please
register
or
login
to post a comment