Toggle navigation
Toggle navigation
This project
Loading...
Sign in
developOne
/
harmonyPool
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
zhaojunkai
2024-05-10 15:49:27 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
f502e2ee84a41e5d70ad7c4d2b27138cf174bc68
f502e2ee
1 parent
3c70a2bf
人民号-动态Tab下的内容分享优化
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
6 deletions
sight_harmony/features/wdComponent/src/main/ets/components/CarderInteraction.ets
sight_harmony/features/wdComponent/src/main/ets/components/cardview/Card20Component.ets
sight_harmony/features/wdComponent/src/main/ets/components/CarderInteraction.ets
View file @
f502e2e
import { ToastUtils } from 'wdKit';
import { SPHelper,Logger,ToastUtils } from 'wdKit';
import { ContentDetailDTO, Action, ContentDTO,batchLikeAndCollectResult } from 'wdBean';
import { ProcessUtils } from 'wdRouter';
import router from '@ohos.router';
import { batchLikeAndCollectParams } from 'wdDetailPlayApi/src/main/ets/request/ContentDetailRequest';
import { MultiPictureDetailViewModel } from '../viewmodel/MultiPictureDetailViewModel';
import { SpConstants } from 'wdConstant/Index';
import { WDShare } from 'wdShare/Index';
const TAG = 'CarderInteraction'
/**
* 卡片 分享、评论、点赞公用组件
*/
@Component
export struct CarderInteraction {
@Prop contentDTO: ContentDTO
@State contentId: string = ''
@State contentDetailData: ContentDetailDTO = {} as ContentDetailDTO
@State newsStatusOfUser: batchLikeAndCollectResult = {} as batchLikeAndCollectResult// 点赞、收藏状态
build() {
Row(){
Row(){
...
...
@@ -18,7 +29,7 @@ export struct CarderInteraction {
}
.justifyContent(FlexAlign.Center)
.onClick(()=>{
ToastUtils.showToast('分享为公共方法,待开发', 1000
)
this.getContentDetailData(
)
})
Row(){
Image($r('app.media.CarderInteraction_comment'))
...
...
@@ -31,7 +42,7 @@ export struct CarderInteraction {
}
.justifyContent(FlexAlign.Center)
.onClick(()=>{
ToastUtils.showToast('分享为公共方法,待开发', 1000
)
ProcessUtils.processPage(this.contentDTO
)
})
Row(){
Image($r('app.media.CarderInteraction_like'))
...
...
@@ -44,7 +55,8 @@ export struct CarderInteraction {
}
.justifyContent(FlexAlign.Center)
.onClick(()=>{
ToastUtils.showToast('分享为公共方法,待开发', 1000)
ProcessUtils.processPage(this.contentDTO)
// ToastUtils.showToast('点赞为公共方法,待开发', 1000)
})
}
.width('100%')
...
...
@@ -56,4 +68,45 @@ export struct CarderInteraction {
.justifyContent(FlexAlign.SpaceBetween)
.alignItems(VerticalAlign.Center)
}
/**
* 请求(动态)详情页数据
* */
private async getContentDetailData() {
try {
let data = await MultiPictureDetailViewModel.getDetailData(this.contentDTO.relId, this.contentDTO.objectId, this.contentDTO.relType)
this.contentDetailData = data[0];
console.log('动态详情',JSON.stringify(this.contentDetailData))
WDShare.shareContent(this.contentDetailData)
} catch (exception) {
console.log('请求失败',JSON.stringify(exception))
}
this.getInteractDataStatus()
}
// 已登录->查询用户对作品点赞、收藏状态
private async getInteractDataStatus() {
// 未登录,跳转登录
const user_id = await SPHelper.default.get(SpConstants.USER_ID, '')
if (!user_id) {
return
}
try {
const params: batchLikeAndCollectParams = {
contentList: [
{
contentId: this.contentDetailData?.newsId + '',
contentType: this.contentDetailData?.newsType + '',
}
]
}
console.error(TAG, JSON.stringify(this.contentDetailData))
let data = await MultiPictureDetailViewModel.getInteractDataStatus(params)
console.error(TAG, '查询用户对作品点赞、收藏状态', JSON.stringify(data))
this.newsStatusOfUser = data[0];
Logger.info(TAG, `newsStatusOfUser:${JSON.stringify(this.newsStatusOfUser)}`)
} catch (exception) {
console.error(TAG, JSON.stringify(exception))
}
}
}
...
...
sight_harmony/features/wdComponent/src/main/ets/components/cardview/Card20Component.ets
View file @
f502e2e
...
...
@@ -37,7 +37,7 @@ export struct Card20Component {
if (this.contentDTO.fullColumnImgUrls[0]) {
createImg({ contentDTO: this.contentDTO })
}
CarderInteraction()
CarderInteraction(
{contentDTO: this.contentDTO}
)
//TODO 底部的:分享、评论、点赞 功能;需要引用一个公共组件
}
.padding({
...
...
Please
register
or
login
to post a comment