Showing
14 changed files
with
87 additions
and
37 deletions
| @@ -34,6 +34,7 @@ | @@ -34,6 +34,7 @@ | ||
| 34 | { | 34 | { |
| 35 | "name": "default", | 35 | "name": "default", |
| 36 | "signingConfig": "default", | 36 | "signingConfig": "default", |
| 37 | + "compileSdkVersion": "5.0.0(12)", | ||
| 37 | "compatibleSdkVersion": "5.0.0(12)", | 38 | "compatibleSdkVersion": "5.0.0(12)", |
| 38 | "runtimeOS": "HarmonyOS", | 39 | "runtimeOS": "HarmonyOS", |
| 39 | } | 40 | } |
| @@ -93,10 +93,8 @@ export class HttpBizUtil { | @@ -93,10 +93,8 @@ export class HttpBizUtil { | ||
| 93 | */ | 93 | */ |
| 94 | static refreshToken(): Promise<string> { | 94 | static refreshToken(): Promise<string> { |
| 95 | let url = HttpUrlUtils.getRefreshTokenUrl(); | 95 | let url = HttpUrlUtils.getRefreshTokenUrl(); |
| 96 | - let params: HashMap<string, string> = new HashMap<string, string>() | ||
| 97 | - params.set('refreshToken', HttpUtils.getRefreshToken()) | ||
| 98 | - params.set('deviceId', HttpUtils.getDeviceId()) | ||
| 99 | - // Logger.debug(TAG, 'refreshToken getRefreshToken: ' + HttpUrlUtils.getRefreshToken()) | 96 | + let params: RefreshTokenParam = |
| 97 | + new RefreshTokenParam(HttpUtils.getRefreshToken(), HttpUtils.getDeviceId()) | ||
| 100 | // 请求刷新token接口 | 98 | // 请求刷新token接口 |
| 101 | return new Promise<string>((success, error) => { | 99 | return new Promise<string>((success, error) => { |
| 102 | WDHttp.post<ResponseDTO<RefreshTokenRes>>(url, params).then((resDTO: ResponseDTO<RefreshTokenRes>) => { | 100 | WDHttp.post<ResponseDTO<RefreshTokenRes>>(url, params).then((resDTO: ResponseDTO<RefreshTokenRes>) => { |
| @@ -123,4 +121,14 @@ export class HttpBizUtil { | @@ -123,4 +121,14 @@ export class HttpBizUtil { | ||
| 123 | }); | 121 | }); |
| 124 | }) | 122 | }) |
| 125 | } | 123 | } |
| 124 | +} | ||
| 125 | + | ||
| 126 | +export class RefreshTokenParam { | ||
| 127 | + refreshToken: string = '' | ||
| 128 | + deviceId: string = '' | ||
| 129 | + | ||
| 130 | + constructor(refreshToken: string, deviceId: string) { | ||
| 131 | + this.refreshToken = refreshToken | ||
| 132 | + this.deviceId = deviceId | ||
| 133 | + } | ||
| 126 | } | 134 | } |
| @@ -90,7 +90,7 @@ export struct WdWebComponent { | @@ -90,7 +90,7 @@ export struct WdWebComponent { | ||
| 90 | } | 90 | } |
| 91 | onReloadStateChanged() { | 91 | onReloadStateChanged() { |
| 92 | Logger.info(TAG, `onReloadStateChanged:::refresh, this.reload: ${this.reload}`); | 92 | Logger.info(TAG, `onReloadStateChanged:::refresh, this.reload: ${this.reload}`); |
| 93 | - if (this.reload > 0) { | 93 | + if (this.reload > 0 && this.isPageEnd) { |
| 94 | this.webviewControl.refresh() | 94 | this.webviewControl.refresh() |
| 95 | } | 95 | } |
| 96 | } | 96 | } |
| @@ -90,6 +90,9 @@ export struct SpacialTopicPageComponent { | @@ -90,6 +90,9 @@ export struct SpacialTopicPageComponent { | ||
| 90 | this.publishCommentModel.targetType = String(this.contentDetailData?.newsType || '') | 90 | this.publishCommentModel.targetType = String(this.contentDetailData?.newsType || '') |
| 91 | this.publishCommentModel.visitorComment = String(this.contentDetailData?.visitorComment || '') | 91 | this.publishCommentModel.visitorComment = String(this.contentDetailData?.visitorComment || '') |
| 92 | // } | 92 | // } |
| 93 | + if (this.contentDetailData[0]?.openComment) { | ||
| 94 | + this.operationButtonList = ['collect', 'share'] | ||
| 95 | + } | ||
| 93 | this.trySendData2H5() | 96 | this.trySendData2H5() |
| 94 | } | 97 | } |
| 95 | } | 98 | } |
| @@ -22,6 +22,8 @@ export struct AdvCardParser { | @@ -22,6 +22,8 @@ export struct AdvCardParser { | ||
| 22 | @State compDTO: CompDTO = {} as CompDTO; | 22 | @State compDTO: CompDTO = {} as CompDTO; |
| 23 | pageModel: PageModel = new PageModel(); | 23 | pageModel: PageModel = new PageModel(); |
| 24 | 24 | ||
| 25 | + | ||
| 26 | + | ||
| 25 | build() { | 27 | build() { |
| 26 | this.contentBuilder(this.pageModel, this.compDTO); | 28 | this.contentBuilder(this.pageModel, this.compDTO); |
| 27 | } | 29 | } |
| 1 | import { CompDTO } from 'wdBean'; | 1 | import { CompDTO } from 'wdBean'; |
| 2 | import { CommonConstants } from 'wdConstant/Index'; | 2 | import { CommonConstants } from 'wdConstant/Index'; |
| 3 | import { ProcessUtils } from 'wdRouter'; | 3 | import { ProcessUtils } from 'wdRouter'; |
| 4 | +import { onlyWifiLoadImg } from '../../utils/lazyloadImg'; | ||
| 4 | import PageModel from '../../viewmodel/PageModel'; | 5 | import PageModel from '../../viewmodel/PageModel'; |
| 5 | import { CardAdvBottom } from './CardAdvBottom'; | 6 | import { CardAdvBottom } from './CardAdvBottom'; |
| 6 | 7 | ||
| @@ -17,8 +18,11 @@ const TAG: string = 'Card2Component'; | @@ -17,8 +18,11 @@ const TAG: string = 'Card2Component'; | ||
| 17 | @Component | 18 | @Component |
| 18 | export struct CardAdvBigImageComponent { | 19 | export struct CardAdvBigImageComponent { |
| 19 | @State compDTO: CompDTO = {} as CompDTO | 20 | @State compDTO: CompDTO = {} as CompDTO |
| 21 | + | ||
| 22 | + @State loadImg: boolean = false; | ||
| 20 | pageModel: PageModel = new PageModel(); | 23 | pageModel: PageModel = new PageModel(); |
| 21 | - aboutToAppear(): void { | 24 | + async aboutToAppear(): Promise<void> { |
| 25 | + this.loadImg = await onlyWifiLoadImg(); | ||
| 22 | 26 | ||
| 23 | } | 27 | } |
| 24 | 28 | ||
| @@ -33,7 +37,8 @@ export struct CardAdvBigImageComponent { | @@ -33,7 +37,8 @@ export struct CardAdvBigImageComponent { | ||
| 33 | //新闻标题 | 37 | //新闻标题 |
| 34 | Text(this.compDTO.matInfo.advTitle).bottomTextStyle().margin({ bottom: 8, }) | 38 | Text(this.compDTO.matInfo.advTitle).bottomTextStyle().margin({ bottom: 8, }) |
| 35 | //大图 | 39 | //大图 |
| 36 | - Image(this.compDTO.matInfo.matImageUrl[0]) | 40 | + Image(this.loadImg ? this.compDTO.matInfo.matImageUrl[0] : '') |
| 41 | + .backgroundColor(this.loadImg ? $r('app.color.color_B0B0B0') : 0xf5f5f5) | ||
| 37 | .width(CommonConstants.FULL_WIDTH) | 42 | .width(CommonConstants.FULL_WIDTH) |
| 38 | .aspectRatio(16 / 9) | 43 | .aspectRatio(16 / 9) |
| 39 | .borderRadius(4) | 44 | .borderRadius(4) |
| @@ -4,6 +4,7 @@ import { AdvExtraData, AdvExtraItemData } from 'wdBean/src/main/ets/bean/adv/Adv | @@ -4,6 +4,7 @@ import { AdvExtraData, AdvExtraItemData } from 'wdBean/src/main/ets/bean/adv/Adv | ||
| 4 | import { CompAdvMatInfoBean } from 'wdBean/src/main/ets/bean/adv/CompAdvInfoBean'; | 4 | import { CompAdvMatInfoBean } from 'wdBean/src/main/ets/bean/adv/CompAdvInfoBean'; |
| 5 | import { CommonConstants } from 'wdConstant/Index'; | 5 | import { CommonConstants } from 'wdConstant/Index'; |
| 6 | import { ProcessUtils } from 'wdRouter'; | 6 | import { ProcessUtils } from 'wdRouter'; |
| 7 | +import { onlyWifiLoadImg } from '../../utils/lazyloadImg'; | ||
| 7 | import PageModel from '../../viewmodel/PageModel'; | 8 | import PageModel from '../../viewmodel/PageModel'; |
| 8 | import { CardAdvTop } from './CardAdvTop'; | 9 | import { CardAdvTop } from './CardAdvTop'; |
| 9 | 10 | ||
| @@ -23,14 +24,14 @@ export struct CardAdvGanMiComponent { | @@ -23,14 +24,14 @@ export struct CardAdvGanMiComponent { | ||
| 23 | @State advExtraData: AdvExtraData = {} as AdvExtraData | 24 | @State advExtraData: AdvExtraData = {} as AdvExtraData |
| 24 | @State advLength: number = 0; | 25 | @State advLength: number = 0; |
| 25 | pageModel: PageModel = new PageModel(); | 26 | pageModel: PageModel = new PageModel(); |
| 27 | + @State loadImg: boolean = false; | ||
| 26 | 28 | ||
| 27 | - aboutToAppear(): void { | 29 | + async aboutToAppear(): Promise<void> { |
| 30 | + this.loadImg = await onlyWifiLoadImg(); | ||
| 28 | 31 | ||
| 29 | let extraData = this.compDTO.matInfo.extraData | 32 | let extraData = this.compDTO.matInfo.extraData |
| 30 | let labelDTO = JSON.parse(extraData) as AdvExtraData | 33 | let labelDTO = JSON.parse(extraData) as AdvExtraData |
| 31 | this.advExtraData = labelDTO | 34 | this.advExtraData = labelDTO |
| 32 | - //this.advExtraData.item = [this.advExtraData.item[0]] | ||
| 33 | - // this.advExtraData.item[2].title ="我爱你中国我爱你中国我爱你中国我爱你中国我爱你中国我爱你中国我爱你中国我爱你中国我爱你中国我爱你中国我爱你中国我爱你中国我爱你中国我爱你中国我爱你中国" | ||
| 34 | this.advLength = this.advExtraData.item.length | 35 | this.advLength = this.advExtraData.item.length |
| 35 | } | 36 | } |
| 36 | 37 | ||
| @@ -46,8 +47,9 @@ export struct CardAdvGanMiComponent { | @@ -46,8 +47,9 @@ export struct CardAdvGanMiComponent { | ||
| 46 | Row() { | 47 | Row() { |
| 47 | Stack() { | 48 | Stack() { |
| 48 | //长图 | 49 | //长图 |
| 49 | - Image(this.advExtraData.itemTopImage) | 50 | + Image(this.loadImg ? this.advExtraData.itemTopImage : '') |
| 50 | .width(CommonConstants.FULL_WIDTH) | 51 | .width(CommonConstants.FULL_WIDTH) |
| 52 | + .backgroundColor(this.loadImg ? $r('app.color.color_B0B0B0') : 0xf5f5f5) | ||
| 51 | .aspectRatio(343 / 40) | 53 | .aspectRatio(343 / 40) |
| 52 | .borderRadius(4) | 54 | .borderRadius(4) |
| 53 | .borderWidth(0.5) | 55 | .borderWidth(0.5) |
| @@ -73,8 +75,9 @@ export struct CardAdvGanMiComponent { | @@ -73,8 +75,9 @@ export struct CardAdvGanMiComponent { | ||
| 73 | // 广告列表信息 | 75 | // 广告列表信息 |
| 74 | Column() { | 76 | Column() { |
| 75 | 77 | ||
| 76 | - Image(content.image) | 78 | + Image(this.loadImg ? content.image : '') |
| 77 | .width('100%') | 79 | .width('100%') |
| 80 | + .backgroundColor(this.loadImg ? $r('app.color.color_B0B0B0') : 0xf5f5f5) | ||
| 78 | .aspectRatio(150 / 84) | 81 | .aspectRatio(150 / 84) |
| 79 | .borderWidth(0.5) | 82 | .borderWidth(0.5) |
| 80 | .borderColor($r('app.color.color_0D000000')) | 83 | .borderColor($r('app.color.color_0D000000')) |
| @@ -84,7 +87,7 @@ export struct CardAdvGanMiComponent { | @@ -84,7 +87,7 @@ export struct CardAdvGanMiComponent { | ||
| 84 | .fontSize('16fp') | 87 | .fontSize('16fp') |
| 85 | .fontColor($r('app.color.color_222222')) | 88 | .fontColor($r('app.color.color_222222')) |
| 86 | .fontSize('15fp') | 89 | .fontSize('15fp') |
| 87 | - .maxLines(3) | 90 | + .maxLines(2) |
| 88 | .lineHeight(20) | 91 | .lineHeight(20) |
| 89 | .textOverflow({ overflow: TextOverflow.Ellipsis }) | 92 | .textOverflow({ overflow: TextOverflow.Ellipsis }) |
| 90 | .width('100%') | 93 | .width('100%') |
| @@ -143,7 +146,9 @@ function commonButton(advExtraData: AdvExtraData) { | @@ -143,7 +146,9 @@ function commonButton(advExtraData: AdvExtraData) { | ||
| 143 | Row() { | 146 | Row() { |
| 144 | Row() { | 147 | Row() { |
| 145 | Blank() | 148 | Blank() |
| 146 | - Text('查看更多').fontColor('#222222').fontSize('14fp') | 149 | + Text(advExtraData.itemMore.title == null ? $r('app.string.look_more') : advExtraData.itemMore.title) |
| 150 | + .fontColor('#222222') | ||
| 151 | + .fontSize('14fp') | ||
| 147 | Image($r('app.media.icon_comp_more_right_red')).width(16).height(16) | 152 | Image($r('app.media.icon_comp_more_right_red')).width(16).height(16) |
| 148 | Blank() | 153 | Blank() |
| 149 | 154 |
sight_harmony/features/wdComponent/src/main/ets/components/cardViewAdv/CardAdvLongImageComponent.ets
| @@ -2,6 +2,7 @@ | @@ -2,6 +2,7 @@ | ||
| 2 | import { CompDTO } from 'wdBean'; | 2 | import { CompDTO } from 'wdBean'; |
| 3 | import { CommonConstants, CompStyle } from 'wdConstant/Index'; | 3 | import { CommonConstants, CompStyle } from 'wdConstant/Index'; |
| 4 | import { ProcessUtils } from 'wdRouter'; | 4 | import { ProcessUtils } from 'wdRouter'; |
| 5 | +import { onlyWifiLoadImg } from '../../utils/lazyloadImg'; | ||
| 5 | import PageModel from '../../viewmodel/PageModel'; | 6 | import PageModel from '../../viewmodel/PageModel'; |
| 6 | import { CardAdvBottom } from './CardAdvBottom'; | 7 | import { CardAdvBottom } from './CardAdvBottom'; |
| 7 | 8 | ||
| @@ -20,8 +21,10 @@ export struct CardAdvLongImageComponent { | @@ -20,8 +21,10 @@ export struct CardAdvLongImageComponent { | ||
| 20 | @State compDTO: CompDTO = {} as CompDTO | 21 | @State compDTO: CompDTO = {} as CompDTO |
| 21 | @State haveTitle: boolean = true | 22 | @State haveTitle: boolean = true |
| 22 | pageModel: PageModel = new PageModel(); | 23 | pageModel: PageModel = new PageModel(); |
| 24 | + @State loadImg: boolean = false; | ||
| 23 | 25 | ||
| 24 | - aboutToAppear(): void { | 26 | + async aboutToAppear(): Promise<void> { |
| 27 | + this.loadImg = await onlyWifiLoadImg(); | ||
| 25 | this.haveTitle = this.compDTO.matInfo.advSubType === CompStyle.Card_Adv_7; | 28 | this.haveTitle = this.compDTO.matInfo.advSubType === CompStyle.Card_Adv_7; |
| 26 | } | 29 | } |
| 27 | 30 | ||
| @@ -37,7 +40,8 @@ export struct CardAdvLongImageComponent { | @@ -37,7 +40,8 @@ export struct CardAdvLongImageComponent { | ||
| 37 | Text(this.compDTO.matInfo.advTitle).width('100%').bottomTextStyle().margin({ bottom: 8, }) | 40 | Text(this.compDTO.matInfo.advTitle).width('100%').bottomTextStyle().margin({ bottom: 8, }) |
| 38 | } | 41 | } |
| 39 | //长图 | 42 | //长图 |
| 40 | - Image(this.compDTO.matInfo.matImageUrl[0]) | 43 | + Image(this.loadImg ? this.compDTO.matInfo.matImageUrl[0] : '') |
| 44 | + .backgroundColor(this.loadImg ? $r('app.color.color_B0B0B0') : 0xf5f5f5) | ||
| 41 | .width(CommonConstants.FULL_WIDTH) | 45 | .width(CommonConstants.FULL_WIDTH) |
| 42 | .aspectRatio(343 / 96) | 46 | .aspectRatio(343 / 96) |
| 43 | .borderRadius(4) | 47 | .borderRadius(4) |
| @@ -6,6 +6,7 @@ import measure from '@ohos.measure'; | @@ -6,6 +6,7 @@ import measure from '@ohos.measure'; | ||
| 6 | import { DisplayUtils } from 'wdKit/Index'; | 6 | import { DisplayUtils } from 'wdKit/Index'; |
| 7 | import { CardAdvBottom } from './CardAdvBottom'; | 7 | import { CardAdvBottom } from './CardAdvBottom'; |
| 8 | import PageModel from '../../viewmodel/PageModel'; | 8 | import PageModel from '../../viewmodel/PageModel'; |
| 9 | +import { onlyWifiLoadImg } from '../../utils/lazyloadImg'; | ||
| 9 | 10 | ||
| 10 | const TAG: string = 'CardAdvSmallImageComponent'; | 11 | const TAG: string = 'CardAdvSmallImageComponent'; |
| 11 | 12 | ||
| @@ -22,7 +23,10 @@ export struct CardAdvSmallImageComponent { | @@ -22,7 +23,10 @@ export struct CardAdvSmallImageComponent { | ||
| 22 | @State compDTO: CompDTO = {} as CompDTO | 23 | @State compDTO: CompDTO = {} as CompDTO |
| 23 | @State isBigThreeLine: boolean = false // 标题的行数大于等于3行 是true | 24 | @State isBigThreeLine: boolean = false // 标题的行数大于等于3行 是true |
| 24 | pageModel: PageModel = new PageModel(); | 25 | pageModel: PageModel = new PageModel(); |
| 25 | - aboutToAppear(): void { | 26 | + @State loadImg: boolean = false; |
| 27 | + | ||
| 28 | + async aboutToAppear(): Promise<void> { | ||
| 29 | + this.loadImg = await onlyWifiLoadImg(); | ||
| 26 | 30 | ||
| 27 | // 计算标题文本行数 | 31 | // 计算标题文本行数 |
| 28 | let screenWith = DisplayUtils.getDeviceWidth(); | 32 | let screenWith = DisplayUtils.getDeviceWidth(); |
| @@ -54,14 +58,14 @@ export struct CardAdvSmallImageComponent { | @@ -54,14 +58,14 @@ export struct CardAdvSmallImageComponent { | ||
| 54 | .id("title_name") | 58 | .id("title_name") |
| 55 | 59 | ||
| 56 | // 广告图 | 60 | // 广告图 |
| 57 | - Image(this.compDTO.matInfo.matImageUrl[0]) | 61 | + Image(this.loadImg ? this.compDTO.matInfo.matImageUrl[0] : '') |
| 58 | .width('34%') | 62 | .width('34%') |
| 59 | .aspectRatio(3 / 2) | 63 | .aspectRatio(3 / 2) |
| 60 | .id('adv_imag') | 64 | .id('adv_imag') |
| 65 | + .backgroundColor(this.loadImg ? $r('app.color.color_B0B0B0') : 0xf5f5f5) | ||
| 61 | .borderWidth(0.5) | 66 | .borderWidth(0.5) |
| 62 | .borderColor($r('app.color.color_0D000000')) | 67 | .borderColor($r('app.color.color_0D000000')) |
| 63 | - .borderRadius(4) | ||
| 64 | - //.alt('wwww.baidu.com') | 68 | + .borderRadius(4)//.alt('wwww.baidu.com') |
| 65 | .alignRules({ | 69 | .alignRules({ |
| 66 | top: { anchor: 'title_name', align: VerticalAlign.Top }, | 70 | top: { anchor: 'title_name', align: VerticalAlign.Top }, |
| 67 | left: { anchor: 'title_name', align: HorizontalAlign.End }, | 71 | left: { anchor: 'title_name', align: HorizontalAlign.End }, |
| @@ -69,7 +73,7 @@ export struct CardAdvSmallImageComponent { | @@ -69,7 +73,7 @@ export struct CardAdvSmallImageComponent { | ||
| 69 | .margin({ left: 12 }) | 73 | .margin({ left: 12 }) |
| 70 | 74 | ||
| 71 | 75 | ||
| 72 | - CardAdvBottom({pageModel:this.pageModel,compDTO:this.compDTO}).width('62%').id('bottom_adv').alignRules({ | 76 | + CardAdvBottom({ pageModel: this.pageModel, compDTO: this.compDTO }).width('62%').id('bottom_adv').alignRules({ |
| 73 | bottom: { anchor: this.isBigThreeLine ? '' : 'adv_imag', align: VerticalAlign.Bottom }, | 77 | bottom: { anchor: this.isBigThreeLine ? '' : 'adv_imag', align: VerticalAlign.Bottom }, |
| 74 | right: { anchor: this.isBigThreeLine ? '' : 'adv_imag', align: HorizontalAlign.Start }, | 78 | right: { anchor: this.isBigThreeLine ? '' : 'adv_imag', align: HorizontalAlign.Start }, |
| 75 | top: { anchor: this.isBigThreeLine ? 'title_name' : '', align: VerticalAlign.Bottom }, | 79 | top: { anchor: this.isBigThreeLine ? 'title_name' : '', align: VerticalAlign.Bottom }, |
| @@ -94,13 +98,15 @@ export struct CardAdvSmallImageComponent { | @@ -94,13 +98,15 @@ export struct CardAdvSmallImageComponent { | ||
| 94 | } | 98 | } |
| 95 | 99 | ||
| 96 | // 获取文本几行 | 100 | // 获取文本几行 |
| 97 | - private getTextLineNum(text: string, constraintWidth: number, lineHeight: number, fontSize: number | string | Resource) { | 101 | + private getTextLineNum(text: string, constraintWidth: number, lineHeight: number, |
| 102 | + fontSize: number | string | Resource) { | ||
| 98 | let size = this.topMeasureText(text, constraintWidth, lineHeight, fontSize) | 103 | let size = this.topMeasureText(text, constraintWidth, lineHeight, fontSize) |
| 99 | let height: number = Number(size.height) | 104 | let height: number = Number(size.height) |
| 100 | return Math.ceil(px2vp(height) / lineHeight) | 105 | return Math.ceil(px2vp(height) / lineHeight) |
| 101 | } | 106 | } |
| 102 | 107 | ||
| 103 | - private topMeasureText(text: string, constraintWidth: number, lineHeight: number, fontSize: number | string | Resource) { | 108 | + private topMeasureText(text: string, constraintWidth: number, lineHeight: number, |
| 109 | + fontSize: number | string | Resource) { | ||
| 104 | return measure.measureTextSize({ | 110 | return measure.measureTextSize({ |
| 105 | textContent: text, | 111 | textContent: text, |
| 106 | fontSize: fontSize, | 112 | fontSize: fontSize, |
| @@ -2,6 +2,7 @@ | @@ -2,6 +2,7 @@ | ||
| 2 | import { CompDTO } from 'wdBean'; | 2 | import { CompDTO } from 'wdBean'; |
| 3 | import { CommonConstants } from 'wdConstant/Index'; | 3 | import { CommonConstants } from 'wdConstant/Index'; |
| 4 | import { ProcessUtils } from 'wdRouter'; | 4 | import { ProcessUtils } from 'wdRouter'; |
| 5 | +import { onlyWifiLoadImg } from '../../utils/lazyloadImg'; | ||
| 5 | import PageModel from '../../viewmodel/PageModel'; | 6 | import PageModel from '../../viewmodel/PageModel'; |
| 6 | import { CardAdvBottom } from './CardAdvBottom'; | 7 | import { CardAdvBottom } from './CardAdvBottom'; |
| 7 | 8 | ||
| @@ -18,9 +19,11 @@ const TAG: string = 'Card2Component'; | @@ -18,9 +19,11 @@ const TAG: string = 'Card2Component'; | ||
| 18 | @Component | 19 | @Component |
| 19 | export struct CardAdvThreeImageComponent { | 20 | export struct CardAdvThreeImageComponent { |
| 20 | @State compDTO: CompDTO = {} as CompDTO | 21 | @State compDTO: CompDTO = {} as CompDTO |
| 22 | + @State loadImg: boolean = false; | ||
| 21 | pageModel: PageModel = new PageModel(); | 23 | pageModel: PageModel = new PageModel(); |
| 22 | - aboutToAppear(): void { | ||
| 23 | 24 | ||
| 25 | + async aboutToAppear(): Promise<void> { | ||
| 26 | + this.loadImg = await onlyWifiLoadImg(); | ||
| 24 | } | 27 | } |
| 25 | 28 | ||
| 26 | aboutToDisappear(): void { | 29 | aboutToDisappear(): void { |
| @@ -43,7 +46,8 @@ export struct CardAdvThreeImageComponent { | @@ -43,7 +46,8 @@ export struct CardAdvThreeImageComponent { | ||
| 43 | ForEach(this.compDTO.matInfo.matImageUrl, (url: string, index: number) => { | 46 | ForEach(this.compDTO.matInfo.matImageUrl, (url: string, index: number) => { |
| 44 | if (index < 3) { | 47 | if (index < 3) { |
| 45 | GridCol({ span: { xs: 4 } }) { | 48 | GridCol({ span: { xs: 4 } }) { |
| 46 | - Image(url) | 49 | + Image(this.loadImg ? url : '') |
| 50 | + .backgroundColor(this.loadImg ? $r('app.color.color_B0B0B0') : 0xf5f5f5) | ||
| 47 | .width('100%') | 51 | .width('100%') |
| 48 | .aspectRatio(113 / 75) | 52 | .aspectRatio(113 / 75) |
| 49 | .borderRadius({ | 53 | .borderRadius({ |
| @@ -62,7 +66,7 @@ export struct CardAdvThreeImageComponent { | @@ -62,7 +66,7 @@ export struct CardAdvThreeImageComponent { | ||
| 62 | .margin({ top: 8 }) | 66 | .margin({ top: 8 }) |
| 63 | 67 | ||
| 64 | // 广告工具组件 | 68 | // 广告工具组件 |
| 65 | - CardAdvBottom({pageModel:this.pageModel,compDTO:this.compDTO}).width('100%').margin({ top: 8 }) | 69 | + CardAdvBottom({ pageModel: this.pageModel, compDTO: this.compDTO }).width('100%').margin({ top: 8 }) |
| 66 | } | 70 | } |
| 67 | .width('100%') | 71 | .width('100%') |
| 68 | .justifyContent(FlexAlign.Start) | 72 | .justifyContent(FlexAlign.Start) |
| @@ -2,6 +2,7 @@ | @@ -2,6 +2,7 @@ | ||
| 2 | import { CompDTO, ContentDTO } from 'wdBean'; | 2 | import { CompDTO, ContentDTO } from 'wdBean'; |
| 3 | import { CommonConstants } from 'wdConstant/Index'; | 3 | import { CommonConstants } from 'wdConstant/Index'; |
| 4 | import { ProcessUtils } from 'wdRouter'; | 4 | import { ProcessUtils } from 'wdRouter'; |
| 5 | +import { onlyWifiLoadImg } from '../../utils/lazyloadImg'; | ||
| 5 | import PageModel from '../../viewmodel/PageModel'; | 6 | import PageModel from '../../viewmodel/PageModel'; |
| 6 | import { CardMediaInfo } from '../cardCommon/CardMediaInfo'; | 7 | import { CardMediaInfo } from '../cardCommon/CardMediaInfo'; |
| 7 | import { CardAdvBottom } from './CardAdvBottom'; | 8 | import { CardAdvBottom } from './CardAdvBottom'; |
| @@ -20,11 +21,11 @@ const TAG: string = 'Card2Component'; | @@ -20,11 +21,11 @@ const TAG: string = 'Card2Component'; | ||
| 20 | export struct CardAdvVideoComponent { | 21 | export struct CardAdvVideoComponent { |
| 21 | @State compDTO: CompDTO = {} as CompDTO | 22 | @State compDTO: CompDTO = {} as CompDTO |
| 22 | @State contentDTO: ContentDTO = new ContentDTO() | 23 | @State contentDTO: ContentDTO = new ContentDTO() |
| 24 | + @State loadImg: boolean = false; | ||
| 23 | pageModel: PageModel = new PageModel(); | 25 | pageModel: PageModel = new PageModel(); |
| 24 | - aboutToAppear(): void { | ||
| 25 | 26 | ||
| 26 | - // this.contentDTO.objectType = '1' | ||
| 27 | - // this.contentDTO.videoInfo = { videoDuration: 1000 } as VideoInfoDTO | 27 | + async aboutToAppear(): Promise<void> { |
| 28 | + this.loadImg = await onlyWifiLoadImg(); | ||
| 28 | } | 29 | } |
| 29 | 30 | ||
| 30 | aboutToDisappear(): void { | 31 | aboutToDisappear(): void { |
| @@ -39,7 +40,8 @@ export struct CardAdvVideoComponent { | @@ -39,7 +40,8 @@ export struct CardAdvVideoComponent { | ||
| 39 | Text(this.compDTO.matInfo.advTitle).bottomTextStyle() | 40 | Text(this.compDTO.matInfo.advTitle).bottomTextStyle() |
| 40 | //大图 | 41 | //大图 |
| 41 | Stack() { | 42 | Stack() { |
| 42 | - Image(this.compDTO.matInfo.matImageUrl[0]) | 43 | + Image(this.loadImg ? this.compDTO.matInfo.matImageUrl[0] : '') |
| 44 | + .backgroundColor(this.loadImg ? $r('app.color.color_B0B0B0') : 0xf5f5f5) | ||
| 43 | .width(CommonConstants.FULL_WIDTH) | 45 | .width(CommonConstants.FULL_WIDTH) |
| 44 | .aspectRatio(16 / 9) | 46 | .aspectRatio(16 / 9) |
| 45 | .borderRadius(4) | 47 | .borderRadius(4) |
| @@ -54,7 +56,7 @@ export struct CardAdvVideoComponent { | @@ -54,7 +56,7 @@ export struct CardAdvVideoComponent { | ||
| 54 | .width(CommonConstants.FULL_WIDTH) | 56 | .width(CommonConstants.FULL_WIDTH) |
| 55 | .margin({ top: 8 }) | 57 | .margin({ top: 8 }) |
| 56 | 58 | ||
| 57 | - CardAdvBottom({pageModel:this.pageModel,compDTO:this.compDTO}).margin({ | 59 | + CardAdvBottom({ pageModel: this.pageModel, compDTO: this.compDTO }).margin({ |
| 58 | top: 8, | 60 | top: 8, |
| 59 | }) | 61 | }) |
| 60 | } | 62 | } |
| @@ -3,6 +3,7 @@ import { AdvExtraData, AdvExtraItemData } from 'wdBean/src/main/ets/bean/adv/Adv | @@ -3,6 +3,7 @@ import { AdvExtraData, AdvExtraItemData } from 'wdBean/src/main/ets/bean/adv/Adv | ||
| 3 | import { CompAdvMatInfoBean } from 'wdBean/src/main/ets/bean/adv/CompAdvInfoBean'; | 3 | import { CompAdvMatInfoBean } from 'wdBean/src/main/ets/bean/adv/CompAdvInfoBean'; |
| 4 | import { CommonConstants } from 'wdConstant/Index'; | 4 | import { CommonConstants } from 'wdConstant/Index'; |
| 5 | import { ProcessUtils } from 'wdRouter'; | 5 | import { ProcessUtils } from 'wdRouter'; |
| 6 | +import { onlyWifiLoadImg } from '../../utils/lazyloadImg'; | ||
| 6 | import PageModel from '../../viewmodel/PageModel'; | 7 | import PageModel from '../../viewmodel/PageModel'; |
| 7 | import { CardAdvTop } from './CardAdvTop'; | 8 | import { CardAdvTop } from './CardAdvTop'; |
| 8 | 9 | ||
| @@ -21,9 +22,10 @@ export struct CardAdvVideoExComponent { | @@ -21,9 +22,10 @@ export struct CardAdvVideoExComponent { | ||
| 21 | @State compDTO: CompDTO = {} as CompDTO | 22 | @State compDTO: CompDTO = {} as CompDTO |
| 22 | @State advExtraData: AdvExtraData = {} as AdvExtraData | 23 | @State advExtraData: AdvExtraData = {} as AdvExtraData |
| 23 | pageModel: PageModel = new PageModel(); | 24 | pageModel: PageModel = new PageModel(); |
| 25 | + @State loadImg: boolean = false; | ||
| 24 | 26 | ||
| 25 | - aboutToAppear(): void { | ||
| 26 | - | 27 | + async aboutToAppear(): Promise<void> { |
| 28 | + this.loadImg = await onlyWifiLoadImg(); | ||
| 27 | 29 | ||
| 28 | let extraData = this.compDTO.matInfo.extraData | 30 | let extraData = this.compDTO.matInfo.extraData |
| 29 | let labelDTO = JSON.parse(extraData) as AdvExtraData | 31 | let labelDTO = JSON.parse(extraData) as AdvExtraData |
| @@ -40,14 +42,14 @@ export struct CardAdvVideoExComponent { | @@ -40,14 +42,14 @@ export struct CardAdvVideoExComponent { | ||
| 40 | 42 | ||
| 41 | Stack() { | 43 | Stack() { |
| 42 | //长图 | 44 | //长图 |
| 43 | - Image(this.advExtraData.itemTopImage) | 45 | + Image(this.loadImg ? this.advExtraData.itemTopImage : '') |
| 44 | .width(CommonConstants.FULL_WIDTH) | 46 | .width(CommonConstants.FULL_WIDTH) |
| 47 | + .backgroundColor(this.loadImg ? $r('app.color.color_B0B0B0') : 0xf5f5f5) | ||
| 45 | .aspectRatio(343 / 80) | 48 | .aspectRatio(343 / 80) |
| 46 | .borderRadius(4) | 49 | .borderRadius(4) |
| 47 | .borderWidth(0.5) | 50 | .borderWidth(0.5) |
| 48 | .borderColor($r('app.color.color_0D000000')) | 51 | .borderColor($r('app.color.color_0D000000')) |
| 49 | 52 | ||
| 50 | - | ||
| 51 | CardAdvTop({ pageModel: this.pageModel, compDTO: this.compDTO }) | 53 | CardAdvTop({ pageModel: this.pageModel, compDTO: this.compDTO }) |
| 52 | } | 54 | } |
| 53 | .alignContent(Alignment.Top) | 55 | .alignContent(Alignment.Top) |
| @@ -78,9 +78,12 @@ export struct PeopleShipHomeArticleListComponent { | @@ -78,9 +78,12 @@ export struct PeopleShipHomeArticleListComponent { | ||
| 78 | 78 | ||
| 79 | List({scroller: this.scroller}) { | 79 | List({scroller: this.scroller}) { |
| 80 | // 下拉刷新 | 80 | // 下拉刷新 |
| 81 | - ForEach(this.arr, (item: ContentDTO) => { | 81 | + ForEach(this.arr, (item: ContentDTO, index: number) => { |
| 82 | ListItem() { | 82 | ListItem() { |
| 83 | - CardParser({compDTO:new CompDTO, contentDTO: item }) | 83 | + Column() { |
| 84 | + CardParser({compDTO:new CompDTO, contentDTO: item }) | ||
| 85 | + Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 }) | ||
| 86 | + } | ||
| 84 | }.width("100%") | 87 | }.width("100%") |
| 85 | .backgroundColor(Color.Transparent) | 88 | .backgroundColor(Color.Transparent) |
| 86 | }, (item: ContentDTO, index: number) => item.objectId + index.toString()) | 89 | }, (item: ContentDTO, index: number) => item.objectId + index.toString()) |
-
Please register or login to post a comment