陈剑华

feat: 16910 功能缺陷--回看类型的稿件鸿蒙版缺少**人参与与安卓不一致

1 -import { ContentDTO } from 'wdBean/Index' 1 +import { ContentDTO, joinPeopleNum } from 'wdBean/Index'
2 import { DateTimeUtils } from 'wdKit/Index' 2 import { DateTimeUtils } from 'wdKit/Index'
  3 +import { LiveModel } from '../../viewmodel/LiveModel'
3 4
4 /** 5 /**
5 * 这里是样式卡中,右下角显示的音视频信息 6 * 这里是样式卡中,右下角显示的音视频信息
@@ -10,10 +11,50 @@ import { DateTimeUtils } from 'wdKit/Index' @@ -10,10 +11,50 @@ import { DateTimeUtils } from 'wdKit/Index'
10 @Component 11 @Component
11 export struct CardMediaInfo { 12 export struct CardMediaInfo {
12 @State contentDTO: ContentDTO = new ContentDTO() // 如果有duraion,代表点播,显示时长;如果不传或者传0,显示直播中 13 @State contentDTO: ContentDTO = new ContentDTO() // 如果有duraion,代表点播,显示时长;如果不传或者传0,显示直播中
13 - 14 + @State joinPeopleNum: number = 0;
14 // objectType 0:不跳转 1:点播,2:直播,3:活动,4:广告,5:专题,6:链接,7:榜单,8:图文,9:组图,10:H5新闻,11:频道,12:组件,13:音频, 15 // objectType 0:不跳转 1:点播,2:直播,3:活动,4:广告,5:专题,6:链接,7:榜单,8:图文,9:组图,10:H5新闻,11:频道,12:组件,13:音频,
15 // 14动态图文,15动态视频16问政;100人民号,101标签 16 // 14动态图文,15动态视频16问政;100人民号,101标签
16 17
  18 + aboutToAppear(): void {
  19 + this.getJoinPeopleNum();
  20 + }
  21 +
  22 + /**
  23 + * 全域数字显示规则
  24 + * 1、当数量为千位以內时,显示数字,不保留小数点,比如 4585
  25 + * 2、当数量为万位~1亿时,显示xx 万,保留小数点后一位,比如1517.9w、2.9w
  26 + * 3、当数量为1亿~千亿时,显示XX 亿,保留小数点后一位,比如1517.9亿、2.9亿
  27 + * 4、不进行四舍五入
  28 + * 5、0 和空 不显示
  29 + */
  30 + handlerNum(number: string) {
  31 + const num = number??'0';
  32 + if (Number.parseInt(num) <= 9999) {
  33 + return Number.parseInt(num).toString()
  34 + } else if (Number.parseInt(num) > 9999 && Number.parseInt(num) <= 99999999) {
  35 + const num1: string = num.slice(0, -4); // 万
  36 + const num2: string = num.slice(-4, -3); // 千
  37 + return num2 === '0' ? num1 +'万' : num1 + '.' + num2 + '万'
  38 + } else if (Number.parseInt(num) > 99999999) {
  39 + const num1: string = num.slice(0, -8); // 亿
  40 + const num2: string = num.slice(-8, -7);
  41 + return num2 === '0' ? num1 +'亿' : num1 + '.' + num2 + '亿'
  42 + }
  43 + return num
  44 + }
  45 +
  46 + //
  47 + /**
  48 + * 获取直播节目参与人数
  49 + */
  50 + async getJoinPeopleNum() {
  51 + if (this.contentDTO.objectType !== '2') return;
  52 + console.log('getJoinPeopleNum-ContentDTO', JSON.stringify(this.contentDTO.objectId))
  53 + let liveIdList: string = this.contentDTO.objectId
  54 + let data: joinPeopleNum[] = await LiveModel.getJoinPeopleNum(liveIdList)
  55 + this.joinPeopleNum = data[0].pv;
  56 + }
  57 +
17 build() { 58 build() {
18 Row() { 59 Row() {
19 if (this.contentDTO?.objectType === '1' || this.contentDTO?.objectType === '15') { 60 if (this.contentDTO?.objectType === '1' || this.contentDTO?.objectType === '15') {
@@ -24,6 +65,7 @@ export struct CardMediaInfo { @@ -24,6 +65,7 @@ export struct CardMediaInfo {
24 if (this.contentDTO.videoInfo != null) { 65 if (this.contentDTO.videoInfo != null) {
25 Text(DateTimeUtils.getFormattedDuration(this.contentDTO.videoInfo.videoDuration * 1000)) 66 Text(DateTimeUtils.getFormattedDuration(this.contentDTO.videoInfo.videoDuration * 1000))
26 .mediaText() 67 .mediaText()
  68 + .fontFamily('BebasNeueBold')
27 } 69 }
28 } 70 }
29 } else if (this.contentDTO.objectType === '2') { 71 } else if (this.contentDTO.objectType === '2') {
@@ -50,6 +92,10 @@ export struct CardMediaInfo { @@ -50,6 +92,10 @@ export struct CardMediaInfo {
50 Text('已结束') 92 Text('已结束')
51 .mediaText() 93 .mediaText()
52 } 94 }
  95 + Text(' | ')
  96 + .mediaText()
  97 + Text(`${this.handlerNum(this.joinPeopleNum.toString())}人参加`)
  98 + .mediaText()
53 // } else if (this.contentDTO?.liveInfo?.liveState === 'end' && this.contentDTO?.liveInfo 99 // } else if (this.contentDTO?.liveInfo?.liveState === 'end' && this.contentDTO?.liveInfo
54 // ?.replayUri) { 100 // ?.replayUri) {
55 // // Image($r('app.media.card_live')) 101 // // Image($r('app.media.card_live'))
@@ -73,6 +119,7 @@ export struct CardMediaInfo { @@ -73,6 +119,7 @@ export struct CardMediaInfo {
73 .mediaLogo() 119 .mediaLogo()
74 Text(DateTimeUtils.getFormattedDuration(this.contentDTO.voiceInfo.voiceDuration * 1000)) 120 Text(DateTimeUtils.getFormattedDuration(this.contentDTO.voiceInfo.voiceDuration * 1000))
75 .mediaText() 121 .mediaText()
  122 + .fontFamily('BebasNeueBold')
76 } 123 }
77 } else if (this.contentDTO.objectType === '4') {//广告标签 124 } else if (this.contentDTO.objectType === '4') {//广告标签
78 Text($r('app.string.comp_advertisement')) 125 Text($r('app.string.comp_advertisement'))