daijian_wd

稿件底部评论点赞组件封装完善2

... ... @@ -46,10 +46,6 @@ export class HttpUrlUtils {
*/
static readonly INTERACT_EXECUTELIKE: string = "/api/rmrb-interact/interact/zh/c/like/executeLike";
/**
* 收藏、取消收藏
*/
static readonly INTERACT_EXECUTECOLLECTRECORD: string = "/api/rmrb-interact/interact/zh/c/collect/executeCollcetRecord";
/**
* 关注号主
*/
static readonly INTERACT_ACCENTION_OPERATION: string = "/api/rmrb-interact/interact/zh/c/attention/operation";
... ...
... ... @@ -2,11 +2,11 @@
* 批查接口查询互动相关数据,返回数据bean
*/
export interface InteractDataDTO {
collectNum: number | String;
commentNum: number | String;
collectNum: number | string;
commentNum: number | string;
contentId: string;
contentType: number;
likeNum: number | String;
likeNum: number | string;
readNum: number;
shareNum: number;
}
\ No newline at end of file
... ...
... ... @@ -38,7 +38,7 @@ export struct ImageAndTextPageComponent {
@State interactData: InteractDataDTO = {} as InteractDataDTO
@State isPageEnd: boolean = false
@State publishTime: string = ''
@State publishCommentModel: publishCommentModel = {} as publishCommentModel
@State publishCommentModel: publishCommentModel = new publishCommentModel()
build() {
Column() {
... ... @@ -142,7 +142,10 @@ export struct ImageAndTextPageComponent {
//底部交互区
if (this.contentDetailData?.length) {
OperRowListView({ contentDetailData: this.contentDetailData[0] })
OperRowListView({
contentDetailData: this.contentDetailData[0],
publishCommentModel: this.publishCommentModel
})
}
}
... ...
... ... @@ -30,21 +30,21 @@ const TAG = 'OperRowListView';
* comment--评论;like--点赞;collect--收藏;share--分享;
*
* 传值示例:
OperRowListView({
contentDetailData: this.contentDetailData[0],
operationButtonList: ['comment', 'like', 'collect', 'share']
})
OperRowListView({
contentDetailData: this.contentDetailData[0],
operationButtonList: ['comment', 'like', 'collect', 'share']
})
*/
@Preview
@Component
export struct OperRowListView {
@Prop contentDetailData: ContentDetailDTO // 稿件详情
@State operationButtonList: string[] = ['comment', 'like', 'collect', 'share'] // 组件展示条件
@Prop publishCommentModel: publishCommentModel
// @State contentDetailData: ContentDetailDTO = {} as ContentDetailDTO
@State interactData: InteractDataDTO = {} as InteractDataDTO
@State newsStatusOfUser: batchLikeAndCollectResult | undefined = undefined // 点赞、收藏状态
@State likeBean: Record<string, string> = {}
@State publishCommentModel: publishCommentModel = new publishCommentModel()
async aboutToAppear() {
const user_id = await SPHelper.default.get(SpConstants.USER_ID, '')
... ... @@ -62,13 +62,13 @@ export struct OperRowListView {
console.info(TAG, 'contentDetailData----', JSON.stringify(this.contentDetailData))
console.info(TAG, 'likeBean----', JSON.stringify(this.likeBean))
// 评论需要数据
this.publishCommentModel.targetId = this.contentDetailData.newsId + ''
this.publishCommentModel.targetRelId = this.contentDetailData.reLInfo?.relId + ''
this.publishCommentModel.targetTitle = this.contentDetailData.newsTitle + ''
this.publishCommentModel.targetRelType = this.contentDetailData.reLInfo?.relType + ''
this.publishCommentModel.targetRelObjectId = this.contentDetailData.reLInfo?.relObjectId + ''
this.publishCommentModel.keyArticle = this.contentDetailData.keyArticle + ''
this.publishCommentModel.targetType = this.contentDetailData.newsType + ''
/* this.publishCommentModel.targetId = this.contentDetailData.newsId + ''
this.publishCommentModel.targetRelId = this.contentDetailData.reLInfo?.relId + ''
this.publishCommentModel.targetTitle = this.contentDetailData.newsTitle + ''
this.publishCommentModel.targetRelType = this.contentDetailData.reLInfo?.relType + ''
this.publishCommentModel.targetRelObjectId = this.contentDetailData.reLInfo?.relObjectId + ''
this.publishCommentModel.keyArticle = this.contentDetailData.keyArticle + ''
this.publishCommentModel.targetType = this.contentDetailData.newsType + ''*/
}
build() {
... ... @@ -232,7 +232,6 @@ export struct OperRowListView {
}
PageRepository.postExecuteCollectRecord(params).then(res => {
// console.log(TAG, '收藏、取消收藏', 'toggleLikeStatus==',)
if (this.newsStatusOfUser) {
this.newsStatusOfUser.collectStatus = this.newsStatusOfUser?.collectStatus === 1 ? 0 : 1
this.queryContentInteractCount()
... ... @@ -258,7 +257,9 @@ export struct OperRowListView {
this.interactData.collectNum = NumberFormatterUtils.formatNumberWithWan(res.data[0]?.collectNum)
this.interactData.commentNum = NumberFormatterUtils.formatNumberWithWan(res.data[0]?.commentNum)
// 评论组件需要数据
this.publishCommentModel.totalCommentNumer = this.interactData.commentNum + '' || '0'
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.interactData', JSON.stringify(this.interactData))
... ...
... ... @@ -283,7 +283,7 @@ export class PageRepository {
* @returns
*/
static postExecuteCollectRecord(params: postExecuteCollectRecordParams): Promise<ResponseDTO> {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_EXECUTECOLLECTRECORD
let url = HttpUrlUtils.getExecuteCollcetUrl()
return WDHttp.post(url, params)
}
... ...
... ... @@ -288,7 +288,7 @@ export class ContentDetailRequest {
* @returns
*/
static postExecuteCollectRecord(params: postExecuteCollectRecordParams): Promise<ResponseDTO> {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_EXECUTECOLLECTRECORD
let url = HttpUrlUtils.getExecuteCollcetUrl()
return WDHttp.post(url, params)
}
... ...