Showing
2 changed files
with
55 additions
and
2 deletions
| @@ -7,6 +7,7 @@ import { RefreshLayoutBean } from '../page/RefreshLayoutBean'; | @@ -7,6 +7,7 @@ import { RefreshLayoutBean } from '../page/RefreshLayoutBean'; | ||
| 7 | import PageModel from '../../viewmodel/PageModel'; | 7 | import PageModel from '../../viewmodel/PageModel'; |
| 8 | import { LazyDataSource } from 'wdKit/Index'; | 8 | import { LazyDataSource } from 'wdKit/Index'; |
| 9 | import { router } from '@kit.ArkUI'; | 9 | import { router } from '@kit.ArkUI'; |
| 10 | +import { LiveModel } from '../../viewmodel/LiveModel'; | ||
| 10 | 11 | ||
| 11 | const TAG: string = 'ReserveMorePage'; | 12 | const TAG: string = 'ReserveMorePage'; |
| 12 | 13 | ||
| @@ -29,6 +30,8 @@ struct ReserveMorePage { | @@ -29,6 +30,8 @@ struct ReserveMorePage { | ||
| 29 | pageSize: number = 20; | 30 | pageSize: number = 20; |
| 30 | operDataList: ContentDTO[] = []; | 31 | operDataList: ContentDTO[] = []; |
| 31 | title: string = '预约列表' | 32 | title: string = '预约列表' |
| 33 | + //是否预约过直播 | ||
| 34 | + @State isAppointmentLive: boolean = false | ||
| 32 | @State contentDTO: ContentDTO = { | 35 | @State contentDTO: ContentDTO = { |
| 33 | // appStyle: '15', | 36 | // appStyle: '15', |
| 34 | // coverType: 1, | 37 | // coverType: 1, |
| @@ -199,7 +202,7 @@ struct ReserveMorePage { | @@ -199,7 +202,7 @@ struct ReserveMorePage { | ||
| 199 | .margin(12) | 202 | .margin(12) |
| 200 | 203 | ||
| 201 | Flex({ justifyContent: FlexAlign.Center }) { | 204 | Flex({ justifyContent: FlexAlign.Center }) { |
| 202 | - Text('预约') | 205 | + Text(this.isAppointmentLive ? '已预约' : '预约') |
| 203 | .fontSize(12) | 206 | .fontSize(12) |
| 204 | .fontWeight(400) | 207 | .fontWeight(400) |
| 205 | .fontFamily('PingFang SC-Regular') | 208 | .fontFamily('PingFang SC-Regular') |
| @@ -207,6 +210,9 @@ struct ReserveMorePage { | @@ -207,6 +210,9 @@ struct ReserveMorePage { | ||
| 207 | .height(24) | 210 | .height(24) |
| 208 | .fontColor(Color.White) | 211 | .fontColor(Color.White) |
| 209 | .textAlign(TextAlign.Center) | 212 | .textAlign(TextAlign.Center) |
| 213 | + .onClick(() => { | ||
| 214 | + this.liveAppointment(item) | ||
| 215 | + }) | ||
| 210 | } | 216 | } |
| 211 | .width(52) | 217 | .width(52) |
| 212 | .backgroundColor('#ED2800') | 218 | .backgroundColor('#ED2800') |
| @@ -254,6 +260,22 @@ struct ReserveMorePage { | @@ -254,6 +260,22 @@ struct ReserveMorePage { | ||
| 254 | } | 260 | } |
| 255 | } | 261 | } |
| 256 | 262 | ||
| 263 | + async liveAppointment(item: ContentDTO) { | ||
| 264 | + // this.liveViewModel.liveAppointment( | ||
| 265 | + // this.liveDetailsBean.reLInfo ? this.liveDetailsBean.reLInfo.relId : '', | ||
| 266 | + // this.liveDetailsBean.newsId, | ||
| 267 | + // !this.isAppointmentLive).then( | ||
| 268 | + // (data) => { | ||
| 269 | + // if (data.success) { | ||
| 270 | + // this.isAppointmentLive = !this.isAppointmentLive | ||
| 271 | + // } | ||
| 272 | + // }, | ||
| 273 | + // () => { | ||
| 274 | + // | ||
| 275 | + // }) | ||
| 276 | + const liveDetail = await LiveModel.liveAppointment(item?.relId || '', item?.objectId || '', this.isAppointmentLive || false) | ||
| 277 | + } | ||
| 278 | + | ||
| 257 | /*导航栏*/ | 279 | /*导航栏*/ |
| 258 | @Builder | 280 | @Builder |
| 259 | TabbarNormal() { | 281 | TabbarNormal() { |
| 1 | import HashMap from '@ohos.util.HashMap'; | 1 | import HashMap from '@ohos.util.HashMap'; |
| 2 | import { HttpUrlUtils, ResponseDTO } from 'wdNetwork'; | 2 | import { HttpUrlUtils, ResponseDTO } from 'wdNetwork'; |
| 3 | import { HttpRequest } from 'wdNetwork/src/main/ets/http/HttpRequest'; | 3 | import { HttpRequest } from 'wdNetwork/src/main/ets/http/HttpRequest'; |
| 4 | -import { Logger } from 'wdKit'; | 4 | +import { Logger, ToastUtils } from 'wdKit'; |
| 5 | import { LiveDetailsBean } from 'wdBean/Index'; | 5 | import { LiveDetailsBean } from 'wdBean/Index'; |
| 6 | 6 | ||
| 7 | const TAG = 'LiveModel' | 7 | const TAG = 'LiveModel' |
| @@ -35,5 +35,36 @@ export class LiveModel { | @@ -35,5 +35,36 @@ export class LiveModel { | ||
| 35 | }) | 35 | }) |
| 36 | }) | 36 | }) |
| 37 | } | 37 | } |
| 38 | + | ||
| 39 | + /** | ||
| 40 | + * 直播预约/取消预约 | ||
| 41 | + * @param relationId | ||
| 42 | + * @param mLiveId | ||
| 43 | + * @param isSubscribe | ||
| 44 | + * @returns | ||
| 45 | + */ | ||
| 46 | + static liveAppointment(relationId: string, liveId: string, isSubscribe: boolean) { | ||
| 47 | + let params: Record<string, string> = {}; | ||
| 48 | + params['relationId'] = relationId | ||
| 49 | + params['liveId'] = liveId | ||
| 50 | + params['isSubscribe'] = `${isSubscribe}` | ||
| 51 | + let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | ||
| 52 | + return new Promise<ResponseDTO<string>>((success, fail) => { | ||
| 53 | + HttpRequest.post<ResponseDTO<string>>( | ||
| 54 | + HttpUrlUtils.getLiveAppointmentUrl(), | ||
| 55 | + params, | ||
| 56 | + headers).then((data: ResponseDTO<string>) => { | ||
| 57 | + if (data.code != 0) { | ||
| 58 | + fail(data.message) | ||
| 59 | + ToastUtils.shortToast(data.message) | ||
| 60 | + return | ||
| 61 | + } | ||
| 62 | + success(data) | ||
| 63 | + }, (error: Error) => { | ||
| 64 | + fail(error.message) | ||
| 65 | + Logger.debug(TAG + ":error ", error.toString()) | ||
| 66 | + }) | ||
| 67 | + }) | ||
| 68 | + } | ||
| 38 | } | 69 | } |
| 39 | 70 |
-
Please register or login to post a comment