Showing
10 changed files
with
286 additions
and
110 deletions
| @@ -61,6 +61,7 @@ export class ContentDTO implements BaseDTO { | @@ -61,6 +61,7 @@ export class ContentDTO implements BaseDTO { | ||
| 61 | videoInfo: VideoInfoDTO = {} as VideoInfoDTO; // 视频新闻信息【BFF聚合】,视频非原片+清晰度最高的 | 61 | videoInfo: VideoInfoDTO = {} as VideoInfoDTO; // 视频新闻信息【BFF聚合】,视频非原片+清晰度最高的 |
| 62 | 62 | ||
| 63 | newsSummary: string = ''; //appstyle:2 ,新闻详情 | 63 | newsSummary: string = ''; //appstyle:2 ,新闻详情 |
| 64 | + contentText?: string =''; | ||
| 64 | 65 | ||
| 65 | // 二次请求接口,返回的数据,这里组装到content里; | 66 | // 二次请求接口,返回的数据,这里组装到content里; |
| 66 | interactData?: InteractDataDTO; | 67 | interactData?: InteractDataDTO; |
| @@ -16,6 +16,7 @@ import { Card17Component } from './cardview/Card17Component'; | @@ -16,6 +16,7 @@ import { Card17Component } from './cardview/Card17Component'; | ||
| 16 | import { Card19Component } from './cardview/Card19Component'; | 16 | import { Card19Component } from './cardview/Card19Component'; |
| 17 | import { Card20Component } from './cardview/Card20Component'; | 17 | import { Card20Component } from './cardview/Card20Component'; |
| 18 | import { Card21Component } from './cardview/Card21Component'; | 18 | import { Card21Component } from './cardview/Card21Component'; |
| 19 | +import { SearchContentComponent } from './cardview/SearchContentComponent'; | ||
| 19 | 20 | ||
| 20 | /** | 21 | /** |
| 21 | * card适配器,卡片样式汇总,依据ContentDTO#appStyle | 22 | * card适配器,卡片样式汇总,依据ContentDTO#appStyle |
| @@ -32,45 +33,50 @@ export struct CardParser { | @@ -32,45 +33,50 @@ export struct CardParser { | ||
| 32 | 33 | ||
| 33 | @Builder | 34 | @Builder |
| 34 | contentBuilder(contentDTO: ContentDTO, compDTO: CompDTO) { | 35 | contentBuilder(contentDTO: ContentDTO, compDTO: CompDTO) { |
| 35 | - if (contentDTO.appStyle === CompStyle.Card_02) { | ||
| 36 | - Card2Component({ contentDTO }) | ||
| 37 | - } else if (contentDTO.appStyle === CompStyle.Card_03) { | ||
| 38 | - Card3Component({ contentDTO }) | ||
| 39 | - } else if (contentDTO.appStyle === CompStyle.Card_04) { | ||
| 40 | - Card4Component({ contentDTO }) | ||
| 41 | - } else if (contentDTO.appStyle === CompStyle.Card_05) { | ||
| 42 | - Card5Component({ contentDTO, titleShowPolicy: compDTO.titleShowPolicy }) | ||
| 43 | - } else if (contentDTO.appStyle === CompStyle.Card_06 || contentDTO.appStyle === CompStyle | ||
| 44 | - .Card_13) { | ||
| 45 | - Card6Component({ contentDTO }) | ||
| 46 | - } else if (contentDTO.appStyle === CompStyle.Card_09) { | ||
| 47 | - Card9Component({ contentDTO }) | ||
| 48 | - } else if (contentDTO.appStyle === CompStyle.Card_10) { | ||
| 49 | - Card10Component({ contentDTO }) | ||
| 50 | - } else if (contentDTO.appStyle === CompStyle.Card_11) { | ||
| 51 | - Card11Component({ contentDTO }) | ||
| 52 | - } else if (contentDTO.appStyle === CompStyle.Card_12) { | ||
| 53 | - Card12Component({ contentDTO }) | ||
| 54 | - } else if (contentDTO.appStyle === CompStyle.Card_14) { | ||
| 55 | - Card14Component({ contentDTO }) | ||
| 56 | - } else if (contentDTO.appStyle === CompStyle.Card_15) { | ||
| 57 | - Card15Component({ contentDTO }) | ||
| 58 | - } else if (contentDTO.appStyle === CompStyle.Card_16) { | ||
| 59 | - Card16Component({ contentDTO }) | ||
| 60 | - } else if (contentDTO.appStyle === CompStyle.Card_17) { | ||
| 61 | - Card17Component({ contentDTO }) | ||
| 62 | - } else if (contentDTO.appStyle === CompStyle.Card_19) { | ||
| 63 | - Card19Component({ contentDTO }) | ||
| 64 | - } else if (contentDTO.appStyle === CompStyle.Card_20) { | ||
| 65 | - Card20Component({ contentDTO }) | ||
| 66 | - } else if (contentDTO.appStyle === CompStyle.Card_21) { | ||
| 67 | - Card21Component({ contentDTO }) | 36 | + if (!!contentDTO.contentText) { |
| 37 | + SearchContentComponent({ contentDTO }) | ||
| 68 | } else { | 38 | } else { |
| 69 | - // todo:组件未实现 / Component Not Implemented | ||
| 70 | - // Text(contentDTO.appStyle) | ||
| 71 | - // .width(CommonConstants.FULL_PARENT) | ||
| 72 | - // .padding(10) | ||
| 73 | - // .backgroundColor(Color.Brown) // 展示本页未实现的compStyle | 39 | + if (contentDTO.appStyle === CompStyle.Card_02) { |
| 40 | + Card2Component({ contentDTO }) | ||
| 41 | + } else if (contentDTO.appStyle === CompStyle.Card_03) { | ||
| 42 | + Card3Component({ contentDTO }) | ||
| 43 | + } else if (contentDTO.appStyle === CompStyle.Card_04) { | ||
| 44 | + Card4Component({ contentDTO }) | ||
| 45 | + } else if (contentDTO.appStyle === CompStyle.Card_05) { | ||
| 46 | + Card5Component({ contentDTO, titleShowPolicy: compDTO.titleShowPolicy }) | ||
| 47 | + } else if (contentDTO.appStyle === CompStyle.Card_06 || contentDTO.appStyle === CompStyle | ||
| 48 | + .Card_13) { | ||
| 49 | + Card6Component({ contentDTO }) | ||
| 50 | + } else if (contentDTO.appStyle === CompStyle.Card_09) { | ||
| 51 | + Card9Component({ contentDTO }) | ||
| 52 | + } else if (contentDTO.appStyle === CompStyle.Card_10) { | ||
| 53 | + Card10Component({ contentDTO }) | ||
| 54 | + } else if (contentDTO.appStyle === CompStyle.Card_11) { | ||
| 55 | + Card11Component({ contentDTO }) | ||
| 56 | + } else if (contentDTO.appStyle === CompStyle.Card_12) { | ||
| 57 | + Card12Component({ contentDTO }) | ||
| 58 | + } else if (contentDTO.appStyle === CompStyle.Card_14) { | ||
| 59 | + Card14Component({ contentDTO }) | ||
| 60 | + } else if (contentDTO.appStyle === CompStyle.Card_15) { | ||
| 61 | + Card15Component({ contentDTO }) | ||
| 62 | + } else if (contentDTO.appStyle === CompStyle.Card_16) { | ||
| 63 | + Card16Component({ contentDTO }) | ||
| 64 | + } else if (contentDTO.appStyle === CompStyle.Card_17) { | ||
| 65 | + Card17Component({ contentDTO }) | ||
| 66 | + } else if (contentDTO.appStyle === CompStyle.Card_19) { | ||
| 67 | + Card19Component({ contentDTO }) | ||
| 68 | + } else if (contentDTO.appStyle === CompStyle.Card_20) { | ||
| 69 | + Card20Component({ contentDTO }) | ||
| 70 | + } else if (contentDTO.appStyle === CompStyle.Card_21) { | ||
| 71 | + Card21Component({ contentDTO }) | ||
| 72 | + } else { | ||
| 73 | + // todo:组件未实现 / Component Not Implemented | ||
| 74 | + // Text(contentDTO.appStyle) | ||
| 75 | + // .width(CommonConstants.FULL_PARENT) | ||
| 76 | + // .padding(10) | ||
| 77 | + // .backgroundColor(Color.Brown) // 展示本页未实现的compStyle | ||
| 78 | + } | ||
| 74 | } | 79 | } |
| 80 | + | ||
| 75 | } | 81 | } |
| 76 | } | 82 | } |
| @@ -96,10 +96,10 @@ export struct RmhTitle { | @@ -96,10 +96,10 @@ export struct RmhTitle { | ||
| 96 | build() { | 96 | build() { |
| 97 | Flex() { | 97 | Flex() { |
| 98 | Stack() { | 98 | Stack() { |
| 99 | - Image(this.rmhInfo.rmhHeadUrl) | 99 | + Image(this.rmhInfo?.rmhHeadUrl) |
| 100 | .width(36) | 100 | .width(36) |
| 101 | .height(36).borderRadius(50) | 101 | .height(36).borderRadius(50) |
| 102 | - Image(this.rmhInfo.authIcon) | 102 | + Image(this.rmhInfo?.authIcon) |
| 103 | .width(14) | 103 | .width(14) |
| 104 | .height(14) | 104 | .height(14) |
| 105 | .borderRadius(50) | 105 | .borderRadius(50) |
| @@ -109,7 +109,7 @@ export struct RmhTitle { | @@ -109,7 +109,7 @@ export struct RmhTitle { | ||
| 109 | .flexShrink(0) | 109 | .flexShrink(0) |
| 110 | 110 | ||
| 111 | Column() { | 111 | Column() { |
| 112 | - Text(this.rmhInfo.rmhName) | 112 | + Text(this.rmhInfo?.rmhName) |
| 113 | .fontSize($r('app.float.font_size_13')) | 113 | .fontSize($r('app.float.font_size_13')) |
| 114 | .fontColor($r('app.color.color_222222')) | 114 | .fontColor($r('app.color.color_222222')) |
| 115 | .fontWeight(600) | 115 | .fontWeight(600) |
| @@ -122,13 +122,13 @@ export struct RmhTitle { | @@ -122,13 +122,13 @@ export struct RmhTitle { | ||
| 122 | .fontSize($r("app.float.font_size_12")) | 122 | .fontSize($r("app.float.font_size_12")) |
| 123 | .fontColor($r("app.color.color_B0B0B0")) | 123 | .fontColor($r("app.color.color_B0B0B0")) |
| 124 | } | 124 | } |
| 125 | - if (this.publishTime && this.rmhInfo.rmhDesc) { | 125 | + if (this.publishTime && this.rmhInfo?.rmhDesc) { |
| 126 | Image($r('app.media.point')) | 126 | Image($r('app.media.point')) |
| 127 | .width(16) | 127 | .width(16) |
| 128 | .height(16) | 128 | .height(16) |
| 129 | } | 129 | } |
| 130 | } | 130 | } |
| 131 | - Text(this.rmhInfo.rmhDesc) | 131 | + Text(this.rmhInfo?.rmhDesc) |
| 132 | .fontSize($r("app.float.font_size_12")) | 132 | .fontSize($r("app.float.font_size_12")) |
| 133 | .fontColor($r("app.color.color_B0B0B0")) | 133 | .fontColor($r("app.color.color_B0B0B0")) |
| 134 | .maxLines(1) | 134 | .maxLines(1) |
| @@ -141,7 +141,7 @@ export struct RmhTitle { | @@ -141,7 +141,7 @@ export struct RmhTitle { | ||
| 141 | } | 141 | } |
| 142 | 142 | ||
| 143 | Blank() | 143 | Blank() |
| 144 | - if (this.rmhInfo.cnIsAttention) { | 144 | + if (this.rmhInfo?.cnIsAttention) { |
| 145 | Row() { | 145 | Row() { |
| 146 | if (Number(this.followStatus) === 0) { | 146 | if (Number(this.followStatus) === 0) { |
| 147 | Image($r('app.media.rmh_follow')) | 147 | Image($r('app.media.rmh_follow')) |
| @@ -40,7 +40,7 @@ export struct Card17Component { | @@ -40,7 +40,7 @@ export struct Card17Component { | ||
| 40 | this.contentDTO.fullColumnImgUrls.length > 0 ? this.contentDTO.fullColumnImgUrls[0].url : '' : '') | 40 | this.contentDTO.fullColumnImgUrls.length > 0 ? this.contentDTO.fullColumnImgUrls[0].url : '' : '') |
| 41 | .backgroundColor(this.loadImg ? '#f5f5f5' : 0xf5f5f5) | 41 | .backgroundColor(this.loadImg ? '#f5f5f5' : 0xf5f5f5) |
| 42 | .width(CommonConstants.FULL_WIDTH) | 42 | .width(CommonConstants.FULL_WIDTH) |
| 43 | - .aspectRatio(16 / 9) | 43 | + .height(160)// .aspectRatio(CompUtils.ASPECT_RATIO_16_9) |
| 44 | .borderRadius({ | 44 | .borderRadius({ |
| 45 | topLeft: $r('app.float.image_border_radius'), | 45 | topLeft: $r('app.float.image_border_radius'), |
| 46 | bottomLeft: $r('app.float.image_border_radius'), | 46 | bottomLeft: $r('app.float.image_border_radius'), |
| @@ -52,7 +52,7 @@ export struct Card17Component { | @@ -52,7 +52,7 @@ export struct Card17Component { | ||
| 52 | this.contentDTO.fullColumnImgUrls.length > 1 ? this.contentDTO.fullColumnImgUrls[1].url : '' : '') | 52 | this.contentDTO.fullColumnImgUrls.length > 1 ? this.contentDTO.fullColumnImgUrls[1].url : '' : '') |
| 53 | .backgroundColor(this.loadImg ? '#f5f5f5' : 0xf5f5f5) | 53 | .backgroundColor(this.loadImg ? '#f5f5f5' : 0xf5f5f5) |
| 54 | .width(CommonConstants.FULL_WIDTH) | 54 | .width(CommonConstants.FULL_WIDTH) |
| 55 | - .aspectRatio(16 / 9) | 55 | + .height(79)// .aspectRatio(CompUtils.ASPECT_RATIO_16_9) |
| 56 | .margin({ bottom: 1 }) | 56 | .margin({ bottom: 1 }) |
| 57 | .borderRadius({ | 57 | .borderRadius({ |
| 58 | topRight: $r('app.float.image_border_radius'), | 58 | topRight: $r('app.float.image_border_radius'), |
| @@ -69,7 +69,7 @@ export struct Card17Component { | @@ -69,7 +69,7 @@ export struct Card17Component { | ||
| 69 | this.contentDTO.fullColumnImgUrls.length > 2 ? this.contentDTO.fullColumnImgUrls[2].url : '' : '') | 69 | this.contentDTO.fullColumnImgUrls.length > 2 ? this.contentDTO.fullColumnImgUrls[2].url : '' : '') |
| 70 | .backgroundColor(this.loadImg ? '#f5f5f5' : 0xf5f5f5) | 70 | .backgroundColor(this.loadImg ? '#f5f5f5' : 0xf5f5f5) |
| 71 | .width(CommonConstants.FULL_WIDTH) | 71 | .width(CommonConstants.FULL_WIDTH) |
| 72 | - .aspectRatio(16 / 9) | 72 | + .height(79)// .aspectRatio(CompUtils.ASPECT_RATIO_16_9) |
| 73 | .margin({ top: 1 }) | 73 | .margin({ top: 1 }) |
| 74 | .borderRadius({ | 74 | .borderRadius({ |
| 75 | bottomRight: $r('app.float.image_border_radius'), | 75 | bottomRight: $r('app.float.image_border_radius'), |
| @@ -107,4 +107,12 @@ export struct Card17Component { | @@ -107,4 +107,12 @@ export struct Card17Component { | ||
| 107 | bottom: $r('app.float.card_comp_pagePadding_tb') | 107 | bottom: $r('app.float.card_comp_pagePadding_tb') |
| 108 | }) | 108 | }) |
| 109 | } | 109 | } |
| 110 | +} | ||
| 111 | + | ||
| 112 | +// 全局公共样式 | ||
| 113 | +@Styles | ||
| 114 | +function ImageSize() { | ||
| 115 | + .padding({ right: 18, left: 18 }) | ||
| 116 | + .width('100%') | ||
| 117 | + .margin({ top: 10 }) | ||
| 110 | } | 118 | } |
| @@ -22,10 +22,24 @@ export struct Card2Component { | @@ -22,10 +22,24 @@ export struct Card2Component { | ||
| 22 | @State contentDTO: ContentDTO = new ContentDTO(); | 22 | @State contentDTO: ContentDTO = new ContentDTO(); |
| 23 | @State loadImg: boolean = false; | 23 | @State loadImg: boolean = false; |
| 24 | @State clicked: boolean = false; | 24 | @State clicked: boolean = false; |
| 25 | + @State titleMarked: boolean = false; | ||
| 26 | + @State str01: string = ''; | ||
| 27 | + @State str02: string = ''; | ||
| 28 | + @State str03: string = ''; | ||
| 25 | 29 | ||
| 26 | async aboutToAppear(): Promise<void> { | 30 | async aboutToAppear(): Promise<void> { |
| 27 | this.loadImg = await onlyWifiLoadImg(); | 31 | this.loadImg = await onlyWifiLoadImg(); |
| 28 | // this.clicked = hasClicked(this.contentDTO.objectId) | 32 | // this.clicked = hasClicked(this.contentDTO.objectId) |
| 33 | + this.titleInit(); | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + titleInit() { | ||
| 37 | + if (this.contentDTO.title.includes('<em>') && this.contentDTO.title.includes('</em>')) { | ||
| 38 | + this.titleMarked = true; | ||
| 39 | + this.str01 = this.contentDTO.newsTitle?.split('<em>')[0] || ''; | ||
| 40 | + this.str02 = this.contentDTO.newsTitle?.split('<em>')[1].split('</em>')[0] || ''; | ||
| 41 | + this.str03 = this.contentDTO.newsTitle?.split('<em>')[1].split('</em>')[1] || ''; | ||
| 42 | + } | ||
| 29 | } | 43 | } |
| 30 | 44 | ||
| 31 | build() { | 45 | build() { |
| @@ -36,13 +50,23 @@ export struct Card2Component { | @@ -36,13 +50,23 @@ export struct Card2Component { | ||
| 36 | if (this.contentDTO.objectType == '5') { | 50 | if (this.contentDTO.objectType == '5') { |
| 37 | Notes({ objectType: this.contentDTO.objectType }) | 51 | Notes({ objectType: this.contentDTO.objectType }) |
| 38 | } | 52 | } |
| 39 | - Text(this.contentDTO.newsTitle) | ||
| 40 | - .fontSize($r('app.float.font_size_17')) | ||
| 41 | - .fontColor(this.clicked ? 0x848484 : $r('app.color.color_222222')) | ||
| 42 | - .maxLines(2) | ||
| 43 | - .textOverflow({ overflow: TextOverflow.Ellipsis })// 超出的部分显示省略号。 | ||
| 44 | - .align(Alignment.Start) | ||
| 45 | - .textIndent(this.contentDTO.objectType == '5' ? 35 : 0) | 53 | + |
| 54 | + Text() { | ||
| 55 | + if (this.titleMarked) { | ||
| 56 | + Span(this.str01) | ||
| 57 | + Span(this.str02) | ||
| 58 | + .fontColor(0xED2800) | ||
| 59 | + Span(this.str03) | ||
| 60 | + } else { | ||
| 61 | + Span(this.contentDTO.newsTitle) | ||
| 62 | + } | ||
| 63 | + } | ||
| 64 | + .fontSize($r('app.float.font_size_17')) | ||
| 65 | + .fontColor(this.clicked ? 0x848484 : $r('app.color.color_222222')) | ||
| 66 | + .maxLines(2) | ||
| 67 | + .textOverflow({ overflow: TextOverflow.Ellipsis })// 超出的部分显示省略号。 | ||
| 68 | + .align(Alignment.Start) | ||
| 69 | + .textIndent(this.contentDTO.objectType == '5' ? 35 : 0) | ||
| 46 | } | 70 | } |
| 47 | .alignContent(Alignment.TopStart) | 71 | .alignContent(Alignment.TopStart) |
| 48 | 72 |
| @@ -18,10 +18,24 @@ export struct Card4Component { | @@ -18,10 +18,24 @@ export struct Card4Component { | ||
| 18 | @State contentDTO: ContentDTO = new ContentDTO(); | 18 | @State contentDTO: ContentDTO = new ContentDTO(); |
| 19 | @State loadImg: boolean = false; | 19 | @State loadImg: boolean = false; |
| 20 | @State clicked: boolean = false; | 20 | @State clicked: boolean = false; |
| 21 | + @State titleMarked: boolean = false; | ||
| 22 | + @State str01: string = ''; | ||
| 23 | + @State str02: string = ''; | ||
| 24 | + @State str03: string = ''; | ||
| 21 | 25 | ||
| 22 | 26 | ||
| 23 | async aboutToAppear(): Promise<void> { | 27 | async aboutToAppear(): Promise<void> { |
| 24 | this.loadImg = await onlyWifiLoadImg(); | 28 | this.loadImg = await onlyWifiLoadImg(); |
| 29 | + this.titleInit(); | ||
| 30 | + } | ||
| 31 | + | ||
| 32 | + titleInit() { | ||
| 33 | + if (this.contentDTO.title.includes('<em>') && this.contentDTO.title.includes('</em>')) { | ||
| 34 | + this.titleMarked = true; | ||
| 35 | + this.str01 = this.contentDTO.newsTitle?.split('<em>')[0] || ''; | ||
| 36 | + this.str02 = this.contentDTO.newsTitle?.split('<em>')[1].split('</em>')[0] || ''; | ||
| 37 | + this.str03 = this.contentDTO.newsTitle?.split('<em>')[1].split('</em>')[1] || ''; | ||
| 38 | + } | ||
| 25 | } | 39 | } |
| 26 | 40 | ||
| 27 | build() { | 41 | build() { |
| @@ -29,7 +43,16 @@ export struct Card4Component { | @@ -29,7 +43,16 @@ export struct Card4Component { | ||
| 29 | //body | 43 | //body |
| 30 | Column() { | 44 | Column() { |
| 31 | //新闻标题 | 45 | //新闻标题 |
| 32 | - Text(this.contentDTO.newsTitle) | 46 | + Text() { |
| 47 | + if (this.titleMarked) { | ||
| 48 | + Span(this.str01) | ||
| 49 | + Span(this.str02) | ||
| 50 | + .fontColor(0xED2800) | ||
| 51 | + Span(this.str03) | ||
| 52 | + } else { | ||
| 53 | + Span(this.contentDTO.newsTitle) | ||
| 54 | + } | ||
| 55 | + } | ||
| 33 | .fontSize($r('app.float.font_size_17')) | 56 | .fontSize($r('app.float.font_size_17')) |
| 34 | .fontColor(this.clicked ? 0x848484 : $r('app.color.color_222222')) | 57 | .fontColor(this.clicked ? 0x848484 : $r('app.color.color_222222')) |
| 35 | .maxLines(3) | 58 | .maxLines(3) |
sight_harmony/features/wdComponent/src/main/ets/components/cardview/SearchContentComponent.ets
0 → 100644
| 1 | +import { ContentDTO, FullColumnImgUrlDTO } from 'wdBean'; | ||
| 2 | +import { CommonConstants } from 'wdConstant/Index'; | ||
| 3 | +import { ProcessUtils } from 'wdRouter'; | ||
| 4 | +import { CardSourceInfo } from '../cardCommon/CardSourceInfo' | ||
| 5 | +import { CardMediaInfo } from '../cardCommon/CardMediaInfo' | ||
| 6 | +import { onlyWifiLoadImg } from '../../utils/lazyloadImg'; | ||
| 7 | +const TAG: string = 'Card4Component'; | ||
| 8 | + | ||
| 9 | +/** | ||
| 10 | + * 上图下文,用于搜索页命中搜索内容展示 | ||
| 11 | + */ | ||
| 12 | +@Component | ||
| 13 | +export struct SearchContentComponent { | ||
| 14 | + @State contentDTO: ContentDTO = new ContentDTO(); | ||
| 15 | + @State loadImg: boolean = false; | ||
| 16 | + @State clicked: boolean = false; | ||
| 17 | + @State str01: string = ''; | ||
| 18 | + @State str02: string = ''; | ||
| 19 | + @State str03: string = ''; | ||
| 20 | + | ||
| 21 | + | ||
| 22 | + async aboutToAppear(): Promise<void> { | ||
| 23 | + this.loadImg = await onlyWifiLoadImg(); | ||
| 24 | + this.titleInit(); | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + titleInit() { | ||
| 28 | + this.str01 = this.contentDTO.contentText?.split('<em>')[0] || ''; | ||
| 29 | + this.str02 = this.contentDTO.contentText?.split('<em>')[1].split('</em>')[0] || ''; | ||
| 30 | + this.str03 = this.contentDTO.contentText?.split('<em>')[1].split('</em>')[1] || ''; | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + build() { | ||
| 34 | + Column() { | ||
| 35 | + //body | ||
| 36 | + Column() { | ||
| 37 | + //新闻标题 | ||
| 38 | + Text(this.contentDTO.newsTitle) | ||
| 39 | + .fontSize($r('app.float.font_size_17')) | ||
| 40 | + .fontColor(this.clicked ? 0x848484 : $r('app.color.color_222222')) | ||
| 41 | + .maxLines(3) | ||
| 42 | + .textOverflow({ overflow: TextOverflow.Ellipsis }) // 超出的部分显示省略号。 | ||
| 43 | + | ||
| 44 | + // 命中内容 | ||
| 45 | + Text(this.contentDTO.contentText) { | ||
| 46 | + Span(this.str01) | ||
| 47 | + Span(this.str02) | ||
| 48 | + .fontColor(0xED2800) | ||
| 49 | + Span(this.str03) | ||
| 50 | + } | ||
| 51 | + .fontSize(13) | ||
| 52 | + .width(CommonConstants.FULL_PARENT) | ||
| 53 | + .margin({ top: 8 }) | ||
| 54 | + .fontColor(0x222222) | ||
| 55 | + } | ||
| 56 | + .width('100%') | ||
| 57 | + .justifyContent(FlexAlign.Start) | ||
| 58 | + .alignItems(HorizontalAlign.Start) | ||
| 59 | + .onClick((event: ClickEvent) => { | ||
| 60 | + this.clicked = true; | ||
| 61 | + ProcessUtils.processPage(this.contentDTO) | ||
| 62 | + }) | ||
| 63 | + //bottom 评论等信息 | ||
| 64 | + CardSourceInfo({ contentDTO: this.contentDTO }) | ||
| 65 | + } | ||
| 66 | + .width(CommonConstants.FULL_WIDTH) | ||
| 67 | + .padding({ | ||
| 68 | + left: $r('app.float.card_comp_pagePadding_lf'), | ||
| 69 | + right: $r('app.float.card_comp_pagePadding_lf'), | ||
| 70 | + top: $r('app.float.card_comp_pagePadding_tb'), | ||
| 71 | + bottom: $r('app.float.card_comp_pagePadding_tb') | ||
| 72 | + }) | ||
| 73 | + } | ||
| 74 | +} | ||
| 75 | + | ||
| 76 | + | ||
| 77 | +@Extend(Text) | ||
| 78 | +function bottomTextStyle() { | ||
| 79 | + .fontSize(12) | ||
| 80 | + .fontColor('#B0B0B0') | ||
| 81 | +} |
| 1 | import { CompDTO, ContentDTO, LiveRoomDataBean } from 'wdBean'; | 1 | import { CompDTO, ContentDTO, LiveRoomDataBean } from 'wdBean'; |
| 2 | import { CommonConstants } from 'wdConstant/Index'; | 2 | import { CommonConstants } from 'wdConstant/Index'; |
| 3 | -import { Logger, LazyDataSource } from 'wdKit/Index'; | 3 | +import { Logger } from 'wdKit/Index'; |
| 4 | import { ProcessUtils } from 'wdRouter'; | 4 | import { ProcessUtils } from 'wdRouter'; |
| 5 | import PageViewModel from '../../viewmodel/PageViewModel'; | 5 | import PageViewModel from '../../viewmodel/PageViewModel'; |
| 6 | import { onlyWifiLoadImg } from '../../utils/lazyloadImg'; | 6 | import { onlyWifiLoadImg } from '../../utils/lazyloadImg'; |
| @@ -8,6 +8,7 @@ import { onlyWifiLoadImg } from '../../utils/lazyloadImg'; | @@ -8,6 +8,7 @@ import { onlyWifiLoadImg } from '../../utils/lazyloadImg'; | ||
| 8 | const TAG = 'Zh_Grid_Layout-02'; | 8 | const TAG = 'Zh_Grid_Layout-02'; |
| 9 | const FULL_PARENT: string = '100%'; | 9 | const FULL_PARENT: string = '100%'; |
| 10 | let listSize: number = 2; | 10 | let listSize: number = 2; |
| 11 | + | ||
| 11 | /** | 12 | /** |
| 12 | * 双图卡 | 13 | * 双图卡 |
| 13 | * 枚举值Zh_Grid_Layout-02 | 14 | * 枚举值Zh_Grid_Layout-02 |
| @@ -20,6 +21,8 @@ export struct ZhGridLayout02 { | @@ -20,6 +21,8 @@ export struct ZhGridLayout02 { | ||
| 20 | @State operDataList: ContentDTO[] = [] | 21 | @State operDataList: ContentDTO[] = [] |
| 21 | @State loadImg: boolean = false; | 22 | @State loadImg: boolean = false; |
| 22 | @State liveRoomList: LiveRoomDataBean[] = [] | 23 | @State liveRoomList: LiveRoomDataBean[] = [] |
| 24 | + currentPage = 1 | ||
| 25 | + pageSize = 12 | ||
| 23 | 26 | ||
| 24 | async aboutToAppear(): Promise<void> { | 27 | async aboutToAppear(): Promise<void> { |
| 25 | Logger.debug(TAG, 'aboutToAppear ' + this.compDTO.objectTitle) | 28 | Logger.debug(TAG, 'aboutToAppear ' + this.compDTO.objectTitle) |
| @@ -33,9 +36,6 @@ export struct ZhGridLayout02 { | @@ -33,9 +36,6 @@ export struct ZhGridLayout02 { | ||
| 33 | this.loadImg = await onlyWifiLoadImg(); | 36 | this.loadImg = await onlyWifiLoadImg(); |
| 34 | } | 37 | } |
| 35 | 38 | ||
| 36 | - currentPage = 1 | ||
| 37 | - pageSize = 12 | ||
| 38 | - | ||
| 39 | build() { | 39 | build() { |
| 40 | Column() { | 40 | Column() { |
| 41 | Scroll() { | 41 | Scroll() { |
| @@ -51,7 +51,7 @@ export struct ZhGridLayout02 { | @@ -51,7 +51,7 @@ export struct ZhGridLayout02 { | ||
| 51 | .fontWeight(600) | 51 | .fontWeight(600) |
| 52 | } | 52 | } |
| 53 | .justifyContent(FlexAlign.Start) | 53 | .justifyContent(FlexAlign.Start) |
| 54 | - .margin({ top: 8, bottom: 8 }) | 54 | + .margin({ top: 16, bottom: 8 }) |
| 55 | .width(CommonConstants.FULL_WIDTH) | 55 | .width(CommonConstants.FULL_WIDTH) |
| 56 | 56 | ||
| 57 | GridRow({ | 57 | GridRow({ |
| @@ -101,7 +101,7 @@ export struct ZhGridLayout02 { | @@ -101,7 +101,7 @@ export struct ZhGridLayout02 { | ||
| 101 | @Builder | 101 | @Builder |
| 102 | buildItemCard(item: ContentDTO) { | 102 | buildItemCard(item: ContentDTO) { |
| 103 | Column() { | 103 | Column() { |
| 104 | - Stack({alignContent: Alignment.BottomEnd}) { | 104 | + Stack({ alignContent: Alignment.BottomEnd }) { |
| 105 | Image(this.loadImg ? item.fullColumnImgUrls[0].url : '') | 105 | Image(this.loadImg ? item.fullColumnImgUrls[0].url : '') |
| 106 | .backgroundColor(0xf5f5f5) | 106 | .backgroundColor(0xf5f5f5) |
| 107 | .width('100%') | 107 | .width('100%') |
| @@ -114,12 +114,13 @@ export struct ZhGridLayout02 { | @@ -114,12 +114,13 @@ export struct ZhGridLayout02 { | ||
| 114 | .fontColor(Color.White) | 114 | .fontColor(Color.White) |
| 115 | .margin({ | 115 | .margin({ |
| 116 | right: '5vp', | 116 | right: '5vp', |
| 117 | - bottom:'5vp' | 117 | + bottom: '5vp' |
| 118 | }) | 118 | }) |
| 119 | } | 119 | } |
| 120 | } | 120 | } |
| 121 | + | ||
| 121 | Text(item.newsTitle) | 122 | Text(item.newsTitle) |
| 122 | - .margin({top:'5'}) | 123 | + .margin({ top: '5' }) |
| 123 | .fontSize(13) | 124 | .fontSize(13) |
| 124 | .maxLines(2) | 125 | .maxLines(2) |
| 125 | .textOverflow({ overflow: TextOverflow.Ellipsis }) | 126 | .textOverflow({ overflow: TextOverflow.Ellipsis }) |
| @@ -130,14 +131,6 @@ export struct ZhGridLayout02 { | @@ -130,14 +131,6 @@ export struct ZhGridLayout02 { | ||
| 130 | }) | 131 | }) |
| 131 | } | 132 | } |
| 132 | 133 | ||
| 133 | - | ||
| 134 | - private getLiveDetailIds(list: ContentDTO[]): string { | ||
| 135 | - let idList: string[] = [] | ||
| 136 | - list.forEach(item => { | ||
| 137 | - idList.push(item.objectId) | ||
| 138 | - }); | ||
| 139 | - return idList.join(',') | ||
| 140 | - } | ||
| 141 | // 获取评论数 | 134 | // 获取评论数 |
| 142 | async getLiveRoomDataInfo(list: ContentDTO[]) { | 135 | async getLiveRoomDataInfo(list: ContentDTO[]) { |
| 143 | const reserveIds = this.getLiveDetailIds(list) | 136 | const reserveIds = this.getLiveDetailIds(list) |
| @@ -145,12 +138,12 @@ export struct ZhGridLayout02 { | @@ -145,12 +138,12 @@ export struct ZhGridLayout02 { | ||
| 145 | if (result && result.length > 0) { | 138 | if (result && result.length > 0) { |
| 146 | this.liveRoomList.push(...result) | 139 | this.liveRoomList.push(...result) |
| 147 | } | 140 | } |
| 148 | - }).catch(() =>{ | 141 | + }).catch(() => { |
| 149 | }) | 142 | }) |
| 150 | } | 143 | } |
| 151 | 144 | ||
| 152 | // 判断是否预约 | 145 | // 判断是否预约 |
| 153 | - getLiveRoomNumber(item: ContentDTO): string { | 146 | + getLiveRoomNumber(item: ContentDTO): string { |
| 154 | const objc = this.liveRoomList.find((element: LiveRoomDataBean) => { | 147 | const objc = this.liveRoomList.find((element: LiveRoomDataBean) => { |
| 155 | return element.liveId.toString() == item.objectId | 148 | return element.liveId.toString() == item.objectId |
| 156 | }) | 149 | }) |
| @@ -160,16 +153,6 @@ export struct ZhGridLayout02 { | @@ -160,16 +153,6 @@ export struct ZhGridLayout02 { | ||
| 160 | return '' | 153 | return '' |
| 161 | } | 154 | } |
| 162 | 155 | ||
| 163 | - private computeShowNum(count: number): string { | ||
| 164 | - if (count >= 10000) { | ||
| 165 | - let num = ( count / 10000).toFixed(1) | ||
| 166 | - if (Number(num.substring(num.length-1)) == 0) { | ||
| 167 | - num = num.substring(0, num.length-2) | ||
| 168 | - } | ||
| 169 | - return num + '万人参加' | ||
| 170 | - } | ||
| 171 | - return `${count}人参加` | ||
| 172 | - } | ||
| 173 | addItems() { | 156 | addItems() { |
| 174 | Logger.debug(TAG, 'addItems') | 157 | Logger.debug(TAG, 'addItems') |
| 175 | this.currentPage++ | 158 | this.currentPage++ |
| @@ -179,6 +162,25 @@ export struct ZhGridLayout02 { | @@ -179,6 +162,25 @@ export struct ZhGridLayout02 { | ||
| 179 | Logger.debug(TAG, 'addItems after: ' + this.operDataList.length) | 162 | Logger.debug(TAG, 'addItems after: ' + this.operDataList.length) |
| 180 | }) | 163 | }) |
| 181 | } | 164 | } |
| 165 | + | ||
| 166 | + private getLiveDetailIds(list: ContentDTO[]): string { | ||
| 167 | + let idList: string[] = [] | ||
| 168 | + list.forEach(item => { | ||
| 169 | + idList.push(item.objectId) | ||
| 170 | + }); | ||
| 171 | + return idList.join(',') | ||
| 172 | + } | ||
| 173 | + | ||
| 174 | + private computeShowNum(count: number): string { | ||
| 175 | + if (count >= 10000) { | ||
| 176 | + let num = (count / 10000).toFixed(1) | ||
| 177 | + if (Number(num.substring(num.length - 1)) == 0) { | ||
| 178 | + num = num.substring(0, num.length - 2) | ||
| 179 | + } | ||
| 180 | + return num + '万人参加' | ||
| 181 | + } | ||
| 182 | + return `${count}人参加` | ||
| 183 | + } | ||
| 182 | } | 184 | } |
| 183 | 185 | ||
| 184 | 186 |
| @@ -49,7 +49,7 @@ export class LiveModel { | @@ -49,7 +49,7 @@ export class LiveModel { | ||
| 49 | success(data.data) | 49 | success(data.data) |
| 50 | }, (error: Error) => { | 50 | }, (error: Error) => { |
| 51 | fail(error.message) | 51 | fail(error.message) |
| 52 | - Logger.debug(TAG + ":error ", error.toString()) | 52 | + Logger.debug(TAG + ":error ", error.message) |
| 53 | }) | 53 | }) |
| 54 | }) | 54 | }) |
| 55 | } | 55 | } |
| @@ -26,32 +26,57 @@ export struct TabComponent { | @@ -26,32 +26,57 @@ export struct TabComponent { | ||
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | build() { | 28 | build() { |
| 29 | - Tabs({ barPosition: BarPosition.Start, index: this.currentIndex, controller: this.controller }) { | ||
| 30 | - ForEach(this.tabs, (item: string, index: number) => { | ||
| 31 | - TabContent() { | ||
| 32 | - if ('简介' === item) { | ||
| 33 | - TabInfoComponent() | ||
| 34 | - } else if ('直播间' === item) { | ||
| 35 | - TabLiveComponent() | ||
| 36 | - } else if ('大家聊' === item) { | ||
| 37 | - TabChatComponent() | 29 | + Stack({alignContent: Alignment.TopStart}) { |
| 30 | + Tabs({ barPosition: BarPosition.Start, index: this.currentIndex, controller: this.controller }) { | ||
| 31 | + ForEach(this.tabs, (item: string, index: number) => { | ||
| 32 | + TabContent() { | ||
| 33 | + if ('简介' === item) { | ||
| 34 | + TabInfoComponent() | ||
| 35 | + } else if ('直播间' === item) { | ||
| 36 | + TabLiveComponent() | ||
| 37 | + } else if ('大家聊' === item) { | ||
| 38 | + TabChatComponent() | ||
| 39 | + } | ||
| 38 | } | 40 | } |
| 39 | - }.tabBar(this.tabBuilder(index, item)) | ||
| 40 | - .backgroundColor('#F5F5F5') | ||
| 41 | - }, (item: string, index: number) => { | ||
| 42 | - return item + index | 41 | + .backgroundColor('#F5F5F5') |
| 42 | + }, (item: string, index: number) => { | ||
| 43 | + return item + index | ||
| 44 | + }) | ||
| 45 | + } | ||
| 46 | + .layoutWeight(1) | ||
| 47 | + .vertical(false) | ||
| 48 | + .barMode(BarMode.Fixed) | ||
| 49 | + .barHeight(48) | ||
| 50 | + .animationDuration(100) | ||
| 51 | + .onChange((index: number) => { | ||
| 52 | + this.currentIndex = index | ||
| 43 | }) | 53 | }) |
| 44 | - } | ||
| 45 | - .layoutWeight(1) | ||
| 46 | - .vertical(false) | ||
| 47 | - .barMode(BarMode.Fixed) | ||
| 48 | - .barWidth(70 * this.tabs.length) | ||
| 49 | - .barHeight(48) | ||
| 50 | - .animationDuration(100) | ||
| 51 | - .onChange((index: number) => { | ||
| 52 | - this.currentIndex = index | ||
| 53 | - }) | ||
| 54 | - .backgroundColor(Color.White) | 54 | + .backgroundColor(Color.White) |
| 55 | + | ||
| 56 | + // 页签 | ||
| 57 | + Row() { | ||
| 58 | + Scroll() { | ||
| 59 | + Row({space: '24vp'}) { | ||
| 60 | + ForEach(this.tabs, (item: string, index: number) => { | ||
| 61 | + this.tabBuilder(index, item) | ||
| 62 | + }) | ||
| 63 | + } | ||
| 64 | + .width('100%') | ||
| 65 | + .justifyContent(FlexAlign.Center) | ||
| 66 | + } | ||
| 67 | + .backgroundColor(Color.White) | ||
| 68 | + .align(Alignment.Start) | ||
| 69 | + .scrollable(ScrollDirection.Horizontal) | ||
| 70 | + .scrollBar(BarState.Off) | ||
| 71 | + .width('100%') | ||
| 72 | + } | ||
| 73 | + .backgroundColor(Color.White) | ||
| 74 | + .height('48vp') | ||
| 75 | + .alignItems(VerticalAlign.Bottom) | ||
| 76 | + .width('100%') | ||
| 77 | + }.layoutWeight(1) | ||
| 78 | + | ||
| 79 | + | ||
| 55 | } | 80 | } |
| 56 | 81 | ||
| 57 | @Builder | 82 | @Builder |
| @@ -60,7 +85,7 @@ export struct TabComponent { | @@ -60,7 +85,7 @@ export struct TabComponent { | ||
| 60 | Text(name) | 85 | Text(name) |
| 61 | .margin({ top: 6 }) | 86 | .margin({ top: 6 }) |
| 62 | .fontColor(this.currentIndex === index ? this.selectedFontColor : this.fontColor) | 87 | .fontColor(this.currentIndex === index ? this.selectedFontColor : this.fontColor) |
| 63 | - .fontSize('18fp') | 88 | + .fontSize('18vp') |
| 64 | .fontWeight(this.currentIndex === index ? 600 : 400) | 89 | .fontWeight(this.currentIndex === index ? 600 : 400) |
| 65 | Divider() | 90 | Divider() |
| 66 | .strokeWidth(2) | 91 | .strokeWidth(2) |
| @@ -68,7 +93,13 @@ export struct TabComponent { | @@ -68,7 +93,13 @@ export struct TabComponent { | ||
| 68 | .width(15) | 93 | .width(15) |
| 69 | .color('#CB0000') | 94 | .color('#CB0000') |
| 70 | .visibility(this.currentIndex === index ? Visibility.Visible : Visibility.Hidden) | 95 | .visibility(this.currentIndex === index ? Visibility.Visible : Visibility.Hidden) |
| 71 | - }.width('100%') | 96 | + }.justifyContent(FlexAlign.Center) |
| 97 | + .constraintSize({ minWidth: 35 }) | ||
| 98 | + .height('48vp') | ||
| 99 | + .onClick(() => { | ||
| 100 | + this.controller.changeIndex(index) | ||
| 101 | + this.currentIndex = index | ||
| 102 | + }) | ||
| 72 | } | 103 | } |
| 73 | 104 | ||
| 74 | aboutToDisappear(): void { | 105 | aboutToDisappear(): void { |
-
Please register or login to post a comment