Showing
7 changed files
with
77 additions
and
21 deletions
| @@ -751,7 +751,7 @@ export struct DynamicDetailComponent { | @@ -751,7 +751,7 @@ export struct DynamicDetailComponent { | ||
| 751 | return | 751 | return |
| 752 | } | 752 | } |
| 753 | const params: postExecuteLikeParams = { | 753 | const params: postExecuteLikeParams = { |
| 754 | - status: this.newsStatusOfUser?.likeStatus === '1' ? '0' : '1', | 754 | + status: this.newsStatusOfUser?.likeStatus === '1' ? 0 : 1, |
| 755 | contentId: this.contentDetailData?.newsId + '', | 755 | contentId: this.contentDetailData?.newsId + '', |
| 756 | contentType: this.contentDetailData?.newsType + '', | 756 | contentType: this.contentDetailData?.newsType + '', |
| 757 | } | 757 | } |
| @@ -5,6 +5,11 @@ import { WDRouterPage, WDRouterRule } from 'wdRouter/Index'; | @@ -5,6 +5,11 @@ import { WDRouterPage, WDRouterRule } from 'wdRouter/Index'; | ||
| 5 | import { SpConstants } from 'wdConstant/Index'; | 5 | import { SpConstants } from 'wdConstant/Index'; |
| 6 | import { ContentDetailDTO } from 'wdBean/Index'; | 6 | import { ContentDetailDTO } from 'wdBean/Index'; |
| 7 | import measure from '@ohos.measure' | 7 | import measure from '@ohos.measure' |
| 8 | +import { | ||
| 9 | + ContentDetailRequest, | ||
| 10 | + postExecuteLikeParams, | ||
| 11 | + batchLikeAndCollectParams, | ||
| 12 | +} from 'wdDetailPlayApi/src/main/ets/request/ContentDetailRequest'; | ||
| 8 | 13 | ||
| 9 | const TAG = 'LikeComponent'; | 14 | const TAG = 'LikeComponent'; |
| 10 | 15 | ||
| @@ -40,8 +45,9 @@ export struct LikeComponent { | @@ -40,8 +45,9 @@ export struct LikeComponent { | ||
| 40 | } | 45 | } |
| 41 | 46 | ||
| 42 | onDataUpdated() { | 47 | onDataUpdated() { |
| 48 | + console.log(TAG, '点赞点击') | ||
| 43 | if (this.data) { | 49 | if (this.data) { |
| 44 | - if (this.data['channelId'] !== 'undefined') { | 50 | + if (this.data['contentType'] !== 'undefined') { |
| 45 | //获取点赞状态 | 51 | //获取点赞状态 |
| 46 | this.getLikeStatus() | 52 | this.getLikeStatus() |
| 47 | //获取点赞数 | 53 | //获取点赞数 |
| @@ -300,13 +306,26 @@ export struct LikeComponent { | @@ -300,13 +306,26 @@ export struct LikeComponent { | ||
| 300 | 306 | ||
| 301 | executeLike(status: string) { | 307 | executeLike(status: string) { |
| 302 | console.log(TAG, '点赞接口调用', status) | 308 | console.log(TAG, '点赞接口调用', status) |
| 303 | - this.data['status'] = status | ||
| 304 | - this.data['contentId'] = this.contentDetailData?.newsId + '' | ||
| 305 | - this.data['contentType'] = this.contentDetailData?.newsType + '' | ||
| 306 | 309 | ||
| 307 | - this.viewModel.executeLike2(this.data).then(() => { | 310 | + const params: postExecuteLikeParams = { |
| 311 | + status: Number(status), | ||
| 312 | + contentId: this.data['contentId'], | ||
| 313 | + contentType: this.data['contentType'] | ||
| 314 | + } | ||
| 315 | + if(this.data['relType']) { | ||
| 316 | + params.relType = this.data['relType'] | ||
| 317 | + } | ||
| 318 | + if(this.data['contentRelId']) { | ||
| 319 | + params.contentRelId = this.data['contentRelId'] | ||
| 320 | + } | ||
| 321 | + if(this.data['channelId']) { | ||
| 322 | + params.channelId = this.data['channelId'] | ||
| 323 | + } | ||
| 324 | + | ||
| 325 | + console.log(TAG, "点赞 params", JSON.stringify(params)) | ||
| 326 | + ContentDetailRequest.postExecuteLike(params).then((data) => { | ||
| 308 | 327 | ||
| 309 | - console.log(TAG, '点赞接口调用成功') | 328 | + console.log(TAG, '点赞接口调用成功', JSON.stringify(data)) |
| 310 | 329 | ||
| 311 | // 直播点赞一直增加 | 330 | // 直播点赞一直增加 |
| 312 | if (this.contentDetailData.liveInfo) { | 331 | if (this.contentDetailData.liveInfo) { |
| @@ -333,12 +352,26 @@ export struct LikeComponent { | @@ -333,12 +352,26 @@ export struct LikeComponent { | ||
| 333 | } | 352 | } |
| 334 | 353 | ||
| 335 | getLikeStatus() { | 354 | getLikeStatus() { |
| 336 | - this.viewModel.getLikeStatus(this.data).then((data) => { | ||
| 337 | - if (data && data['data'].length && data['data'][0]['likeStatus']) { | ||
| 338 | - this.likeStatus = data['data'][0]['likeStatus'] | 355 | + // console.log(TAG, "this.data", JSON.stringify(this.data)) |
| 356 | + const params: batchLikeAndCollectParams = { | ||
| 357 | + contentList: [ | ||
| 358 | + { | ||
| 359 | + contentId: this.data['contentId'], | ||
| 360 | + contentType: this.data['contentType'], | ||
| 361 | + contentRelId: this.data['contentRelId'] || '' + '', | ||
| 362 | + } | ||
| 363 | + ] | ||
| 364 | + } | ||
| 365 | + console.log(TAG, "查询点赞状态params", JSON.stringify(params)) | ||
| 366 | + ContentDetailRequest.postBatchLikeAndCollectStatus(params).then(res => { | ||
| 367 | + console.log(TAG, '查询点赞、收藏状态==', JSON.stringify(res.data)) | ||
| 368 | + if (res.data) { | ||
| 369 | + if(res.data[0].likeStatus) { | ||
| 370 | + this.likeStatus = res.data[0].likeStatus ? true : false | ||
| 339 | } else { | 371 | } else { |
| 340 | this.likeStatus = false | 372 | this.likeStatus = false |
| 341 | } | 373 | } |
| 374 | + } | ||
| 342 | }).catch(() => { | 375 | }).catch(() => { |
| 343 | this.likeStatus = false | 376 | this.likeStatus = false |
| 344 | }) | 377 | }) |
| @@ -36,6 +36,7 @@ const TAG = 'OperRowListView'; | @@ -36,6 +36,7 @@ const TAG = 'OperRowListView'; | ||
| 36 | * 注意:外层需注册 @Provide contentDetailData:contentDetailData = {} as contentDetailData | 36 | * 注意:外层需注册 @Provide contentDetailData:contentDetailData = {} as contentDetailData |
| 37 | * 传值示例: | 37 | * 传值示例: |
| 38 | OperRowListView({ | 38 | OperRowListView({ |
| 39 | + | ||
| 39 | contentDetailData: this.contentDetailData[0], | 40 | contentDetailData: this.contentDetailData[0], |
| 40 | operationButtonList: ['comment', 'like', 'collect', 'listen', 'share'] | 41 | operationButtonList: ['comment', 'like', 'collect', 'listen', 'share'] |
| 41 | }) | 42 | }) |
| @@ -119,11 +120,25 @@ export struct OperRowListView { | @@ -119,11 +120,25 @@ export struct OperRowListView { | ||
| 119 | await this.queryContentInteractCount() | 120 | await this.queryContentInteractCount() |
| 120 | // 点赞需要数据 | 121 | // 点赞需要数据 |
| 121 | this.likeBean['contentId'] = this.contentDetailData.newsId + '' | 122 | this.likeBean['contentId'] = this.contentDetailData.newsId + '' |
| 123 | + if(this.contentDetailData.userInfo?.userName) { | ||
| 122 | this.likeBean['userName'] = this.contentDetailData.userInfo?.userName + '' | 124 | this.likeBean['userName'] = this.contentDetailData.userInfo?.userName + '' |
| 125 | + } | ||
| 123 | this.likeBean['contentType'] = this.contentDetailData.newsType + '' | 126 | this.likeBean['contentType'] = this.contentDetailData.newsType + '' |
| 127 | + if(this.contentDetailData.newsTitle) { | ||
| 124 | this.likeBean['title'] = this.contentDetailData.newsTitle + '' | 128 | this.likeBean['title'] = this.contentDetailData.newsTitle + '' |
| 129 | + } | ||
| 130 | + if(this.contentDetailData.userInfo?.headPhotoUrl) { | ||
| 125 | this.likeBean['userHeaderUrl'] = this.contentDetailData.userInfo?.headPhotoUrl + '' | 131 | this.likeBean['userHeaderUrl'] = this.contentDetailData.userInfo?.headPhotoUrl + '' |
| 132 | + } | ||
| 133 | + if(this.contentDetailData.reLInfo?.channelId) { | ||
| 126 | this.likeBean['channelId'] = this.contentDetailData.reLInfo?.channelId + '' | 134 | this.likeBean['channelId'] = this.contentDetailData.reLInfo?.channelId + '' |
| 135 | + } | ||
| 136 | + if(this.contentDetailData?.reLInfo?.relType) { | ||
| 137 | + this.likeBean['relType'] = this.contentDetailData?.reLInfo?.relType + '' | ||
| 138 | + } | ||
| 139 | + if(this.contentDetailData?.reLInfo?.relId) { | ||
| 140 | + this.likeBean['contentRelId'] = this.contentDetailData?.reLInfo?.relId + '' | ||
| 141 | + } | ||
| 127 | console.info(TAG, 'contentDetailData----', JSON.stringify(this.contentDetailData)) | 142 | console.info(TAG, 'contentDetailData----', JSON.stringify(this.contentDetailData)) |
| 128 | console.info(TAG, 'likeBean----', JSON.stringify(this.likeBean)) | 143 | console.info(TAG, 'likeBean----', JSON.stringify(this.likeBean)) |
| 129 | // 评论需要数据 | 144 | // 评论需要数据 |
| @@ -198,7 +213,7 @@ export struct OperRowListView { | @@ -198,7 +213,7 @@ export struct OperRowListView { | ||
| 198 | .padding({ | 213 | .padding({ |
| 199 | top: 10, | 214 | top: 10, |
| 200 | // bottom: 10 | 215 | // bottom: 10 |
| 201 | - bottom: px2vp(this.bottomSafeHeight) | 216 | + bottom: `${this.bottomSafeHeight}px` |
| 202 | // bottom: 50 | 217 | // bottom: 50 |
| 203 | }) | 218 | }) |
| 204 | } | 219 | } |
| @@ -383,6 +398,7 @@ export struct OperRowListView { | @@ -383,6 +398,7 @@ export struct OperRowListView { | ||
| 383 | } | 398 | } |
| 384 | ] | 399 | ] |
| 385 | } | 400 | } |
| 401 | + console.info(TAG, '查询用户对作品收藏1', JSON.stringify(params)) | ||
| 386 | // console.info(TAG, '查询用户对作品收藏11', JSON.stringify(params)) | 402 | // console.info(TAG, '查询用户对作品收藏11', JSON.stringify(params)) |
| 387 | let data = await MultiPictureDetailViewModel.getInteractDataStatus(params) | 403 | let data = await MultiPictureDetailViewModel.getInteractDataStatus(params) |
| 388 | console.info(TAG, '查询用户对作品收藏22', JSON.stringify(data)) | 404 | console.info(TAG, '查询用户对作品收藏22', JSON.stringify(data)) |
| @@ -119,7 +119,7 @@ export interface postBatchAttentionStatusResult { | @@ -119,7 +119,7 @@ export interface postBatchAttentionStatusResult { | ||
| 119 | 119 | ||
| 120 | 120 | ||
| 121 | export interface postExecuteLikeParams { | 121 | export interface postExecuteLikeParams { |
| 122 | - status: string; | 122 | + status: number; |
| 123 | contentId: string; | 123 | contentId: string; |
| 124 | contentType: string; | 124 | contentType: string; |
| 125 | relType?: string; | 125 | relType?: string; |
| @@ -112,7 +112,7 @@ export struct DetailPlayShortVideoPage { | @@ -112,7 +112,7 @@ export struct DetailPlayShortVideoPage { | ||
| 112 | { | 112 | { |
| 113 | contentId: this.contentDetailData?.newsId + '', | 113 | contentId: this.contentDetailData?.newsId + '', |
| 114 | contentType: this.contentDetailData?.newsType + '', | 114 | contentType: this.contentDetailData?.newsType + '', |
| 115 | - contentRelId: this.contentDetailData?.reLInfo?.relId + '', | 115 | + contentRelId: this.contentDetailData?.reLInfo?.relId || '' + '', |
| 116 | } | 116 | } |
| 117 | ] | 117 | ] |
| 118 | } | 118 | } |
| @@ -74,7 +74,7 @@ export struct OperationListView { | @@ -74,7 +74,7 @@ export struct OperationListView { | ||
| 74 | return | 74 | return |
| 75 | } | 75 | } |
| 76 | const params: postExecuteLikeParams = { | 76 | const params: postExecuteLikeParams = { |
| 77 | - status: this.newsStatusOfUser?.likeStatus === '1' ? '0' : '1', | 77 | + status: this.newsStatusOfUser?.likeStatus === '1' ? 0 : 1, |
| 78 | contentId: this.contentDetailData?.newsId + '', | 78 | contentId: this.contentDetailData?.newsId + '', |
| 79 | contentType: this.contentDetailData?.newsType + '', | 79 | contentType: this.contentDetailData?.newsType + '', |
| 80 | } | 80 | } |
| @@ -56,15 +56,22 @@ export struct PlayerRightView { | @@ -56,15 +56,22 @@ export struct PlayerRightView { | ||
| 56 | return | 56 | return |
| 57 | } | 57 | } |
| 58 | const params: postExecuteLikeParams = { | 58 | const params: postExecuteLikeParams = { |
| 59 | - status: this.newsStatusOfUser?.likeStatus === '1' ? '0' : '1', | 59 | + status: this.newsStatusOfUser?.likeStatus === '1' ? 0 : 1, |
| 60 | contentId: this.contentDetailData?.newsId + '', | 60 | contentId: this.contentDetailData?.newsId + '', |
| 61 | contentType: this.contentDetailData?.newsType + '', | 61 | contentType: this.contentDetailData?.newsType + '', |
| 62 | + userName: this.contentDetailData?.userInfo?.userName || '' + '', | ||
| 63 | + contentRelId: this.contentDetailData?.reLInfo?.relId || '' + '', | ||
| 64 | + title: this.contentDetailData?.newsTitle || '' + '', | ||
| 65 | + channelId: this.contentDetailData?.reLInfo?.channelId + '', | ||
| 66 | + relType: this.contentDetailData?.reLInfo?.relType || '' + '', | ||
| 67 | + userHeaderUrl: this.contentDetailData?.userInfo?.headPhotoUrl || '' + '', | ||
| 62 | } | 68 | } |
| 69 | + console.log(TAG, '点赞params', JSON.stringify(params)) | ||
| 63 | ContentDetailRequest.postExecuteLike(params).then(res => { | 70 | ContentDetailRequest.postExecuteLike(params).then(res => { |
| 64 | - | 71 | + console.log(TAG, '点赞this.newsStatusOfUser', JSON.stringify(this.newsStatusOfUser)) |
| 65 | if (this.newsStatusOfUser) { | 72 | if (this.newsStatusOfUser) { |
| 66 | - this.newsStatusOfUser.likeStatus = this.newsStatusOfUser?.likeStatus === '1' ? '0' : '1' | ||
| 67 | - if (this.newsStatusOfUser.likeStatus === '1') { | 73 | + this.newsStatusOfUser.likeStatus = this.newsStatusOfUser?.likeStatus == '1' ? '0' : '1' |
| 74 | + if (this.newsStatusOfUser.likeStatus == '1') { | ||
| 68 | this.interactData.likeNum = Number(this.interactData.likeNum || 0) + 1 | 75 | this.interactData.likeNum = Number(this.interactData.likeNum || 0) + 1 |
| 69 | } else { | 76 | } else { |
| 70 | this.interactData.likeNum = Math.max(0, Number(this.interactData.likeNum || 0) - 1) | 77 | this.interactData.likeNum = Math.max(0, Number(this.interactData.likeNum || 0) - 1) |
| @@ -237,17 +244,17 @@ export struct PlayerRightView { | @@ -237,17 +244,17 @@ export struct PlayerRightView { | ||
| 237 | transLikeStyle(): ILikeStyleResp { | 244 | transLikeStyle(): ILikeStyleResp { |
| 238 | if (this.likesStyle === 1) { | 245 | if (this.likesStyle === 1) { |
| 239 | return { | 246 | return { |
| 240 | - url: this.newsStatusOfUser.likeStatus === '1' ? $r(`app.media.ic_like_check`) : $r(`app.media.ic_like_uncheck`), | 247 | + url: this.newsStatusOfUser.likeStatus == '1' ? $r(`app.media.ic_like_check`) : $r(`app.media.ic_like_uncheck`), |
| 241 | name: '赞' | 248 | name: '赞' |
| 242 | } | 249 | } |
| 243 | } else if (this.likesStyle === 2) { | 250 | } else if (this.likesStyle === 2) { |
| 244 | return { | 251 | return { |
| 245 | - url: this.newsStatusOfUser.likeStatus === '1' ? $r(`app.media.ic_thub_check`) : $r(`app.media.ic_thub_uncheck`), | 252 | + url: this.newsStatusOfUser.likeStatus == '1' ? $r(`app.media.ic_thub_check`) : $r(`app.media.ic_thub_uncheck`), |
| 246 | name: '祈祷' | 253 | name: '祈祷' |
| 247 | } | 254 | } |
| 248 | } else if (this.likesStyle === 3) { | 255 | } else if (this.likesStyle === 3) { |
| 249 | return { | 256 | return { |
| 250 | - url: this.newsStatusOfUser.likeStatus === '1' ? $r(`app.media.ic_candle_check`) : | 257 | + url: this.newsStatusOfUser.likeStatus == '1' ? $r(`app.media.ic_candle_check`) : |
| 251 | $r(`app.media.ic_candle_uncheck`), | 258 | $r(`app.media.ic_candle_uncheck`), |
| 252 | name: '默哀' | 259 | name: '默哀' |
| 253 | } | 260 | } |
-
Please register or login to post a comment