Showing
4 changed files
with
31 additions
and
8 deletions
| @@ -8,11 +8,20 @@ export class NumberFormatterUtils { | @@ -8,11 +8,20 @@ export class NumberFormatterUtils { | ||
| 8 | */ | 8 | */ |
| 9 | static formatNumberWithWan(inputNumber: number | String): string { | 9 | static formatNumberWithWan(inputNumber: number | String): string { |
| 10 | const num = typeof inputNumber === 'number' ? inputNumber : Number(inputNumber); | 10 | const num = typeof inputNumber === 'number' ? inputNumber : Number(inputNumber); |
| 11 | - if (Number.isNaN(num) || num < 10000) { | 11 | + if (Number.isNaN(num)) { |
| 12 | + return ''; | ||
| 13 | + } else if (num < 10000) { | ||
| 12 | return num.toString(); | 14 | return num.toString(); |
| 13 | - } else { | 15 | + } else if (num < 100000000) { |
| 16 | + // 处理 1万到1亿之间的数字,使用万作为单位,小数点后为0则不显示 | ||
| 14 | const wanUnit = num / 10000; | 17 | const wanUnit = num / 10000; |
| 15 | - return `${wanUnit.toFixed(1)}万`; | 18 | + const formattedWan = wanUnit.toFixed(1); |
| 19 | + return formattedWan.endsWith('.0') ? `${Math.floor(wanUnit)}万` : `${formattedWan}万`; | ||
| 20 | + } else { | ||
| 21 | + // 数字达到1亿及以上时,转换为亿并处理小数点后为0的情况 | ||
| 22 | + const yiUnit = num / 100000000; | ||
| 23 | + const formattedYi = yiUnit.toFixed(1); | ||
| 24 | + return formattedYi.endsWith('.0') ? `${formattedYi.slice(0, -2)}亿` : `${formattedYi}亿`; | ||
| 16 | } | 25 | } |
| 17 | } | 26 | } |
| 18 | } | 27 | } |
| @@ -43,7 +43,7 @@ import { EmptyComponent } from './view/EmptyComponent'; | @@ -43,7 +43,7 @@ import { EmptyComponent } from './view/EmptyComponent'; | ||
| 43 | import { detailedSkeleton } from './skeleton/detailSkeleton'; | 43 | import { detailedSkeleton } from './skeleton/detailSkeleton'; |
| 44 | import { viewBlogItemInsightIntentShare } from '../utils/InsightIntentShare' | 44 | import { viewBlogItemInsightIntentShare } from '../utils/InsightIntentShare' |
| 45 | import { common } from '@kit.AbilityKit'; | 45 | import { common } from '@kit.AbilityKit'; |
| 46 | - | 46 | +import { ParamType, TrackConstants, TrackingButton, TrackingContent } from 'wdTracking/Index'; |
| 47 | const TAG = 'DynamicDetailComponent' | 47 | const TAG = 'DynamicDetailComponent' |
| 48 | const PATTERN_DATE_CN_RN: string = 'yyyy年MM月dd日 HH:mm'; | 48 | const PATTERN_DATE_CN_RN: string = 'yyyy年MM月dd日 HH:mm'; |
| 49 | 49 | ||
| @@ -81,6 +81,7 @@ export struct DynamicDetailComponent { | @@ -81,6 +81,7 @@ export struct DynamicDetailComponent { | ||
| 81 | @State likesStyle: number | string = 1 // 赞样式 1红心(点赞) 2大拇指(祈福) 3蜡烛(默哀) 4置空 | 81 | @State likesStyle: number | string = 1 // 赞样式 1红心(点赞) 2大拇指(祈福) 3蜡烛(默哀) 4置空 |
| 82 | @State openLikes: boolean = false // 是否可以点赞 1:可以 0:不可以 | 82 | @State openLikes: boolean = false // 是否可以点赞 1:可以 0:不可以 |
| 83 | 83 | ||
| 84 | + pageParam: ParamType = {} | ||
| 84 | async aboutToAppear() { | 85 | async aboutToAppear() { |
| 85 | await this.getContentDetailData() | 86 | await this.getContentDetailData() |
| 86 | // 内容用 点赞样式 1红心(点赞) 2大拇指(祈福) 3蜡烛(默哀) 4置空 | 87 | // 内容用 点赞样式 1红心(点赞) 2大拇指(祈福) 3蜡烛(默哀) 4置空 |
| @@ -540,7 +541,6 @@ export struct DynamicDetailComponent { | @@ -540,7 +541,6 @@ export struct DynamicDetailComponent { | ||
| 540 | //点赞操作 | 541 | //点赞操作 |
| 541 | this.toggleLikeStatus() | 542 | this.toggleLikeStatus() |
| 542 | //内容点赞/取消点赞埋点 | 543 | //内容点赞/取消点赞埋点 |
| 543 | - | ||
| 544 | }) | 544 | }) |
| 545 | .visibility(this.likesStyle == 4 || !this.openLikes ? Visibility.None : Visibility.Visible) | 545 | .visibility(this.likesStyle == 4 || !this.openLikes ? Visibility.None : Visibility.Visible) |
| 546 | 546 | ||
| @@ -614,6 +614,12 @@ export struct DynamicDetailComponent { | @@ -614,6 +614,12 @@ export struct DynamicDetailComponent { | ||
| 614 | this.makeJumpInfo() | 614 | this.makeJumpInfo() |
| 615 | this.interactDataV2() | 615 | this.interactDataV2() |
| 616 | this.viewBlogInsightIntentShare() | 616 | this.viewBlogInsightIntentShare() |
| 617 | + | ||
| 618 | + this.pageParam = { | ||
| 619 | + 'contentType': `${this.contentDetailData.newsType}`, | ||
| 620 | + 'contentId': `${this.contentDetailData.newsId}`, | ||
| 621 | + 'contentName': `${this.contentDetailData.newsTitle || ''}`, | ||
| 622 | + } | ||
| 617 | } | 623 | } |
| 618 | 624 | ||
| 619 | private async interactDataV2() { | 625 | private async interactDataV2() { |
| @@ -743,8 +749,10 @@ export struct DynamicDetailComponent { | @@ -743,8 +749,10 @@ export struct DynamicDetailComponent { | ||
| 743 | console.log('关注号主==', JSON.stringify(res.data)) | 749 | console.log('关注号主==', JSON.stringify(res.data)) |
| 744 | if (this.followStatus == '1') { | 750 | if (this.followStatus == '1') { |
| 745 | this.followStatus = '0' | 751 | this.followStatus = '0' |
| 752 | + TrackingContent.follow(true,this.contentDetailData.rmhInfo == null ?"":this.contentDetailData.rmhInfo.rmhId,this.contentDetailData.rmhInfo == null ?"":this.contentDetailData.rmhInfo.rmhName,TrackConstants.PageName.DynamicDetail,TrackConstants.PageName.DynamicDetail,this.pageParam) | ||
| 746 | } else { | 753 | } else { |
| 747 | this.followStatus = '1' | 754 | this.followStatus = '1' |
| 755 | + TrackingContent.follow(false,this.contentDetailData.rmhInfo == null ?"":this.contentDetailData.rmhInfo.rmhId,this.contentDetailData.rmhInfo == null ?"":this.contentDetailData.rmhInfo.rmhName,TrackConstants.PageName.DynamicDetail,TrackConstants.PageName.DynamicDetail,this.pageParam) | ||
| 748 | } | 756 | } |
| 749 | }) | 757 | }) |
| 750 | } | 758 | } |
| @@ -772,6 +780,14 @@ export struct DynamicDetailComponent { | @@ -772,6 +780,14 @@ export struct DynamicDetailComponent { | ||
| 772 | this.interactDataDTO.likeNum = Number(this.interactDataDTO.likeNum) - 1 | 780 | this.interactDataDTO.likeNum = Number(this.interactDataDTO.likeNum) - 1 |
| 773 | } | 781 | } |
| 774 | console.log('点赞、取消点赞==', this.newsStatusOfUser?.likeStatus, this.interactDataDTO?.likeNum) | 782 | console.log('点赞、取消点赞==', this.newsStatusOfUser?.likeStatus, this.interactDataDTO?.likeNum) |
| 783 | + | ||
| 784 | + //内容点赞、取消点赞Tracking 1点赞 0取消点赞 | ||
| 785 | + TrackingContent.like(this.newsStatusOfUser?.likeStatus === '1', TrackConstants.PageName.DynamicDetail, TrackConstants.PageName.DynamicDetail, | ||
| 786 | + { | ||
| 787 | + 'contentType': `${this.contentDetailData.newsType}`, | ||
| 788 | + 'contentId': `${this.contentDetailData.newsId}`, | ||
| 789 | + 'contentName': `${this.contentDetailData.newsTitle || ''}`, | ||
| 790 | + }) | ||
| 775 | }) | 791 | }) |
| 776 | } | 792 | } |
| 777 | 793 |
| @@ -212,8 +212,6 @@ export namespace TrackConstants { | @@ -212,8 +212,6 @@ export namespace TrackConstants { | ||
| 212 | Interest = "preferenceSelectionPage", | 212 | Interest = "preferenceSelectionPage", |
| 213 | //意见反馈 | 213 | //意见反馈 |
| 214 | FeedbackPage = 'feedbackPage', | 214 | FeedbackPage = 'feedbackPage', |
| 215 | - //动态详情 | ||
| 216 | - DynamicDetailPage = 'dynamicDetailPage', | ||
| 217 | //早晚报 | 215 | //早晚报 |
| 218 | NewsPaperPage = 'newsPaperPage', | 216 | NewsPaperPage = 'newsPaperPage', |
| 219 | } | 217 | } |
| @@ -37,7 +37,7 @@ struct DynamicDetailPage { | @@ -37,7 +37,7 @@ struct DynamicDetailPage { | ||
| 37 | } | 37 | } |
| 38 | onPageHide() { | 38 | onPageHide() { |
| 39 | //页面浏览 | 39 | //页面浏览 |
| 40 | - TrackingPageBrowse.trackCommonPageExposureEnd(TrackConstants.PageName.DynamicDetailPage,TrackConstants.PageName.DynamicDetailPage,Math.floor((DateTimeUtils.getTimeStamp() - this.pageShowTime)/1000)) | 40 | + TrackingPageBrowse.trackCommonPageExposureEnd(TrackConstants.PageName.DynamicDetail,TrackConstants.PageName.DynamicDetail,Math.floor((DateTimeUtils.getTimeStamp() - this.pageShowTime)/1000)) |
| 41 | 41 | ||
| 42 | } | 42 | } |
| 43 | } | 43 | } |
-
Please register or login to post a comment