陈剑华

fix: 16975 功能缺陷--进入金刚位,点击知识2,进入知识2列表页,点击关注按钮没有反应

1 /** 1 /**
2 * 这里是人民号动态中的顶部信息:人民号logo,名字,描述,关注等 2 * 这里是人民号动态中的顶部信息:人民号logo,名字,描述,关注等
3 */ 3 */
  4 +import {
  5 + ContentDetailRequest,
  6 + postInteractAccentionOperateParams
  7 +} from 'wdDetailPlayApi/src/main/ets/request/ContentDetailRequest';
4 import { RmhInfoDTO } from 'wdBean' 8 import { RmhInfoDTO } from 'wdBean'
5 import { CommonConstants } from 'wdConstant/Index'; 9 import { CommonConstants } from 'wdConstant/Index';
6 -import { DateTimeUtils, SPHelper } from 'wdKit'; 10 +import { DateTimeUtils, SPHelper, Logger, ToastUtils } from 'wdKit';
7 import { SpConstants } from 'wdConstant/Index' 11 import { SpConstants } from 'wdConstant/Index'
8 import { WDRouterPage, WDRouterRule } from 'wdRouter/Index'; 12 import { WDRouterPage, WDRouterRule } from 'wdRouter/Index';
9 import router from '@ohos.router' 13 import router from '@ohos.router'
  14 +import { postBatchAttentionStatusParams } from 'wdBean/Index';
  15 +import { MultiPictureDetailViewModel } from '../../viewmodel/MultiPictureDetailViewModel'
10 16
11 @Component 17 @Component
12 export struct RmhTitle { 18 export struct RmhTitle {
13 @Prop rmhInfo: RmhInfoDTO 19 @Prop rmhInfo: RmhInfoDTO
14 @Prop publishTime: string | undefined 20 @Prop publishTime: string | undefined
  21 + /**
  22 + * 是否需要隐藏发布时间超过2天的时间展示,默认不隐藏
  23 + */
15 @Prop hideTime: boolean 24 @Prop hideTime: boolean
  25 + /**
  26 + * 默认未关注 点击去关注
  27 + */
  28 + @State followStatus: String = '0';
16 29
17 - async appointReq() { 30 + /**
  31 + * 关注号主
  32 + */
  33 + async handleAccention() {
18 // 未登录,跳转登录 34 // 未登录,跳转登录
19 const user_id = await SPHelper.default.get(SpConstants.USER_ID, '') 35 const user_id = await SPHelper.default.get(SpConstants.USER_ID, '')
20 if (!user_id) { 36 if (!user_id) {
21 WDRouterRule.jumpWithPage(WDRouterPage.loginPage) 37 WDRouterRule.jumpWithPage(WDRouterPage.loginPage)
22 return 38 return
23 } 39 }
  40 +
  41 + const params2: postInteractAccentionOperateParams = {
  42 + attentionUserType: this.rmhInfo?.userType || '', //被关注用户类型(1 普通用户 2 视频号 3 矩阵号)
  43 + attentionUserId: this.rmhInfo?.userId || '', // 被关注用户号主id
  44 + attentionCreatorId: this.rmhInfo?.rmhId || '', // 被关注用户号主id
  45 + status: this.followStatus == '0' ? 1 : 0,
  46 + }
  47 + ContentDetailRequest.postInteractAccentionOperate(params2).then(res => {
  48 + console.log('关注号主==', JSON.stringify(res.data))
  49 + if (this.followStatus == '1') {
  50 + this.followStatus = '0'
  51 + } else {
  52 + this.followStatus = '1'
  53 + // 弹窗样式与何时调用待确认
  54 + ContentDetailRequest.postPointLevelOperate({ operateType: 6 }).then((res) => {
  55 + console.log('关注号主获取积分==', JSON.stringify(res.data))
  56 + if (res.data?.showToast) {
  57 + ToastUtils.showToast(res.data.ruleName + '+' + res.data.rulePoint + '积分', 1000);
  58 + }
  59 + })
  60 + }
  61 + })
  62 + }
  63 + /**
  64 + * 查询当前登录用户是否关注作品号主
  65 + * */
  66 + private async getBatchAttentionStatus() {
  67 + try {
  68 + const params: postBatchAttentionStatusParams = {
  69 + creatorIds: [{ creatorId: this.rmhInfo?.rmhId ?? '' }]
  70 + }
  71 + let data = await MultiPictureDetailViewModel.getBatchAttentionStatus(params)
  72 + this.followStatus = data[0]?.status;
  73 + Logger.info(`rmhTitle-followStatus:${JSON.stringify(this.followStatus)}`)
  74 + } catch (exception) {
  75 +
  76 + }
24 } 77 }
25 78
26 aboutToAppear(): void { 79 aboutToAppear(): void {
@@ -28,6 +81,8 @@ export struct RmhTitle { @@ -28,6 +81,8 @@ export struct RmhTitle {
28 if (page.path.includes('/page/PeopleShipHomePage') || page.path.includes('/pages/MainPage')) { 81 if (page.path.includes('/page/PeopleShipHomePage') || page.path.includes('/pages/MainPage')) {
29 this.hideTime = true; 82 this.hideTime = true;
30 } 83 }
  84 +
  85 + this.getBatchAttentionStatus()
31 } 86 }
32 87
33 getDaysBetweenDates(date: number) { 88 getDaysBetweenDates(date: number) {
@@ -88,17 +143,20 @@ export struct RmhTitle { @@ -88,17 +143,20 @@ export struct RmhTitle {
88 Blank() 143 Blank()
89 if (this.rmhInfo.cnIsAttention) { 144 if (this.rmhInfo.cnIsAttention) {
90 Row() { 145 Row() {
  146 + if (this.followStatus === '0') {
91 Image($r('app.media.rmh_follow')) 147 Image($r('app.media.rmh_follow'))
92 .width(16) 148 .width(16)
93 .height(16) 149 .height(16)
94 - Text('关注') 150 + }
  151 +
  152 + Text(this.followStatus === '0' ? '关注' : '已关注')
95 .fontSize($r('app.float.font_size_13')) 153 .fontSize($r('app.float.font_size_13'))
96 .fontColor($r('app.color.color_ED2800')) 154 .fontColor($r('app.color.color_ED2800'))
97 } 155 }
98 .flexShrink(0) 156 .flexShrink(0)
99 .alignSelf(ItemAlign.Center) 157 .alignSelf(ItemAlign.Center)
100 .onClick(() => { 158 .onClick(() => {
101 - this.appointReq(); 159 + this.handleAccention();
102 }) 160 })
103 } 161 }
104 } 162 }