xugenyuan

ref |> 直播模块新增发布评论接口调用

... ... @@ -681,6 +681,15 @@ export class HttpUrlUtils {
return url
}
static getLiveSendBarrageUrl() {
let url = HttpUrlUtils.getHost() + "/api/live-center-message/zh/c/live/message/chat/send"
return url
}
static getLiveTouristSendBarrageUrl() {
let url = HttpUrlUtils.getHost() + "/api/live-center-message/zh/a/live/message/chat/tourist/send"
return url
}
static getAppointmentStatusUrl() {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.LIVE_APPOINTMENT_BATCH_PATH
return url
... ...
... ... @@ -466,14 +466,20 @@ export struct LiveOperRowListView {
this.showCommentInput = canComment
let mLiveId: string = this.contentDetailData.liveInfo.mlive.mliveId as string
if (!HttpUtils.isLogin() || mLiveId == undefined) {
if (!mLiveId) {
return
}
if (!HttpUtils.isLogin()) {
this.banComment = false
return
}
// 查询是否被禁言
PageRepository.fetchLiveBarrageBan(mLiveId).then(res => {
this.banComment = res.data as boolean
this.showCommentInput = !this.banComment && canComment
if (res.code == 0) {
this.banComment = res.data as boolean
this.showCommentInput = !this.banComment && canComment
}
})
}
}
\ No newline at end of file
... ...
... ... @@ -79,7 +79,7 @@ export struct DetailPlayLivePage {
},
onCommentInputed: (content) => {
if (content.comment) {
this.liveViewModel.sendComment(content.comment)
this.liveViewModel.sendComment(content.comment, this.contentDetailData)
}
}
}).visibility(this.displayDirection == DisplayDirection.VERTICAL ? Visibility.Visible : Visibility.None)
... ...
import { HttpUrlUtils, ResponseDTO } from 'wdNetwork';
import { HttpUrlUtils, HttpUtils, ResponseDTO } from 'wdNetwork';
import { HttpRequest } from 'wdNetwork/src/main/ets/http/HttpRequest';
import { Logger, ToastUtils, EmitterEventId, EmitterUtils } from 'wdKit';
import { Logger, ToastUtils, EmitterEventId, EmitterUtils, SPHelper } from 'wdKit';
import { ContentDetailDTO, LiveDetailsBean, LiveRoomBean, LiveRoomDataBean, ReserveItemBean, ValueType } from 'wdBean/Index';
import { ContentDetailRequest } from 'wdDetailPlayApi/Index';
import { SpConstants } from 'wdConstant/Index';
const TAG = 'LiveModel'
... ... @@ -266,5 +267,40 @@ export class LiveModel {
})
})
}
liveSendComment(comment: string, content: ContentDetailDTO) {
let tourist: boolean = !HttpUtils.isLogin()
let roomId: string = content.liveInfo.mlive.roomId as string
let liveId: string = content.newsId + ''
let mLiveId: string = content.liveInfo.mlive.mliveId as string
let params: Record<string, string | number> = {};
params["liveId"] = liveId
params["mliveId"] = mLiveId
params["roomId"] = roomId
params["title"] = content.newsTitle
params["text"] = comment
if (tourist) {
params["deviceId"] = HttpUtils.getDeviceId()
params["senderUserName"] = SPHelper.default.getSync(SpConstants.TOURIST_NICK_NAME, "") as string
} else {
params["senderUserId"] = SPHelper.default.getSync(SpConstants.USER_ID, "") as string
params["senderAvatarUrl"] = SPHelper.default.getSync(SpConstants.USER_HEAD_PHOTO_URL, "") as string
params["senderUserName"] = SPHelper.default.getSync(SpConstants.USER_NAME, "") as string
}
params["customizeExpression"] = 0
params["role"] = tourist ? "tourist" : "audience"
let url = tourist ? HttpUrlUtils.getLiveTouristSendBarrageUrl() : HttpUrlUtils.getLiveSendBarrageUrl()
return new Promise<ResponseDTO<Record<string, string | number>>>((success, fail) => {
HttpRequest.post<ResponseDTO<Record<string, string | number>>>(url, params).then((data) => {
success(data)
}, (error: Error) => {
fail(error.message)
Logger.debug(TAG + ":error ", error.toString())
})
})
}
}
... ...
... ... @@ -136,7 +136,15 @@ export class LiveViewModel {
})
}
sendComment(comment: string) {
// 发送评论
sendComment(comment: string, content: ContentDetailDTO) {
return new Promise<ResponseDTO<string>>((success, fail) => {
this.liveModel.liveSendComment(comment, content).then((data) => {
// success(data)
}).catch((message: string) => {
fail(message)
})
})
}
}
\ No newline at end of file
... ...
... ... @@ -122,7 +122,7 @@ export struct PlayerCommentComponent {
},
onCommentInputed: (content) => {
if (content.comment) {
this.liveViewModel.sendComment(content.comment)
this.liveViewModel.sendComment(content.comment, this.contentDetailData)
}
},
onBack: () => {
... ...