Showing
5 changed files
with
61 additions
and
37 deletions
| @@ -32,4 +32,6 @@ export { SystemUtils } from './src/main/ets/utils/SystemUtils' | @@ -32,4 +32,6 @@ export { SystemUtils } from './src/main/ets/utils/SystemUtils' | ||
| 32 | 32 | ||
| 33 | export { PermissionUtil } from './src/main/ets/utils/PermissionUtil' | 33 | export { PermissionUtil } from './src/main/ets/utils/PermissionUtil' |
| 34 | 34 | ||
| 35 | -export { UserDataLocal } from './src/main/ets/utils/UserDataLocal' | ||
| 35 | +export { UserDataLocal } from './src/main/ets/utils/UserDataLocal' | ||
| 36 | + | ||
| 37 | +export { NumberFormatterUtils } from './src/main/ets/utils/NumberFormatterUtils' |
| 1 | + | ||
| 2 | +export class NumberFormatterUtils { | ||
| 3 | + | ||
| 4 | + /** | ||
| 5 | + * 数据小于一万返回原数据,大于一万保留小数点后一位,加上万字 | ||
| 6 | + * @param num | ||
| 7 | + * @returns | ||
| 8 | + */ | ||
| 9 | + static formatNumberWithWan(inputNumber: number | String): string { | ||
| 10 | + const num = typeof inputNumber === 'number' ? inputNumber : Number(inputNumber); | ||
| 11 | + if (isNaN(num) || num < 10000) { | ||
| 12 | + return num.toString(); | ||
| 13 | + } else { | ||
| 14 | + const wanUnit = num / 10000; | ||
| 15 | + return `${wanUnit.toFixed(1)}万`; | ||
| 16 | + } | ||
| 17 | + } | ||
| 18 | +} |
| @@ -2,11 +2,11 @@ | @@ -2,11 +2,11 @@ | ||
| 2 | * 批查接口查询互动相关数据,返回数据bean | 2 | * 批查接口查询互动相关数据,返回数据bean |
| 3 | */ | 3 | */ |
| 4 | export interface InteractDataDTO { | 4 | export interface InteractDataDTO { |
| 5 | - collectNum: number; | ||
| 6 | - commentNum: number; | 5 | + collectNum: number | String; |
| 6 | + commentNum: number | String; | ||
| 7 | contentId: string; | 7 | contentId: string; |
| 8 | contentType: number; | 8 | contentType: number; |
| 9 | - likeNum: number; | 9 | + likeNum: number | String; |
| 10 | readNum: number; | 10 | readNum: number; |
| 11 | shareNum: number; | 11 | shareNum: number; |
| 12 | } | 12 | } |
| @@ -19,7 +19,7 @@ export struct MultiPictureDetailPageComponent { | @@ -19,7 +19,7 @@ export struct MultiPictureDetailPageComponent { | ||
| 19 | private screenWidth: number = 0 | 19 | private screenWidth: number = 0 |
| 20 | private picWidth: number = 0 | 20 | private picWidth: number = 0 |
| 21 | @State picHeight: number = 0 | 21 | @State picHeight: number = 0 |
| 22 | - @State contentDetailData: ContentDetailDTO[] = [] as ContentDetailDTO[] | 22 | + @State contentDetailData: ContentDetailDTO = {} as ContentDetailDTO |
| 23 | @Provide @Watch('onCurrentPageNumUpdated') currentPageNum: string = '01' | 23 | @Provide @Watch('onCurrentPageNumUpdated') currentPageNum: string = '01' |
| 24 | private swiperController: SwiperController = new SwiperController() | 24 | private swiperController: SwiperController = new SwiperController() |
| 25 | @State swiperIndex: number = 0; | 25 | @State swiperIndex: number = 0; |
| @@ -58,10 +58,10 @@ export struct MultiPictureDetailPageComponent { | @@ -58,10 +58,10 @@ export struct MultiPictureDetailPageComponent { | ||
| 58 | 58 | ||
| 59 | build() { | 59 | build() { |
| 60 | RelativeContainer() { | 60 | RelativeContainer() { |
| 61 | - if (this.contentDetailData && this.contentDetailData.length > 0 && this.contentDetailData[0].photoList && this.contentDetailData[0].photoList?.length > 0) { | 61 | + if (this.contentDetailData?.photoList && this.contentDetailData?.photoList?.length > 0) { |
| 62 | Swiper(this.swiperController) { | 62 | Swiper(this.swiperController) { |
| 63 | - ForEach(this.contentDetailData[0].photoList, (item: PhotoListBean, index: number) => { | ||
| 64 | - MultiPictureDetailItemComponent({ photoListLength: this.contentDetailData[0].photoList?.length , index: index, newsTitle: this.contentDetailData[0].newsTitle, MultiPictureDetailItem: item }) | 63 | + ForEach(this.contentDetailData.photoList, (item: PhotoListBean, index: number) => { |
| 64 | + MultiPictureDetailItemComponent({ photoListLength: this.contentDetailData.photoList?.length , index: index, newsTitle: this.contentDetailData.newsTitle, MultiPictureDetailItem: item }) | ||
| 65 | }) | 65 | }) |
| 66 | } | 66 | } |
| 67 | .index(this.swiperIndex) | 67 | .index(this.swiperIndex) |
| @@ -80,17 +80,18 @@ export struct MultiPictureDetailPageComponent { | @@ -80,17 +80,18 @@ export struct MultiPictureDetailPageComponent { | ||
| 80 | .onChange((index: number) => { | 80 | .onChange((index: number) => { |
| 81 | this.swiperIndex = index | 81 | this.swiperIndex = index |
| 82 | }) | 82 | }) |
| 83 | + | ||
| 84 | + OperRowListView({ | ||
| 85 | + contentDetailData: this.contentDetailData, | ||
| 86 | + }) | ||
| 87 | + .alignRules({ | ||
| 88 | + bottom: { anchor: "__container__", align: VerticalAlign.Bottom }, | ||
| 89 | + middle: { anchor: "__container__", align: HorizontalAlign.Center } | ||
| 90 | + }) | ||
| 91 | + .width('100%').height(56).margin(16) | ||
| 92 | + .border({ width: {top: 0.5}, color: '#FFFFFF' }) | ||
| 93 | + .id('e_oper_row') | ||
| 83 | } | 94 | } |
| 84 | - OperRowListView({ | ||
| 85 | - contentDetailData: this.contentDetailData?.[0], | ||
| 86 | - }) | ||
| 87 | - .alignRules({ | ||
| 88 | - bottom: { anchor: "__container__", align: VerticalAlign.Bottom }, | ||
| 89 | - middle: { anchor: "__container__", align: HorizontalAlign.Center } | ||
| 90 | - }) | ||
| 91 | - .width('100%').height(56).margin(16) | ||
| 92 | - .border({ width: {top: 0.5}, color: '#FFFFFF' }) | ||
| 93 | - .id('e_oper_row') | ||
| 94 | } | 95 | } |
| 95 | .width('100%') | 96 | .width('100%') |
| 96 | .height('100%') | 97 | .height('100%') |
| @@ -101,7 +102,7 @@ export struct MultiPictureDetailPageComponent { | @@ -101,7 +102,7 @@ export struct MultiPictureDetailPageComponent { | ||
| 101 | private async getContentDetailData() { | 102 | private async getContentDetailData() { |
| 102 | try { | 103 | try { |
| 103 | let data = await MultiPictureDetailViewModel.getDetailData(this.relId, this.contentId, this.relType) | 104 | let data = await MultiPictureDetailViewModel.getDetailData(this.relId, this.contentId, this.relType) |
| 104 | - this.contentDetailData = data; | 105 | + this.contentDetailData = data?.[0]; |
| 105 | Logger.info(TAG, `contentDetailData:${JSON.stringify(this.contentDetailData)}`) | 106 | Logger.info(TAG, `contentDetailData:${JSON.stringify(this.contentDetailData)}`) |
| 106 | } catch (exception) { | 107 | } catch (exception) { |
| 107 | 108 | ||
| @@ -115,12 +116,12 @@ export struct MultiPictureDetailPageComponent { | @@ -115,12 +116,12 @@ export struct MultiPictureDetailPageComponent { | ||
| 115 | delStatus: 0, | 116 | delStatus: 0, |
| 116 | contentList: [{ | 117 | contentList: [{ |
| 117 | browseTime: DateTimeUtils.getCurDate(DateTimeUtils.PATTERN_DATE_TIME_HYPHEN), | 118 | browseTime: DateTimeUtils.getCurDate(DateTimeUtils.PATTERN_DATE_TIME_HYPHEN), |
| 118 | - contentId: this.contentDetailData?.[0].newsId + '', | ||
| 119 | - contentType: this.contentDetailData?.[0].newsType || 0, | 119 | + contentId: this.contentDetailData?.newsId + '', |
| 120 | + contentType: this.contentDetailData?.newsType || 0, | ||
| 120 | }] | 121 | }] |
| 121 | } | 122 | } |
| 122 | MultiPictureDetailViewModel.getInteractBrowsOperate(params).then(res => { | 123 | MultiPictureDetailViewModel.getInteractBrowsOperate(params).then(res => { |
| 123 | - console.log('记录浏览历史==', JSON.stringify(res.data)) | 124 | + console.log(TAG, '记录浏览历史==', JSON.stringify(res.data)) |
| 124 | }) | 125 | }) |
| 125 | } catch (exception) { | 126 | } catch (exception) { |
| 126 | 127 | ||
| @@ -131,7 +132,7 @@ export struct MultiPictureDetailPageComponent { | @@ -131,7 +132,7 @@ export struct MultiPictureDetailPageComponent { | ||
| 131 | private async getBatchAttentionStatus() { | 132 | private async getBatchAttentionStatus() { |
| 132 | try { | 133 | try { |
| 133 | const params: postBatchAttentionStatusParams = { | 134 | const params: postBatchAttentionStatusParams = { |
| 134 | - creatorIds: [{ creatorId: this.contentDetailData?.[0]?.rmhInfo?.rmhId ?? '' }] | 135 | + creatorIds: [{ creatorId: this.contentDetailData?.rmhInfo?.rmhId ?? '' }] |
| 135 | } | 136 | } |
| 136 | let data = await MultiPictureDetailViewModel.getBatchAttentionStatus(params) | 137 | let data = await MultiPictureDetailViewModel.getBatchAttentionStatus(params) |
| 137 | this.followStatus = data[0]?.status; | 138 | this.followStatus = data[0]?.status; |
| 1 | -import { ToastUtils, Logger } from 'wdKit'; | 1 | +import { ToastUtils, Logger, NumberFormatterUtils } from 'wdKit'; |
| 2 | import { | 2 | import { |
| 3 | InputMethodProperty, | 3 | InputMethodProperty, |
| 4 | batchLikeAndCollectResult, | 4 | batchLikeAndCollectResult, |
| @@ -29,7 +29,7 @@ const TAG = 'OperRowListView'; | @@ -29,7 +29,7 @@ const TAG = 'OperRowListView'; | ||
| 29 | @Component | 29 | @Component |
| 30 | export struct OperRowListView { | 30 | export struct OperRowListView { |
| 31 | private contentDetailData: ContentDetailDTO = {} as ContentDetailDTO | 31 | private contentDetailData: ContentDetailDTO = {} as ContentDetailDTO |
| 32 | - private interactData: InteractDataDTO | undefined = undefined | 32 | + @State interactData: InteractDataDTO = {} as InteractDataDTO |
| 33 | @State newsStatusOfUser: batchLikeAndCollectResult | undefined = undefined // 点赞、收藏状态 | 33 | @State newsStatusOfUser: batchLikeAndCollectResult | undefined = undefined // 点赞、收藏状态 |
| 34 | 34 | ||
| 35 | @State operationList: OperationItem[] = [ | 35 | @State operationList: OperationItem[] = [ |
| @@ -139,7 +139,7 @@ export struct OperRowListView { | @@ -139,7 +139,7 @@ export struct OperRowListView { | ||
| 139 | middle: { anchor: '__container__', align: HorizontalAlign.Center } | 139 | middle: { anchor: '__container__', align: HorizontalAlign.Center } |
| 140 | }) | 140 | }) |
| 141 | .id(`e_row1_${index}`) | 141 | .id(`e_row1_${index}`) |
| 142 | - if(this.interactData?.likeNum) { | 142 | + if(this.interactData?.likeNum > 0) { |
| 143 | Row() { | 143 | Row() { |
| 144 | Image($r('app.media.corner_mark')) | 144 | Image($r('app.media.corner_mark')) |
| 145 | .width(25) | 145 | .width(25) |
| @@ -184,7 +184,7 @@ export struct OperRowListView { | @@ -184,7 +184,7 @@ export struct OperRowListView { | ||
| 184 | middle: { anchor: '__container__', align: HorizontalAlign.Center } | 184 | middle: { anchor: '__container__', align: HorizontalAlign.Center } |
| 185 | }) | 185 | }) |
| 186 | .id(`e_row1_${index}`) | 186 | .id(`e_row1_${index}`) |
| 187 | - if(this.interactData?.collectNum) { | 187 | + if(this.interactData?.collectNum > 0) { |
| 188 | Row() { | 188 | Row() { |
| 189 | Image($r('app.media.corner_mark')) | 189 | Image($r('app.media.corner_mark')) |
| 190 | .width(25) | 190 | .width(25) |
| @@ -229,7 +229,7 @@ export struct OperRowListView { | @@ -229,7 +229,7 @@ export struct OperRowListView { | ||
| 229 | middle: { anchor: '__container__', align: HorizontalAlign.Center } | 229 | middle: { anchor: '__container__', align: HorizontalAlign.Center } |
| 230 | }) | 230 | }) |
| 231 | .id(`e_row1_${index}`) | 231 | .id(`e_row1_${index}`) |
| 232 | - if(this.interactData?.commentNum) { | 232 | + if(this.interactData?.commentNum > 0) { |
| 233 | Row() { | 233 | Row() { |
| 234 | Image($r('app.media.corner_mark')) | 234 | Image($r('app.media.corner_mark')) |
| 235 | .width(25) | 235 | .width(25) |
| @@ -325,12 +325,13 @@ export struct OperRowListView { | @@ -325,12 +325,13 @@ export struct OperRowListView { | ||
| 325 | } | 325 | } |
| 326 | ] | 326 | ] |
| 327 | } | 327 | } |
| 328 | + console.error(TAG, JSON.stringify(this.contentDetailData)) | ||
| 328 | let data = await MultiPictureDetailViewModel.getInteractDataStatus(params) | 329 | let data = await MultiPictureDetailViewModel.getInteractDataStatus(params) |
| 329 | - console.error(TAG, JSON.stringify(data)) | 330 | + console.error(TAG, '查询用户对作品点赞、收藏状态', JSON.stringify(data)) |
| 330 | this.newsStatusOfUser = data[0]; | 331 | this.newsStatusOfUser = data[0]; |
| 331 | Logger.info(TAG, `newsStatusOfUser:${JSON.stringify(this.newsStatusOfUser)}`) | 332 | Logger.info(TAG, `newsStatusOfUser:${JSON.stringify(this.newsStatusOfUser)}`) |
| 332 | } catch (exception) { | 333 | } catch (exception) { |
| 333 | - | 334 | + console.error(TAG, JSON.stringify(exception)) |
| 334 | } | 335 | } |
| 335 | } | 336 | } |
| 336 | 337 | ||
| @@ -349,7 +350,7 @@ export struct OperRowListView { | @@ -349,7 +350,7 @@ export struct OperRowListView { | ||
| 349 | contentType: this.contentDetailData?.newsType + '', | 350 | contentType: this.contentDetailData?.newsType + '', |
| 350 | } | 351 | } |
| 351 | PageRepository.postExecuteLike(params).then(res => { | 352 | PageRepository.postExecuteLike(params).then(res => { |
| 352 | - console.log('toggleLikeStatus==',) | 353 | + console.log(TAG, '点赞、取消点赞', 'toggleLikeStatus==',) |
| 353 | if (this.newsStatusOfUser) { | 354 | if (this.newsStatusOfUser) { |
| 354 | this.newsStatusOfUser.likeStatus = this.newsStatusOfUser?.likeStatus === '1' ? '0' : '1' | 355 | this.newsStatusOfUser.likeStatus = this.newsStatusOfUser?.likeStatus === '1' ? '0' : '1' |
| 355 | this.queryContentInteractCount() | 356 | this.queryContentInteractCount() |
| @@ -375,7 +376,7 @@ export struct OperRowListView { | @@ -375,7 +376,7 @@ export struct OperRowListView { | ||
| 375 | 376 | ||
| 376 | } | 377 | } |
| 377 | PageRepository.postExecuteCollectRecord(params).then(res => { | 378 | PageRepository.postExecuteCollectRecord(params).then(res => { |
| 378 | - console.log('toggleLikeStatus==',) | 379 | + console.log(TAG, '收藏、取消收藏','toggleLikeStatus==',) |
| 379 | if (this.newsStatusOfUser) { | 380 | if (this.newsStatusOfUser) { |
| 380 | this.newsStatusOfUser.collectStatus = this.newsStatusOfUser?.collectStatus === 1 ? 0 : 1 | 381 | this.newsStatusOfUser.collectStatus = this.newsStatusOfUser?.collectStatus === 1 ? 0 : 1 |
| 381 | this.queryContentInteractCount() | 382 | this.queryContentInteractCount() |
| @@ -388,6 +389,7 @@ export struct OperRowListView { | @@ -388,6 +389,7 @@ export struct OperRowListView { | ||
| 388 | * 查询点赞、收藏数量 | 389 | * 查询点赞、收藏数量 |
| 389 | */ | 390 | */ |
| 390 | queryContentInteractCount() { | 391 | queryContentInteractCount() { |
| 392 | + console.error(TAG,'contentDetailData2222', JSON.stringify(this.contentDetailData)) | ||
| 391 | const params: contentListParams = { | 393 | const params: contentListParams = { |
| 392 | contentList: [{ | 394 | contentList: [{ |
| 393 | contentId: this.contentDetailData?.newsId + '', | 395 | contentId: this.contentDetailData?.newsId + '', |
| @@ -395,12 +397,13 @@ export struct OperRowListView { | @@ -395,12 +397,13 @@ export struct OperRowListView { | ||
| 395 | }] | 397 | }] |
| 396 | } | 398 | } |
| 397 | PageRepository.getContentInteract(params).then(res => { | 399 | PageRepository.getContentInteract(params).then(res => { |
| 398 | - if (res.data && this.interactData) { | ||
| 399 | - this.interactData.likeNum = res.data[0]?.likeNum | ||
| 400 | - this.interactData.collectNum = res.data[0]?.collectNum | ||
| 401 | - this.interactData.commentNum = res.data[0]?.commentNum | 400 | + if (res.data) { |
| 401 | + this.interactData.likeNum = NumberFormatterUtils.formatNumberWithWan(res.data[0]?.likeNum) | ||
| 402 | + this.interactData.collectNum = NumberFormatterUtils.formatNumberWithWan(res.data[0]?.collectNum) | ||
| 403 | + this.interactData.commentNum = NumberFormatterUtils.formatNumberWithWan(res.data[0]?.commentNum) | ||
| 402 | } | 404 | } |
| 403 | - console.log('获取互动点赞等数据===', JSON.stringify(res)) | 405 | + console.log(TAG, '获取互动点赞等数据===', JSON.stringify(res)) |
| 406 | + console.log(TAG, 'this.interactData', JSON.stringify(this.interactData)) | ||
| 404 | }) | 407 | }) |
| 405 | } | 408 | } |
| 406 | } | 409 | } |
-
Please register or login to post a comment