张善主

feat(动态):查询点赞收藏接口参数调整/点赞尺寸调整

@@ -44,9 +44,9 @@ export struct DynamicDetailComponent { @@ -44,9 +44,9 @@ export struct DynamicDetailComponent {
44 /** 44 /**
45 * 关注状态:默认未关注 点击去关注 45 * 关注状态:默认未关注 点击去关注
46 */ 46 */
47 - @State followStatus: String = '0'; 47 + @State followStatus: String = '';
48 48
49 - @State newsStatusOfUser: batchLikeAndCollectResult | undefined = undefined// 点赞、收藏状态 49 + @State newsStatusOfUser: batchLikeAndCollectResult = {} as batchLikeAndCollectResult// 点赞、收藏状态
50 //跳转 50 //跳转
51 private mJumpInfo: ContentDTO = {} as ContentDTO; 51 private mJumpInfo: ContentDTO = {} as ContentDTO;
52 52
@@ -121,31 +121,33 @@ export struct DynamicDetailComponent { @@ -121,31 +121,33 @@ export struct DynamicDetailComponent {
121 } 121 }
122 .width('63%') 122 .width('63%')
123 .margin({right: $r('app.float.margin_6')}) 123 .margin({right: $r('app.float.margin_6')})
124 - if (this.followStatus == '0') {  
125 - Text('关注')  
126 - .width($r('app.float.margin_54'))  
127 - .height($r('app.float.margin_24'))  
128 - .textAlign(TextAlign.Center)  
129 - .fontSize($r('app.float.font_size_12'))  
130 - .borderRadius($r('app.float.vp_3'))  
131 - .backgroundColor($r('app.color.color_ED2800'))  
132 - .fontColor($r('app.color.color_fff'))  
133 - .onClick(() => {  
134 - this.handleAccention()  
135 - })  
136 - } else {  
137 - Text('已关注')  
138 - .width($r('app.float.margin_54'))  
139 - .height($r('app.float.margin_24'))  
140 - .borderWidth(1)  
141 - .textAlign(TextAlign.Center)  
142 - .fontSize($r('app.float.font_size_12'))  
143 - .borderRadius($r('app.float.vp_3'))  
144 - .borderColor($r('app.color.color_CCCCCC'))  
145 - .fontColor($r('app.color.color_CCCCCC'))  
146 - .onClick(() => {  
147 - this.handleAccention()  
148 - }) 124 + if(!StringUtils.isEmpty(this.followStatus)){
  125 + if (this.followStatus == '0') {
  126 + Text('关注')
  127 + .width($r('app.float.margin_54'))
  128 + .height($r('app.float.margin_24'))
  129 + .textAlign(TextAlign.Center)
  130 + .fontSize($r('app.float.font_size_12'))
  131 + .borderRadius($r('app.float.vp_3'))
  132 + .backgroundColor($r('app.color.color_ED2800'))
  133 + .fontColor($r('app.color.color_fff'))
  134 + .onClick(() => {
  135 + this.handleAccention()
  136 + })
  137 + } else {
  138 + Text('已关注')
  139 + .width($r('app.float.margin_54'))
  140 + .height($r('app.float.margin_24'))
  141 + .borderWidth(1)
  142 + .textAlign(TextAlign.Center)
  143 + .fontSize($r('app.float.font_size_12'))
  144 + .borderRadius($r('app.float.vp_3'))
  145 + .borderColor($r('app.color.color_CCCCCC'))
  146 + .fontColor($r('app.color.color_CCCCCC'))
  147 + .onClick(() => {
  148 + this.handleAccention()
  149 + })
  150 + }
149 } 151 }
150 } 152 }
151 .width('100%') 153 .width('100%')
@@ -330,8 +332,8 @@ export struct DynamicDetailComponent { @@ -330,8 +332,8 @@ export struct DynamicDetailComponent {
330 Image(this.newsStatusOfUser?.likeStatus == '1'? 332 Image(this.newsStatusOfUser?.likeStatus == '1'?
331 $r('app.media.icon_like_selected_redheart') 333 $r('app.media.icon_like_selected_redheart')
332 :$r('app.media.icon_like_unselect_grey_redheart')) 334 :$r('app.media.icon_like_unselect_grey_redheart'))
333 - .width($r('app.float.margin_24'))  
334 - .height($r('app.float.margin_24')) 335 + .width($r('app.float.margin_36'))
  336 + .height($r('app.float.margin_36'))
335 .objectFit(ImageFit.Cover) 337 .objectFit(ImageFit.Cover)
336 if(this.interactDataDTO?.likeNum != 0){ 338 if(this.interactDataDTO?.likeNum != 0){
337 Text(NumberFormatterUtils.formatNumberWithWan(this.interactDataDTO?.likeNum)) 339 Text(NumberFormatterUtils.formatNumberWithWan(this.interactDataDTO?.likeNum))
@@ -430,12 +432,18 @@ export struct DynamicDetailComponent { @@ -430,12 +432,18 @@ export struct DynamicDetailComponent {
430 432
431 // 已登录->查询用户对作品点赞、收藏状态 433 // 已登录->查询用户对作品点赞、收藏状态
432 private async getInteractDataStatus() { 434 private async getInteractDataStatus() {
  435 + // 未登录,跳转登录
  436 + const user_id = await SPHelper.default.get(SpConstants.USER_ID, '')
  437 + if (!user_id) {
  438 + WDRouterRule.jumpWithPage(WDRouterPage.loginPage)
  439 + return
  440 + }
433 try { 441 try {
434 const params: batchLikeAndCollectParams = { 442 const params: batchLikeAndCollectParams = {
435 contentList: [ 443 contentList: [
436 { 444 {
437 - contentId: this.contentDetailData[0]?.newsId + '',  
438 - contentType: this.contentDetailData[0]?.newsType + '', 445 + contentId: this.contentDetailData?.newsId + '',
  446 + contentType: this.contentDetailData?.newsType + '',
439 } 447 }
440 ] 448 ]
441 } 449 }
@@ -453,16 +461,23 @@ export struct DynamicDetailComponent { @@ -453,16 +461,23 @@ export struct DynamicDetailComponent {
453 * 查询当前登录用户是否关注作品号主 461 * 查询当前登录用户是否关注作品号主
454 * */ 462 * */
455 private async getBatchAttentionStatus() { 463 private async getBatchAttentionStatus() {
  464 + // 未登录,跳转登录
  465 + const user_id = await SPHelper.default.get(SpConstants.USER_ID, '')
  466 + if (!user_id) {
  467 + WDRouterRule.jumpWithPage(WDRouterPage.loginPage)
  468 + this.followStatus = '0';
  469 + return
  470 + }
456 try { 471 try {
457 - const params: postBatchAttentionStatusParams = {  
458 - creatorIds: [{ creatorId: this.contentDetailData?.rmhInfo?.rmhId ?? '' }] 472 + const params: postBatchAttentionStatusParams = {
  473 + creatorIds: [{ creatorId: this.contentDetailData?.rmhInfo?.rmhId ?? '' }]
  474 + }
  475 + let data = await MultiPictureDetailViewModel.getBatchAttentionStatus(params)
  476 + this.followStatus = data[0]?.status;
  477 + Logger.info(TAG, `followStatus:${JSON.stringify(this.followStatus)}`)
  478 + } catch (exception) {
  479 + this.followStatus = '0';
459 } 480 }
460 - let data = await MultiPictureDetailViewModel.getBatchAttentionStatus(params)  
461 - this.followStatus = data[0]?.status;  
462 - Logger.info(TAG, `followStatus:${JSON.stringify(this.followStatus)}`)  
463 - } catch (exception) {  
464 -  
465 - }  
466 } 481 }
467 482
468 //创建跳转信息 483 //创建跳转信息
@@ -558,18 +573,13 @@ export struct DynamicDetailComponent { @@ -558,18 +573,13 @@ export struct DynamicDetailComponent {
558 contentType: this.contentDetailData?.newsType + '', 573 contentType: this.contentDetailData?.newsType + '',
559 } 574 }
560 ContentDetailRequest.postExecuteLike(params).then(res => { 575 ContentDetailRequest.postExecuteLike(params).then(res => {
561 -  
562 - if (this.newsStatusOfUser) {  
563 - this.newsStatusOfUser.likeStatus = this.newsStatusOfUser?.likeStatus === '1' ? '0' : '1'  
564 - if (this.newsStatusOfUser.likeStatus === '1') {  
565 - this.interactDataDTO.likeNum = Number(this.interactDataDTO.likeNum) + 1  
566 - } else {  
567 - this.interactDataDTO.likeNum = Number(this.interactDataDTO.likeNum) - 1  
568 - }  
569 - console.log('点赞、取消点赞==', this.newsStatusOfUser?.likeStatus, this.interactDataDTO?.likeNum)  
570 - // this.queryContentInteractCount() 576 + this.newsStatusOfUser.likeStatus = this.newsStatusOfUser?.likeStatus === '1' ? '0' : '1'
  577 + if (this.newsStatusOfUser.likeStatus === '1') {
  578 + this.interactDataDTO.likeNum = Number(this.interactDataDTO.likeNum) + 1
  579 + } else {
  580 + this.interactDataDTO.likeNum = Number(this.interactDataDTO.likeNum) - 1
571 } 581 }
572 - 582 + console.log('点赞、取消点赞==', this.newsStatusOfUser?.likeStatus, this.interactDataDTO?.likeNum)
573 }) 583 })
574 } 584 }
575 } 585 }