Showing
6 changed files
with
65 additions
and
6 deletions
| @@ -681,6 +681,15 @@ export class HttpUrlUtils { | @@ -681,6 +681,15 @@ export class HttpUrlUtils { | ||
| 681 | return url | 681 | return url |
| 682 | } | 682 | } |
| 683 | 683 | ||
| 684 | + static getLiveSendBarrageUrl() { | ||
| 685 | + let url = HttpUrlUtils.getHost() + "/api/live-center-message/zh/c/live/message/chat/send" | ||
| 686 | + return url | ||
| 687 | + } | ||
| 688 | + static getLiveTouristSendBarrageUrl() { | ||
| 689 | + let url = HttpUrlUtils.getHost() + "/api/live-center-message/zh/a/live/message/chat/tourist/send" | ||
| 690 | + return url | ||
| 691 | + } | ||
| 692 | + | ||
| 684 | static getAppointmentStatusUrl() { | 693 | static getAppointmentStatusUrl() { |
| 685 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.LIVE_APPOINTMENT_BATCH_PATH | 694 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.LIVE_APPOINTMENT_BATCH_PATH |
| 686 | return url | 695 | return url |
| @@ -466,14 +466,20 @@ export struct LiveOperRowListView { | @@ -466,14 +466,20 @@ export struct LiveOperRowListView { | ||
| 466 | this.showCommentInput = canComment | 466 | this.showCommentInput = canComment |
| 467 | 467 | ||
| 468 | let mLiveId: string = this.contentDetailData.liveInfo.mlive.mliveId as string | 468 | let mLiveId: string = this.contentDetailData.liveInfo.mlive.mliveId as string |
| 469 | - if (!HttpUtils.isLogin() || mLiveId == undefined) { | 469 | + if (!mLiveId) { |
| 470 | + return | ||
| 471 | + } | ||
| 472 | + if (!HttpUtils.isLogin()) { | ||
| 473 | + this.banComment = false | ||
| 470 | return | 474 | return |
| 471 | } | 475 | } |
| 472 | 476 | ||
| 473 | // 查询是否被禁言 | 477 | // 查询是否被禁言 |
| 474 | PageRepository.fetchLiveBarrageBan(mLiveId).then(res => { | 478 | PageRepository.fetchLiveBarrageBan(mLiveId).then(res => { |
| 479 | + if (res.code == 0) { | ||
| 475 | this.banComment = res.data as boolean | 480 | this.banComment = res.data as boolean |
| 476 | this.showCommentInput = !this.banComment && canComment | 481 | this.showCommentInput = !this.banComment && canComment |
| 482 | + } | ||
| 477 | }) | 483 | }) |
| 478 | } | 484 | } |
| 479 | } | 485 | } |
| @@ -79,7 +79,7 @@ export struct DetailPlayLivePage { | @@ -79,7 +79,7 @@ export struct DetailPlayLivePage { | ||
| 79 | }, | 79 | }, |
| 80 | onCommentInputed: (content) => { | 80 | onCommentInputed: (content) => { |
| 81 | if (content.comment) { | 81 | if (content.comment) { |
| 82 | - this.liveViewModel.sendComment(content.comment) | 82 | + this.liveViewModel.sendComment(content.comment, this.contentDetailData) |
| 83 | } | 83 | } |
| 84 | } | 84 | } |
| 85 | }).visibility(this.displayDirection == DisplayDirection.VERTICAL ? Visibility.Visible : Visibility.None) | 85 | }).visibility(this.displayDirection == DisplayDirection.VERTICAL ? Visibility.Visible : Visibility.None) |
| 1 | -import { HttpUrlUtils, ResponseDTO } from 'wdNetwork'; | 1 | +import { HttpUrlUtils, HttpUtils, ResponseDTO } from 'wdNetwork'; |
| 2 | import { HttpRequest } from 'wdNetwork/src/main/ets/http/HttpRequest'; | 2 | import { HttpRequest } from 'wdNetwork/src/main/ets/http/HttpRequest'; |
| 3 | -import { Logger, ToastUtils, EmitterEventId, EmitterUtils } from 'wdKit'; | 3 | +import { Logger, ToastUtils, EmitterEventId, EmitterUtils, SPHelper } from 'wdKit'; |
| 4 | import { ContentDetailDTO, LiveDetailsBean, LiveRoomBean, LiveRoomDataBean, ReserveItemBean, ValueType } from 'wdBean/Index'; | 4 | import { ContentDetailDTO, LiveDetailsBean, LiveRoomBean, LiveRoomDataBean, ReserveItemBean, ValueType } from 'wdBean/Index'; |
| 5 | import { ContentDetailRequest } from 'wdDetailPlayApi/Index'; | 5 | import { ContentDetailRequest } from 'wdDetailPlayApi/Index'; |
| 6 | +import { SpConstants } from 'wdConstant/Index'; | ||
| 6 | 7 | ||
| 7 | const TAG = 'LiveModel' | 8 | const TAG = 'LiveModel' |
| 8 | 9 | ||
| @@ -266,5 +267,40 @@ export class LiveModel { | @@ -266,5 +267,40 @@ export class LiveModel { | ||
| 266 | }) | 267 | }) |
| 267 | }) | 268 | }) |
| 268 | } | 269 | } |
| 270 | + | ||
| 271 | + liveSendComment(comment: string, content: ContentDetailDTO) { | ||
| 272 | + let tourist: boolean = !HttpUtils.isLogin() | ||
| 273 | + let roomId: string = content.liveInfo.mlive.roomId as string | ||
| 274 | + let liveId: string = content.newsId + '' | ||
| 275 | + let mLiveId: string = content.liveInfo.mlive.mliveId as string | ||
| 276 | + | ||
| 277 | + let params: Record<string, string | number> = {}; | ||
| 278 | + params["liveId"] = liveId | ||
| 279 | + params["mliveId"] = mLiveId | ||
| 280 | + params["roomId"] = roomId | ||
| 281 | + params["title"] = content.newsTitle | ||
| 282 | + params["text"] = comment | ||
| 283 | + | ||
| 284 | + if (tourist) { | ||
| 285 | + params["deviceId"] = HttpUtils.getDeviceId() | ||
| 286 | + params["senderUserName"] = SPHelper.default.getSync(SpConstants.TOURIST_NICK_NAME, "") as string | ||
| 287 | + } else { | ||
| 288 | + params["senderUserId"] = SPHelper.default.getSync(SpConstants.USER_ID, "") as string | ||
| 289 | + params["senderAvatarUrl"] = SPHelper.default.getSync(SpConstants.USER_HEAD_PHOTO_URL, "") as string | ||
| 290 | + params["senderUserName"] = SPHelper.default.getSync(SpConstants.USER_NAME, "") as string | ||
| 291 | + } | ||
| 292 | + params["customizeExpression"] = 0 | ||
| 293 | + params["role"] = tourist ? "tourist" : "audience" | ||
| 294 | + | ||
| 295 | + let url = tourist ? HttpUrlUtils.getLiveTouristSendBarrageUrl() : HttpUrlUtils.getLiveSendBarrageUrl() | ||
| 296 | + return new Promise<ResponseDTO<Record<string, string | number>>>((success, fail) => { | ||
| 297 | + HttpRequest.post<ResponseDTO<Record<string, string | number>>>(url, params).then((data) => { | ||
| 298 | + success(data) | ||
| 299 | + }, (error: Error) => { | ||
| 300 | + fail(error.message) | ||
| 301 | + Logger.debug(TAG + ":error ", error.toString()) | ||
| 302 | + }) | ||
| 303 | + }) | ||
| 304 | + } | ||
| 269 | } | 305 | } |
| 270 | 306 |
| @@ -136,7 +136,15 @@ export class LiveViewModel { | @@ -136,7 +136,15 @@ export class LiveViewModel { | ||
| 136 | }) | 136 | }) |
| 137 | } | 137 | } |
| 138 | 138 | ||
| 139 | - sendComment(comment: string) { | 139 | + // 发送评论 |
| 140 | + sendComment(comment: string, content: ContentDetailDTO) { | ||
| 141 | + return new Promise<ResponseDTO<string>>((success, fail) => { | ||
| 142 | + this.liveModel.liveSendComment(comment, content).then((data) => { | ||
| 140 | 143 | ||
| 144 | + // success(data) | ||
| 145 | + }).catch((message: string) => { | ||
| 146 | + fail(message) | ||
| 147 | + }) | ||
| 148 | + }) | ||
| 141 | } | 149 | } |
| 142 | } | 150 | } |
| @@ -122,7 +122,7 @@ export struct PlayerCommentComponent { | @@ -122,7 +122,7 @@ export struct PlayerCommentComponent { | ||
| 122 | }, | 122 | }, |
| 123 | onCommentInputed: (content) => { | 123 | onCommentInputed: (content) => { |
| 124 | if (content.comment) { | 124 | if (content.comment) { |
| 125 | - this.liveViewModel.sendComment(content.comment) | 125 | + this.liveViewModel.sendComment(content.comment, this.contentDetailData) |
| 126 | } | 126 | } |
| 127 | }, | 127 | }, |
| 128 | onBack: () => { | 128 | onBack: () => { |
-
Please register or login to post a comment