陈剑华

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

/**
* 这里是人民号动态中的顶部信息:人民号logo,名字,描述,关注等
*/
import {
ContentDetailRequest,
postInteractAccentionOperateParams
} from 'wdDetailPlayApi/src/main/ets/request/ContentDetailRequest';
import { RmhInfoDTO } from 'wdBean'
import { CommonConstants } from 'wdConstant/Index';
import { DateTimeUtils, SPHelper } from 'wdKit';
import { DateTimeUtils, SPHelper, Logger, ToastUtils } from 'wdKit';
import { SpConstants } from 'wdConstant/Index'
import { WDRouterPage, WDRouterRule } from 'wdRouter/Index';
import router from '@ohos.router'
import { postBatchAttentionStatusParams } from 'wdBean/Index';
import { MultiPictureDetailViewModel } from '../../viewmodel/MultiPictureDetailViewModel'
@Component
export struct RmhTitle {
@Prop rmhInfo: RmhInfoDTO
@Prop publishTime: string | undefined
/**
* 是否需要隐藏发布时间超过2天的时间展示,默认不隐藏
*/
@Prop hideTime: boolean
/**
* 默认未关注 点击去关注
*/
@State followStatus: String = '0';
async appointReq() {
/**
* 关注号主
*/
async handleAccention() {
// 未登录,跳转登录
const user_id = await SPHelper.default.get(SpConstants.USER_ID, '')
if (!user_id) {
WDRouterRule.jumpWithPage(WDRouterPage.loginPage)
return
}
const params2: postInteractAccentionOperateParams = {
attentionUserType: this.rmhInfo?.userType || '', //被关注用户类型(1 普通用户 2 视频号 3 矩阵号)
attentionUserId: this.rmhInfo?.userId || '', // 被关注用户号主id
attentionCreatorId: this.rmhInfo?.rmhId || '', // 被关注用户号主id
status: this.followStatus == '0' ? 1 : 0,
}
ContentDetailRequest.postInteractAccentionOperate(params2).then(res => {
console.log('关注号主==', JSON.stringify(res.data))
if (this.followStatus == '1') {
this.followStatus = '0'
} else {
this.followStatus = '1'
// 弹窗样式与何时调用待确认
ContentDetailRequest.postPointLevelOperate({ operateType: 6 }).then((res) => {
console.log('关注号主获取积分==', JSON.stringify(res.data))
if (res.data?.showToast) {
ToastUtils.showToast(res.data.ruleName + '+' + res.data.rulePoint + '积分', 1000);
}
})
}
})
}
/**
* 查询当前登录用户是否关注作品号主
* */
private async getBatchAttentionStatus() {
try {
const params: postBatchAttentionStatusParams = {
creatorIds: [{ creatorId: this.rmhInfo?.rmhId ?? '' }]
}
let data = await MultiPictureDetailViewModel.getBatchAttentionStatus(params)
this.followStatus = data[0]?.status;
Logger.info(`rmhTitle-followStatus:${JSON.stringify(this.followStatus)}`)
} catch (exception) {
}
}
aboutToAppear(): void {
... ... @@ -28,6 +81,8 @@ export struct RmhTitle {
if (page.path.includes('/page/PeopleShipHomePage') || page.path.includes('/pages/MainPage')) {
this.hideTime = true;
}
this.getBatchAttentionStatus()
}
getDaysBetweenDates(date: number) {
... ... @@ -88,17 +143,20 @@ export struct RmhTitle {
Blank()
if (this.rmhInfo.cnIsAttention) {
Row() {
if (this.followStatus === '0') {
Image($r('app.media.rmh_follow'))
.width(16)
.height(16)
Text('关注')
}
Text(this.followStatus === '0' ? '关注' : '已关注')
.fontSize($r('app.float.font_size_13'))
.fontColor($r('app.color.color_ED2800'))
}
.flexShrink(0)
.alignSelf(ItemAlign.Center)
.onClick(() => {
this.appointReq();
this.handleAccention();
})
}
}
... ...