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
zhenghy
2024-05-28 21:15:47 +0800
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
7c5f3634de9a885592d50e6a5e34a9e4430050bf
7c5f3634
2 parents
ab7a2bc9
9d1a1dff
Merge remote-tracking branch 'origin/main'
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
154 additions
and
64 deletions
sight_harmony/commons/wdNetwork/src/main/ets/http/HttpUrlUtils.ets
sight_harmony/features/wdComponent/src/main/ets/components/view/LiveOperRowListView.ets
sight_harmony/features/wdComponent/src/main/ets/repository/PageRepository.ets
sight_harmony/features/wdDetailPlayLive/src/main/ets/pages/DetailPlayLivePage.ets
sight_harmony/features/wdDetailPlayLive/src/main/ets/viewModel/LiveViewModel.ets
sight_harmony/features/wdDetailPlayLive/src/main/ets/widgets/vertical/PlayerCommentComponent.ets
sight_harmony/commons/wdNetwork/src/main/ets/http/HttpUrlUtils.ets
View file @
7c5f363
...
...
@@ -226,6 +226,15 @@ export class HttpUrlUtils {
* 预约状态
*/
static readonly LIVE_APPOINTMENT_BATCH_PATH: string = "/api/live-center-message/zh/c/live/subscribe/user/batch";
/**
* 查询是否被禁言
*/
static getLiveBarrageHasBanUrl() {
let url = HttpUrlUtils.getHost() + "/api/live-center-message/zh/c/mlive/barrage/ban"
return url
}
/**
* 搜索结果 显示tab 数
...
...
sight_harmony/features/wdComponent/src/main/ets/components/view/LiveOperRowListView.ets
View file @
7c5f363
import { NumberFormatterUtils, SPHelper } from 'wdKit';
import { NumberFormatterUtils, SPHelper
, ToastUtils
} from 'wdKit';
import promptAction from '@ohos.promptAction';
import {
batchLikeAndCollectResult,
...
...
@@ -19,6 +19,8 @@ import { SpConstants } from 'wdConstant/Index';
import { WDShare } from 'wdShare/Index';
import { EmitterEventId, EmitterUtils } from 'wdKit/Index'
import { ParamType, TrackConstants, TrackingContent } from 'wdTracking/Index';
import { CommentCustomDialog, CommentDialogInputContent } from '../comment/view/CommentCustomDialog';
import { HttpUtils } from 'wdNetwork/Index';
const TAG = 'LiveOperRowListView';
...
...
@@ -43,12 +45,8 @@ const TAG = 'LiveOperRowListView';
export struct LiveOperRowListView {
private onBack: () => void = () => {
}
private onCommentFocus: () => void = () => {
}
private onCommentIconClick: () => void = () => {
}
@Provide inDialog: boolean = false
private onCommentInputFocus?: () => void
private onCommentInputed?: (comment: CommentDialogInputContent) => void
@Prop @Watch('onDetailUpdated') contentDetailData: ContentDetailDTO // 稿件详情
/**
...
...
@@ -60,9 +58,7 @@ export struct LiveOperRowListView {
@Prop showBackIcon?: boolean = true
@Prop operationButtonList?: string[] = ['comment', 'collect', 'share'] // 组件展示条件
@State needLike: boolean = true
@ObjectLink publishCommentModel: publishCommentModel
@State styleType: number = -1
@State showCommentIcon: boolean = true // 评论图标
@State bgColor: ResourceColor = Color.White
@State interactData: InteractDataDTO = {} as InteractDataDTO
@State newsStatusOfUser: batchLikeAndCollectResult | undefined = undefined // 点赞、收藏状态
...
...
@@ -73,20 +69,18 @@ export struct LiveOperRowListView {
@State likesStyle: number | string = "love" // 点赞样式 love爱心型 thumb点赞手势 mourning 蜡烛(默哀) pray 祈福
@State openLikes: boolean = false // 是否可以点赞 1:可以 0:不可以
/// comment
@State showCommentInput: boolean = false
private banComment: boolean = true // 是否已禁言
private commentInputDialogController?: CustomDialogController
@State publishCommentModel: publishCommentModel = new publishCommentModel()
async aboutToAppear() {
console.info(TAG, 'this.needLike', this.needLike)
this.handleStyle()
this.onDetailUpdated()
//注册通知,来自别的组件的评论成功通知
EmitterUtils.receiveEvent(EmitterEventId.COMMENT_PUBLISH, (targetId?: string) => {
if (targetId) {
if (targetId == this.publishCommentModel.targetId) {
//新增评论
this.queryContentInteractCount()
}
}
})
this.contentTrackingDict()
this.checkCanInputComment()
}
contentTrackingDict(){
...
...
@@ -193,49 +187,54 @@ export struct LiveOperRowListView {
@Builder
builderComment() {
Column() {
if (this.contentDetailData.openComment == 1
&& this.contentDetailData.commentDisplay == 1
&& this.publishCommentModel?.targetId) {
CommentTabComponent({
publishCommentModel: this.publishCommentModel,
contentDetail: this.contentDetailData,
onCommentFocus: this.onCommentFocus,
pageComponentType: this.pageComponentType,
onLoad: (dialogController: CustomDialogController | null) => {
this.dialogController = dialogController
if (this.showCommentInput) {
Row() {
Stack({ alignContent: Alignment.Start }) {
RelativeContainer() {
Image($r('app.media.comment_img_input_hui'))
.objectFit(ImageFit.Fill)
.resizable({
slice: {
top: 1,
left: 1,
right: 20,
bottom: 1
}
})
} else {
Blank()
}
}
.layoutWeight(1)
.margin({
right: this.pageComponentType === 1 ? 20 : 0,
left: 16
.alignRules({
top: { anchor: "__container__", align: VerticalAlign.Top },
left: { anchor: "__container__", align: HorizontalAlign.Start },
right: { anchor: "__container__", align: HorizontalAlign.End },
bottom: { anchor: "__container__", align: VerticalAlign.Bottom },
})
if (this.showCommentIcon // 页面控制开关,直播传false
&& this.contentDetailData.openComment == 1 // 内容开关
&& this.publishCommentModel?.targetId) {
Column() {
CommentIconComponent({
publishCommentModel: this.publishCommentModel,
styleType: this.styleType,
contentDetail: this.contentDetailData
.id("Image")
Text("说两句...")
.fontSize(12)
.fontColor('#999999')
.margin({ left: 10 })
.alignRules({
top: { anchor: "__container__", align: VerticalAlign.Top },
left: { anchor: "__container__", align: HorizontalAlign.Start },
bottom: { anchor: "__container__", align: VerticalAlign.Bottom },
})
.id("Text")
}
}
}
.height(30)
.onClick(() => {
this.onCommentIconClick()
console.log(JSON.stringify(this.dialogController?.open))
// 评论弹框内部嵌入
!this.showBackIcon && this.dialogController?.open()
if (this.onCommentInputFocus) {
this.onCommentInputFocus()
}
this.showCommentDialog()
})
} else {
Blank()
}
.width(48)
}
.layoutWeight(1)
.margin({ left: 16 })
}
/**
...
...
@@ -325,6 +324,57 @@ export struct LiveOperRowListView {
WDShare.shareContent(this.contentDetailData)
}
showCommentDialog() {
if (this.contentDetailData.liveInfo.openComment != 1) {
ToastUtils.showToast("暂时无法评论", 3000)
return
}
//未登录,游客评论打开
if (!HttpUtils.isLogin() && this.contentDetailData.visitorComment == 1) {
this.commentDialog()
return
}
if (!HttpUtils.isLogin()) {
WDRouterRule.jumpWithPage(WDRouterPage.loginPage)
return
}
if (this.banComment) {
ToastUtils.showToast("暂时无法评论", 3000)
return
}
this.commentDialog()
}
private commentDialog() {
this.commentInputDialogController = new CustomDialogController({
builder: CommentCustomDialog({
onPublishBtnClick: (content: CommentDialogInputContent) => {
if (this.banComment) {
ToastUtils.showToast("暂时无法评论", 3000)
} else if (this.onCommentInputed) {
this.onCommentInputed(content)
}
this.commentInputDialogController?.close()
return true
},
publishCommentModel: this.publishCommentModel
}),
autoCancel: true,
alignment: DialogAlignment.Bottom,
customStyle: true,
offset: {
dx: 0,
dy: -20
},
backgroundColor: "#50000000",
})
this.publishCommentModel.rootCommentId = '-1';
this.publishCommentModel.parentId = '-1';
this.publishCommentModel.placeHolderText = "说两句..."
this.commentInputDialogController?.open();
}
// 已登录->查询用户对作品收藏状态
private async getInteractDataStatus() {
try {
...
...
@@ -404,15 +454,26 @@ export struct LiveOperRowListView {
this.interactData.likeNum = NumberFormatterUtils.formatNumberWithWan(res.data[0]?.likeNum)
this.interactData.collectNum = NumberFormatterUtils.formatNumberWithWan(res.data[0]?.collectNum)
this.interactData.commentNum = NumberFormatterUtils.formatNumberWithWan(res.data[0]?.commentNum)
// 评论组件需要数据
if (Number.parseInt(this.interactData.commentNum) >
Number.parseInt(this.publishCommentModel.totalCommentNumer)) {
this.publishCommentModel.totalCommentNumer = this.interactData.commentNum + '' || '0'
}
}
// console.log(TAG, '获取互动点赞等数据===', JSON.stringify(res))
console.log(TAG, 'this.interactData44', JSON.stringify(this.interactData))
console.log(TAG, 'this.publishCommentModel', JSON.stringify(this.publishCommentModel))
})
}
async checkCanInputComment() {
// 允许评论,且大家聊没隐藏
let canComment = (this.contentDetailData.liveInfo.openComment == 1 && this.contentDetailData.liveInfo.liveStyle != 2)
this.showCommentInput = canComment
let mLiveId: string = this.contentDetailData.liveInfo.mlive.mliveId as string
if (!HttpUtils.isLogin() || mLiveId == undefined) {
return
}
// 查询是否被禁言
PageRepository.fetchLiveBarrageBan(mLiveId).then(res => {
this.banComment = res.data as boolean
this.showCommentInput = !this.banComment && canComment
})
}
}
\ No newline at end of file
...
...
sight_harmony/features/wdComponent/src/main/ets/repository/PageRepository.ets
View file @
7c5f363
...
...
@@ -480,4 +480,11 @@ export class PageRepository {
url = url + "?liveIdList=" + ids;
return WDHttp.get<ResponseDTO<LiveRoomDataBean[]>>(url)
};
static fetchLiveBarrageBan(mLiveId: string) {
let url = HttpUrlUtils.getLiveBarrageHasBanUrl()
url = url + "?mliveId=" + mLiveId
return WDHttp.get<ResponseDTO<boolean>>(url)
}
}
...
...
sight_harmony/features/wdDetailPlayLive/src/main/ets/pages/DetailPlayLivePage.ets
View file @
7c5f363
...
...
@@ -73,11 +73,14 @@ export struct DetailPlayLivePage {
operationButtonList: ['comment', 'collect', 'share', 'like'],
styleType: 1,
contentDetailData: this.contentDetailData,
publishCommentModel: this.publishCommentModel,
showCommentIcon: false,
onCommentFocus: () => {
onCommentInputFocus: () => {
// 切换到大家聊
this.changeToTab = Math.random()
},
onCommentInputed: (content) => {
if (content.comment) {
this.liveViewModel.sendComment(content.comment)
}
}
}).visibility(this.displayDirection == DisplayDirection.VERTICAL ? Visibility.Visible : Visibility.None)
...
...
sight_harmony/features/wdDetailPlayLive/src/main/ets/viewModel/LiveViewModel.ets
View file @
7c5f363
...
...
@@ -110,4 +110,8 @@ export class LiveViewModel {
})
})
}
sendComment(comment: string) {
}
}
\ No newline at end of file
...
...
sight_harmony/features/wdDetailPlayLive/src/main/ets/widgets/vertical/PlayerCommentComponent.ets
View file @
7c5f363
...
...
@@ -117,8 +117,14 @@ export struct PlayerCommentComponent {
pageComponentType: 2, // 竖屏直播页
operationButtonList: ['comment', 'collect', 'share', 'like'],
contentDetailData: this.contentDetailData,
publishCommentModel: this.publishCommentModel,
showCommentIcon: false,
onCommentInputFocus: () => {
},
onCommentInputed: (content) => {
if (content.comment) {
this.liveViewModel.sendComment(content.comment)
}
},
onBack: () => {
WindowModel.shared.setWindowLayoutFullScreen(false)
WindowModel.shared.setWindowSystemBarProperties({ statusBarContentColor: '#000000', })
...
...
Please
register
or
login
to post a comment