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
陈剑华
2024-05-08 15:01:44 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
6ec32d9427c6fd1b405461aa1192a28b360e4223
6ec32d94
1 parent
0e7c6299
fix: 直播预约卡预约功能
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
139 additions
and
63 deletions
sight_harmony/features/wdComponent/src/main/ets/components/compview/ZhSingleRow03.ets
sight_harmony/features/wdComponent/src/main/ets/components/page/ReserveMorePage.ets
sight_harmony/features/wdComponent/src/main/ets/viewmodel/LiveModel.ets
sight_harmony/features/wdComponent/src/main/ets/components/compview/ZhSingleRow03.ets
View file @
6ec32d9
...
...
@@ -5,6 +5,8 @@ import { PageRepository } from '../../repository/PageRepository';
import { ProcessUtils } from 'wdRouter';
import { HttpUtils } from 'wdNetwork/Index';
import { DateTimeUtils } from 'wdKit';
import { LiveModel } from '../../viewmodel/LiveModel'
import { Logger, ToastUtils } from 'wdKit';
/**
* 直播预约卡
...
...
@@ -12,13 +14,62 @@ import { DateTimeUtils } from 'wdKit';
*/
const TAG = 'Zh_Single_Row-03'
interface reserveItem {
liveId: number,
relationId: string,
subscribe: boolean
}
interface reserveReqItem {
liveId: string,
relationId: string,
}
@Entry
@Component
export struct ZhSingleRow03 {
@State compDTO: CompDTO = {} as CompDTO
@State isEndEdge: boolean = false;
// @State reserveStatus: reserveItem[] = []
@State reservedIds: number[] = [];
scroller: Scroller = new Scroller()
aboutToAppear(): void {
this.getReserveState();
}
// 请求所有预约状态
async getReserveState() {
const reserveBean: reserveReqItem[] = this.compDTO.operDataList.map((item: ContentDTO) => {
const reqItem: reserveReqItem = {
liveId: item.objectId,
relationId: item.relId
}
return reqItem;
})
const res = await LiveModel.getAppointmentStatus(reserveBean);
// this.reserveStatus = res;
res.map((item: reserveItem) => {
if (item.subscribe) {
this.reservedIds.push(item.liveId)
}
})
}
// 判断是否预约
isReserved(liveId: number) {
return this.reservedIds.includes(liveId)
}
// 预约/取消预约
async bookAndCancel(relationId: string, liveId: string, isSubscribe: boolean) {
const res = await LiveModel.liveAppointment(relationId, liveId, isSubscribe);
if (res.code == 0) {
ToastUtils.shortToast(isSubscribe ? '预约成功' : '取消预约成功')
this.getReserveState();
}
}
format(timeNum: number) {
const todayDate = new Date().setHours(0,0,0,0)
const parseDate = new Date(timeNum).setHours(0,0,0,0);
...
...
@@ -44,64 +95,7 @@ export struct ZhSingleRow03 {
Scroll(this.scroller){
Row() {
ForEach(this.compDTO.operDataList, (item: ContentDTO) => {
Column() {
Row() {
Image(item.coverUrl)
.width(106)
.height(60)
.margin({right: 12})
Text(item.newsTitle)
.width(154)
.height(60)
.maxLines(3)
.textOverflow({overflow: TextOverflow.Ellipsis})
}
.margin({bottom: 16})
Row() {
Flex({justifyContent: FlexAlign.SpaceBetween}){
Row() {
Text(this.format(new Date(item.liveInfo.liveStartTime).getTime()))
.margin({right: 6})
.fontColor(0x000000)
.fontSize(13)
.textAlign(TextAlign.Start)
Image($r('app.media.timeline_rect'))
.width(4)
.height(3)
.margin({right: 6})
Text(item.liveInfo.liveStartTime.split(' ')[1].slice(0, 5))
.margin({right: 6})
.fontColor(0x000000)
.fontSize(13)
Text('开始直播')
.fontColor(0xC8C8C8)
.fontSize(13)
}
Row() {
Text('预约')
.width(48)
.height(24)
.backgroundColor(0xED2800)
.fontColor(0xffffff)
.fontSize(12)
.textAlign(TextAlign.Center)
.borderRadius(3)
}
.margin({top: -5})
}
}
}
.width(298)
.height(116)
.padding({top: 12, bottom: 12, left: 12, right: 12})
.backgroundColor(0xf9f9f9)
.margin({right: 8})
.onClick(() => {
ProcessUtils.processPage(item)
})
this.ItemCard(item)
})
}
}
...
...
@@ -131,6 +125,73 @@ export struct ZhSingleRow03 {
}
@Builder
ItemCard(item: ContentDTO) {
Column() {
Row() {
Image(item.coverUrl)
.width(106)
.height(60)
.margin({right: 12})
Text(item.newsTitle)
.width(154)
.height(60)
.maxLines(3)
.textOverflow({overflow: TextOverflow.Ellipsis})
}
.margin({bottom: 16})
Row() {
Flex({justifyContent: FlexAlign.SpaceBetween}){
Row() {
Text(this.format(new Date(item.liveInfo.liveStartTime).getTime()))
.margin({right: 6})
.fontColor(0x000000)
.fontSize(13)
.textAlign(TextAlign.Start)
Image($r('app.media.timeline_rect'))
.width(4)
.height(3)
.margin({right: 6})
Text(item.liveInfo.liveStartTime.split(' ')[1].slice(0, 5))
.margin({right: 6})
.fontColor(0x000000)
.fontSize(13)
Text('开始直播')
.fontColor(0xC8C8C8)
.fontSize(13)
}
Row() {
Text(this.isReserved(Number(item.objectId)) ? '已预约' : '预约')
.width(48)
.height(24)
.backgroundColor(this.isReserved(Number(item.objectId)) ? 0xffffff : 0xED2800)
.fontColor(this.isReserved(Number(item.objectId)) ? 0xC8C8C8 : 0xffffff)
.fontSize(12)
.textAlign(TextAlign.Center)
.borderRadius(3)
.onClick(() => {
this.bookAndCancel(item.relId, item.objectId, !this.isReserved(Number(item.objectId)))
})
}
.margin({top: -5})
}
}
}
.width(298)
.height(116)
.padding({top: 12, bottom: 12, left: 12, right: 12})
.backgroundColor(0xf9f9f9)
.margin({right: 8})
.onClick(() => {
ProcessUtils.processPage(item)
})
}
@Builder
CompHeader(item: CompDTO) {
Row() {
Row() {
...
...
sight_harmony/features/wdComponent/src/main/ets/components/page/ReserveMorePage.ets
View file @
6ec32d9
...
...
@@ -83,7 +83,7 @@ struct ReserveMorePage {
this.reserveBean = this.transformToLiveDetailsBeans(liveReviewDTO.list)
const apointMentStatus = await LiveModel.getAppointmentStatus(this.reserveBean)
console.info(`cj2024 ${apointMentStatus.code}`)
//
console.info(`cj2024 ${apointMentStatus.code}`)
})
...
...
sight_harmony/features/wdComponent/src/main/ets/viewmodel/LiveModel.ets
View file @
6ec32d9
...
...
@@ -5,6 +5,17 @@ import { LiveDetailsBean, ReserveBean } from 'wdBean/Index';
const TAG = 'LiveModel'
interface ReserveRes {
code: string | number,
data: ReserveItem[]
}
interface ReserveItem {
liveId: number,
relationId: string,
subscribe: boolean
}
export class LiveModel {
/**
* 直播内容详情
...
...
@@ -74,17 +85,21 @@ export class LiveModel {
static getAppointmentStatus(reserveBean: ReserveBean[]) {
// let params: Record<string, ArrayList<ReserveBean>> = {};
// params = reserveBean
return new Promise<ResponseDTO<string>>((success, fail) => {
HttpRequest.post<ResponseDTO<string>>(
return new Promise<Array<ReserveItem>>((success, fail) => {
HttpRequest.post<ResponseDTO<Array<ReserveItem>>>(
HttpUrlUtils.getAppointmentStatusUrl(),
reserveBean,
).then((data: ResponseDTO<string>) => {
).then((data: ResponseDTO<Array<ReserveItem>>) => {
if (!data || !data.data) {
fail("数据为空")
return
}
if (data.code != 0) {
fail(data.message)
ToastUtils.shortToast(data.message)
return
}
success(data)
success(data
.data
)
}, (error: Error) => {
fail(error.message)
Logger.debug(TAG + ":error ", error.toString())
...
...
Please
register
or
login
to post a comment