douaojie

Merge remote-tracking branch 'origin/main'

@@ -563,6 +563,12 @@ export class HttpUrlUtils { @@ -563,6 +563,12 @@ export class HttpUrlUtils {
563 return url 563 return url
564 } 564 }
565 565
  566 + /*评论点赞*/
  567 + static getCommentLikeUrl() {
  568 + let url = HttpUrlUtils._hostUrl + "/api/rmrb-comment/comment/zh/c/commentLike"
  569 + return url
  570 + }
  571 +
566 /*levleIcon*/ 572 /*levleIcon*/
567 static getBatchUserUrl() { 573 static getBatchUserUrl() {
568 let url = HttpUrlUtils._hostUrl + "/api/rmrb-user-point/auth/level/zh/c/batchUser" 574 let url = HttpUrlUtils._hostUrl + "/api/rmrb-user-point/auth/level/zh/c/batchUser"
@@ -35,13 +35,6 @@ export class commentListModel extends PageModel{ @@ -35,13 +35,6 @@ export class commentListModel extends PageModel{
35 list: commentItemModel[] = [] 35 list: commentItemModel[] = []
36 } 36 }
37 37
38 -export class commentStatusListModel extends PageModel{  
39 - pageNum: number = 0  
40 - pageSize: number = 0  
41 - totalCount: number = 0  
42 - hasNext: number = 0  
43 - list: commentStatusModel[] = []  
44 -}  
45 38
46 39
47 @Observed 40 @Observed
@@ -68,8 +61,7 @@ export class commentItemModel { @@ -68,8 +61,7 @@ export class commentItemModel {
68 fromUserType: WDPublicUserType = 0 61 fromUserType: WDPublicUserType = 0
69 id: string = '' 62 id: string = ''
70 likeNum: string = '' 63 likeNum: string = ''
71 - /*是否点赞*/  
72 - isLike: boolean = false 64 +
73 mySelf: string = '' 65 mySelf: string = ''
74 parentId: string = '' 66 parentId: string = ''
75 region: string = '' 67 region: string = ''
@@ -104,7 +96,8 @@ export class commentItemModel { @@ -104,7 +96,8 @@ export class commentItemModel {
104 shareInfo:commentItemShareInfoModel = new commentItemShareInfoModel; 96 shareInfo:commentItemShareInfoModel = new commentItemShareInfoModel;
105 97
106 api_commentId:string = ''; 98 api_commentId:string = '';
107 - api_status:string = ''; 99 + /*评论点赞状态 0-未点赞 1-已点赞*/
  100 + api_status:boolean = false;
108 101
109 api_level:string = ''; 102 api_level:string = '';
110 api_levelHead:string = 'http'; 103 api_levelHead:string = 'http';
@@ -116,6 +109,7 @@ export class commentItemModel { @@ -116,6 +109,7 @@ export class commentItemModel {
116 109
117 } 110 }
118 111
  112 +@Observed
119 export class commentItemShareInfoModel { 113 export class commentItemShareInfoModel {
120 shareCoverUrl: string = '' 114 shareCoverUrl: string = ''
121 shareSummary: string = '' 115 shareSummary: string = ''
@@ -123,9 +117,20 @@ export class commentItemShareInfoModel { @@ -123,9 +117,20 @@ export class commentItemShareInfoModel {
123 shareUrl: string = '' 117 shareUrl: string = ''
124 } 118 }
125 119
  120 +@Observed
  121 +export class commentStatusListModel extends PageModel{
  122 + pageNum: number = 0
  123 + pageSize: number = 0
  124 + totalCount: number = 0
  125 + hasNext: number = 0
  126 + list: commentStatusModel[] = []
  127 +}
  128 +
  129 +
  130 +@Observed
126 export class commentStatusModel { 131 export class commentStatusModel {
127 commentId:string = ''; 132 commentId:string = '';
128 - status:string = ''; 133 + status:boolean = false;
129 134
130 level:string = ''; 135 level:string = '';
131 levelHead:string = ''; 136 levelHead:string = '';
@@ -137,3 +142,5 @@ export class commentStatusModel { @@ -137,3 +142,5 @@ export class commentStatusModel {
137 authIcon:string = ''; 142 authIcon:string = '';
138 143
139 } 144 }
  145 +
  146 +
@@ -35,16 +35,17 @@ export struct QualityCommentsComponent { @@ -35,16 +35,17 @@ export struct QualityCommentsComponent {
35 35
36 this.fullScreen(); 36 this.fullScreen();
37 37
38 -  
39 - // commentViewModel.fetchQualityCommentListLocal(getContext()).then(commentListModel => {  
40 - // this.allDatas.push(...commentListModel.list)  
41 - // })  
42 -  
43 commentViewModel.fetchQualityCommentList('1').then((commentListModel) => { 38 commentViewModel.fetchQualityCommentList('1').then((commentListModel) => {
44 if (commentListModel && commentListModel.list && commentListModel.list.length > 0) { 39 if (commentListModel && commentListModel.list && commentListModel.list.length > 0) {
45 // commentListModel.hasMore = true; 40 // commentListModel.hasMore = true;
46 // this.browSingModel.viewType = ViewType.LOADED; 41 // this.browSingModel.viewType = ViewType.LOADED;
  42 +
  43 + // commentListModel.list.forEach(element => {
  44 + // this.allDatas.push(new commentItemModel())
  45 + // });
  46 +
47 this.allDatas.push(...commentListModel.list) 47 this.allDatas.push(...commentListModel.list)
  48 +
48 // if (commentListModel.list.length === this.browSingModel.pageSize) { 49 // if (commentListModel.list.length === this.browSingModel.pageSize) {
49 // this.browSingModel.currentPage++; 50 // this.browSingModel.currentPage++;
50 // this.browSingModel.hasMore = true; 51 // this.browSingModel.hasMore = true;
@@ -103,7 +104,7 @@ export struct QualityCommentsComponent { @@ -103,7 +104,7 @@ export struct QualityCommentsComponent {
103 left: { anchor: "__container__", align: HorizontalAlign.Start } 104 left: { anchor: "__container__", align: HorizontalAlign.Start }
104 }) 105 })
105 .offset({ 106 .offset({
106 - y: (this.topSafeHeight / 2) + 'px' 107 + y: (this.topSafeHeight / 2) + 'px'
107 }) 108 })
108 .margin({ left: 16 }) 109 .margin({ left: 16 })
109 .onClick(() => { 110 .onClick(() => {
@@ -131,15 +132,14 @@ export struct QualityCommentsComponent { @@ -131,15 +132,14 @@ export struct QualityCommentsComponent {
131 left: { anchor: "__container__", align: HorizontalAlign.Start } 132 left: { anchor: "__container__", align: HorizontalAlign.Start }
132 }) 133 })
133 .offset({ 134 .offset({
134 - y: (this.topSafeHeight / 2) + 'px' 135 + y: (this.topSafeHeight / 2) + 'px'
135 }) 136 })
136 .margin({ left: 16 }) 137 .margin({ left: 16 })
137 .onClick(() => { 138 .onClick(() => {
138 router.back() 139 router.back()
139 }) 140 })
140 141
141 - Text('精选评论')  
142 - // .height('42lpx') 142 + Text('精选评论')// .height('42lpx')
143 .maxLines(1) 143 .maxLines(1)
144 .id("title") 144 .id("title")
145 .fontSize('35lpx') 145 .fontSize('35lpx')
@@ -147,11 +147,11 @@ export struct QualityCommentsComponent { @@ -147,11 +147,11 @@ export struct QualityCommentsComponent {
147 .fontColor($r('app.color.color_222222')) 147 .fontColor($r('app.color.color_222222'))
148 .lineHeight('42lpx') 148 .lineHeight('42lpx')
149 .alignRules({ 149 .alignRules({
150 - center: {anchor: "__container__", align: VerticalAlign.Center},  
151 - middle: {anchor: "__container__", align: HorizontalAlign.Center} 150 + center: { anchor: "__container__", align: VerticalAlign.Center },
  151 + middle: { anchor: "__container__", align: HorizontalAlign.Center }
152 }) 152 })
153 .offset({ 153 .offset({
154 - y: (this.topSafeHeight / 2) + 'px' 154 + y: (this.topSafeHeight / 2) + 'px'
155 }) 155 })
156 } 156 }
157 .visibility(this.tileOpacity > 0 ? 0 : 1) 157 .visibility(this.tileOpacity > 0 ? 0 : 1)
@@ -315,17 +315,24 @@ struct QualityCommentItem { @@ -315,17 +315,24 @@ struct QualityCommentItem {
315 } 315 }
316 316
317 Row() { 317 Row() {
318 - //comment_like_select  
319 - Image($r(this.item.likeNum ? 'app.media.comment_like_select' : 'app.media.comment_like_normal')) 318 + Image($r(this.item.api_status ? 'app.media.comment_like_select' : 'app.media.comment_like_normal'))
320 .width(16) 319 .width(16)
321 .height(16) 320 .height(16)
322 - if (this.item.likeNum) { 321 + if (this.item.likeNum && this.item.likeNum != '0') {
323 Text(this.item.likeNum) 322 Text(this.item.likeNum)
324 - .fontColor(this.item.isLike ? '#ED2800' : '#999999') 323 + .fontColor(this.item.api_status ? '#ED2800' : '#999999')
325 .fontSize(14) 324 .fontSize(14)
326 .margin({ left: 3 }) 325 .margin({ left: 3 })
327 } 326 }
328 - } 327 + }.onClick(() => {
  328 + this.item.api_status = !this.item.api_status
  329 + // commentViewModel.commnetLikeChange(this.item)
  330 + commentViewModel.commentLike(this.item).then(() => {
  331 +
  332 + }).catch(() => {
  333 + // commentViewModel.commnetLikeChange(this.item)
  334 + })
  335 + })
329 } 336 }
330 }.height(38).width('100%').justifyContent(FlexAlign.SpaceBetween) 337 }.height(38).width('100%').justifyContent(FlexAlign.SpaceBetween)
331 338
1 -import { Logger, ResourcesUtils } from 'wdKit/Index'; 1 +import { Logger, ResourcesUtils, UserDataLocal } from 'wdKit/Index';
2 import { HttpBizUtil, HttpUrlUtils, ResponseDTO } from 'wdNetwork/Index'; 2 import { HttpBizUtil, HttpUrlUtils, ResponseDTO } from 'wdNetwork/Index';
3 import { HttpRequest } from 'wdNetwork/src/main/ets/http/HttpRequest'; 3 import { HttpRequest } from 'wdNetwork/src/main/ets/http/HttpRequest';
4 import { commentItemModel, commentListModel, commentStatusListModel, commentStatusModel } from '../model/CommentModel'; 4 import { commentItemModel, commentListModel, commentStatusListModel, commentStatusModel } from '../model/CommentModel';
@@ -48,7 +48,7 @@ class CommentViewModel { @@ -48,7 +48,7 @@ class CommentViewModel {
48 } 48 }
49 49
50 /*获取热门评论*/ 50 /*获取热门评论*/
51 - fetchQualityCommentList(pageNum: string): Promise<commentListModel> { 51 + fetchQualityCommentList(pageNum: string): Promise<commentListModel> {
52 let url = HttpUrlUtils.getQualityCommentUrl() + `?&pageSize=${10}&pageNum=${pageNum}` 52 let url = HttpUrlUtils.getQualityCommentUrl() + `?&pageSize=${10}&pageNum=${pageNum}`
53 let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); 53 let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
54 return new Promise<commentListModel>((success, fail) => { 54 return new Promise<commentListModel>((success, fail) => {
@@ -63,15 +63,11 @@ class CommentViewModel { @@ -63,15 +63,11 @@ class CommentViewModel {
63 } 63 }
64 let listData = data.data as commentListModel 64 let listData = data.data as commentListModel
65 65
66 - this.fetchCommentStatusAndConfigAuthIcon(listData).then((commentListModel) =>{ 66 + this.fetchCommentStatusAndConfigAuthIcon(listData).then((commentListModel) => {
67 console.log(TAG, 'fetchCommentStatusAndConfigAuthIcon完成') 67 console.log(TAG, 'fetchCommentStatusAndConfigAuthIcon完成')
68 success(commentListModel) 68 success(commentListModel)
69 }) 69 })
70 70
71 - // return this.fetchCommentStatusAndConfigAuthIcon(listData)  
72 -  
73 - // this.fetchCommentStatusAndConfigAuthIcon(listData)  
74 - // success(listData)  
75 }, (error: Error) => { 71 }, (error: Error) => {
76 fail(error.message) 72 fail(error.message)
77 Logger.debug(TAG, error.toString()) 73 Logger.debug(TAG, error.toString())
@@ -79,8 +75,49 @@ class CommentViewModel { @@ -79,8 +75,49 @@ class CommentViewModel {
79 }) 75 })
80 } 76 }
81 77
  78 + /*点赞*/
  79 + commentLike(model: commentItemModel) {
  80 +
  81 + return new Promise<void>((success, fail) => {
  82 + let url = HttpUrlUtils.getCommentLikeUrl()
  83 + let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
  84 + let bean: Record<string, string> = {};
  85 +
  86 + // commentId number
  87 + // 被点赞的评论ID
  88 + // targetId string
  89 + // 被点赞的内容ID
  90 + // targetType number
  91 + // 内容类别,1:点播,2:直播,3:活动,4:广告,5:专题,6:链接,7:榜单,8:图文,9:组图,10:H5新闻,11:频道,12:组件,13:音频,14:动态(13和14为中文版新增)
  92 + // status number
  93 + // 点赞状态 0:取消点赞 1:点赞
  94 + // userName string
  95 + // 【迭代二新增】当前用户的用户名
  96 + // userHeaderUrl string
  97 + // 【迭代二新增】当前用户的头像url
  98 +
  99 + bean['commentId'] = model.id;
  100 + bean['targetId'] = model.targetId;
  101 + bean['targetType'] = model.targetType;
  102 + bean['status'] = model.api_status ? '1' : '0';
  103 + bean['userName'] = UserDataLocal.getUserId();
  104 + bean['userHeaderUrl'] = UserDataLocal.getUserHeaderUrl();
  105 +
  106 + HttpRequest.post<ResponseDTO<commentStatusModel[]>>(url, bean, headers).then((data: ResponseDTO<commentStatusModel[]>) => {
  107 + if (data.code != 0) {
  108 + fail()
  109 + return
  110 + }
  111 + success()
  112 + }, (error: Error) => {
  113 + fail()
  114 + Logger.debug(TAG, error.toString())
  115 + })
  116 + })
  117 + }
  118 +
82 /*多接口批查*/ 119 /*多接口批查*/
83 - fetchCommentStatusAndConfigAuthIcon(model: commentListModel): Promise<commentListModel> { 120 + fetchCommentStatusAndConfigAuthIcon(model: commentListModel): Promise<commentListModel> {
84 121
85 let commentIDs: string[] = []; 122 let commentIDs: string[] = [];
86 123
@@ -142,7 +179,7 @@ class CommentViewModel { @@ -142,7 +179,7 @@ class CommentViewModel {
142 return 179 return
143 } 180 }
144 let listData = data.data as commentStatusModel[] 181 let listData = data.data as commentStatusModel[]
145 - 182 +//点赞
146 for (const element of listData) { 183 for (const element of listData) {
147 for (const commentModel of model.list) { 184 for (const commentModel of model.list) {
148 if (element.commentId == commentModel.id) { 185 if (element.commentId == commentModel.id) {
@@ -265,6 +302,22 @@ class CommentViewModel { @@ -265,6 +302,22 @@ class CommentViewModel {
265 302
266 303
267 } 304 }
  305 +
  306 +
  307 + commnetLikeChange(model:commentItemModel){
  308 + model.api_status = !model.api_status
  309 + //点赞
  310 + if (model.api_status) {
  311 + model.likeNum = (Number.parseInt(model.likeNum) + 1) + ''
  312 + }
  313 + //取消点赞
  314 + if (!model.api_status) {
  315 + model.likeNum = (Number.parseInt(model.likeNum) - 1) + ''
  316 + if (Number.parseInt(model.likeNum) < 0) {
  317 + model.likeNum = '0'
  318 + }
  319 + }
  320 + }
268 } 321 }
269 322
270 323