yanlu

fix:16994 功能缺陷--进入直播,点击直播预告,点击更多按钮,进入直播预告详情页,已预约直播间,显示预约按钮,预期显示已预约按钮

... ... @@ -26,6 +26,9 @@ export enum EmitterEventId {
// 换绑成功
PHONE_CHANGE_SUCCESS = 9,
// 直播间-取消-预约成功
LIVE_ROOM_SUBSCRIBE = 10,
// App回到前台
APP_ENTER_FOREGROUD = 100,
// App进入后台
... ...
... ... @@ -213,7 +213,7 @@ export class HttpUrlUtils {
/**
* 预约状态
*/
static readonly LIVE_APPOINTMENT_BATCH_PATH: string = "api/live-center-message/zh/c/live/subscribe/user/batch";
static readonly LIVE_APPOINTMENT_BATCH_PATH: string = "/api/live-center-message/zh/c/live/subscribe/user/batch";
/**
* 搜索结果 显示tab 数
... ...
... ... @@ -123,7 +123,7 @@ export class WDRouterPage {
//直播更多页
static liveMorePage = new WDRouterPage("wdComponent", "ets/components/page/LiveMorePage");
//预约更多页
static reserveMorePage = new WDRouterPage("wdComponent", "ets/components/page/ReserveMorePage");
static reserveMorePage = new WDRouterPage("wdComponent", "ets/components/reserveMore/ReserveMorePage");
//金刚位聚合页
static themeListPage = new WDRouterPage("wdComponent", "ets/components/page/ThemeListPage");
// 栏目页面、频道详情
... ...
... ... @@ -168,4 +168,7 @@ export { GoldenPositionExtraBean } from './src/main/ets/bean/content/GoldenPosit
export { ClassBean } from './src/main/ets/bean/content/ClassBean';
export { CreatorsBean } from './src/main/ets/bean/content/CreatorsBean';
export { MasterDetailRes } from './src/main/ets/bean/user/MasterDetailRes';
\ No newline at end of file
export { MasterDetailRes } from './src/main/ets/bean/user/MasterDetailRes';
export { ReserveItemBean } from './src/main/ets/bean/live/ReserveItemBean';
... ...
@Observed export class ReserveItemBean {
liveId: number
relationId: string
subscribe: boolean
constructor( liveId: number, relationId: string, subscribe: boolean) {
this.liveId = liveId;
this.relationId = relationId;
this.subscribe = subscribe;
}
}
... ...
import { CompDTO, ContentDTO, Params, Action } from 'wdBean';
import { CompDTO, ContentDTO, Params, Action, ReserveItemBean} from 'wdBean';
import { WDRouterPage, WDRouterRule } from 'wdRouter/Index';
import { postInteractAccentionOperateParams } from 'wdBean';
import { PageRepository } from '../../repository/PageRepository';
... ... @@ -16,11 +16,6 @@ import { SpConstants } from 'wdConstant/Index'
*/
const TAG = 'Zh_Single_Row-03'
interface reserveItem {
liveId: number,
relationId: string,
subscribe: boolean
}
interface reserveReqItem {
liveId: string,
... ... @@ -54,7 +49,8 @@ export struct ZhSingleRow03 {
})
const res = await LiveModel.getAppointmentStatus(reserveBean);
// this.reserveStatus = res;
res.map((item: reserveItem) => {
Logger.debug(TAG, '数据信息:' + `${JSON.stringify(res)}`)
res.map((item: ReserveItemBean) => {
if (item.subscribe) {
this.reservedIds.push(item.liveId.toString())
}
... ...
import { ContentDTO, ReserveBean } from 'wdBean';
import { ProcessUtils } from 'wdRouter';
import { CommonConstants } from 'wdConstant/Index';
import PageViewModel from '../../viewmodel/PageViewModel';
import RefreshLayout from '../page/RefreshLayout';
import { RefreshLayoutBean } from '../page/RefreshLayoutBean';
import PageModel from '../../viewmodel/PageModel';
import { LazyDataSource } from 'wdKit/Index';
import { router } from '@kit.ArkUI';
import { LiveModel } from '../../viewmodel/LiveModel';
const TAG: string = 'ReserveMorePage';
/**
* 预约更多:
* type=1 直播
* type=2 预约
* 卡片结构:上下结构
* 卡片宽度:充满父窗口
* 卡片高度,仅包含横板图片:图片高度由图片的宽度及宽高比决定,图片宽度占父窗口'100%',宽高比为16:9:
*/
@Entry
@Component
struct ReserveMorePage {
@State private pageModel: PageModel = new PageModel();
@State data: LazyDataSource<ContentDTO> = new LazyDataSource();
reserveBean: ReserveBean[] = []
topSafeHeight: number = AppStorage.get<number>('topSafeHeight') as number;
type: number = 2;
currentPage: number = 1;
pageSize: number = 20;
operDataList: ContentDTO[] = [];
title: string = '预约列表'
//是否预约过直播
@State isAppointmentLive: boolean = false
@State contentDTO: ContentDTO = new ContentDTO()
// appStyle: '15',
// coverType: 1,
// objectType: '9',
// coverUrl: 'https://rmrbcmsonline.peopleapp.com/rb_recsys/img/2024/0413/VL20Z09ISBEKXZU_963672030241091584.jpeg?x-oss-process=image/resize,m_fill,h_450,w_800/quality,q_90',
// fullColumnImgUrls: [
// {
// landscape: 2,
// size: 1,
// url: 'https://rmrbcmsonline.peopleapp.com/rb_recsys/img/2024/0413/VL20Z09ISBEKXZU_963672030241091584.jpeg?x-oss-process=image/resize,m_fill,h_450,w_800/quality,q_90',
// weight: 1170
// }
// ],
// newsTitle: '押解画面公开!被湖北民警从柬埔寨押解回国被湖北民警从柬埔寨押解回国的130名涉赌诈嫌疑人是他们被湖北民警从柬埔寨押解回国的130名涉赌诈嫌疑人是他们的130名涉赌诈嫌疑人是他们',
// publishTime: '1712993333000',
// rmhInfo: {
// authIcon: '',
// authTitle: '',
// authTitle2: '',
// banControl: 0,
// cnIsAttention: 1,
// rmhDesc: '中共武汉市委机关报长江日报官方人民号',
// rmhHeadUrl: 'https://uatjdcdnphoto.aikan.pdnews.cn/vod/content/202302/202302Sa121448724/TUw.png?x-oss-process=image/resize,l_100/auto-orient,1/quality,q_90/format,jpg',
// rmhId: '4255270',
// rmhName: '长江日报',
// userId: '513696944662469',
// userType: '3'
// },
// videoInfo: {
// firstFrameImageUri: '',
// videoDuration: 12,
// // videoLandscape: 2,
// videoUrl: 'https://rmrbcmsonline.peopleapp.com/rb_recsys/video/2024/0413/VL20Z09ISBEKXZU_963672027208609792.mp4'
// },
// photoNum: '9',
// voiceInfo: {
// voiceDuration: 12
// }
// } as ContentDTO;
async aboutToAppear(): Promise<void> {
// PageViewModel.get
PageViewModel.getLiveMoreUrl(this.type, this.currentPage, this.pageSize).then(async (liveReviewDTO) => {
// this.operDataList = []
// this.operDataList.push(...liveReviewDTO.list)
this.data.push(...liveReviewDTO.list)
this.reserveBean = this.transformToLiveDetailsBeans(liveReviewDTO.list)
const apointMentStatus = await LiveModel.getAppointmentStatus(this.reserveBean)
// console.info(`cj2024 ${apointMentStatus.code}`)
})
}
// 这个函数遍历liveReviewDTO.list并转换为LiveDetailsBean数组
transformToLiveDetailsBeans(list: ContentDTO[]): ReserveBean[] {
const liveDetailsBeans: ReserveBean[] = [];
list.forEach(item => {
liveDetailsBeans.push({
relationId: item.relId,
liveId: item.objectId,
});
});
return liveDetailsBeans
}
build() {
// Navigation() {
// //滑动区域
// this.ListLayout()
// }
// .titleMode(NavigationTitleMode.Mini)
// .title('直播列表')
Column() {
this.TabbarNormal()
Column() {
this.ListLayout()
}
.padding({
left: $r('app.float.card_comp_pagePadding_lf'),
right: $r('app.float.card_comp_pagePadding_lf'),
bottom: $r('app.float.card_comp_pagePadding_tb')
})
}
.backgroundColor('#F5F5F5')
// .onClick((event: ClickEvent) => {
// ProcessUtils.processPage(this.contentDTO)
// })
}
@Builder
ListLayout() {
List() {
// 下拉刷新
ListItem() {
RefreshLayout({
refreshBean: new RefreshLayoutBean(this.pageModel.isVisiblePullDown, this.pageModel.pullDownRefreshImage,
this.pageModel.pullDownRefreshText, this.pageModel.pullDownRefreshHeight)
})
}
LazyForEach(this.data, (contentDTO: ContentDTO, contentIndex: number) => {
ListItem() {
// Column() {
// CompParser({ compDTO: compDTO, compIndex: compIndex });
// }
this.buildItem(contentDTO)
}
},
(contentDTO: ContentDTO, contentIndex: number) => contentDTO.pageId + contentIndex.toString()
)
}
.scrollBar(BarState.Off)
.cachedCount(8)
.height(CommonConstants.FULL_PARENT)
.backgroundColor('#F5F5F5')
.onScrollIndex((start: number, end: number) => {
// Listen to the first index of the current list.
this.pageModel.startIndex = start;
// 包含了 头尾item,判断时需要考虑+2
this.pageModel.endIndex = end;
})
}
/**
* 组件项
*
* @param programmeBean item 组件项, 上面icon,下面标题
*/
@Builder
buildItem(item: ContentDTO) {
Column({ space: 8 }) {
Stack() {
Image(item.fullColumnImgUrls[0].url)
.width('100%')
.height(196)
.borderRadius(4)
this.LiveImage()
}
.alignContent(Alignment.BottomEnd)
Text(item.newsTitle)
.fontSize(17)
.maxLines(2)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.margin({ top: 16, left: 12, right: 12 })
.alignSelf(ItemAlign.Start)
Row() {
Row() {
Image($r('app.media.reserve_play_icon'))
.width(20)
.height(20)
.margin({ left: 10, top: 2, bottom: 2, right: 6 })
// Text(DateTimeUtils.formatDate(item.liveInfo.liveStartTime, "MM月dd日 HH:mm"))
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)
Flex({ justifyContent: FlexAlign.Center }) {
Text(this.isAppointmentLive ? '已预约' : '预约')
.fontSize(12)
.fontWeight(400)
.fontFamily('PingFang SC-Regular')
.width(52)
.height(24)
.fontColor(Color.White)
.textAlign(TextAlign.Center)
.onClick(() => {
this.liveAppointment(item)
})
}
.width(52)
.backgroundColor('#ED2800')
.borderRadius(3)
.margin({ right: 12 })
}
.width('100%')
.justifyContent(FlexAlign.SpaceBetween)
}
.borderRadius(4)
.backgroundColor(Color.White)
.width('100%')
.margin({ top: 12, bottom: 8 })
.onClick(() => {
ProcessUtils.processPage(item)
})
}
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')}开始`; // 格式化时间,确保分钟是两位数
// 计算时间差
const timeDifference = eventDateTime.getTime() - currentDateTime.getTime();
// 如果事件在24小时内
if (type === 1) {
if (timeDifference > 0 && timeDifference <= 24 * 60 * 60 * 1000) {
return `今天`;
} else {
// 如果事件不在24小时内
const month = eventDateTime.getMonth() + 1; // 月份从0开始
const date = eventDateTime.getDate();
return `${month}月${date}日`;
}
} else {
return `${eventTimeStr}`;
}
}
async liveAppointment(item: ContentDTO) {
// this.liveViewModel.liveAppointment(
// this.liveDetailsBean.reLInfo ? this.liveDetailsBean.reLInfo.relId : '',
// this.liveDetailsBean.newsId,
// !this.isAppointmentLive).then(
// (data) => {
// if (data.success) {
// this.isAppointmentLive = !this.isAppointmentLive
// }
// },
// () => {
//
// })
const liveDetail = await LiveModel.liveAppointment(item?.relId || '', item?.objectId || '', this.isAppointmentLive || false)
// const liveDetail = await LiveModel.getAppointmentStatus(item?.relId || '', item?.objectId || '', this.isAppointmentLive || false)
}
/*导航栏*/
@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)// .height('42lpx')
.maxLines(1)
.id("title")
.fontSize('35lpx')
.fontWeight(400)
.fontColor($r('app.color.color_222222'))
.lineHeight('42lpx')
.alignRules({
center: { anchor: "__container__", align: VerticalAlign.Center },
middle: { anchor: "__container__", align: HorizontalAlign.Center }
})
}
.backgroundColor('#FFFFFF')
.height(44)
.width('100%')
}
@Builder
LiveImage() {
Row() {
Image($r('app.media.reserve_icon'))
.width(22)
.height(18)
Text('预约')
.fontSize('11fp')
.fontWeight(400)
.fontColor(Color.White)
}
.backgroundColor('#4D000000')
.margin({ right: 8, bottom: 8 })
}
}
\ No newline at end of file
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';
const TAG: string = 'ReserveMorePage';
/**
* 预约更多:
* type=1 直播
* type=2 预约
* 卡片结构:上下结构
* 卡片宽度:充满父窗口
* 卡片高度,仅包含横板图片:图片高度由图片的宽度及宽高比决定,图片宽度占父窗口'100%',宽高比为16:9:
*/
@Entry
@Component
struct ReserveMorePage {
@State data: LazyDataSource<ContentDTO> = new LazyDataSource();
@State reserveList: ReserveItemBean[] = []
topSafeHeight: number = AppStorage.get<number>('topSafeHeight') as number;
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
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'))
}
@Builder
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.isLoading) {
PeopleShipNoMoreData()
}
}
}
.cachedCount(8)
.edgeEffect(EdgeEffect.None)
.scrollBar(BarState.Off)
.backgroundColor('#F5F5F5')
.layoutWeight(1)
.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(item.fullColumnImgUrls[0].url)
.width('100%')
.height(196)
.borderRadius(4)
this.LiveImage()
}
.alignContent(Alignment.BottomEnd)
Text(item.newsTitle)
.fontSize(17)
.maxLines(2)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.margin({ top: 16, left: 12, right: 12 })
.alignSelf(ItemAlign.Start)
Row() {
Row() {
Image($r('app.media.reserve_play_icon'))
.width(20)
.height(20)
.margin({ left: 10, top: 2, bottom: 2, right: 6 })
// Text(DateTimeUtils.formatDate(item.liveInfo.liveStartTime, "MM月dd日 HH:mm"))
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)
// Flex({ justifyContent: FlexAlign.Center }) {
// Text(this.isAppointmentLive ? '已预约' : '预约')
// .fontSize(12)
// .fontWeight(400)
// .fontFamily('PingFang SC-Regular')
// .width(52)
// .height(24)
// .fontColor(Color.White)
// .textAlign(TextAlign.Center)
// .onClick(() => {
// this.liveAppointment(item)
// })
// }
// .width(52)
// .backgroundColor('#ED2800')
// .borderRadius(3)
// ReserveMoreAttentionComponent({reserveItem: this.getAttentionItem(item), })
// .margin({ right: 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'
})
.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(() => {
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)// .height('42lpx')
.maxLines(1)
.id("title")
.fontSize('35lpx')
.fontWeight(400)
.fontColor($r('app.color.color_222222'))
.lineHeight('42lpx')
.alignRules({
center: { anchor: "__container__", align: VerticalAlign.Center },
middle: { anchor: "__container__", align: HorizontalAlign.Center }
})
}
.backgroundColor('#FFFFFF')
.height(44)
.width('100%')
}
@Builder
LiveImage() {
Row() {
Image($r('app.media.reserve_icon'))
.width(22)
.height(18)
Text('预约')
.fontSize('11fp')
.fontWeight(400)
.fontColor(Color.White)
}
.backgroundColor('#4D000000')
.margin({ right: 8, bottom: 8 })
}
async aboutToAppear(): Promise<void> {
// 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.data.reloadData()
this.isShow = true
}
}
})
}
}
})
}
onPageShow(): void {
if (this.isShow) {
this.data.reloadData()
this.isShow = false
}
}
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.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.data.reloadData()
}
}).catch(() =>{
// this.data.push(...list)
})
}else {
// this.data.push(...list)
}
}
// 判断是否预约
isReserved(item: ContentDTO) {
const objc = this.getAttentionItem(item)
if (objc) {
return objc.subscribe
}
return false
}
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 {
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)}`)
this.data.reloadData()
}
})
}
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')}开始`; // 格式化时间,确保分钟是两位数
// 计算时间差
const timeDifference = eventDateTime.getTime() - currentDateTime.getTime();
// 如果事件在24小时内
if (type === 1) {
if (timeDifference > 0 && timeDifference <= 24 * 60 * 60 * 1000) {
return `今天`;
} else {
// 如果事件不在24小时内
const month = eventDateTime.getMonth() + 1; // 月份从0开始
const date = eventDateTime.getDate();
return `${month}月${date}日`;
}
} else {
return `${eventTimeStr}`;
}
}
async liveAppointment(item: ContentDTO) {
const liveDetail = await LiveModel.liveAppointment(item?.relId || '', item?.objectId || '', this.isAppointmentLive || false)
}
}
\ No newline at end of file
... ...
import { PullToRefresh, PullToRefreshConfigurator } from '@ohos/pulltorefresh';
import { LazyDataSource } from 'wdKit';
@Component
export struct CustomPullToRefresh {
@Link alldata: Object[];
@Link alldata: Object[] | LazyDataSource<Object>;
scroller: Scroller = new Scroller();
@BuilderParam customList: () => void;
onRefresh: (resolve?: (value: string | PromiseLike<string>) => void) => void = () => {
... ... @@ -15,7 +16,7 @@ export struct CustomPullToRefresh {
build() {
Column(){
PullToRefresh({
data:this.alldata,
data:$alldata,
scroller:this.scroller,
refreshConfigurator:this.refreshConfigurator,
customList:()=>{
... ...
import { HttpUrlUtils, ResponseDTO } from 'wdNetwork';
import { HttpRequest } from 'wdNetwork/src/main/ets/http/HttpRequest';
import { Logger, ToastUtils } from 'wdKit';
import { LiveDetailsBean, ReserveBean } from 'wdBean/Index';
import { Logger, ToastUtils, EmitterEventId, EmitterUtils } from 'wdKit';
import { LiveDetailsBean, ReserveBean, ReserveItemBean } from 'wdBean/Index';
const TAG = 'LiveModel'
interface ReserveRes {
code: string | number,
data: ReserveItem[]
}
interface ReserveItem {
liveId: number,
relationId: string,
subscribe: boolean
}
export class LiveModel {
/**
... ... @@ -70,6 +62,10 @@ export class LiveModel {
ToastUtils.shortToast(data.message)
return
}
if (data.code == 0) {
const reserveModel = new ReserveItemBean(Number(liveId), relationId, isSubscribe)
EmitterUtils.sendEvent(EmitterEventId.LIVE_ROOM_SUBSCRIBE, JSON.stringify(reserveModel))
}
success(data)
Logger.info('liveAppointment', JSON.stringify(data))
}, (error: Error) => {
... ... @@ -89,11 +85,12 @@ export class LiveModel {
static getAppointmentStatus(reserveBean: ReserveBean[]) {
// let params: Record<string, ArrayList<ReserveBean>> = {};
// params = reserveBean
return new Promise<Array<ReserveItem>>((success, fail) => {
HttpRequest.post<ResponseDTO<Array<ReserveItem>>>(
return new Promise<Array<ReserveItemBean>>((success, fail) => {
HttpRequest.post<ResponseDTO<Array<ReserveItemBean>>>(
HttpUrlUtils.getAppointmentStatusUrl(),
reserveBean,
).then((data: ResponseDTO<Array<ReserveItem>>) => {
).then((data: ResponseDTO<Array<ReserveItemBean>>) => {
Logger.debug(TAG, 'getAppointmentStatus:' + `${JSON.stringify(data)}`)
if (!data || !data.data) {
fail("数据为空")
return
... ...
... ... @@ -19,7 +19,7 @@
"components/page/PeopleShipHomePage",
"pages/MultiPictureListPage",
"components/page/LiveMorePage",
"components/page/ReserveMorePage",
"components/reserveMore/ReserveMorePage",
"pages/VideoPlayPage",
"components/page/ThemeListPage",
"pages/ShowUserHeaderPage",
... ...
import { HttpUrlUtils, ResponseDTO } from 'wdNetwork';
import { HttpRequest } from 'wdNetwork/src/main/ets/http/HttpRequest';
import { Logger, ToastUtils } from 'wdKit';
import { ContentDetailDTO, LiveDetailsBean, LiveRoomBean, LiveRoomDataBean } from 'wdBean/Index';
import { Logger, ToastUtils, EmitterEventId, EmitterUtils } from 'wdKit';
import { ContentDetailDTO, LiveDetailsBean, LiveRoomBean, LiveRoomDataBean, ReserveItemBean } from 'wdBean/Index';
import { ContentDetailRequest } from 'wdDetailPlayApi/Index';
const TAG = 'LiveModel'
... ... @@ -199,6 +199,10 @@ export class LiveModel {
ToastUtils.shortToast(data.message)
return
}
if (data.code == 0) {
const reserveModel = new ReserveItemBean(Number(liveId), relationId, isSubscribe)
EmitterUtils.sendEvent(EmitterEventId.LIVE_ROOM_SUBSCRIBE, JSON.stringify(reserveModel))
}
success(data)
}, (error: Error) => {
fail(error.message)
... ...