陈剑华

fix: 17150 功能缺陷-搜索结果页-命中内容未露出展示

@@ -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,6 +33,9 @@ export struct CardParser { @@ -32,6 +33,9 @@ export struct CardParser {
32 33
33 @Builder 34 @Builder
34 contentBuilder(contentDTO: ContentDTO, compDTO: CompDTO) { 35 contentBuilder(contentDTO: ContentDTO, compDTO: CompDTO) {
  36 + if (!!contentDTO.contentText) {
  37 + SearchContentComponent({ contentDTO })
  38 + } else {
35 if (contentDTO.appStyle === CompStyle.Card_02) { 39 if (contentDTO.appStyle === CompStyle.Card_02) {
36 Card2Component({ contentDTO }) 40 Card2Component({ contentDTO })
37 } else if (contentDTO.appStyle === CompStyle.Card_03) { 41 } else if (contentDTO.appStyle === CompStyle.Card_03) {
@@ -73,4 +77,6 @@ export struct CardParser { @@ -73,4 +77,6 @@ export struct CardParser {
73 // .backgroundColor(Color.Brown) // 展示本页未实现的compStyle 77 // .backgroundColor(Color.Brown) // 展示本页未实现的compStyle
74 } 78 }
75 } 79 }
  80 +
  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,7 +50,17 @@ export struct Card2Component { @@ -36,7 +50,17 @@ 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) 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 + }
40 .fontSize($r('app.float.font_size_17')) 64 .fontSize($r('app.float.font_size_17'))
41 .fontColor(this.clicked ? 0x848484 : $r('app.color.color_222222')) 65 .fontColor(this.clicked ? 0x848484 : $r('app.color.color_222222'))
42 .maxLines(2) 66 .maxLines(2)
@@ -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)
  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 +}