chenjun3_wd

预约功能 TODO

... ... @@ -7,6 +7,7 @@ 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';
... ... @@ -29,6 +30,8 @@ struct ReserveMorePage {
pageSize: number = 20;
operDataList: ContentDTO[] = [];
title: string = '预约列表'
//是否预约过直播
@State isAppointmentLive: boolean = false
@State contentDTO: ContentDTO = {
// appStyle: '15',
// coverType: 1,
... ... @@ -199,7 +202,7 @@ struct ReserveMorePage {
.margin(12)
Flex({ justifyContent: FlexAlign.Center }) {
Text('预约')
Text(this.isAppointmentLive ? '已预约' : '预约')
.fontSize(12)
.fontWeight(400)
.fontFamily('PingFang SC-Regular')
... ... @@ -207,6 +210,9 @@ struct ReserveMorePage {
.height(24)
.fontColor(Color.White)
.textAlign(TextAlign.Center)
.onClick(() => {
this.liveAppointment(item)
})
}
.width(52)
.backgroundColor('#ED2800')
... ... @@ -254,6 +260,22 @@ struct ReserveMorePage {
}
}
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)
}
/*导航栏*/
@Builder
TabbarNormal() {
... ...
import HashMap from '@ohos.util.HashMap';
import { HttpUrlUtils, ResponseDTO } from 'wdNetwork';
import { HttpRequest } from 'wdNetwork/src/main/ets/http/HttpRequest';
import { Logger } from 'wdKit';
import { Logger, ToastUtils } from 'wdKit';
import { LiveDetailsBean } from 'wdBean/Index';
const TAG = 'LiveModel'
... ... @@ -35,5 +35,36 @@ export class LiveModel {
})
})
}
/**
* 直播预约/取消预约
* @param relationId
* @param mLiveId
* @param isSubscribe
* @returns
*/
static liveAppointment(relationId: string, liveId: string, isSubscribe: boolean) {
let params: Record<string, string> = {};
params['relationId'] = relationId
params['liveId'] = liveId
params['isSubscribe'] = `${isSubscribe}`
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return new Promise<ResponseDTO<string>>((success, fail) => {
HttpRequest.post<ResponseDTO<string>>(
HttpUrlUtils.getLiveAppointmentUrl(),
params,
headers).then((data: ResponseDTO<string>) => {
if (data.code != 0) {
fail(data.message)
ToastUtils.shortToast(data.message)
return
}
success(data)
}, (error: Error) => {
fail(error.message)
Logger.debug(TAG + ":error ", error.toString())
})
})
}
}
... ...