wangyong_wd

卡片右下角样式组件优化

@@ -67,6 +67,6 @@ export interface ContentDTO { @@ -67,6 +67,6 @@ export interface ContentDTO {
67 voiceInfo: VoiceInfoDTO; 67 voiceInfo: VoiceInfoDTO;
68 tagWord: number; 68 tagWord: number;
69 rmhInfo: RmhInfoDTO; // 人民号信息 69 rmhInfo: RmhInfoDTO; // 人民号信息
70 - photoNum: string; 70 + photoNum: number;
71 71
72 } 72 }
@@ -15,37 +15,31 @@ export struct CardMediaInfo { @@ -15,37 +15,31 @@ export struct CardMediaInfo {
15 15
16 build() { 16 build() {
17 Row() { 17 Row() {
18 - if(this.contentDTO.objectType === '1') {  
19 - // 显示点播 18 + if(this.contentDTO.objectType === '1' || this.contentDTO.objectType === '15' ) {
  19 + // 点播、动态视频
20 Row(){ 20 Row(){
21 Image($r('app.media.videoTypeIcon')) 21 Image($r('app.media.videoTypeIcon'))
22 - .width(22)  
23 - .height(18)  
24 - .borderRadius($r('app.float.button_border_radius')) 22 + .mediaLogo()
25 Text(DateTimeUtils.getFormattedDuration(this.contentDTO.videoInfo.videoDuration * 1000)) 23 Text(DateTimeUtils.getFormattedDuration(this.contentDTO.videoInfo.videoDuration * 1000))
26 - .fontColor($r('app.color.color_fff'))  
27 - .fontSize($r('app.float.font_size_12'))  
28 - .width(40)  
29 - .height(18)  
30 - .textAlign(TextAlign.Center)  
31 - .margin({ left: -3 }) 24 + .mediaText()
32 } 25 }
33 .backgroundColor('#4d000000') 26 .backgroundColor('#4d000000')
34 .borderRadius($r('app.float.button_border_radius')) 27 .borderRadius($r('app.float.button_border_radius'))
35 } else if(this.contentDTO.objectType === '2') { 28 } else if(this.contentDTO.objectType === '2') {
  29 + // liveInfo.liveState 直播新闻-直播状态 wait待开播running直播中end已结束cancel已取消paused暂停
36 // 显示直播信息 30 // 显示直播信息
37 Row(){ 31 Row(){
  32 + if(this.contentDTO.liveInfo.liveState === 'running') {
38 Image($r('app.media.icon_live')) 33 Image($r('app.media.icon_live'))
39 - .width(22)  
40 - .height(18)  
41 - .borderRadius($r('app.float.button_border_radius')) 34 + .mediaLogo()
42 Text('直播中') 35 Text('直播中')
43 - .fontColor($r('app.color.color_fff'))  
44 - .fontSize($r('app.float.font_size_12'))  
45 - .width(40)  
46 - .height(18)  
47 - .textAlign(TextAlign.Center)  
48 - .margin({ left: -3 }) 36 + .mediaText()
  37 + } else if(this.contentDTO.liveInfo.liveState === 'end'){
  38 + Image($r('app.media.videoTypeIcon'))
  39 + .mediaLogo()
  40 + Text('回看')
  41 + .mediaText()
  42 + }
49 } 43 }
50 .backgroundColor('#4d000000') 44 .backgroundColor('#4d000000')
51 .borderRadius($r('app.float.button_border_radius')) 45 .borderRadius($r('app.float.button_border_radius'))
@@ -53,16 +47,10 @@ export struct CardMediaInfo { @@ -53,16 +47,10 @@ export struct CardMediaInfo {
53 // 显示组图;图片数量 47 // 显示组图;图片数量
54 Row(){ 48 Row(){
55 Image($r('app.media.album_card_shape')) 49 Image($r('app.media.album_card_shape'))
56 - .width(22)  
57 - .height(18)  
58 - .borderRadius($r('app.float.button_border_radius'))  
59 - Text(this.contentDTO.photoNum)  
60 - .fontColor($r('app.color.color_fff'))  
61 - .fontSize($r('app.float.font_size_12')) 50 + .mediaLogo()
  51 + Text(`${this.contentDTO.photoNum}`)
  52 + .mediaText()
62 .width(20) 53 .width(20)
63 - .height(18)  
64 - .textAlign(TextAlign.Center)  
65 - .margin({ left: -3 })  
66 } 54 }
67 .backgroundColor('#4d000000') 55 .backgroundColor('#4d000000')
68 .borderRadius($r('app.float.button_border_radius')) 56 .borderRadius($r('app.float.button_border_radius'))
@@ -73,15 +61,25 @@ export struct CardMediaInfo { @@ -73,15 +61,25 @@ export struct CardMediaInfo {
73 .height(14) 61 .height(14)
74 .borderRadius($r('app.float.button_border_radius')) 62 .borderRadius($r('app.float.button_border_radius'))
75 Text(DateTimeUtils.getFormattedDuration(this.contentDTO.voiceInfo.voiceDuration * 1000)) 63 Text(DateTimeUtils.getFormattedDuration(this.contentDTO.voiceInfo.voiceDuration * 1000))
  64 + .mediaText()
  65 + }
  66 + }
  67 + }
  68 + .margin(6)
  69 + }
  70 +
  71 + @Styles mediaLogo() {
  72 + .width(22)
  73 + .height(18)
  74 + .borderRadius($r('app.float.button_border_radius'))
  75 + }
  76 +}
  77 +
  78 +@Extend(Text) function mediaText() {
76 .fontColor($r('app.color.color_fff')) 79 .fontColor($r('app.color.color_fff'))
77 .fontSize($r('app.float.font_size_12')) 80 .fontSize($r('app.float.font_size_12'))
78 .width(40) 81 .width(40)
79 .height(18) 82 .height(18)
80 .textAlign(TextAlign.Center) 83 .textAlign(TextAlign.Center)
81 .margin({ left: -3 }) 84 .margin({ left: -3 })
82 - }  
83 - }  
84 - }  
85 - .margin(6)  
86 - }  
87 } 85 }