Showing
6 changed files
with
155 additions
and
65 deletions
| @@ -226,6 +226,15 @@ export class HttpUrlUtils { | @@ -226,6 +226,15 @@ export class HttpUrlUtils { | ||
| 226 | * 预约状态 | 226 | * 预约状态 |
| 227 | */ | 227 | */ |
| 228 | static readonly LIVE_APPOINTMENT_BATCH_PATH: string = "/api/live-center-message/zh/c/live/subscribe/user/batch"; | 228 | static readonly LIVE_APPOINTMENT_BATCH_PATH: string = "/api/live-center-message/zh/c/live/subscribe/user/batch"; |
| 229 | + | ||
| 230 | + /** | ||
| 231 | + * 查询是否被禁言 | ||
| 232 | + */ | ||
| 233 | + static getLiveBarrageHasBanUrl() { | ||
| 234 | + let url = HttpUrlUtils.getHost() + "/api/live-center-message/zh/c/mlive/barrage/ban" | ||
| 235 | + return url | ||
| 236 | + } | ||
| 237 | + | ||
| 229 | /** | 238 | /** |
| 230 | 239 | ||
| 231 | * 搜索结果 显示tab 数 | 240 | * 搜索结果 显示tab 数 |
| 1 | -import { NumberFormatterUtils, SPHelper } from 'wdKit'; | 1 | +import { NumberFormatterUtils, SPHelper, ToastUtils } from 'wdKit'; |
| 2 | import promptAction from '@ohos.promptAction'; | 2 | import promptAction from '@ohos.promptAction'; |
| 3 | import { | 3 | import { |
| 4 | batchLikeAndCollectResult, | 4 | batchLikeAndCollectResult, |
| @@ -19,6 +19,8 @@ import { SpConstants } from 'wdConstant/Index'; | @@ -19,6 +19,8 @@ import { SpConstants } from 'wdConstant/Index'; | ||
| 19 | import { WDShare } from 'wdShare/Index'; | 19 | import { WDShare } from 'wdShare/Index'; |
| 20 | import { EmitterEventId, EmitterUtils } from 'wdKit/Index' | 20 | import { EmitterEventId, EmitterUtils } from 'wdKit/Index' |
| 21 | import { ParamType, TrackConstants, TrackingContent } from 'wdTracking/Index'; | 21 | import { ParamType, TrackConstants, TrackingContent } from 'wdTracking/Index'; |
| 22 | +import { CommentCustomDialog, CommentDialogInputContent } from '../comment/view/CommentCustomDialog'; | ||
| 23 | +import { HttpUtils } from 'wdNetwork/Index'; | ||
| 22 | 24 | ||
| 23 | const TAG = 'LiveOperRowListView'; | 25 | const TAG = 'LiveOperRowListView'; |
| 24 | 26 | ||
| @@ -43,12 +45,8 @@ const TAG = 'LiveOperRowListView'; | @@ -43,12 +45,8 @@ const TAG = 'LiveOperRowListView'; | ||
| 43 | export struct LiveOperRowListView { | 45 | export struct LiveOperRowListView { |
| 44 | private onBack: () => void = () => { | 46 | private onBack: () => void = () => { |
| 45 | } | 47 | } |
| 46 | - private onCommentFocus: () => void = () => { | ||
| 47 | - } | ||
| 48 | - private onCommentIconClick: () => void = () => { | ||
| 49 | - } | ||
| 50 | - | ||
| 51 | - @Provide inDialog: boolean = false | 48 | + private onCommentInputFocus?: () => void |
| 49 | + private onCommentInputed?: (comment: CommentDialogInputContent) => void | ||
| 52 | 50 | ||
| 53 | @Prop @Watch('onDetailUpdated') contentDetailData: ContentDetailDTO // 稿件详情 | 51 | @Prop @Watch('onDetailUpdated') contentDetailData: ContentDetailDTO // 稿件详情 |
| 54 | /** | 52 | /** |
| @@ -60,9 +58,7 @@ export struct LiveOperRowListView { | @@ -60,9 +58,7 @@ export struct LiveOperRowListView { | ||
| 60 | @Prop showBackIcon?: boolean = true | 58 | @Prop showBackIcon?: boolean = true |
| 61 | @Prop operationButtonList?: string[] = ['comment', 'collect', 'share'] // 组件展示条件 | 59 | @Prop operationButtonList?: string[] = ['comment', 'collect', 'share'] // 组件展示条件 |
| 62 | @State needLike: boolean = true | 60 | @State needLike: boolean = true |
| 63 | - @ObjectLink publishCommentModel: publishCommentModel | ||
| 64 | @State styleType: number = -1 | 61 | @State styleType: number = -1 |
| 65 | - @State showCommentIcon: boolean = true // 评论图标 | ||
| 66 | @State bgColor: ResourceColor = Color.White | 62 | @State bgColor: ResourceColor = Color.White |
| 67 | @State interactData: InteractDataDTO = {} as InteractDataDTO | 63 | @State interactData: InteractDataDTO = {} as InteractDataDTO |
| 68 | @State newsStatusOfUser: batchLikeAndCollectResult | undefined = undefined // 点赞、收藏状态 | 64 | @State newsStatusOfUser: batchLikeAndCollectResult | undefined = undefined // 点赞、收藏状态 |
| @@ -73,20 +69,18 @@ export struct LiveOperRowListView { | @@ -73,20 +69,18 @@ export struct LiveOperRowListView { | ||
| 73 | @State likesStyle: number | string = "love" // 点赞样式 love爱心型 thumb点赞手势 mourning 蜡烛(默哀) pray 祈福 | 69 | @State likesStyle: number | string = "love" // 点赞样式 love爱心型 thumb点赞手势 mourning 蜡烛(默哀) pray 祈福 |
| 74 | @State openLikes: boolean = false // 是否可以点赞 1:可以 0:不可以 | 70 | @State openLikes: boolean = false // 是否可以点赞 1:可以 0:不可以 |
| 75 | 71 | ||
| 72 | + /// comment | ||
| 73 | + @State showCommentInput: boolean = false | ||
| 74 | + private banComment: boolean = true // 是否已禁言 | ||
| 75 | + private commentInputDialogController?: CustomDialogController | ||
| 76 | + @State publishCommentModel: publishCommentModel = new publishCommentModel() | ||
| 77 | + | ||
| 76 | async aboutToAppear() { | 78 | async aboutToAppear() { |
| 77 | console.info(TAG, 'this.needLike', this.needLike) | 79 | console.info(TAG, 'this.needLike', this.needLike) |
| 78 | this.handleStyle() | 80 | this.handleStyle() |
| 79 | this.onDetailUpdated() | 81 | this.onDetailUpdated() |
| 80 | - //注册通知,来自别的组件的评论成功通知 | ||
| 81 | - EmitterUtils.receiveEvent(EmitterEventId.COMMENT_PUBLISH, (targetId?: string) => { | ||
| 82 | - if (targetId) { | ||
| 83 | - if (targetId == this.publishCommentModel.targetId) { | ||
| 84 | - //新增评论 | ||
| 85 | - this.queryContentInteractCount() | ||
| 86 | - } | ||
| 87 | - } | ||
| 88 | - }) | ||
| 89 | this.contentTrackingDict() | 82 | this.contentTrackingDict() |
| 83 | + this.checkCanInputComment() | ||
| 90 | } | 84 | } |
| 91 | 85 | ||
| 92 | contentTrackingDict(){ | 86 | contentTrackingDict(){ |
| @@ -193,49 +187,54 @@ export struct LiveOperRowListView { | @@ -193,49 +187,54 @@ export struct LiveOperRowListView { | ||
| 193 | @Builder | 187 | @Builder |
| 194 | builderComment() { | 188 | builderComment() { |
| 195 | Column() { | 189 | Column() { |
| 196 | - if (this.contentDetailData.openComment == 1 | ||
| 197 | - && this.contentDetailData.commentDisplay == 1 | ||
| 198 | - && this.publishCommentModel?.targetId) { | ||
| 199 | - CommentTabComponent({ | ||
| 200 | - publishCommentModel: this.publishCommentModel, | ||
| 201 | - contentDetail: this.contentDetailData, | ||
| 202 | - onCommentFocus: this.onCommentFocus, | ||
| 203 | - pageComponentType: this.pageComponentType, | ||
| 204 | - onLoad: (dialogController: CustomDialogController | null) => { | ||
| 205 | - this.dialogController = dialogController | 190 | + if (this.showCommentInput) { |
| 191 | + Row() { | ||
| 192 | + Stack({ alignContent: Alignment.Start }) { | ||
| 193 | + RelativeContainer() { | ||
| 194 | + | ||
| 195 | + Image($r('app.media.comment_img_input_hui')) | ||
| 196 | + .objectFit(ImageFit.Fill) | ||
| 197 | + .resizable({ | ||
| 198 | + slice: { | ||
| 199 | + top: 1, | ||
| 200 | + left: 1, | ||
| 201 | + right: 20, | ||
| 202 | + bottom: 1 | ||
| 203 | + } | ||
| 204 | + }) | ||
| 205 | + .alignRules({ | ||
| 206 | + top: { anchor: "__container__", align: VerticalAlign.Top }, | ||
| 207 | + left: { anchor: "__container__", align: HorizontalAlign.Start }, | ||
| 208 | + right: { anchor: "__container__", align: HorizontalAlign.End }, | ||
| 209 | + bottom: { anchor: "__container__", align: VerticalAlign.Bottom }, | ||
| 210 | + }) | ||
| 211 | + .id("Image") | ||
| 212 | + Text("说两句...") | ||
| 213 | + .fontSize(12) | ||
| 214 | + .fontColor('#999999') | ||
| 215 | + .margin({ left: 10 }) | ||
| 216 | + .alignRules({ | ||
| 217 | + top: { anchor: "__container__", align: VerticalAlign.Top }, | ||
| 218 | + left: { anchor: "__container__", align: HorizontalAlign.Start }, | ||
| 219 | + bottom: { anchor: "__container__", align: VerticalAlign.Bottom }, | ||
| 220 | + }) | ||
| 221 | + .id("Text") | ||
| 222 | + } | ||
| 223 | + } | ||
| 224 | + } | ||
| 225 | + .height(30) | ||
| 226 | + .onClick(() => { | ||
| 227 | + if (this.onCommentInputFocus) { | ||
| 228 | + this.onCommentInputFocus() | ||
| 206 | } | 229 | } |
| 230 | + this.showCommentDialog() | ||
| 207 | }) | 231 | }) |
| 208 | } else { | 232 | } else { |
| 209 | Blank() | 233 | Blank() |
| 210 | } | 234 | } |
| 211 | } | 235 | } |
| 212 | .layoutWeight(1) | 236 | .layoutWeight(1) |
| 213 | - .margin({ | ||
| 214 | - right: this.pageComponentType === 1 ? 20 : 0, | ||
| 215 | - left: 16 | ||
| 216 | - }) | ||
| 217 | - | ||
| 218 | - if (this.showCommentIcon // 页面控制开关,直播传false | ||
| 219 | - && this.contentDetailData.openComment == 1 // 内容开关 | ||
| 220 | - && this.publishCommentModel?.targetId) { | ||
| 221 | - Column() { | ||
| 222 | - CommentIconComponent({ | ||
| 223 | - publishCommentModel: this.publishCommentModel, | ||
| 224 | - styleType: this.styleType, | ||
| 225 | - contentDetail: this.contentDetailData | ||
| 226 | - }) | ||
| 227 | - .onClick(() => { | ||
| 228 | - this.onCommentIconClick() | ||
| 229 | - | ||
| 230 | - console.log(JSON.stringify(this.dialogController?.open)) | ||
| 231 | - | ||
| 232 | - // 评论弹框内部嵌入 | ||
| 233 | - !this.showBackIcon && this.dialogController?.open() | ||
| 234 | - }) | ||
| 235 | - } | ||
| 236 | - .width(48) | ||
| 237 | - } | ||
| 238 | - | 237 | + .margin({ left: 16 }) |
| 239 | } | 238 | } |
| 240 | 239 | ||
| 241 | /** | 240 | /** |
| @@ -325,6 +324,57 @@ export struct LiveOperRowListView { | @@ -325,6 +324,57 @@ export struct LiveOperRowListView { | ||
| 325 | WDShare.shareContent(this.contentDetailData) | 324 | WDShare.shareContent(this.contentDetailData) |
| 326 | } | 325 | } |
| 327 | 326 | ||
| 327 | + showCommentDialog() { | ||
| 328 | + if (this.contentDetailData.liveInfo.openComment != 1) { | ||
| 329 | + ToastUtils.showToast("暂时无法评论", 3000) | ||
| 330 | + return | ||
| 331 | + } | ||
| 332 | + //未登录,游客评论打开 | ||
| 333 | + if (!HttpUtils.isLogin() && this.contentDetailData.visitorComment == 1) { | ||
| 334 | + this.commentDialog() | ||
| 335 | + return | ||
| 336 | + } | ||
| 337 | + | ||
| 338 | + if (!HttpUtils.isLogin()) { | ||
| 339 | + WDRouterRule.jumpWithPage(WDRouterPage.loginPage) | ||
| 340 | + return | ||
| 341 | + } | ||
| 342 | + if (this.banComment) { | ||
| 343 | + ToastUtils.showToast("暂时无法评论", 3000) | ||
| 344 | + return | ||
| 345 | + } | ||
| 346 | + this.commentDialog() | ||
| 347 | + } | ||
| 348 | + | ||
| 349 | + private commentDialog() { | ||
| 350 | + this.commentInputDialogController = new CustomDialogController({ | ||
| 351 | + builder: CommentCustomDialog({ | ||
| 352 | + onPublishBtnClick: (content: CommentDialogInputContent) => { | ||
| 353 | + if (this.banComment) { | ||
| 354 | + ToastUtils.showToast("暂时无法评论", 3000) | ||
| 355 | + } else if (this.onCommentInputed) { | ||
| 356 | + this.onCommentInputed(content) | ||
| 357 | + } | ||
| 358 | + this.commentInputDialogController?.close() | ||
| 359 | + return true | ||
| 360 | + }, | ||
| 361 | + publishCommentModel: this.publishCommentModel | ||
| 362 | + }), | ||
| 363 | + autoCancel: true, | ||
| 364 | + alignment: DialogAlignment.Bottom, | ||
| 365 | + customStyle: true, | ||
| 366 | + offset: { | ||
| 367 | + dx: 0, | ||
| 368 | + dy: -20 | ||
| 369 | + }, | ||
| 370 | + backgroundColor: "#50000000", | ||
| 371 | + }) | ||
| 372 | + this.publishCommentModel.rootCommentId = '-1'; | ||
| 373 | + this.publishCommentModel.parentId = '-1'; | ||
| 374 | + this.publishCommentModel.placeHolderText = "说两句..." | ||
| 375 | + this.commentInputDialogController?.open(); | ||
| 376 | + } | ||
| 377 | + | ||
| 328 | // 已登录->查询用户对作品收藏状态 | 378 | // 已登录->查询用户对作品收藏状态 |
| 329 | private async getInteractDataStatus() { | 379 | private async getInteractDataStatus() { |
| 330 | try { | 380 | try { |
| @@ -404,15 +454,26 @@ export struct LiveOperRowListView { | @@ -404,15 +454,26 @@ export struct LiveOperRowListView { | ||
| 404 | this.interactData.likeNum = NumberFormatterUtils.formatNumberWithWan(res.data[0]?.likeNum) | 454 | this.interactData.likeNum = NumberFormatterUtils.formatNumberWithWan(res.data[0]?.likeNum) |
| 405 | this.interactData.collectNum = NumberFormatterUtils.formatNumberWithWan(res.data[0]?.collectNum) | 455 | this.interactData.collectNum = NumberFormatterUtils.formatNumberWithWan(res.data[0]?.collectNum) |
| 406 | this.interactData.commentNum = NumberFormatterUtils.formatNumberWithWan(res.data[0]?.commentNum) | 456 | this.interactData.commentNum = NumberFormatterUtils.formatNumberWithWan(res.data[0]?.commentNum) |
| 407 | - // 评论组件需要数据 | ||
| 408 | - if (Number.parseInt(this.interactData.commentNum) > | ||
| 409 | - Number.parseInt(this.publishCommentModel.totalCommentNumer)) { | ||
| 410 | - this.publishCommentModel.totalCommentNumer = this.interactData.commentNum + '' || '0' | ||
| 411 | - } | ||
| 412 | } | 457 | } |
| 413 | // console.log(TAG, '获取互动点赞等数据===', JSON.stringify(res)) | 458 | // console.log(TAG, '获取互动点赞等数据===', JSON.stringify(res)) |
| 414 | console.log(TAG, 'this.interactData44', JSON.stringify(this.interactData)) | 459 | console.log(TAG, 'this.interactData44', JSON.stringify(this.interactData)) |
| 415 | - console.log(TAG, 'this.publishCommentModel', JSON.stringify(this.publishCommentModel)) | 460 | + }) |
| 461 | + } | ||
| 462 | + | ||
| 463 | + async checkCanInputComment() { | ||
| 464 | + // 允许评论,且大家聊没隐藏 | ||
| 465 | + let canComment = (this.contentDetailData.liveInfo.openComment == 1 && this.contentDetailData.liveInfo.liveStyle != 2) | ||
| 466 | + this.showCommentInput = canComment | ||
| 467 | + | ||
| 468 | + let mLiveId: string = this.contentDetailData.liveInfo.mlive.mliveId as string | ||
| 469 | + if (!HttpUtils.isLogin() || mLiveId == undefined) { | ||
| 470 | + return | ||
| 471 | + } | ||
| 472 | + | ||
| 473 | + // 查询是否被禁言 | ||
| 474 | + PageRepository.fetchLiveBarrageBan(mLiveId).then(res => { | ||
| 475 | + this.banComment = res.data as boolean | ||
| 476 | + this.showCommentInput = !this.banComment && canComment | ||
| 416 | }) | 477 | }) |
| 417 | } | 478 | } |
| 418 | } | 479 | } |
| @@ -480,4 +480,11 @@ export class PageRepository { | @@ -480,4 +480,11 @@ export class PageRepository { | ||
| 480 | url = url + "?liveIdList=" + ids; | 480 | url = url + "?liveIdList=" + ids; |
| 481 | return WDHttp.get<ResponseDTO<LiveRoomDataBean[]>>(url) | 481 | return WDHttp.get<ResponseDTO<LiveRoomDataBean[]>>(url) |
| 482 | }; | 482 | }; |
| 483 | + | ||
| 484 | + static fetchLiveBarrageBan(mLiveId: string) { | ||
| 485 | + let url = HttpUrlUtils.getLiveBarrageHasBanUrl() | ||
| 486 | + url = url + "?mliveId=" + mLiveId | ||
| 487 | + return WDHttp.get<ResponseDTO<boolean>>(url) | ||
| 488 | + } | ||
| 489 | + | ||
| 483 | } | 490 | } |
| @@ -73,11 +73,14 @@ export struct DetailPlayLivePage { | @@ -73,11 +73,14 @@ export struct DetailPlayLivePage { | ||
| 73 | operationButtonList: ['comment', 'collect', 'share', 'like'], | 73 | operationButtonList: ['comment', 'collect', 'share', 'like'], |
| 74 | styleType: 1, | 74 | styleType: 1, |
| 75 | contentDetailData: this.contentDetailData, | 75 | contentDetailData: this.contentDetailData, |
| 76 | - publishCommentModel: this.publishCommentModel, | ||
| 77 | - showCommentIcon: false, | ||
| 78 | - onCommentFocus: () => { | 76 | + onCommentInputFocus: () => { |
| 79 | // 切换到大家聊 | 77 | // 切换到大家聊 |
| 80 | this.changeToTab = Math.random() | 78 | this.changeToTab = Math.random() |
| 79 | + }, | ||
| 80 | + onCommentInputed: (content) => { | ||
| 81 | + if (content.comment) { | ||
| 82 | + this.liveViewModel.sendComment(content.comment) | ||
| 83 | + } | ||
| 81 | } | 84 | } |
| 82 | }).visibility(this.displayDirection == DisplayDirection.VERTICAL ? Visibility.Visible : Visibility.None) | 85 | }).visibility(this.displayDirection == DisplayDirection.VERTICAL ? Visibility.Visible : Visibility.None) |
| 83 | 86 |
| @@ -117,8 +117,14 @@ export struct PlayerCommentComponent { | @@ -117,8 +117,14 @@ export struct PlayerCommentComponent { | ||
| 117 | pageComponentType: 2, // 竖屏直播页 | 117 | pageComponentType: 2, // 竖屏直播页 |
| 118 | operationButtonList: ['comment', 'collect', 'share', 'like'], | 118 | operationButtonList: ['comment', 'collect', 'share', 'like'], |
| 119 | contentDetailData: this.contentDetailData, | 119 | contentDetailData: this.contentDetailData, |
| 120 | - publishCommentModel: this.publishCommentModel, | ||
| 121 | - showCommentIcon: false, | 120 | + onCommentInputFocus: () => { |
| 121 | + | ||
| 122 | + }, | ||
| 123 | + onCommentInputed: (content) => { | ||
| 124 | + if (content.comment) { | ||
| 125 | + this.liveViewModel.sendComment(content.comment) | ||
| 126 | + } | ||
| 127 | + }, | ||
| 122 | onBack: () => { | 128 | onBack: () => { |
| 123 | WindowModel.shared.setWindowLayoutFullScreen(false) | 129 | WindowModel.shared.setWindowLayoutFullScreen(false) |
| 124 | WindowModel.shared.setWindowSystemBarProperties({ statusBarContentColor: '#000000', }) | 130 | WindowModel.shared.setWindowSystemBarProperties({ statusBarContentColor: '#000000', }) |
-
Please register or login to post a comment