xugenyuan

ref |> 增加刚发的评论可以点赞

Signed-off-by: xugenyuan <xugenyuan@wondertek.com.cn>
... ... @@ -151,6 +151,7 @@ export class commentStatusListModel extends PageModel {
@Observed
export class commentStatusModel {
commentId: string = '';
uuid: string = ''
status: boolean = false;
level: string = '';
levelHead: string = '';
... ...
... ... @@ -874,13 +874,13 @@ struct commentFooterView {
}
}
if (this.item.id) { // 审核通过的才显示点赞
// if (this.item.id) { // 审核通过的才显示点赞
Row({ space: 6 }) {
Text(this.item.likeNum)
.fontColor(this.item.api_status?$r('app.color.color_ED2800') : $r('app.color.color_666666'))
Text(this.item.likeNum + "")
.fontColor(this.item.api_status == true ?$r('app.color.color_ED2800') : $r('app.color.color_666666'))
.fontSize(14)
Image(this.item.api_status ? $r('app.media.comment_like_select') : $r('app.media.comment_like_normal'))
Image(this.item.api_status == true ? $r('app.media.comment_like_select') : $r('app.media.comment_like_normal'))
.size({
width: 16,
height: 16
... ... @@ -890,7 +890,7 @@ struct commentFooterView {
.onClick(() => {
this.clickLike()
})
}
// }
}
// .alignItems(VerticalAlign.Bottom)
.justifyContent(FlexAlign.SpaceBetween)
... ...
import { ViewType } from 'wdConstant/Index'
import { DateTimeUtils, LazyDataSource, Logger, ToastUtils, WindowModel } from 'wdKit/Index'
import { DateTimeUtils, LazyDataSource, Logger, NumberFormatterUtils, ToastUtils, WindowModel } from 'wdKit/Index'
import { commentItemModel } from '../model/CommentModel'
import commentViewModel from '../viewmodel/CommentViewModel'
import { router, window } from '@kit.ArkUI'
... ... @@ -387,6 +387,12 @@ struct QualityCommentItem {
Row({ space: 16 }) {
Row() {
Image($r('app.media.comment_icon_pinglun')).width(16).height(16)
if (this.item.replyNum && this.item.replyNum.length > 0 && this.item.replyNum != '0') {
Text(NumberFormatterUtils.formatNumberWithWan(this.item.replyNum))
.fontSize(14)
.fontColor('#999999')
.margin({ left: 3 })
}
}.height('100%')
.onClick(() => {
this.replyComment()
... ...
... ... @@ -54,7 +54,7 @@ class CommentViewModel {
return
}
let listData = data.data as commentListModel
this.fetchCommentStatusAndConfigAuthIcon(listData, false).then((commentListModel) => {
this.fetchCommentStatusAndConfigAuthIcon(listData, false, contentId).then((commentListModel) => {
console.log(TAG, 'fetchCommentStatusAndConfigAuthIcon完成')
if (pageNum !== "1") {
... ... @@ -63,7 +63,7 @@ class CommentViewModel {
}
// 热门评论批查
this.fetchCommentStatusAndConfigAuthIcon(listData, true).then((commentListModel) => {
this.fetchCommentStatusAndConfigAuthIcon(listData, true, contentId).then((commentListModel) => {
console.log(TAG, 'hot comment fetchCommentStatusAndConfigAuthIcon完成')
listData.hotList.forEach((item) => {
... ... @@ -101,7 +101,7 @@ class CommentViewModel {
// success(listData)
this.fetchCommentStatusAndConfigAuthIcon(listData).then((commentListModel) => {
this.fetchCommentStatusAndConfigAuthIcon(listData, false, contentId).then((commentListModel) => {
console.log(TAG, 'fetchCommentStatusAndConfigAuthIcon完成')
success(commentListModel)
})
... ... @@ -160,7 +160,8 @@ class CommentViewModel {
// userHeaderUrl string
// 【迭代二新增】当前用户的头像url
bean['commentId'] = model.id;
bean['commentId'] = (model.id + "").length > 0 ? (model.id + "") : "0";
bean['uuid'] = model.uuid;
bean['targetId'] = model.targetId;
bean['targetType'] = model.targetType;
bean['status'] = model.api_status ? '1' : '0';
... ... @@ -214,7 +215,7 @@ class CommentViewModel {
return
}
ToastUtils.showToast(data.message, 1000);
let model = data.data as commentItemModel
let comment = data.data as commentItemModel
let firstCommentTime = SPHelper.default.getSync(SpConstants.FIRSTCOMMENTTIME, '') as string
... ... @@ -223,8 +224,13 @@ class CommentViewModel {
SPHelper.default.saveSync(SpConstants.FIRSTCOMMENTTIME, DateTimeUtils.formatDate(data.timestamp, DateTimeUtils.PATTERN_DATE_TIME_HYPHEN))
}
await this.fetchCurrentUserAuthIcons(model)
let newModel = commentViewModel.deepCopyCommentItemModel(model)
comment.targetId = model.targetId
comment.targetRelId = model.targetRelId
comment.targetRelType = model.targetRelType
comment.targetType = model.targetType
comment.targetRelObjectId = model.targetRelObjectId
await this.fetchCurrentUserAuthIcons(comment)
let newModel = commentViewModel.deepCopyCommentItemModel(comment)
success(newModel)
}, (error: Error) => {
ToastUtils.showToast('评论失败', 1000);
... ... @@ -254,9 +260,12 @@ class CommentViewModel {
}
/*多接口批查*/
fetchCommentStatusAndConfigAuthIcon(model: commentListModel, hot: boolean = false): Promise<commentListModel> {
// hot 表示是否批查热门评论
// targetId 是指针对某一篇稿件的评论场景
fetchCommentStatusAndConfigAuthIcon(model: commentListModel, hot: boolean = false, targetId?: string): Promise<commentListModel> {
let commentIDs: string[] = [];
let uuidIDs: string[] = [];
let fromUserIDs: string[] = [];
... ... @@ -264,8 +273,10 @@ class CommentViewModel {
//主评论
for (const element of (hot ? model.hotList : model.list)) {
if ((element.id + '').length > 0) {
if ((element.id + '').length > 0 && (element.id + "") != "0") {
commentIDs.push(element.id + '')
} else {
uuidIDs.push(element.uuid)
}
if ((element.fromUserId + '').length > 0) {
fromUserIDs.push(element.fromUserId)
... ... @@ -278,8 +289,10 @@ class CommentViewModel {
//子评论
if (element.childComments) {
for (const obj2 of element.childComments) {
if ((obj2.id + '').length > 0) {
if ((obj2.id + '').length > 0 && (obj2.id + "") != "0") {
commentIDs.push(obj2.id + '')
} else {
uuidIDs.push(obj2.uuid)
}
if ((obj2.fromUserId + '').length > 0) {
fromUserIDs.push(obj2.fromUserId)
... ... @@ -300,8 +313,10 @@ class CommentViewModel {
let promise1 = new Promise<void>((success) => {
// HttpRequest HttpBizUtil
let url = HttpUrlUtils.getBatchCommentStatusUrl();
let bean: Record<string, string[]> = {};
let bean: Record<string, string | string[]> = {};
bean['commentIdList'] = commentIDs;
bean['targetId'] = targetId ?? ""
bean['uuidList'] = uuidIDs
HttpRequest.post<ResponseDTO<commentStatusModel[]>>(url, bean).then((data: ResponseDTO<commentStatusModel[]>) => {
if (!data || !data.data) {
success()
... ... @@ -319,13 +334,25 @@ class CommentViewModel {
//点赞
for (const element of listData) {
for (const commentModel of (hot ? model.hotList : model.list)) {
if (element.commentId == commentModel.id) {
commentModel.api_status = element.status
if ((commentModel.id + '').length > 0 && (commentModel.id + "") != "0") {
if (element.commentId == commentModel.id) {
commentModel.api_status = element.status
}
} else {
if (element.uuid == commentModel.uuid) {
commentModel.api_status = element.status
}
}
if (commentModel.childComments) {
for (const childCommentModel of commentModel.childComments) {
if (element.commentId == childCommentModel.id) {
childCommentModel.api_status = element.status
if ((childCommentModel.id + '').length > 0 && (childCommentModel.id + "") != "0") {
if (element.commentId == childCommentModel.id) {
childCommentModel.api_status = element.status
}
} else {
if (element.uuid == childCommentModel.uuid) {
childCommentModel.api_status = element.status
}
}
}
}
... ... @@ -477,7 +504,7 @@ class CommentViewModel {
newModel.mySelf = model.mySelf
newModel.parentId = model.parentId
newModel.region = model.region
newModel.replyNum = model.replyNum
newModel.replyNum = model.replyNum + ""
newModel.rootCommentId = model.rootCommentId
newModel.sensitiveExist = model.sensitiveExist
newModel.sensitiveShow = model.sensitiveShow
... ...