Showing
5 changed files
with
181 additions
and
46 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 | } |
| @@ -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 | +} |
-
Please register or login to post a comment