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
王士厅
2024-04-07 15:21:22 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
bed013058027c79e30d1471930f735e2bf531c32
bed01305
1 parent
e8a1af5b
多图(图集)详情页点赞、收藏联调完成
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
61 additions
and
37 deletions
sight_harmony/commons/wdKit/Index.ets
sight_harmony/commons/wdKit/src/main/ets/utils/NumberFormatterUtils.ets
sight_harmony/features/wdBean/src/main/ets/bean/content/InteractDataDTO.ets
sight_harmony/features/wdComponent/src/main/ets/components/MultiPictureDetailPageComponent.ets
sight_harmony/features/wdComponent/src/main/ets/components/view/OperRowListView.ets
sight_harmony/commons/wdKit/Index.ets
View file @
bed0130
...
...
@@ -32,4 +32,6 @@ export { SystemUtils } from './src/main/ets/utils/SystemUtils'
export { PermissionUtil } from './src/main/ets/utils/PermissionUtil'
export { UserDataLocal } from './src/main/ets/utils/UserDataLocal'
\ No newline at end of file
export { UserDataLocal } from './src/main/ets/utils/UserDataLocal'
export { NumberFormatterUtils } from './src/main/ets/utils/NumberFormatterUtils'
\ No newline at end of file
...
...
sight_harmony/commons/wdKit/src/main/ets/utils/NumberFormatterUtils.ets
0 → 100644
View file @
bed0130
export class NumberFormatterUtils {
/**
* 数据小于一万返回原数据,大于一万保留小数点后一位,加上万字
* @param num
* @returns
*/
static formatNumberWithWan(inputNumber: number | String): string {
const num = typeof inputNumber === 'number' ? inputNumber : Number(inputNumber);
if (isNaN(num) || num < 10000) {
return num.toString();
} else {
const wanUnit = num / 10000;
return `${wanUnit.toFixed(1)}万`;
}
}
}
\ No newline at end of file
...
...
sight_harmony/features/wdBean/src/main/ets/bean/content/InteractDataDTO.ets
View file @
bed0130
...
...
@@ -2,11 +2,11 @@
* 批查接口查询互动相关数据,返回数据bean
*/
export interface InteractDataDTO {
collectNum: number;
commentNum: number;
collectNum: number | String;
commentNum: number | String;
contentId: string;
contentType: number;
likeNum: number;
likeNum: number
| String
;
readNum: number;
shareNum: number;
}
\ No newline at end of file
...
...
sight_harmony/features/wdComponent/src/main/ets/components/MultiPictureDetailPageComponent.ets
View file @
bed0130
...
...
@@ -19,7 +19,7 @@ export struct MultiPictureDetailPageComponent {
private screenWidth: number = 0
private picWidth: number = 0
@State picHeight: number = 0
@State contentDetailData: ContentDetailDTO
[] = [] as ContentDetailDTO[]
@State contentDetailData: ContentDetailDTO
= {} as ContentDetailDTO
@Provide @Watch('onCurrentPageNumUpdated') currentPageNum: string = '01'
private swiperController: SwiperController = new SwiperController()
@State swiperIndex: number = 0;
...
...
@@ -58,10 +58,10 @@ export struct MultiPictureDetailPageComponent {
build() {
RelativeContainer() {
if (this.contentDetailData
&& this.contentDetailData.length > 0 && this.contentDetailData[0].photoList && this.contentDetailData[0]
.photoList?.length > 0) {
if (this.contentDetailData
?.photoList && this.contentDetailData?
.photoList?.length > 0) {
Swiper(this.swiperController) {
ForEach(this.contentDetailData[0].photoList, (item: PhotoListBean, index: number) => {
MultiPictureDetailItemComponent({ photoListLength: this.contentDetailData[0].photoList?.length , index: index, newsTitle: this.contentDetailData[0].newsTitle, MultiPictureDetailItem: item })
ForEach(this.contentDetailData.photoList, (item: PhotoListBean, index: number) => {
MultiPictureDetailItemComponent({ photoListLength: this.contentDetailData.photoList?.length , index: index, newsTitle: this.contentDetailData.newsTitle, MultiPictureDetailItem: item })
})
}
.index(this.swiperIndex)
...
...
@@ -80,17 +80,18 @@ export struct MultiPictureDetailPageComponent {
.onChange((index: number) => {
this.swiperIndex = index
})
OperRowListView({
contentDetailData: this.contentDetailData,
})
.alignRules({
bottom: { anchor: "__container__", align: VerticalAlign.Bottom },
middle: { anchor: "__container__", align: HorizontalAlign.Center }
})
.width('100%').height(56).margin(16)
.border({ width: {top: 0.5}, color: '#FFFFFF' })
.id('e_oper_row')
}
OperRowListView({
contentDetailData: this.contentDetailData?.[0],
})
.alignRules({
bottom: { anchor: "__container__", align: VerticalAlign.Bottom },
middle: { anchor: "__container__", align: HorizontalAlign.Center }
})
.width('100%').height(56).margin(16)
.border({ width: {top: 0.5}, color: '#FFFFFF' })
.id('e_oper_row')
}
.width('100%')
.height('100%')
...
...
@@ -101,7 +102,7 @@ export struct MultiPictureDetailPageComponent {
private async getContentDetailData() {
try {
let data = await MultiPictureDetailViewModel.getDetailData(this.relId, this.contentId, this.relType)
this.contentDetailData = data;
this.contentDetailData = data
?.[0]
;
Logger.info(TAG, `contentDetailData:${JSON.stringify(this.contentDetailData)}`)
} catch (exception) {
...
...
@@ -115,12 +116,12 @@ export struct MultiPictureDetailPageComponent {
delStatus: 0,
contentList: [{
browseTime: DateTimeUtils.getCurDate(DateTimeUtils.PATTERN_DATE_TIME_HYPHEN),
contentId: this.contentDetailData?.[0].newsId + '',
contentType: this.contentDetailData?.[0].newsType || 0,
contentId: this.contentDetailData?.newsId + '',
contentType: this.contentDetailData?.newsType || 0,
}]
}
MultiPictureDetailViewModel.getInteractBrowsOperate(params).then(res => {
console.log('记录浏览历史==', JSON.stringify(res.data))
console.log(
TAG,
'记录浏览历史==', JSON.stringify(res.data))
})
} catch (exception) {
...
...
@@ -131,7 +132,7 @@ export struct MultiPictureDetailPageComponent {
private async getBatchAttentionStatus() {
try {
const params: postBatchAttentionStatusParams = {
creatorIds: [{ creatorId: this.contentDetailData?.
[0]?.
rmhInfo?.rmhId ?? '' }]
creatorIds: [{ creatorId: this.contentDetailData?.rmhInfo?.rmhId ?? '' }]
}
let data = await MultiPictureDetailViewModel.getBatchAttentionStatus(params)
this.followStatus = data[0]?.status;
...
...
sight_harmony/features/wdComponent/src/main/ets/components/view/OperRowListView.ets
View file @
bed0130
import { ToastUtils, Logger } from 'wdKit';
import { ToastUtils, Logger
, NumberFormatterUtils
} from 'wdKit';
import {
InputMethodProperty,
batchLikeAndCollectResult,
...
...
@@ -29,7 +29,7 @@ const TAG = 'OperRowListView';
@Component
export struct OperRowListView {
private contentDetailData: ContentDetailDTO = {} as ContentDetailDTO
private interactData: InteractDataDTO | undefined = undefined
@State interactData: InteractDataDTO = {} as InteractDataDTO
@State newsStatusOfUser: batchLikeAndCollectResult | undefined = undefined // 点赞、收藏状态
@State operationList: OperationItem[] = [
...
...
@@ -139,7 +139,7 @@ export struct OperRowListView {
middle: { anchor: '__container__', align: HorizontalAlign.Center }
})
.id(`e_row1_${index}`)
if(this.interactData?.likeNum) {
if(this.interactData?.likeNum
> 0
) {
Row() {
Image($r('app.media.corner_mark'))
.width(25)
...
...
@@ -184,7 +184,7 @@ export struct OperRowListView {
middle: { anchor: '__container__', align: HorizontalAlign.Center }
})
.id(`e_row1_${index}`)
if(this.interactData?.collectNum) {
if(this.interactData?.collectNum
> 0
) {
Row() {
Image($r('app.media.corner_mark'))
.width(25)
...
...
@@ -229,7 +229,7 @@ export struct OperRowListView {
middle: { anchor: '__container__', align: HorizontalAlign.Center }
})
.id(`e_row1_${index}`)
if(this.interactData?.commentNum) {
if(this.interactData?.commentNum
> 0
) {
Row() {
Image($r('app.media.corner_mark'))
.width(25)
...
...
@@ -325,12 +325,13 @@ export struct OperRowListView {
}
]
}
console.error(TAG, JSON.stringify(this.contentDetailData))
let data = await MultiPictureDetailViewModel.getInteractDataStatus(params)
console.error(TAG, JSON.stringify(data))
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))
}
}
...
...
@@ -349,7 +350,7 @@ export struct OperRowListView {
contentType: this.contentDetailData?.newsType + '',
}
PageRepository.postExecuteLike(params).then(res => {
console.log('toggleLikeStatus==',)
console.log(
TAG, '点赞、取消点赞',
'toggleLikeStatus==',)
if (this.newsStatusOfUser) {
this.newsStatusOfUser.likeStatus = this.newsStatusOfUser?.likeStatus === '1' ? '0' : '1'
this.queryContentInteractCount()
...
...
@@ -375,7 +376,7 @@ export struct OperRowListView {
}
PageRepository.postExecuteCollectRecord(params).then(res => {
console.log('toggleLikeStatus==',)
console.log(
TAG, '收藏、取消收藏',
'toggleLikeStatus==',)
if (this.newsStatusOfUser) {
this.newsStatusOfUser.collectStatus = this.newsStatusOfUser?.collectStatus === 1 ? 0 : 1
this.queryContentInteractCount()
...
...
@@ -388,6 +389,7 @@ export struct OperRowListView {
* 查询点赞、收藏数量
*/
queryContentInteractCount() {
console.error(TAG,'contentDetailData2222', JSON.stringify(this.contentDetailData))
const params: contentListParams = {
contentList: [{
contentId: this.contentDetailData?.newsId + '',
...
...
@@ -395,12 +397,13 @@ export struct OperRowListView {
}]
}
PageRepository.getContentInteract(params).then(res => {
if (res.data && this.interactData) {
this.interactData.likeNum = res.data[0]?.likeNum
this.interactData.collectNum = res.data[0]?.collectNum
this.interactData.commentNum = res.data[0]?.commentNum
if (res.data) {
this.interactData.likeNum = NumberFormatterUtils.formatNumberWithWan(res.data[0]?.likeNum)
this.interactData.collectNum = NumberFormatterUtils.formatNumberWithWan(res.data[0]?.collectNum)
this.interactData.commentNum = NumberFormatterUtils.formatNumberWithWan(res.data[0]?.commentNum)
}
console.log('获取互动点赞等数据===', JSON.stringify(res))
console.log(TAG, '获取互动点赞等数据===', JSON.stringify(res))
console.log(TAG, 'this.interactData', JSON.stringify(this.interactData))
})
}
}
\ No newline at end of file
...
...
Please
register
or
login
to post a comment