xugenyuan

fix |> 【功能】稿件详情发送评论,评论列表用户头像缺少等级外框

http://192.168.1.3:8080/zentao/bug-view-20465.html

Signed-off-by: xugenyuan <xugenyuan@wondertek.com.cn>
... ... @@ -58,6 +58,10 @@ export class HttpUtils {
return SPHelper.default.getSync(SpConstants.USER_ID, "") as string
}
public static getCreatorId(): string {
return SPHelper.default.getSync(SpConstants.USER_CREATOR_ID, "") as string
}
public static getUserType(): string {
return SPHelper.default.getSync(SpConstants.USER_Type, "") as string
}
... ...
... ... @@ -207,7 +207,7 @@ class CommentViewModel {
bean['userName'] = SPHelper.default.getSync(SpConstants.TOURIST_NICK_NAME, "") as string
}
HttpBizUtil.post<ResponseDTO<commentItemModel>>(url, bean).then((data: ResponseDTO<commentItemModel>) => {
HttpBizUtil.post<ResponseDTO<commentItemModel>>(url, bean).then(async (data: ResponseDTO<commentItemModel>) => {
if (data.code != 0) {
ToastUtils.showToast(data.message, 1000);
fail()
... ... @@ -222,7 +222,10 @@ class CommentViewModel {
//保存首次评论时间
SPHelper.default.saveSync(SpConstants.FIRSTCOMMENTTIME, DateTimeUtils.formatDate(data.timestamp, DateTimeUtils.PATTERN_DATE_TIME_HYPHEN))
}
success(model)
await this.fetchCurrentUserAuthIcons(model)
let newModel = commentViewModel.deepCopyCommentItemModel(model)
success(newModel)
}, (error: Error) => {
ToastUtils.showToast('评论失败', 1000);
fail()
... ... @@ -231,6 +234,25 @@ class CommentViewModel {
})
}
async fetchCurrentUserAuthIcons(model: commentItemModel) {
if (false == HttpUtils.isLogin()) {
return
}
if (HttpUtils.getUserType() == "1") { // 普通用户
let fromUserIDs = [HttpUtils.getUserId()];
const response = await HttpRequest.post<ResponseDTO<commentStatusModel[]>>(HttpUrlUtils.getBatchUserUrl(), fromUserIDs)
if (response && response.data && response.data.length > 0) {
model.api_levelHead = response.data[0].levelHead
}
} else { // 创作者
let bean: Record<string, string[]> = {"creatorIdList": [HttpUtils.getCreatorId()]};
const response = await HttpRequest.post<ResponseDTO<commentStatusModel[]>>(HttpUrlUtils.getDetailListUrl(), bean)
if (response && response.data && response.data.length > 0) {
model.api_authIcon = response.data[0].authIcon
}
}
}
/*多接口批查*/
fetchCommentStatusAndConfigAuthIcon(model: commentListModel, hot: boolean = false): Promise<commentListModel> {
... ... @@ -421,7 +443,7 @@ class CommentViewModel {
newModel.api_customType = model.api_customType
newModel.authorLike = model.authorLike
newModel.avatarFrame = model.avatarFrame
newModel.avatarFrame = model.avatarFrame ?? ""
newModel.checkStatus = model.checkStatus
newModel.childCommentNum = model.childCommentNum
newModel.childComments = model.childComments
... ...