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-09-21 12:29:27 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
9b6efbcf15468bfb7406da1d09c190dae2d76058
9b6efbcf
1 parent
5132e4bc
fix: 动态详情点赞,返回信息流列表页,点赞效果未回显
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
69 additions
and
19 deletions
sight_harmony/commons/wdKit/src/main/ets/utils/EmitterEventId.ts
sight_harmony/features/wdComponent/src/main/ets/components/CarderInteraction.ets
sight_harmony/features/wdComponent/src/main/ets/components/DynamicDetailComponent.ets
sight_harmony/features/wdComponent/src/main/ets/components/ImageAndTextPageComponent.ets
sight_harmony/features/wdComponent/src/main/ets/components/cardview/Card19Component.ets
sight_harmony/features/wdComponent/src/main/ets/components/view/LikeComponent.ets
sight_harmony/commons/wdKit/src/main/ets/utils/EmitterEventId.ts
View file @
9b6efbc
...
...
@@ -49,5 +49,8 @@ export enum EmitterEventId {
// 全屏
FULL_SCREEN
=
14
,
// 图文详情页点赞状态
LIKE_CHANGE_STATUS
=
15
,
}
...
...
sight_harmony/features/wdComponent/src/main/ets/components/CarderInteraction.ets
View file @
9b6efbc
import { SPHelper, Logger, ToastUtils } from 'wdKit';
import { SPHelper, Logger, ToastUtils
, EmitterUtils, EmitterEventId
} from 'wdKit';
import { ContentDetailDTO, Action, ContentDTO, batchLikeAndCollectResult } from 'wdBean';
import { ProcessUtils } from 'wdRouter';
import router from '@ohos.router';
...
...
@@ -11,6 +11,11 @@ import { TrackConstants } from 'wdTracking/Index';
const TAG = 'CarderInteraction'
interface parsedObj {
contentId: string,
likeStatus: string
}
/**
* 卡片 分享、评论、点赞公用组件
*/
...
...
@@ -47,6 +52,25 @@ export struct CarderInteraction {
// console.log(TAG, 'this.isShowComment', this.isShowComment)
// console.log(TAG, 'this.isShowLike', this.isShowLike)
// console.log(TAG, 'router.getState().name', router.getState().name)
EmitterUtils.receiveEvent(EmitterEventId.LIKE_CHANGE_STATUS, (val: string | undefined) => {
// console.log(TAG,'val点赞', val)
if (val === undefined) {
console.error('Value is undefined');
return;
}
try {
const parsedVal: parsedObj = JSON.parse(val);
if (parsedVal.contentId === this.contentDetailData.newsId + '') {
// console.log(TAG,'params点赞状态', parsedVal.likeStatus)
this.likeBean['likeStatus'] = parsedVal.likeStatus
// console.log(TAG,'this.likeBean点赞状态', this.likeBean['likeStatus'])
}
} catch (error) {
console.error('Error parsing JSON:', error);
}
});
}
...
...
sight_harmony/features/wdComponent/src/main/ets/components/DynamicDetailComponent.ets
View file @
9b6efbc
...
...
@@ -53,6 +53,11 @@ import { onlyWifiLoadImg } from '../utils/lazyloadImg';
const TAG = 'DynamicDetailComponent'
const PATTERN_DATE_CN_RN: string = 'yyyy年MM月dd日 HH:mm';
interface parsedObj {
contentId: string,
likeStatus: string
}
/**
* 动态详情页UI
...
...
@@ -782,11 +787,11 @@ export struct DynamicDetailComponent {
}
]
}
console.error(TAG, JSON.stringify(this.contentDetailData
))
// console.error(TAG,'CarderInteraction', JSON.stringify(params.contentList
))
let data = await MultiPictureDetailViewModel.getInteractDataStatus(params)
console.error(TAG, '
查询用户对作品点赞、收藏状态', JSON.stringify(data))
// console.error(TAG, 'CarderInteraction
查询用户对作品点赞、收藏状态', JSON.stringify(data))
this.newsStatusOfUser = data[0];
Logger.info(TAG, `newsStatusOfUser:${JSON.stringify(this.newsStatusOfUser)}`)
//
Logger.info(TAG, `newsStatusOfUser:${JSON.stringify(this.newsStatusOfUser)}`)
} catch (exception) {
console.error(TAG, JSON.stringify(exception))
}
...
...
@@ -808,7 +813,7 @@ export struct DynamicDetailComponent {
}
let data = await MultiPictureDetailViewModel.getBatchAttentionStatus(params)
this.followStatus = data[0]?.status;
Logger.info(TAG, `followStatus:${JSON.stringify(this.followStatus)}`)
//
Logger.info(TAG, `followStatus:${JSON.stringify(this.followStatus)}`)
} catch (exception) {
this.followStatus = '0';
}
...
...
@@ -882,7 +887,7 @@ export struct DynamicDetailComponent {
status: this.followStatus == '0' ? 1 : 0,
}
ContentDetailRequest.postInteractAccentionOperate(params2).then(res => {
console.log('关注号主==', JSON.stringify(res.data))
//
console.log('关注号主==', JSON.stringify(res.data))
if (this.followStatus == '1') {
this.followStatus = '0'
TrackingContent.follow(true,this.contentDetailData.rmhInfo == null ?"":this.contentDetailData.rmhInfo.rmhId,this.contentDetailData.rmhInfo == null ?"":this.contentDetailData.rmhInfo.rmhName,TrackConstants.PageName.DynamicDetail,TrackConstants.PageName.DynamicDetail,this.pageParam)
...
...
@@ -915,7 +920,14 @@ export struct DynamicDetailComponent {
} else {
this.interactDataDTO.likeNum = Number(this.interactDataDTO.likeNum) - 1
}
console.log('点赞、取消点赞==', this.newsStatusOfUser?.likeStatus, this.interactDataDTO?.likeNum)
let parsedVal: parsedObj = {
contentId: params.contentId,
likeStatus: this.newsStatusOfUser.likeStatus
}
EmitterUtils.sendEvent(EmitterEventId.LIKE_CHANGE_STATUS, JSON.stringify(parsedVal))
// console.log(TAG, 'CarderInteraction 点赞parsedVal', JSON.stringify(parsedVal))
// console.log('点赞、取消点赞==', this.newsStatusOfUser?.likeStatus, this.interactDataDTO?.likeNum)
//内容点赞、取消点赞Tracking 1点赞 0取消点赞
TrackingContent.like(this.newsStatusOfUser?.likeStatus == '1', TrackConstants.PageName.DynamicDetail, TrackConstants.PageName.DynamicDetail,
...
...
sight_harmony/features/wdComponent/src/main/ets/components/ImageAndTextPageComponent.ets
View file @
9b6efbc
...
...
@@ -440,10 +440,10 @@ export struct ImageAndTextPageComponent {
userName:this.contentDetailData?.userInfo?.userName || '' + '',
channelId:String(this.contentDetailData?.reLInfo?.channelId) || '' + ''
}
console.log(TAG, '点赞、取消点赞params', JSON.stringify(params))
//
console.log(TAG, '点赞、取消点赞params', JSON.stringify(params))
PageRepository.postExecuteLike(params).then(res => {
// console.log(TAG, '点赞、res', JSON.stringify(res))
console.log(TAG, '点赞、取消点赞 this.newsStatusOfUser', JSON.stringify(this.newsStatusOfUser))
//
console.log(TAG, '点赞、取消点赞 this.newsStatusOfUser', JSON.stringify(this.newsStatusOfUser))
if (this.newsStatusOfUser) {
//内容点赞、取消点赞Tracking 1点赞 0取消点赞
this.newsStatusOfUser.likeStatus = this.newsStatusOfUser?.likeStatus == '1' ? '0' : '1'
...
...
@@ -452,7 +452,7 @@ export struct ImageAndTextPageComponent {
} else {
this.likeNum = Number(this.likeNum) - 1
}
console.log(TAG, '点赞newsStatusOfUser.likeStatus ', this.newsStatusOfUser.likeStatus)
//
console.log(TAG, '点赞newsStatusOfUser.likeStatus ', this.newsStatusOfUser.likeStatus)
// this.queryContentInteractCount()
TrackingContent.like(this.newsStatusOfUser?.likeStatus == '1', TrackConstants.PageName.My, TrackConstants.PageName.My)
} else {
...
...
sight_harmony/features/wdComponent/src/main/ets/components/cardview/Card19Component.ets
View file @
9b6efbc
...
...
@@ -28,7 +28,7 @@ export struct Card19Component {
this.titleInit();
const curRouter = router.getState().name;
this.clicked = hasClicked(this.contentDTO.objectId, curRouter)
console.log('card19',JSON.stringify(this.contentDTO))
//
console.log('card19',JSON.stringify(this.contentDTO))
}
titleInit() {
...
...
sight_harmony/features/wdComponent/src/main/ets/components/view/LikeComponent.ets
View file @
9b6efbc
...
...
@@ -19,6 +19,10 @@ interface ILikeStyleResp {
url: Resource;
name: string;
}
interface parsedObj {
contentId: string,
likeStatus: string
}
@Component
export struct LikeComponent {
...
...
@@ -59,18 +63,18 @@ export struct LikeComponent {
this.likesStyle = this.contentDetailData.likesStyle
this.openLikes = this.contentDetailData.openLikes == 1 ? true : false
}
console.log(TAG, 'this.contentDetailData', JSON.stringify(this.contentDetailData))
console.log(TAG, 'this.componentType', this.componentType)
console.log(TAG, 'this.likesStyle', this.likesStyle)
console.log(TAG, 'this.openLikes', this.openLikes)
// console.log(TAG, 'this.contentDetailData', JSON.stringify(this.contentDetailData))
// console.log(TAG, 'this.componentType', this.componentType)
// console.log(TAG, 'this.likesStyle', this.likesStyle)
// console.log(TAG, 'this.openLikes', this.openLikes)
this.onDataUpdated()
this.contentTrackingDict()
}
onDataUpdated() {
console.log(TAG, '点赞点击')
if (this.data) {
if (this.data['contentType'] !== undefined ) {
console.log(TAG, 'CarderInteraction 点赞点击')
//获取点赞状态
this.getLikeStatus()
//获取点赞数
...
...
@@ -458,6 +462,7 @@ export struct LikeComponent {
this.likeCount--
TrackingContent.like(false,this.pageId,this.pageName,this.pageParam)
}
}
if (this.likeCount <= 0) {
...
...
@@ -479,19 +484,25 @@ export struct LikeComponent {
{
contentId: this.data['contentId'],
contentType: this.data['contentType'],
contentRelId: this.data['contentRelId'] || '' + '',
contentRelId: this.data['contentRelId']
== "0" ? '' : this.data['contentRelId']
|| '' + '',
}
]
}
console.log(TAG, "
查询点赞状态params", JSON.stringify(params))
// console.log(TAG, "CarderInteraction
查询点赞状态params", JSON.stringify(params))
ContentDetailRequest.postBatchLikeAndCollectStatus(params).then(res => {
console.log(TAG, '
查询点赞、收藏状态==', JSON.stringify(res.data))
// console.log(TAG, 'CarderInteraction
查询点赞、收藏状态==', JSON.stringify(res.data))
if (res.data) {
if(res.data[0].likeStatus) {
this.likeStatus = res.data[0].likeStatus ? true : false
} else {
this.likeStatus = false
}
// CarderInteraction组件交互
if (this.data['likeStatus'] == "1") {
this.likeStatus = true
} else if (this.data['likeStatus'] == "0") {
this.likeStatus = false
}
}
}).catch(() => {
this.likeStatus = false
...
...
Please
register
or
login
to post a comment