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
陈剑华
2024-05-13 11:03:32 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
e771fe108553efb15166a7807b5cac679c31f891
e771fe10
1 parent
0a16a082
fix: 17034 功能缺陷--评论卡,点击爱心后,用android 查看精品评论页,爱心没有加1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
25 deletions
sight_harmony/features/wdComponent/src/main/ets/components/compview/ZhSingleRow06.ets
sight_harmony/features/wdComponent/src/main/ets/components/compview/ZhSingleRow06.ets
View file @
e771fe1
import { commentInfo, CompDTO, ContentDTO, Params } from 'wdBean';
import { commentInfo, CompDTO, ContentDTO, Params
, batchLikeAndCollectResult
} from 'wdBean';
import { WDRouterPage, WDRouterRule } from 'wdRouter/Index';
import { DateTimeUtils, SPHelper } from 'wdKit/Index';
import { DateTimeUtils, SPHelper
, Logger
} from 'wdKit/Index';
import { ProcessUtils } from 'wdRouter';
import { SpConstants } from 'wdConstant/Index'
import {
batchLikeAndCollectParams,
ContentDetailRequest,
contentListParams,
postExecuteCollectRecordParams,
postExecuteLikeParams,
postInteractAccentionOperateParams
} from 'wdDetailPlayApi/src/main/ets/request/ContentDetailRequest';
import { MultiPictureDetailViewModel } from '../../viewmodel/MultiPictureDetailViewModel';
/**
* 精选评论卡
* Zh_Single_Row-06
*/
const TAG = 'Zh_Single_Row-06'
// interface commentInfo {
// commentTitle: string,
// newsTitle: string,
// userName: string,
// userHeaderUrl: string,
// publishTime: number
// }
// interface operDataListItem {
// commentInfo: commentInfo
// }
// interface CommentData{
// operDataList: Array<operDataListItem>
// }
@Entry
@Component
export struct ZhSingleRow06 {
@State compDTO: CompDTO = {} as CompDTO
@State likeBl: boolean = false;
@State newsStatusOfUser: batchLikeAndCollectResult = {} as batchLikeAndCollectResult // 点赞、收藏状态
aboutToAppear(): void {
this.getInteractDataStatus()
}
async likeAction() {
/**
* 点赞、取消点赞
*/
async toggleLikeStatus() {
// 未登录,跳转登录
const user_id = await SPHelper.default.get(SpConstants.USER_ID, '')
if (!user_id) {
WDRouterRule.jumpWithPage(WDRouterPage.loginPage)
return
}
const params: postExecuteLikeParams = {
status: this.newsStatusOfUser?.likeStatus === '1' ? '0' : '1',
contentId: this.compDTO.operDataList[0]?.commentInfo?.newsId + '',
contentType: this.compDTO.operDataList[0]?.commentInfo?.newsType + '',
}
ContentDetailRequest.postExecuteLike(params).then(res => {
this.newsStatusOfUser.likeStatus = this.newsStatusOfUser?.likeStatus === '1' ? '0' : '1'
})
}
if (this.likeBl) {
this.likeBl = false;
} else {
this.likeBl = true;
// 已登录->查询用户对作品点赞、收藏状态
private async getInteractDataStatus() {
// 未登录,跳转登录
const user_id = await SPHelper.default.get(SpConstants.USER_ID, '')
if (!user_id) {
return
}
try {
const params: batchLikeAndCollectParams = {
contentList: [
{
contentId: this.compDTO.operDataList[0]?.commentInfo?.newsId + '',
contentType: this.compDTO.operDataList[0]?.commentInfo?.newsType + '',
}
]
}
let data = await MultiPictureDetailViewModel.getInteractDataStatus(params)
console.error(TAG, 'ZhSingleRow06-data', JSON.stringify(data))
this.newsStatusOfUser = data[0];
Logger.info(TAG, `ZhSingleRow06-newsStatusOfUser:${JSON.stringify(this.newsStatusOfUser)}`)
} catch (exception) {
console.error(TAG, JSON.stringify(exception))
}
}
...
...
@@ -95,7 +124,7 @@ export struct ZhSingleRow06 {
.fontColor(0x999999)
Row(){
Image(this.
likeBl
? $r('app.media.icon_like_select') : $r('app.media.icon_like'))
Image(this.
newsStatusOfUser?.likeStatus == '1'
? $r('app.media.icon_like_select') : $r('app.media.icon_like'))
.width(16)
.height(16)
.margin({right: 3})
...
...
@@ -103,9 +132,11 @@ export struct ZhSingleRow06 {
Text('点赞')
.fontSize(15)
.fontColor(0x999999)
.onClick(() => {
})
}
.onClick(() => {
this.
likeAction
()
this.
toggleLikeStatus
()
})
}
.justifyContent(FlexAlign.SpaceBetween)
...
...
Please
register
or
login
to post a comment