Toggle navigation
Toggle navigation
This project
Loading...
Sign in
developOne
/
harmonyPool
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
douaojie
2024-04-19 18:23:49 +0800
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
544c2c399e0c064e4429bb9136755d34feefb180
544c2c39
2 parents
c4b311a5
55e7b360
Merge remote-tracking branch 'origin/main'
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
105 additions
and
32 deletions
sight_harmony/commons/wdNetwork/src/main/ets/http/HttpUrlUtils.ets
sight_harmony/features/wdComponent/src/main/ets/components/comment/model/CommentModel.ets
sight_harmony/features/wdComponent/src/main/ets/components/comment/view/QualityCommentsComponent.ets
sight_harmony/features/wdComponent/src/main/ets/components/comment/viewmodel/CommentViewModel.ets
sight_harmony/commons/wdNetwork/src/main/ets/http/HttpUrlUtils.ets
View file @
544c2c3
...
...
@@ -563,6 +563,12 @@ export class HttpUrlUtils {
return url
}
/*评论点赞*/
static getCommentLikeUrl() {
let url = HttpUrlUtils._hostUrl + "/api/rmrb-comment/comment/zh/c/commentLike"
return url
}
/*levleIcon*/
static getBatchUserUrl() {
let url = HttpUrlUtils._hostUrl + "/api/rmrb-user-point/auth/level/zh/c/batchUser"
...
...
sight_harmony/features/wdComponent/src/main/ets/components/comment/model/CommentModel.ets
View file @
544c2c3
...
...
@@ -35,13 +35,6 @@ export class commentListModel extends PageModel{
list: commentItemModel[] = []
}
export class commentStatusListModel extends PageModel{
pageNum: number = 0
pageSize: number = 0
totalCount: number = 0
hasNext: number = 0
list: commentStatusModel[] = []
}
@Observed
...
...
@@ -68,8 +61,7 @@ export class commentItemModel {
fromUserType: WDPublicUserType = 0
id: string = ''
likeNum: string = ''
/*是否点赞*/
isLike: boolean = false
mySelf: string = ''
parentId: string = ''
region: string = ''
...
...
@@ -104,7 +96,8 @@ export class commentItemModel {
shareInfo:commentItemShareInfoModel = new commentItemShareInfoModel;
api_commentId:string = '';
api_status:string = '';
/*评论点赞状态 0-未点赞 1-已点赞*/
api_status:boolean = false;
api_level:string = '';
api_levelHead:string = 'http';
...
...
@@ -116,6 +109,7 @@ export class commentItemModel {
}
@Observed
export class commentItemShareInfoModel {
shareCoverUrl: string = ''
shareSummary: string = ''
...
...
@@ -123,9 +117,20 @@ export class commentItemShareInfoModel {
shareUrl: string = ''
}
@Observed
export class commentStatusListModel extends PageModel{
pageNum: number = 0
pageSize: number = 0
totalCount: number = 0
hasNext: number = 0
list: commentStatusModel[] = []
}
@Observed
export class commentStatusModel {
commentId:string = '';
status:
string = ''
;
status:
boolean = false
;
level:string = '';
levelHead:string = '';
...
...
@@ -137,3 +142,5 @@ export class commentStatusModel {
authIcon:string = '';
}
...
...
sight_harmony/features/wdComponent/src/main/ets/components/comment/view/QualityCommentsComponent.ets
View file @
544c2c3
...
...
@@ -35,16 +35,17 @@ export struct QualityCommentsComponent {
this.fullScreen();
// commentViewModel.fetchQualityCommentListLocal(getContext()).then(commentListModel => {
// this.allDatas.push(...commentListModel.list)
// })
commentViewModel.fetchQualityCommentList('1').then((commentListModel) => {
if (commentListModel && commentListModel.list && commentListModel.list.length > 0) {
// commentListModel.hasMore = true;
// this.browSingModel.viewType = ViewType.LOADED;
// commentListModel.list.forEach(element => {
// this.allDatas.push(new commentItemModel())
// });
this.allDatas.push(...commentListModel.list)
// if (commentListModel.list.length === this.browSingModel.pageSize) {
// this.browSingModel.currentPage++;
// this.browSingModel.hasMore = true;
...
...
@@ -138,8 +139,7 @@ export struct QualityCommentsComponent {
router.back()
})
Text('精选评论')
// .height('42lpx')
Text('精选评论')// .height('42lpx')
.maxLines(1)
.id("title")
.fontSize('35lpx')
...
...
@@ -147,8 +147,8 @@ export struct QualityCommentsComponent {
.fontColor($r('app.color.color_222222'))
.lineHeight('42lpx')
.alignRules({
center: {anchor: "__container__", align: VerticalAlign.Center},
middle: {anchor: "__container__", align: HorizontalAlign.Center}
center: { anchor: "__container__", align: VerticalAlign.Center },
middle: { anchor: "__container__", align: HorizontalAlign.Center }
})
.offset({
y: (this.topSafeHeight / 2) + 'px'
...
...
@@ -315,17 +315,24 @@ struct QualityCommentItem {
}
Row() {
//comment_like_select
Image($r(this.item.likeNum ? 'app.media.comment_like_select' : 'app.media.comment_like_normal'))
Image($r(this.item.api_status ? 'app.media.comment_like_select' : 'app.media.comment_like_normal'))
.width(16)
.height(16)
if (this.item.likeNum) {
if (this.item.likeNum
&& this.item.likeNum != '0'
) {
Text(this.item.likeNum)
.fontColor(this.item.
isLike
? '#ED2800' : '#999999')
.fontColor(this.item.
api_status
? '#ED2800' : '#999999')
.fontSize(14)
.margin({ left: 3 })
}
}
}.onClick(() => {
this.item.api_status = !this.item.api_status
// commentViewModel.commnetLikeChange(this.item)
commentViewModel.commentLike(this.item).then(() => {
}).catch(() => {
// commentViewModel.commnetLikeChange(this.item)
})
})
}
}.height(38).width('100%').justifyContent(FlexAlign.SpaceBetween)
...
...
sight_harmony/features/wdComponent/src/main/ets/components/comment/viewmodel/CommentViewModel.ets
View file @
544c2c3
import { Logger, ResourcesUtils } from 'wdKit/Index';
import { Logger, ResourcesUtils
, UserDataLocal
} from 'wdKit/Index';
import { HttpBizUtil, HttpUrlUtils, ResponseDTO } from 'wdNetwork/Index';
import { HttpRequest } from 'wdNetwork/src/main/ets/http/HttpRequest';
import { commentItemModel, commentListModel, commentStatusListModel, commentStatusModel } from '../model/CommentModel';
...
...
@@ -63,15 +63,11 @@ class CommentViewModel {
}
let listData = data.data as commentListModel
this.fetchCommentStatusAndConfigAuthIcon(listData).then((commentListModel) =>{
this.fetchCommentStatusAndConfigAuthIcon(listData).then((commentListModel) =>
{
console.log(TAG, 'fetchCommentStatusAndConfigAuthIcon完成')
success(commentListModel)
})
// return this.fetchCommentStatusAndConfigAuthIcon(listData)
// this.fetchCommentStatusAndConfigAuthIcon(listData)
// success(listData)
}, (error: Error) => {
fail(error.message)
Logger.debug(TAG, error.toString())
...
...
@@ -79,6 +75,47 @@ class CommentViewModel {
})
}
/*点赞*/
commentLike(model: commentItemModel) {
return new Promise<void>((success, fail) => {
let url = HttpUrlUtils.getCommentLikeUrl()
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
let bean: Record<string, string> = {};
// commentId number
// 被点赞的评论ID
// targetId string
// 被点赞的内容ID
// targetType number
// 内容类别,1:点播,2:直播,3:活动,4:广告,5:专题,6:链接,7:榜单,8:图文,9:组图,10:H5新闻,11:频道,12:组件,13:音频,14:动态(13和14为中文版新增)
// status number
// 点赞状态 0:取消点赞 1:点赞
// userName string
// 【迭代二新增】当前用户的用户名
// userHeaderUrl string
// 【迭代二新增】当前用户的头像url
bean['commentId'] = model.id;
bean['targetId'] = model.targetId;
bean['targetType'] = model.targetType;
bean['status'] = model.api_status ? '1' : '0';
bean['userName'] = UserDataLocal.getUserId();
bean['userHeaderUrl'] = UserDataLocal.getUserHeaderUrl();
HttpRequest.post<ResponseDTO<commentStatusModel[]>>(url, bean, headers).then((data: ResponseDTO<commentStatusModel[]>) => {
if (data.code != 0) {
fail()
return
}
success()
}, (error: Error) => {
fail()
Logger.debug(TAG, error.toString())
})
})
}
/*多接口批查*/
fetchCommentStatusAndConfigAuthIcon(model: commentListModel): Promise<commentListModel> {
...
...
@@ -142,7 +179,7 @@ class CommentViewModel {
return
}
let listData = data.data as commentStatusModel[]
//点赞
for (const element of listData) {
for (const commentModel of model.list) {
if (element.commentId == commentModel.id) {
...
...
@@ -265,6 +302,22 @@ class CommentViewModel {
}
commnetLikeChange(model:commentItemModel){
model.api_status = !model.api_status
//点赞
if (model.api_status) {
model.likeNum = (Number.parseInt(model.likeNum) + 1) + ''
}
//取消点赞
if (!model.api_status) {
model.likeNum = (Number.parseInt(model.likeNum) - 1) + ''
if (Number.parseInt(model.likeNum) < 0) {
model.likeNum = '0'
}
}
}
}
...
...
Please
register
or
login
to post a comment