Showing
16 changed files
with
108 additions
and
43 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 | } |
| @@ -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 | } |
| @@ -5,7 +5,6 @@ import { | @@ -5,7 +5,6 @@ import { | ||
| 5 | EmitterUtils, | 5 | EmitterUtils, |
| 6 | EmitterEventId, | 6 | EmitterEventId, |
| 7 | NetworkUtil, | 7 | NetworkUtil, |
| 8 | - DisplayUtils | ||
| 9 | } from 'wdKit'; | 8 | } from 'wdKit'; |
| 10 | import { | 9 | import { |
| 11 | Action, | 10 | Action, |
| @@ -33,6 +32,7 @@ import { CommentComponent } from '../components/comment/view/CommentComponent' | @@ -33,6 +32,7 @@ import { CommentComponent } from '../components/comment/view/CommentComponent' | ||
| 33 | import { HttpUtils } from 'wdNetwork/Index'; | 32 | import { HttpUtils } from 'wdNetwork/Index'; |
| 34 | import { viewBlogItemInsightIntentShare } from '../utils/InsightIntentShare' | 33 | import { viewBlogItemInsightIntentShare } from '../utils/InsightIntentShare' |
| 35 | import { common } from '@kit.AbilityKit'; | 34 | import { common } from '@kit.AbilityKit'; |
| 35 | +import { componentUtils, window } from '@kit.ArkUI'; | ||
| 36 | 36 | ||
| 37 | const PATTERN_DATE_CN_RN: string = 'yyyy年MM月dd日 HH:mm'; | 37 | const PATTERN_DATE_CN_RN: string = 'yyyy年MM月dd日 HH:mm'; |
| 38 | 38 | ||
| @@ -58,6 +58,9 @@ export struct ImageAndTextPageComponent { | @@ -58,6 +58,9 @@ export struct ImageAndTextPageComponent { | ||
| 58 | @State likeNum: number = 0 | 58 | @State likeNum: number = 0 |
| 59 | @State reachEndIncreament: number = 0 | 59 | @State reachEndIncreament: number = 0 |
| 60 | @State bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0 | 60 | @State bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0 |
| 61 | + @State isScrollTop: boolean = true | ||
| 62 | + @State offsetY: number = 0 | ||
| 63 | + | ||
| 61 | build() { | 64 | build() { |
| 62 | Stack({ alignContent: Alignment.Top }) { | 65 | Stack({ alignContent: Alignment.Top }) { |
| 63 | Stack({ alignContent: Alignment.Bottom }) { | 66 | Stack({ alignContent: Alignment.Bottom }) { |
| @@ -125,9 +128,11 @@ export struct ImageAndTextPageComponent { | @@ -125,9 +128,11 @@ export struct ImageAndTextPageComponent { | ||
| 125 | fixedHeightMode: false, | 128 | fixedHeightMode: false, |
| 126 | reachEndIncreament: this.reachEndIncreament, | 129 | reachEndIncreament: this.reachEndIncreament, |
| 127 | reachEndLoadMoreFinish: () => { | 130 | reachEndLoadMoreFinish: () => { |
| 128 | - | ||
| 129 | } | 131 | } |
| 130 | - }).onAreaChange((oldValue: Area, newValue: Area) => { | 132 | + |
| 133 | + }).id('comment') | ||
| 134 | + | ||
| 135 | + .onAreaChange((oldValue: Area, newValue: Area) => { | ||
| 131 | this.info = newValue | 136 | this.info = newValue |
| 132 | }) | 137 | }) |
| 133 | // .onMeasureSize() | 138 | // .onMeasureSize() |
| @@ -135,6 +140,7 @@ export struct ImageAndTextPageComponent { | @@ -135,6 +140,7 @@ export struct ImageAndTextPageComponent { | ||
| 135 | } | 140 | } |
| 136 | } | 141 | } |
| 137 | } | 142 | } |
| 143 | + .id('imgTextContainer') | ||
| 138 | } | 144 | } |
| 139 | .width(CommonConstants.FULL_WIDTH) | 145 | .width(CommonConstants.FULL_WIDTH) |
| 140 | .height(CommonConstants.FULL_HEIGHT) | 146 | .height(CommonConstants.FULL_HEIGHT) |
| @@ -163,8 +169,27 @@ export struct ImageAndTextPageComponent { | @@ -163,8 +169,27 @@ export struct ImageAndTextPageComponent { | ||
| 163 | publishCommentModel: this.publishCommentModel, | 169 | publishCommentModel: this.publishCommentModel, |
| 164 | operationButtonList: this.operationButtonList, | 170 | operationButtonList: this.operationButtonList, |
| 165 | styleType: 1, | 171 | styleType: 1, |
| 172 | + onCommentIconClick: () => { | ||
| 173 | + const info = componentUtils.getRectangleById('comment'); | ||
| 174 | + console.log(JSON.stringify(info)) | ||
| 175 | + | ||
| 176 | + if (!this.offsetY) { | ||
| 177 | + this.offsetY = componentUtils.getRectangleById('comment').windowOffset.y | ||
| 178 | + } | ||
| 179 | + // 定位到评论区域 | ||
| 180 | + if (this.isScrollTop) { | ||
| 181 | + this.scroller.scrollTo({ | ||
| 182 | + xOffset: 0, | ||
| 183 | + yOffset: this.offsetY, | ||
| 184 | + animation: true | ||
| 185 | + }) | ||
| 186 | + } else { | ||
| 187 | + this.scroller.scrollEdge(Edge.Top) | ||
| 188 | + } | ||
| 189 | + this.isScrollTop = !this.isScrollTop | ||
| 190 | + } | ||
| 166 | }) | 191 | }) |
| 167 | - .position({y: '100%'}) | 192 | + .position({ y: '100%' }) |
| 168 | } | 193 | } |
| 169 | .width(CommonConstants.FULL_WIDTH) | 194 | .width(CommonConstants.FULL_WIDTH) |
| 170 | .height(CommonConstants.FULL_HEIGHT) | 195 | .height(CommonConstants.FULL_HEIGHT) |
| @@ -174,7 +199,7 @@ export struct ImageAndTextPageComponent { | @@ -174,7 +199,7 @@ export struct ImageAndTextPageComponent { | ||
| 174 | // 发布时间 | 199 | // 发布时间 |
| 175 | Column() { | 200 | Column() { |
| 176 | Row() { | 201 | Row() { |
| 177 | - if(this.isNetConnected && !this.detailContentEmpty) { | 202 | + if (this.isNetConnected && !this.detailContentEmpty) { |
| 178 | Image(this.contentDetailData?.rmhInfo ? $r('app.media.logo_rmh') : $r('app.media.logo_rmrb')) | 203 | Image(this.contentDetailData?.rmhInfo ? $r('app.media.logo_rmh') : $r('app.media.logo_rmrb')) |
| 179 | .width(80) | 204 | .width(80) |
| 180 | .height(28) | 205 | .height(28) |
| @@ -207,7 +232,7 @@ export struct ImageAndTextPageComponent { | @@ -207,7 +232,7 @@ export struct ImageAndTextPageComponent { | ||
| 207 | 232 | ||
| 208 | private async getDetail() { | 233 | private async getDetail() { |
| 209 | this.isNetConnected = NetworkUtil.isNetConnected() | 234 | this.isNetConnected = NetworkUtil.isNetConnected() |
| 210 | - if(!this.isNetConnected) { | 235 | + if (!this.isNetConnected) { |
| 211 | this.emptyType = 1 | 236 | this.emptyType = 1 |
| 212 | } | 237 | } |
| 213 | let contentId: string = '' | 238 | let contentId: string = '' |
| @@ -229,7 +254,7 @@ export struct ImageAndTextPageComponent { | @@ -229,7 +254,7 @@ export struct ImageAndTextPageComponent { | ||
| 229 | let detailBeans = await DetailViewModel.getDetailPageData(relId, contentId, relType) | 254 | let detailBeans = await DetailViewModel.getDetailPageData(relId, contentId, relType) |
| 230 | // 判断内容是否已下线,空数组表示下线 | 255 | // 判断内容是否已下线,空数组表示下线 |
| 231 | this.detailContentEmpty = detailBeans.length === 0 ? true : false | 256 | this.detailContentEmpty = detailBeans.length === 0 ? true : false |
| 232 | - if(this.detailContentEmpty) { | 257 | + if (this.detailContentEmpty) { |
| 233 | this.emptyType = 18 | 258 | this.emptyType = 18 |
| 234 | } | 259 | } |
| 235 | console.log(TAG, JSON.stringify(detailBeans)) | 260 | console.log(TAG, JSON.stringify(detailBeans)) |
| @@ -270,12 +295,11 @@ export struct ImageAndTextPageComponent { | @@ -270,12 +295,11 @@ export struct ImageAndTextPageComponent { | ||
| 270 | } | 295 | } |
| 271 | 296 | ||
| 272 | //意图上报 | 297 | //意图上报 |
| 273 | - private viewBlogInsightIntentShare(){ | 298 | + private viewBlogInsightIntentShare() { |
| 274 | let context = getContext(this) as common.UIAbilityContext; | 299 | let context = getContext(this) as common.UIAbilityContext; |
| 275 | - viewBlogItemInsightIntentShare(context,this.contentDetailData, this.interactData) | 300 | + viewBlogItemInsightIntentShare(context, this.contentDetailData, this.interactData) |
| 276 | } | 301 | } |
| 277 | 302 | ||
| 278 | - | ||
| 279 | private async getRecommend() { | 303 | private async getRecommend() { |
| 280 | let params: postRecommendListParams = { | 304 | let params: postRecommendListParams = { |
| 281 | imei: HttpUtils.getImei(), | 305 | imei: HttpUtils.getImei(), |
| @@ -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) |
| @@ -9,7 +9,7 @@ import { ContentDetailDTO } from 'wdBean/Index' | @@ -9,7 +9,7 @@ import { ContentDetailDTO } from 'wdBean/Index' | ||
| 9 | export struct CommentTabComponent { | 9 | export struct CommentTabComponent { |
| 10 | private onCommentFocus: () => void = () => { | 10 | private onCommentFocus: () => void = () => { |
| 11 | } | 11 | } |
| 12 | - private onLoad: (dialogController: CustomDialogController) => void = () => { | 12 | + private onLoad: (dialogController: CustomDialogController | null) => void = () => { |
| 13 | } | 13 | } |
| 14 | @ObjectLink publishCommentModel: publishCommentModel | 14 | @ObjectLink publishCommentModel: publishCommentModel |
| 15 | @Prop contentDetail: ContentDetailDTO | 15 | @Prop contentDetail: ContentDetailDTO |
| @@ -64,6 +64,7 @@ export struct OperRowListView { | @@ -64,6 +64,7 @@ export struct OperRowListView { | ||
| 64 | /** | 64 | /** |
| 65 | * 用于区分页面类型,在哪个页面嵌套就传相应的值 | 65 | * 用于区分页面类型,在哪个页面嵌套就传相应的值 |
| 66 | * 1:视频详情页 2:竖屏直播页 3:图集 4:横屏直播页 | 66 | * 1:视频详情页 2:竖屏直播页 3:图集 4:横屏直播页 |
| 67 | + * 8: 评论弹框内 | ||
| 67 | */ | 68 | */ |
| 68 | @Prop pageComponentType?: number = -1 | 69 | @Prop pageComponentType?: number = -1 |
| 69 | @Prop showBackIcon?: boolean = true | 70 | @Prop showBackIcon?: boolean = true |
| @@ -208,7 +209,7 @@ export struct OperRowListView { | @@ -208,7 +209,7 @@ export struct OperRowListView { | ||
| 208 | contentDetail: this.contentDetailData, | 209 | contentDetail: this.contentDetailData, |
| 209 | onCommentFocus: this.onCommentFocus, | 210 | onCommentFocus: this.onCommentFocus, |
| 210 | pageComponentType: this.pageComponentType, | 211 | pageComponentType: this.pageComponentType, |
| 211 | - onLoad: (dialogController: CustomDialogController) => { | 212 | + onLoad: (dialogController: CustomDialogController | null) => { |
| 212 | this.dialogController = dialogController | 213 | this.dialogController = dialogController |
| 213 | } | 214 | } |
| 214 | }) | 215 | }) |
| @@ -91,6 +91,7 @@ export struct DetailDialog { | @@ -91,6 +91,7 @@ export struct DetailDialog { | ||
| 91 | 91 | ||
| 92 | OperRowListView({ | 92 | OperRowListView({ |
| 93 | componentType: 1, | 93 | componentType: 1, |
| 94 | + pageComponentType: 8, | ||
| 94 | showBackIcon: false, | 95 | showBackIcon: false, |
| 95 | operationButtonList: ['comment', 'like', 'collect', 'share'], | 96 | operationButtonList: ['comment', 'like', 'collect', 'share'], |
| 96 | contentDetailData: this.contentDetailData, | 97 | contentDetailData: this.contentDetailData, |
-
Please register or login to post a comment