Showing
1 changed file
with
33 additions
and
2 deletions
| 1 | -import { Logger } from 'wdKit'; | 1 | +import { AccountManagerUtils, Logger } from 'wdKit'; |
| 2 | import { MultiPictureDetailViewModel } from '../viewmodel/MultiPictureDetailViewModel'; | 2 | import { MultiPictureDetailViewModel } from '../viewmodel/MultiPictureDetailViewModel'; |
| 3 | -import { ContentDetailDTO } from 'wdBean'; | 3 | +import { ContentDetailDTO,batchLikeAndCollectResult,batchLikeAndCollectParams, } from 'wdBean'; |
| 4 | import media from '@ohos.multimedia.media'; | 4 | import media from '@ohos.multimedia.media'; |
| 5 | import { OperRowListView } from './view/OperRowListView'; | 5 | import { OperRowListView } from './view/OperRowListView'; |
| 6 | import { WDPlayerController } from 'wdPlayer/Index'; | 6 | import { WDPlayerController } from 'wdPlayer/Index'; |
| @@ -20,6 +20,7 @@ export struct DynamicDetailComponent { | @@ -20,6 +20,7 @@ export struct DynamicDetailComponent { | ||
| 20 | * 默认未关注 点击去关注 | 20 | * 默认未关注 点击去关注 |
| 21 | */ | 21 | */ |
| 22 | private followStatus: boolean = false; | 22 | private followStatus: boolean = false; |
| 23 | + @State newsStatusOfUser: batchLikeAndCollectResult | undefined = undefined // 点赞、收藏状态 | ||
| 23 | 24 | ||
| 24 | 25 | ||
| 25 | async aboutToAppear() { | 26 | async aboutToAppear() { |
| @@ -160,10 +161,14 @@ export struct DynamicDetailComponent { | @@ -160,10 +161,14 @@ export struct DynamicDetailComponent { | ||
| 160 | .margin({ left: $r('app.float.margin_2')}) | 161 | .margin({ left: $r('app.float.margin_2')}) |
| 161 | } | 162 | } |
| 162 | //评论组件/底部组件 | 163 | //评论组件/底部组件 |
| 164 | + | ||
| 163 | } | 165 | } |
| 164 | } | 166 | } |
| 165 | .backgroundColor('#FFFFFFFF') | 167 | .backgroundColor('#FFFFFFFF') |
| 166 | } | 168 | } |
| 169 | + /** | ||
| 170 | + * 请求(动态)详情页数据 | ||
| 171 | + * */ | ||
| 167 | private async getContentDetailData() { | 172 | private async getContentDetailData() { |
| 168 | try { | 173 | try { |
| 169 | let data = await MultiPictureDetailViewModel.getDetailData(this.relId, this.contentId, this.relType) | 174 | let data = await MultiPictureDetailViewModel.getDetailData(this.relId, this.contentId, this.relType) |
| @@ -172,5 +177,31 @@ export struct DynamicDetailComponent { | @@ -172,5 +177,31 @@ export struct DynamicDetailComponent { | ||
| 172 | } catch (exception) { | 177 | } catch (exception) { |
| 173 | console.log('请求失败',JSON.stringify(exception)) | 178 | console.log('请求失败',JSON.stringify(exception)) |
| 174 | } | 179 | } |
| 180 | + this.getInteractDataStatus() | ||
| 181 | + } | ||
| 182 | + | ||
| 183 | + // 查询当前登录用户点赞状态 | ||
| 184 | + private async getInteractDataStatus() { | ||
| 185 | + //未登录 | ||
| 186 | + if(!AccountManagerUtils.isLoginSync() || this.contentDetailData?.openLikes != 1){ | ||
| 187 | + return | ||
| 188 | + } | ||
| 189 | + try { | ||
| 190 | + const params: batchLikeAndCollectParams = { | ||
| 191 | + contentList: [ | ||
| 192 | + { | ||
| 193 | + contentId: this.contentDetailData?.newsId + '', | ||
| 194 | + contentType: this.contentDetailData?.newsType + '', | ||
| 195 | + } | ||
| 196 | + ] | ||
| 197 | + } | ||
| 198 | + console.error(TAG, JSON.stringify(this.contentDetailData)) | ||
| 199 | + let data = await MultiPictureDetailViewModel.getInteractDataStatus(params) | ||
| 200 | + console.error(TAG, '查询用户对作品点赞、收藏状态', JSON.stringify(data)) | ||
| 201 | + this.newsStatusOfUser = data[0]; | ||
| 202 | + Logger.info(TAG, `newsStatusOfUser:${JSON.stringify(this.newsStatusOfUser)}`) | ||
| 203 | + } catch (exception) { | ||
| 204 | + console.error(TAG, JSON.stringify(exception)) | ||
| 205 | + } | ||
| 175 | } | 206 | } |
| 176 | } | 207 | } |
-
Please register or login to post a comment