ref |> 增加刚发的评论可以点赞
Signed-off-by: xugenyuan <xugenyuan@wondertek.com.cn>
Showing
4 changed files
with
56 additions
and
22 deletions
| @@ -151,6 +151,7 @@ export class commentStatusListModel extends PageModel { | @@ -151,6 +151,7 @@ export class commentStatusListModel extends PageModel { | ||
| 151 | @Observed | 151 | @Observed |
| 152 | export class commentStatusModel { | 152 | export class commentStatusModel { |
| 153 | commentId: string = ''; | 153 | commentId: string = ''; |
| 154 | + uuid: string = '' | ||
| 154 | status: boolean = false; | 155 | status: boolean = false; |
| 155 | level: string = ''; | 156 | level: string = ''; |
| 156 | levelHead: string = ''; | 157 | levelHead: string = ''; |
| @@ -874,13 +874,13 @@ struct commentFooterView { | @@ -874,13 +874,13 @@ struct commentFooterView { | ||
| 874 | } | 874 | } |
| 875 | } | 875 | } |
| 876 | 876 | ||
| 877 | - if (this.item.id) { // 审核通过的才显示点赞 | 877 | + // if (this.item.id) { // 审核通过的才显示点赞 |
| 878 | Row({ space: 6 }) { | 878 | Row({ space: 6 }) { |
| 879 | - Text(this.item.likeNum) | ||
| 880 | - .fontColor(this.item.api_status?$r('app.color.color_ED2800') : $r('app.color.color_666666')) | 879 | + Text(this.item.likeNum + "") |
| 880 | + .fontColor(this.item.api_status == true ?$r('app.color.color_ED2800') : $r('app.color.color_666666')) | ||
| 881 | .fontSize(14) | 881 | .fontSize(14) |
| 882 | 882 | ||
| 883 | - Image(this.item.api_status ? $r('app.media.comment_like_select') : $r('app.media.comment_like_normal')) | 883 | + Image(this.item.api_status == true ? $r('app.media.comment_like_select') : $r('app.media.comment_like_normal')) |
| 884 | .size({ | 884 | .size({ |
| 885 | width: 16, | 885 | width: 16, |
| 886 | height: 16 | 886 | height: 16 |
| @@ -890,7 +890,7 @@ struct commentFooterView { | @@ -890,7 +890,7 @@ struct commentFooterView { | ||
| 890 | .onClick(() => { | 890 | .onClick(() => { |
| 891 | this.clickLike() | 891 | this.clickLike() |
| 892 | }) | 892 | }) |
| 893 | - } | 893 | + // } |
| 894 | } | 894 | } |
| 895 | // .alignItems(VerticalAlign.Bottom) | 895 | // .alignItems(VerticalAlign.Bottom) |
| 896 | .justifyContent(FlexAlign.SpaceBetween) | 896 | .justifyContent(FlexAlign.SpaceBetween) |
sight_harmony/features/wdComponent/src/main/ets/components/comment/view/QualityCommentsComponent.ets
| 1 | import { ViewType } from 'wdConstant/Index' | 1 | import { ViewType } from 'wdConstant/Index' |
| 2 | -import { DateTimeUtils, LazyDataSource, Logger, ToastUtils, WindowModel } from 'wdKit/Index' | 2 | +import { DateTimeUtils, LazyDataSource, Logger, NumberFormatterUtils, ToastUtils, WindowModel } from 'wdKit/Index' |
| 3 | import { commentItemModel } from '../model/CommentModel' | 3 | import { commentItemModel } from '../model/CommentModel' |
| 4 | import commentViewModel from '../viewmodel/CommentViewModel' | 4 | import commentViewModel from '../viewmodel/CommentViewModel' |
| 5 | import { router, window } from '@kit.ArkUI' | 5 | import { router, window } from '@kit.ArkUI' |
| @@ -387,6 +387,12 @@ struct QualityCommentItem { | @@ -387,6 +387,12 @@ struct QualityCommentItem { | ||
| 387 | Row({ space: 16 }) { | 387 | Row({ space: 16 }) { |
| 388 | Row() { | 388 | Row() { |
| 389 | Image($r('app.media.comment_icon_pinglun')).width(16).height(16) | 389 | Image($r('app.media.comment_icon_pinglun')).width(16).height(16) |
| 390 | + if (this.item.replyNum && this.item.replyNum.length > 0 && this.item.replyNum != '0') { | ||
| 391 | + Text(NumberFormatterUtils.formatNumberWithWan(this.item.replyNum)) | ||
| 392 | + .fontSize(14) | ||
| 393 | + .fontColor('#999999') | ||
| 394 | + .margin({ left: 3 }) | ||
| 395 | + } | ||
| 390 | }.height('100%') | 396 | }.height('100%') |
| 391 | .onClick(() => { | 397 | .onClick(() => { |
| 392 | this.replyComment() | 398 | this.replyComment() |
| @@ -54,7 +54,7 @@ class CommentViewModel { | @@ -54,7 +54,7 @@ class CommentViewModel { | ||
| 54 | return | 54 | return |
| 55 | } | 55 | } |
| 56 | let listData = data.data as commentListModel | 56 | let listData = data.data as commentListModel |
| 57 | - this.fetchCommentStatusAndConfigAuthIcon(listData, false).then((commentListModel) => { | 57 | + this.fetchCommentStatusAndConfigAuthIcon(listData, false, contentId).then((commentListModel) => { |
| 58 | console.log(TAG, 'fetchCommentStatusAndConfigAuthIcon完成') | 58 | console.log(TAG, 'fetchCommentStatusAndConfigAuthIcon完成') |
| 59 | 59 | ||
| 60 | if (pageNum !== "1") { | 60 | if (pageNum !== "1") { |
| @@ -63,7 +63,7 @@ class CommentViewModel { | @@ -63,7 +63,7 @@ class CommentViewModel { | ||
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | // 热门评论批查 | 65 | // 热门评论批查 |
| 66 | - this.fetchCommentStatusAndConfigAuthIcon(listData, true).then((commentListModel) => { | 66 | + this.fetchCommentStatusAndConfigAuthIcon(listData, true, contentId).then((commentListModel) => { |
| 67 | console.log(TAG, 'hot comment fetchCommentStatusAndConfigAuthIcon完成') | 67 | console.log(TAG, 'hot comment fetchCommentStatusAndConfigAuthIcon完成') |
| 68 | 68 | ||
| 69 | listData.hotList.forEach((item) => { | 69 | listData.hotList.forEach((item) => { |
| @@ -101,7 +101,7 @@ class CommentViewModel { | @@ -101,7 +101,7 @@ class CommentViewModel { | ||
| 101 | 101 | ||
| 102 | // success(listData) | 102 | // success(listData) |
| 103 | 103 | ||
| 104 | - this.fetchCommentStatusAndConfigAuthIcon(listData).then((commentListModel) => { | 104 | + this.fetchCommentStatusAndConfigAuthIcon(listData, false, contentId).then((commentListModel) => { |
| 105 | console.log(TAG, 'fetchCommentStatusAndConfigAuthIcon完成') | 105 | console.log(TAG, 'fetchCommentStatusAndConfigAuthIcon完成') |
| 106 | success(commentListModel) | 106 | success(commentListModel) |
| 107 | }) | 107 | }) |
| @@ -160,7 +160,8 @@ class CommentViewModel { | @@ -160,7 +160,8 @@ class CommentViewModel { | ||
| 160 | // userHeaderUrl string | 160 | // userHeaderUrl string |
| 161 | // 【迭代二新增】当前用户的头像url | 161 | // 【迭代二新增】当前用户的头像url |
| 162 | 162 | ||
| 163 | - bean['commentId'] = model.id; | 163 | + bean['commentId'] = (model.id + "").length > 0 ? (model.id + "") : "0"; |
| 164 | + bean['uuid'] = model.uuid; | ||
| 164 | bean['targetId'] = model.targetId; | 165 | bean['targetId'] = model.targetId; |
| 165 | bean['targetType'] = model.targetType; | 166 | bean['targetType'] = model.targetType; |
| 166 | bean['status'] = model.api_status ? '1' : '0'; | 167 | bean['status'] = model.api_status ? '1' : '0'; |
| @@ -214,7 +215,7 @@ class CommentViewModel { | @@ -214,7 +215,7 @@ class CommentViewModel { | ||
| 214 | return | 215 | return |
| 215 | } | 216 | } |
| 216 | ToastUtils.showToast(data.message, 1000); | 217 | ToastUtils.showToast(data.message, 1000); |
| 217 | - let model = data.data as commentItemModel | 218 | + let comment = data.data as commentItemModel |
| 218 | 219 | ||
| 219 | let firstCommentTime = SPHelper.default.getSync(SpConstants.FIRSTCOMMENTTIME, '') as string | 220 | let firstCommentTime = SPHelper.default.getSync(SpConstants.FIRSTCOMMENTTIME, '') as string |
| 220 | 221 | ||
| @@ -223,8 +224,13 @@ class CommentViewModel { | @@ -223,8 +224,13 @@ class CommentViewModel { | ||
| 223 | SPHelper.default.saveSync(SpConstants.FIRSTCOMMENTTIME, DateTimeUtils.formatDate(data.timestamp, DateTimeUtils.PATTERN_DATE_TIME_HYPHEN)) | 224 | SPHelper.default.saveSync(SpConstants.FIRSTCOMMENTTIME, DateTimeUtils.formatDate(data.timestamp, DateTimeUtils.PATTERN_DATE_TIME_HYPHEN)) |
| 224 | } | 225 | } |
| 225 | 226 | ||
| 226 | - await this.fetchCurrentUserAuthIcons(model) | ||
| 227 | - let newModel = commentViewModel.deepCopyCommentItemModel(model) | 227 | + comment.targetId = model.targetId |
| 228 | + comment.targetRelId = model.targetRelId | ||
| 229 | + comment.targetRelType = model.targetRelType | ||
| 230 | + comment.targetType = model.targetType | ||
| 231 | + comment.targetRelObjectId = model.targetRelObjectId | ||
| 232 | + await this.fetchCurrentUserAuthIcons(comment) | ||
| 233 | + let newModel = commentViewModel.deepCopyCommentItemModel(comment) | ||
| 228 | success(newModel) | 234 | success(newModel) |
| 229 | }, (error: Error) => { | 235 | }, (error: Error) => { |
| 230 | ToastUtils.showToast('评论失败', 1000); | 236 | ToastUtils.showToast('评论失败', 1000); |
| @@ -254,9 +260,12 @@ class CommentViewModel { | @@ -254,9 +260,12 @@ class CommentViewModel { | ||
| 254 | } | 260 | } |
| 255 | 261 | ||
| 256 | /*多接口批查*/ | 262 | /*多接口批查*/ |
| 257 | - fetchCommentStatusAndConfigAuthIcon(model: commentListModel, hot: boolean = false): Promise<commentListModel> { | 263 | + // hot 表示是否批查热门评论 |
| 264 | + // targetId 是指针对某一篇稿件的评论场景 | ||
| 265 | + fetchCommentStatusAndConfigAuthIcon(model: commentListModel, hot: boolean = false, targetId?: string): Promise<commentListModel> { | ||
| 258 | 266 | ||
| 259 | let commentIDs: string[] = []; | 267 | let commentIDs: string[] = []; |
| 268 | + let uuidIDs: string[] = []; | ||
| 260 | 269 | ||
| 261 | let fromUserIDs: string[] = []; | 270 | let fromUserIDs: string[] = []; |
| 262 | 271 | ||
| @@ -264,8 +273,10 @@ class CommentViewModel { | @@ -264,8 +273,10 @@ class CommentViewModel { | ||
| 264 | 273 | ||
| 265 | //主评论 | 274 | //主评论 |
| 266 | for (const element of (hot ? model.hotList : model.list)) { | 275 | for (const element of (hot ? model.hotList : model.list)) { |
| 267 | - if ((element.id + '').length > 0) { | 276 | + if ((element.id + '').length > 0 && (element.id + "") != "0") { |
| 268 | commentIDs.push(element.id + '') | 277 | commentIDs.push(element.id + '') |
| 278 | + } else { | ||
| 279 | + uuidIDs.push(element.uuid) | ||
| 269 | } | 280 | } |
| 270 | if ((element.fromUserId + '').length > 0) { | 281 | if ((element.fromUserId + '').length > 0) { |
| 271 | fromUserIDs.push(element.fromUserId) | 282 | fromUserIDs.push(element.fromUserId) |
| @@ -278,8 +289,10 @@ class CommentViewModel { | @@ -278,8 +289,10 @@ class CommentViewModel { | ||
| 278 | //子评论 | 289 | //子评论 |
| 279 | if (element.childComments) { | 290 | if (element.childComments) { |
| 280 | for (const obj2 of element.childComments) { | 291 | for (const obj2 of element.childComments) { |
| 281 | - if ((obj2.id + '').length > 0) { | 292 | + if ((obj2.id + '').length > 0 && (obj2.id + "") != "0") { |
| 282 | commentIDs.push(obj2.id + '') | 293 | commentIDs.push(obj2.id + '') |
| 294 | + } else { | ||
| 295 | + uuidIDs.push(obj2.uuid) | ||
| 283 | } | 296 | } |
| 284 | if ((obj2.fromUserId + '').length > 0) { | 297 | if ((obj2.fromUserId + '').length > 0) { |
| 285 | fromUserIDs.push(obj2.fromUserId) | 298 | fromUserIDs.push(obj2.fromUserId) |
| @@ -300,8 +313,10 @@ class CommentViewModel { | @@ -300,8 +313,10 @@ class CommentViewModel { | ||
| 300 | let promise1 = new Promise<void>((success) => { | 313 | let promise1 = new Promise<void>((success) => { |
| 301 | // HttpRequest HttpBizUtil | 314 | // HttpRequest HttpBizUtil |
| 302 | let url = HttpUrlUtils.getBatchCommentStatusUrl(); | 315 | let url = HttpUrlUtils.getBatchCommentStatusUrl(); |
| 303 | - let bean: Record<string, string[]> = {}; | 316 | + let bean: Record<string, string | string[]> = {}; |
| 304 | bean['commentIdList'] = commentIDs; | 317 | bean['commentIdList'] = commentIDs; |
| 318 | + bean['targetId'] = targetId ?? "" | ||
| 319 | + bean['uuidList'] = uuidIDs | ||
| 305 | HttpRequest.post<ResponseDTO<commentStatusModel[]>>(url, bean).then((data: ResponseDTO<commentStatusModel[]>) => { | 320 | HttpRequest.post<ResponseDTO<commentStatusModel[]>>(url, bean).then((data: ResponseDTO<commentStatusModel[]>) => { |
| 306 | if (!data || !data.data) { | 321 | if (!data || !data.data) { |
| 307 | success() | 322 | success() |
| @@ -319,13 +334,25 @@ class CommentViewModel { | @@ -319,13 +334,25 @@ class CommentViewModel { | ||
| 319 | //点赞 | 334 | //点赞 |
| 320 | for (const element of listData) { | 335 | for (const element of listData) { |
| 321 | for (const commentModel of (hot ? model.hotList : model.list)) { | 336 | for (const commentModel of (hot ? model.hotList : model.list)) { |
| 322 | - if (element.commentId == commentModel.id) { | ||
| 323 | - commentModel.api_status = element.status | 337 | + if ((commentModel.id + '').length > 0 && (commentModel.id + "") != "0") { |
| 338 | + if (element.commentId == commentModel.id) { | ||
| 339 | + commentModel.api_status = element.status | ||
| 340 | + } | ||
| 341 | + } else { | ||
| 342 | + if (element.uuid == commentModel.uuid) { | ||
| 343 | + commentModel.api_status = element.status | ||
| 344 | + } | ||
| 324 | } | 345 | } |
| 325 | if (commentModel.childComments) { | 346 | if (commentModel.childComments) { |
| 326 | for (const childCommentModel of commentModel.childComments) { | 347 | for (const childCommentModel of commentModel.childComments) { |
| 327 | - if (element.commentId == childCommentModel.id) { | ||
| 328 | - childCommentModel.api_status = element.status | 348 | + if ((childCommentModel.id + '').length > 0 && (childCommentModel.id + "") != "0") { |
| 349 | + if (element.commentId == childCommentModel.id) { | ||
| 350 | + childCommentModel.api_status = element.status | ||
| 351 | + } | ||
| 352 | + } else { | ||
| 353 | + if (element.uuid == childCommentModel.uuid) { | ||
| 354 | + childCommentModel.api_status = element.status | ||
| 355 | + } | ||
| 329 | } | 356 | } |
| 330 | } | 357 | } |
| 331 | } | 358 | } |
| @@ -477,7 +504,7 @@ class CommentViewModel { | @@ -477,7 +504,7 @@ class CommentViewModel { | ||
| 477 | newModel.mySelf = model.mySelf | 504 | newModel.mySelf = model.mySelf |
| 478 | newModel.parentId = model.parentId | 505 | newModel.parentId = model.parentId |
| 479 | newModel.region = model.region | 506 | newModel.region = model.region |
| 480 | - newModel.replyNum = model.replyNum | 507 | + newModel.replyNum = model.replyNum + "" |
| 481 | newModel.rootCommentId = model.rootCommentId | 508 | newModel.rootCommentId = model.rootCommentId |
| 482 | newModel.sensitiveExist = model.sensitiveExist | 509 | newModel.sensitiveExist = model.sensitiveExist |
| 483 | newModel.sensitiveShow = model.sensitiveShow | 510 | newModel.sensitiveShow = model.sensitiveShow |
-
Please register or login to post a comment