Showing
13 changed files
with
122 additions
and
107 deletions
| @@ -67,15 +67,15 @@ export const enum CompStyle { | @@ -67,15 +67,15 @@ export const enum CompStyle { | ||
| 67 | 67 | ||
| 68 | 68 | ||
| 69 | 69 | ||
| 70 | - Card_Adv_4 = 4, //4:轮播图 5:三图广告 6:小图广告 7:长通栏广告 8:大图广告 9:视频广告 10:展会广告 11:冠名广告 12:顶部长通栏广告 | ||
| 71 | - Card_Adv_5 = 5, | ||
| 72 | - Card_Adv_6 = 5, | ||
| 73 | - Card_Adv_7 = 7, | ||
| 74 | - Card_Adv_8 = 8, | ||
| 75 | - Card_Adv_9 = 9, | ||
| 76 | - Card_Adv_10 = 10, | ||
| 77 | - Card_Adv_11 = 11, | ||
| 78 | - Card_Adv_12 = 12, | 70 | + Card_Adv_4 = 4, //4:轮播图 |
| 71 | + Card_Adv_5 = 5, // 5:三图广告 | ||
| 72 | + Card_Adv_6 = 6, // 6:小图广告 | ||
| 73 | + Card_Adv_7 = 7, // 7:长通栏广告 | ||
| 74 | + Card_Adv_8 = 8, // 8:大图广告 | ||
| 75 | + Card_Adv_9 = 9, // 9:视频广告 | ||
| 76 | + Card_Adv_10 = 10, // 10:展会广告 | ||
| 77 | + Card_Adv_11 = 11, // 11:冠名广告 | ||
| 78 | + Card_Adv_12 = 12, // 12:顶部长通栏广告 | ||
| 79 | 79 | ||
| 80 | /** | 80 | /** |
| 81 | * 本地稿件和组件样式 | 81 | * 本地稿件和组件样式 |
| @@ -17,7 +17,7 @@ const TAG = 'ProcessUtils'; | @@ -17,7 +17,7 @@ const TAG = 'ProcessUtils'; | ||
| 17 | */ | 17 | */ |
| 18 | export class ProcessUtils { | 18 | export class ProcessUtils { |
| 19 | /** | 19 | /** |
| 20 | - * 广告中心的业务广告跳转方法( 现用在挂角广告) | 20 | + * 广告中心的业务广告跳转方法( 现用在挂角广告、信息流页面广告) |
| 21 | * @param advContent | 21 | * @param advContent |
| 22 | */ | 22 | */ |
| 23 | static openAdvDetail(matInfo: CompAdvMatInfoBean) { | 23 | static openAdvDetail(matInfo: CompAdvMatInfoBean) { |
| @@ -23,7 +23,6 @@ import { ZhGridLayout02 } from './compview/ZhGridLayout02'; | @@ -23,7 +23,6 @@ import { ZhGridLayout02 } from './compview/ZhGridLayout02'; | ||
| 23 | import { Card2Component } from './cardview/Card2Component'; | 23 | import { Card2Component } from './cardview/Card2Component'; |
| 24 | import { Card5Component } from './cardview/Card5Component'; | 24 | import { Card5Component } from './cardview/Card5Component'; |
| 25 | import { WDRouterPage, WDRouterRule } from 'wdRouter/Index'; | 25 | import { WDRouterPage, WDRouterRule } from 'wdRouter/Index'; |
| 26 | -import { CardAdvComponent } from './cardViewAdv/CardAdvComponent'; | ||
| 27 | import { AdvCardParser } from './cardViewAdv/AdvCardParser'; | 26 | import { AdvCardParser } from './cardViewAdv/AdvCardParser'; |
| 28 | 27 | ||
| 29 | /** | 28 | /** |
| 1 | import { CompStyle } from 'wdConstant'; | 1 | import { CompStyle } from 'wdConstant'; |
| 2 | import { CompDTO } from 'wdBean'; | 2 | import { CompDTO } from 'wdBean'; |
| 3 | -import { CardAdvComponent } from './CardAdvComponent'; | ||
| 4 | import { CardAdvThreeImageComponent } from './CardAdvThreeImageComponent'; | 3 | import { CardAdvThreeImageComponent } from './CardAdvThreeImageComponent'; |
| 5 | import { CardAdvSmallImageComponent } from './CardAdvSmallImageComponent'; | 4 | import { CardAdvSmallImageComponent } from './CardAdvSmallImageComponent'; |
| 6 | import { CardAdvLongImageComponent } from './CardAdvLongImageComponent'; | 5 | import { CardAdvLongImageComponent } from './CardAdvLongImageComponent'; |
| @@ -22,12 +22,12 @@ export struct CardAdvBigImageComponent { | @@ -22,12 +22,12 @@ export struct CardAdvBigImageComponent { | ||
| 22 | 22 | ||
| 23 | aboutToAppear(): void { | 23 | aboutToAppear(): void { |
| 24 | 24 | ||
| 25 | - console.error('ZZZXXXXX', '--------aboutToAppear-----') | 25 | + console.error('ZZZXXXXX', '----大图卡----aboutToAppear-----') |
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | aboutToDisappear(): void { | 28 | aboutToDisappear(): void { |
| 29 | 29 | ||
| 30 | - console.error('ZZZXXXXX', '--------aboutToDisappear-----') | 30 | + console.error('ZZZXXXXX', '---大图卡-----aboutToDisappear-----') |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | build() { | 33 | build() { |
sight_harmony/features/wdComponent/src/main/ets/components/cardViewAdv/CardAdvComponent.ets
deleted
100644 → 0
| 1 | -//全标题 "appStyle":"2", | ||
| 2 | -import { CompDTO, ContentDTO } from 'wdBean'; | ||
| 3 | -import { CommonConstants } from 'wdConstant/Index'; | ||
| 4 | -import { ProcessUtils } from 'wdRouter'; | ||
| 5 | -import { CardMediaInfo } from '../cardCommon/CardMediaInfo' | ||
| 6 | -import { CardSourceInfo } from '../cardCommon/CardSourceInfo' | ||
| 7 | - | ||
| 8 | -const TAG: string = 'Card2Component'; | ||
| 9 | - | ||
| 10 | -/** | ||
| 11 | - * @Description: 类描述 | ||
| 12 | - * @Author: | ||
| 13 | - * @Email: liyubing@wondertek.com.cn | ||
| 14 | - * @CreateDate: | ||
| 15 | - * @UpdateRemark: 更新说明 | ||
| 16 | - * @Version: 1.0 | ||
| 17 | - */ | ||
| 18 | -@Component | ||
| 19 | -export struct CardAdvComponent { | ||
| 20 | - | ||
| 21 | - @State compDTO: CompDTO = {} as CompDTO | ||
| 22 | - | ||
| 23 | - aboutToAppear(): void { | ||
| 24 | - | ||
| 25 | - console.error('ZZZXXXXX', '--------aboutToAppear-----') | ||
| 26 | - } | ||
| 27 | - | ||
| 28 | - aboutToDisappear(): void { | ||
| 29 | - | ||
| 30 | - console.error('ZZZXXXXX', '--------aboutToDisappear-----') | ||
| 31 | - } | ||
| 32 | - | ||
| 33 | - build() { | ||
| 34 | - | ||
| 35 | - Column() { | ||
| 36 | - Text(this.compDTO.matInfo.advTitle) | ||
| 37 | - .fontSize($r('app.float.font_size_17')) | ||
| 38 | - .fontColor($r('app.color.color_222222')) | ||
| 39 | - .maxLines(3) | ||
| 40 | - .textOverflow({ overflow: TextOverflow.Ellipsis })// 超出的部分显示省略号。 | ||
| 41 | - .align(Alignment.Start) | ||
| 42 | - } | ||
| 43 | - .width(CommonConstants.FULL_WIDTH) | ||
| 44 | - .padding({ | ||
| 45 | - left: $r('app.float.card_comp_pagePadding_lf'), | ||
| 46 | - right: $r('app.float.card_comp_pagePadding_lf'), | ||
| 47 | - top: $r('app.float.card_comp_pagePadding_tb'), | ||
| 48 | - bottom: $r('app.float.card_comp_pagePadding_tb') | ||
| 49 | - }) | ||
| 50 | - .onClick((event: ClickEvent) => { | ||
| 51 | - //ProcessUtils.processPage(this.contentDTO) | ||
| 52 | - }) | ||
| 53 | - } | ||
| 54 | -} | ||
| 55 | - | ||
| 56 | -@Extend(Text) | ||
| 57 | -function bottomTextStyle() { | ||
| 58 | - .fontSize(12) | ||
| 59 | - .fontColor('#B0B0B0') | ||
| 60 | -} |
| @@ -22,12 +22,12 @@ export struct CardAdvGanMiComponent { | @@ -22,12 +22,12 @@ export struct CardAdvGanMiComponent { | ||
| 22 | 22 | ||
| 23 | aboutToAppear(): void { | 23 | aboutToAppear(): void { |
| 24 | 24 | ||
| 25 | - console.error('ZZZXXXXX', '--------aboutToAppear-----') | 25 | + console.error('ZZZXXXXX', '--冠名广告------aboutToAppear-----') |
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | aboutToDisappear(): void { | 28 | aboutToDisappear(): void { |
| 29 | 29 | ||
| 30 | - console.error('ZZZXXXXX', '--------aboutToDisappear-----') | 30 | + console.error('ZZZXXXXX', '--冠名广告------aboutToDisappear-----') |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | build() { | 33 | build() { |
sight_harmony/features/wdComponent/src/main/ets/components/cardViewAdv/CardAdvLongImageComponent.ets
| @@ -22,12 +22,12 @@ export struct CardAdvLongImageComponent { | @@ -22,12 +22,12 @@ export struct CardAdvLongImageComponent { | ||
| 22 | 22 | ||
| 23 | aboutToAppear(): void { | 23 | aboutToAppear(): void { |
| 24 | 24 | ||
| 25 | - console.error('ZZZXXXXX', '--------aboutToAppear-----') | 25 | + console.error('ZZZXXXXX', '--长通栏广告 和 顶部长通栏广告------aboutToAppear-----') |
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | aboutToDisappear(): void { | 28 | aboutToDisappear(): void { |
| 29 | 29 | ||
| 30 | - console.error('ZZZXXXXX', '--------aboutToDisappear-----') | 30 | + console.error('ZZZXXXXX', '--长通栏广告 和 顶部长通栏广告------aboutToDisappear-----') |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | build() { | 33 | build() { |
| 1 | //全标题 "appStyle":"2", | 1 | //全标题 "appStyle":"2", |
| 2 | -import { CompDTO, ContentDTO } from 'wdBean'; | ||
| 3 | -import { CommonConstants } from 'wdConstant/Index'; | 2 | +import { CompDTO } from 'wdBean'; |
| 4 | import { ProcessUtils } from 'wdRouter'; | 3 | import { ProcessUtils } from 'wdRouter'; |
| 5 | -import { CardMediaInfo } from '../cardCommon/CardMediaInfo' | ||
| 6 | -import { CardSourceInfo } from '../cardCommon/CardSourceInfo' | ||
| 7 | - | ||
| 8 | -const TAG: string = 'Card2Component'; | ||
| 9 | - | ||
| 10 | -/** | ||
| 11 | - * @Description: 广告---小图卡 | ||
| 12 | - * @Author: | ||
| 13 | - * @Email: liyubing@wondertek.com.cn | ||
| 14 | - * @CreateDate: | ||
| 15 | - * @UpdateRemark: 更新说明 | ||
| 16 | - * @Version: 1.0 | 4 | + |
| 5 | +import measure from '@ohos.measure'; | ||
| 6 | +import { DisplayUtils } from 'wdKit/Index'; | ||
| 7 | + | ||
| 8 | +const TAG: string = 'CardAdvSmallImageComponent'; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * @Description: 广告---小图卡 | ||
| 12 | + * @Author: | ||
| 13 | + * @Email: liyubing@wondertek.com.cn | ||
| 14 | + * @CreateDate: | ||
| 15 | + * @UpdateRemark: 更新说明 | ||
| 16 | + * @Version: 1.0 | ||
| 17 | */ | 17 | */ |
| 18 | @Component | 18 | @Component |
| 19 | export struct CardAdvSmallImageComponent { | 19 | export struct CardAdvSmallImageComponent { |
| 20 | - | ||
| 21 | @State compDTO: CompDTO = {} as CompDTO | 20 | @State compDTO: CompDTO = {} as CompDTO |
| 21 | + @State isBigThreeLine: boolean = false // 标题的行数大于等于3行 是true | ||
| 22 | 22 | ||
| 23 | aboutToAppear(): void { | 23 | aboutToAppear(): void { |
| 24 | 24 | ||
| 25 | - console.error('ZZZXXXXX', '--------aboutToAppear-----') | 25 | + console.error('ZZZXXXXX', '----小图卡----aboutToAppear-----') |
| 26 | + // 计算标题文本行数 | ||
| 27 | + let screenWith = DisplayUtils.getDeviceWidth(); | ||
| 28 | + screenWith = screenWith * 0.62 | ||
| 29 | + let titleNameLineNum = this.getTextLineNum(this.compDTO.matInfo.advTitle, screenWith, 25, 18) | ||
| 30 | + this.isBigThreeLine = titleNameLineNum >= 3; | ||
| 26 | } | 31 | } |
| 27 | 32 | ||
| 28 | aboutToDisappear(): void { | 33 | aboutToDisappear(): void { |
| 29 | 34 | ||
| 30 | - console.error('ZZZXXXXX', '--------aboutToDisappear-----') | 35 | + console.error('ZZZXXXXX', '---小图卡-----aboutToDisappear-----') |
| 31 | } | 36 | } |
| 32 | 37 | ||
| 33 | build() { | 38 | build() { |
| 34 | 39 | ||
| 35 | - Column() { | 40 | + RelativeContainer() { |
| 41 | + | ||
| 42 | + // 广告标题 | ||
| 36 | Text(this.compDTO.matInfo.advTitle) | 43 | Text(this.compDTO.matInfo.advTitle) |
| 37 | - .fontSize($r('app.float.font_size_17')) | 44 | + .fontSize('18fp') |
| 38 | .fontColor($r('app.color.color_222222')) | 45 | .fontColor($r('app.color.color_222222')) |
| 39 | .maxLines(3) | 46 | .maxLines(3) |
| 47 | + .lineHeight(25) | ||
| 40 | .textOverflow({ overflow: TextOverflow.Ellipsis })// 超出的部分显示省略号。 | 48 | .textOverflow({ overflow: TextOverflow.Ellipsis })// 超出的部分显示省略号。 |
| 41 | - .align(Alignment.Start) | 49 | + .width('62%') |
| 50 | + .alignRules({ | ||
| 51 | + top: { anchor: '__container__', align: VerticalAlign.Top }, | ||
| 52 | + left: { anchor: '__container__', align: HorizontalAlign.Start }, | ||
| 53 | + }) | ||
| 54 | + .id("title_name") | ||
| 55 | + // 广告图 | ||
| 56 | + Image(this.compDTO.matInfo.matImageUrl[0]) | ||
| 57 | + .width('34%') | ||
| 58 | + .aspectRatio(3 / 2) | ||
| 59 | + .borderRadius(4) | ||
| 60 | + .id('adv_imag') | ||
| 61 | + .alignRules({ | ||
| 62 | + top: { anchor: 'title_name', align: VerticalAlign.Top }, | ||
| 63 | + left: { anchor: 'title_name', align: HorizontalAlign.End }, | ||
| 64 | + | ||
| 65 | + }) | ||
| 66 | + .margin({ left: 12 }) | ||
| 67 | + | ||
| 68 | + Row() { | ||
| 69 | + Text($r('app.string.comp_advertisement')).fontSize('12fp').fontColor($r('app.color.color_B0B0B0')) | ||
| 70 | + | ||
| 71 | + Blank() | ||
| 72 | + | ||
| 73 | + Stack() { | ||
| 74 | + Image($r('app.media.comp_adv_close')) | ||
| 75 | + .width(9) | ||
| 76 | + .height(9) | ||
| 77 | + .borderRadius({ | ||
| 78 | + topLeft: '4vp', | ||
| 79 | + topRight: '4vp', | ||
| 80 | + bottomLeft: '4vp', | ||
| 81 | + bottomRight: '4vp' | ||
| 82 | + }) | ||
| 83 | + } | ||
| 84 | + .width(18) | ||
| 85 | + .height(14) | ||
| 86 | + .borderWidth(0.5) | ||
| 87 | + .borderColor($r('app.color.color_EDEDED')) | ||
| 88 | + .borderRadius(4) | ||
| 89 | + | ||
| 90 | + }.width('62%').alignRules({ | ||
| 91 | + bottom: { anchor: this.isBigThreeLine ? '' : 'adv_imag', align: VerticalAlign.Bottom }, | ||
| 92 | + right: { anchor: this.isBigThreeLine ? '' : 'adv_imag', align: HorizontalAlign.Start }, | ||
| 93 | + | ||
| 94 | + top: { anchor: this.isBigThreeLine ? 'title_name' : '', align: VerticalAlign.Bottom }, | ||
| 95 | + left: { anchor: this.isBigThreeLine ? 'title_name' : '', align: HorizontalAlign.Start }, | ||
| 96 | + }).id('bottom_adv').margin({ | ||
| 97 | + right: this.isBigThreeLine ? 0 : 12, | ||
| 98 | + top: this.isBigThreeLine ? 8 : 0, | ||
| 99 | + }) | ||
| 42 | } | 100 | } |
| 43 | - .width(CommonConstants.FULL_WIDTH) | 101 | + .width("100%") |
| 102 | + .height(this.isBigThreeLine ? 127 : 106) | ||
| 44 | .padding({ | 103 | .padding({ |
| 45 | left: $r('app.float.card_comp_pagePadding_lf'), | 104 | left: $r('app.float.card_comp_pagePadding_lf'), |
| 46 | right: $r('app.float.card_comp_pagePadding_lf'), | 105 | right: $r('app.float.card_comp_pagePadding_lf'), |
| @@ -48,13 +107,31 @@ export struct CardAdvSmallImageComponent { | @@ -48,13 +107,31 @@ export struct CardAdvSmallImageComponent { | ||
| 48 | bottom: $r('app.float.card_comp_pagePadding_tb') | 107 | bottom: $r('app.float.card_comp_pagePadding_tb') |
| 49 | }) | 108 | }) |
| 50 | .onClick((event: ClickEvent) => { | 109 | .onClick((event: ClickEvent) => { |
| 51 | - //ProcessUtils.processPage(this.contentDTO) | 110 | + ProcessUtils.openAdvDetail(this.compDTO.matInfo) |
| 111 | + }) | ||
| 112 | + } | ||
| 113 | + | ||
| 114 | + // 获取文本几行 | ||
| 115 | + private getTextLineNum(text: string, constraintWidth: number, lineHeight: number, fontSize: number | string | Resource) { | ||
| 116 | + let size = this.topMeasureText(text, constraintWidth, lineHeight, fontSize) | ||
| 117 | + let height: number = Number(size.height) | ||
| 118 | + return Math.ceil(px2vp(height) / lineHeight) | ||
| 119 | + } | ||
| 120 | + | ||
| 121 | + private topMeasureText(text: string, constraintWidth: number, lineHeight: number, fontSize: number | string | Resource) { | ||
| 122 | + return measure.measureTextSize({ | ||
| 123 | + textContent: text, | ||
| 124 | + fontSize: fontSize, | ||
| 125 | + lineHeight: lineHeight, | ||
| 126 | + constraintWidth: constraintWidth, | ||
| 52 | }) | 127 | }) |
| 53 | } | 128 | } |
| 54 | } | 129 | } |
| 55 | 130 | ||
| 131 | + | ||
| 56 | @Extend(Text) | 132 | @Extend(Text) |
| 57 | function bottomTextStyle() { | 133 | function bottomTextStyle() { |
| 58 | .fontSize(12) | 134 | .fontSize(12) |
| 59 | .fontColor('#B0B0B0') | 135 | .fontColor('#B0B0B0') |
| 60 | -} | ||
| 136 | +} | ||
| 137 | + |
| @@ -22,12 +22,12 @@ export struct CardAdvThreeImageComponent { | @@ -22,12 +22,12 @@ export struct CardAdvThreeImageComponent { | ||
| 22 | 22 | ||
| 23 | aboutToAppear(): void { | 23 | aboutToAppear(): void { |
| 24 | 24 | ||
| 25 | - console.error('ZZZXXXXX', '--------aboutToAppear-----') | 25 | + console.error('ZZZXXXXX', '---三图卡-----aboutToAppear-----') |
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | aboutToDisappear(): void { | 28 | aboutToDisappear(): void { |
| 29 | 29 | ||
| 30 | - console.error('ZZZXXXXX', '--------aboutToDisappear-----') | 30 | + console.error('ZZZXXXXX', '----三图卡----aboutToDisappear-----') |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | build() { | 33 | build() { |
| @@ -22,12 +22,12 @@ export struct CardAdvVideoComponent { | @@ -22,12 +22,12 @@ export struct CardAdvVideoComponent { | ||
| 22 | 22 | ||
| 23 | aboutToAppear(): void { | 23 | aboutToAppear(): void { |
| 24 | 24 | ||
| 25 | - console.error('ZZZXXXXX', '--------aboutToAppear-----') | 25 | + console.error('ZZZXXXXX', '--视频广告------aboutToAppear-----') |
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | aboutToDisappear(): void { | 28 | aboutToDisappear(): void { |
| 29 | 29 | ||
| 30 | - console.error('ZZZXXXXX', '--------aboutToDisappear-----') | 30 | + console.error('ZZZXXXXX', '---视频广告-----aboutToDisappear-----') |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | build() { | 33 | build() { |
| @@ -22,12 +22,12 @@ export struct CardAdvVideoExComponent { | @@ -22,12 +22,12 @@ export struct CardAdvVideoExComponent { | ||
| 22 | 22 | ||
| 23 | aboutToAppear(): void { | 23 | aboutToAppear(): void { |
| 24 | 24 | ||
| 25 | - console.error('ZZZXXXXX', '--------aboutToAppear-----') | 25 | + console.error('ZZZXXXXX', '--冠名广告------aboutToAppear-----') |
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | aboutToDisappear(): void { | 28 | aboutToDisappear(): void { |
| 29 | 29 | ||
| 30 | - console.error('ZZZXXXXX', '--------aboutToDisappear-----') | 30 | + console.error('ZZZXXXXX', '----冠名广告----aboutToDisappear-----') |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | build() { | 33 | build() { |
335 Bytes
-
Please register or login to post a comment