Showing
2 changed files
with
82 additions
and
42 deletions
| @@ -21,7 +21,7 @@ export struct MultiPictureDetailItemComponent { | @@ -21,7 +21,7 @@ export struct MultiPictureDetailItemComponent { | ||
| 21 | .alt($r('app.media.picture_loading')) | 21 | .alt($r('app.media.picture_loading')) |
| 22 | .width(this.imageWidth) | 22 | .width(this.imageWidth) |
| 23 | .aspectRatio(this.ratio) | 23 | .aspectRatio(this.ratio) |
| 24 | - .objectFit(ImageFit.Fill) | 24 | + .objectFit(ImageFit.Contain) |
| 25 | .interpolation(ImageInterpolation.High) | 25 | .interpolation(ImageInterpolation.High) |
| 26 | .onComplete(event => { | 26 | .onComplete(event => { |
| 27 | this.imageWidth = '100%' | 27 | this.imageWidth = '100%' |
| @@ -12,6 +12,7 @@ import display from '@ohos.display'; | @@ -12,6 +12,7 @@ import display from '@ohos.display'; | ||
| 12 | import font from '@ohos.font'; | 12 | import font from '@ohos.font'; |
| 13 | import { OperRowListView } from './view/OperRowListView'; | 13 | import { OperRowListView } from './view/OperRowListView'; |
| 14 | import { MultiPictureDetailItemComponent } from './MultiPictureDetailItemComponent'; | 14 | import { MultiPictureDetailItemComponent } from './MultiPictureDetailItemComponent'; |
| 15 | +import { ImageDownloadComponent } from '../components/ImageDownloadComponent'; | ||
| 15 | import { EmptyComponent } from './view/EmptyComponent'; | 16 | import { EmptyComponent } from './view/EmptyComponent'; |
| 16 | import { DateTimeUtils } from 'wdKit/Index'; | 17 | import { DateTimeUtils } from 'wdKit/Index'; |
| 17 | import { HttpUrlUtils } from 'wdNetwork/Index'; | 18 | import { HttpUrlUtils } from 'wdNetwork/Index'; |
| @@ -37,9 +38,10 @@ export struct MultiPictureDetailPageComponent { | @@ -37,9 +38,10 @@ export struct MultiPictureDetailPageComponent { | ||
| 37 | private swiperController: SwiperController = new SwiperController() | 38 | private swiperController: SwiperController = new SwiperController() |
| 38 | private swiperControllerItem: SwiperController = new SwiperController() | 39 | private swiperControllerItem: SwiperController = new SwiperController() |
| 39 | @State swiperIndex: number = 0; | 40 | @State swiperIndex: number = 0; |
| 40 | - @Provide followStatus: string = '0' // 关注状态 | 41 | + @Provide followStatus: string | undefined = undefined // 关注状态 |
| 41 | private scroller: Scroller = new Scroller() | 42 | private scroller: Scroller = new Scroller() |
| 42 | @State netStatus: number | undefined = undefined // 存储网络状态用来展示缺省图 | 43 | @State netStatus: number | undefined = undefined // 存储网络状态用来展示缺省图 |
| 44 | + @State showDownload: Boolean = false // 控制是否显示下载默认隐藏 | ||
| 43 | 45 | ||
| 44 | //watch监听页码回调 | 46 | //watch监听页码回调 |
| 45 | onCurrentPageNumUpdated(): void { | 47 | onCurrentPageNumUpdated(): void { |
| @@ -146,8 +148,8 @@ export struct MultiPictureDetailPageComponent { | @@ -146,8 +148,8 @@ export struct MultiPictureDetailPageComponent { | ||
| 146 | right: 0 | 148 | right: 0 |
| 147 | }) | 149 | }) |
| 148 | 150 | ||
| 149 | - if (this.followStatus == '0') { | ||
| 150 | Row() { | 151 | Row() { |
| 152 | + if (this.followStatus == '0') { | ||
| 151 | Button({ type: ButtonType.Normal, stateEffect: true }) { | 153 | Button({ type: ButtonType.Normal, stateEffect: true }) { |
| 152 | Row() { | 154 | Row() { |
| 153 | Text('+关注').fontSize(12).fontColor(0xffffff) | 155 | Text('+关注').fontSize(12).fontColor(0xffffff) |
| @@ -160,15 +162,27 @@ export struct MultiPictureDetailPageComponent { | @@ -160,15 +162,27 @@ export struct MultiPictureDetailPageComponent { | ||
| 160 | .onClick(() => { | 162 | .onClick(() => { |
| 161 | this.handleAccention() | 163 | this.handleAccention() |
| 162 | }) | 164 | }) |
| 165 | + } else { | ||
| 166 | + Button({ type: ButtonType.Normal, stateEffect: true }) { | ||
| 167 | + Row() { | ||
| 168 | + Text('已关注').fontSize(12).fontColor(0xffffff) | ||
| 169 | + }.alignItems(VerticalAlign.Center) | ||
| 170 | + } | ||
| 171 | + .borderRadius(4) | ||
| 172 | + .backgroundColor('#B0B0B0') | ||
| 173 | + .width(48) | ||
| 174 | + .height(24) | ||
| 175 | + } | ||
| 176 | + | ||
| 163 | } | 177 | } |
| 164 | .justifyContent(FlexAlign.Center) | 178 | .justifyContent(FlexAlign.Center) |
| 165 | .alignItems(VerticalAlign.Center) | 179 | .alignItems(VerticalAlign.Center) |
| 166 | .width('21.6%') | 180 | .width('21.6%') |
| 167 | .height('100%') | 181 | .height('100%') |
| 168 | } | 182 | } |
| 169 | - } | ||
| 170 | .width('100%') | 183 | .width('100%') |
| 171 | .height(44) | 184 | .height(44) |
| 185 | + .zIndex(10) | ||
| 172 | .alignRules({ | 186 | .alignRules({ |
| 173 | top: { anchor: "__container__", align: VerticalAlign.Top }, | 187 | top: { anchor: "__container__", align: VerticalAlign.Top }, |
| 174 | middle: { anchor: "__container__", align: HorizontalAlign.Center } | 188 | middle: { anchor: "__container__", align: HorizontalAlign.Center } |
| @@ -195,7 +209,7 @@ export struct MultiPictureDetailPageComponent { | @@ -195,7 +209,7 @@ export struct MultiPictureDetailPageComponent { | ||
| 195 | } | 209 | } |
| 196 | .index(this.swiperIndex) | 210 | .index(this.swiperIndex) |
| 197 | .width('100%') | 211 | .width('100%') |
| 198 | - .height(px2vp(this.picHeight) + 32) | 212 | + .height('100%') |
| 199 | .vertical(false) | 213 | .vertical(false) |
| 200 | .autoPlay(false) | 214 | .autoPlay(false) |
| 201 | .cachedCount(3) | 215 | .cachedCount(3) |
| @@ -207,10 +221,28 @@ export struct MultiPictureDetailPageComponent { | @@ -207,10 +221,28 @@ export struct MultiPictureDetailPageComponent { | ||
| 207 | center: { anchor: "__container__", align: VerticalAlign.Center }, | 221 | center: { anchor: "__container__", align: VerticalAlign.Center }, |
| 208 | middle: { anchor: "__container__", align: HorizontalAlign.Center } | 222 | middle: { anchor: "__container__", align: HorizontalAlign.Center } |
| 209 | }) | 223 | }) |
| 224 | + .zIndex(1) | ||
| 210 | .onChange((index: number) => { | 225 | .onChange((index: number) => { |
| 211 | this.swiperIndex = index | 226 | this.swiperIndex = index |
| 212 | }) | 227 | }) |
| 213 | - | 228 | + .onClick(() => { |
| 229 | + this.showDownload = !this.showDownload | ||
| 230 | + }) | ||
| 231 | + } | ||
| 232 | + if (this.netStatus !== undefined) { | ||
| 233 | + EmptyComponent({ | ||
| 234 | + emptyType: this.netStatus, emptyButton: true, retry: () => { | ||
| 235 | + this.getContentDetailData() | ||
| 236 | + } | ||
| 237 | + }) | ||
| 238 | + .id('e_empty_content') | ||
| 239 | + .alignRules({ | ||
| 240 | + center: { anchor: "__container__", align: VerticalAlign.Center }, | ||
| 241 | + middle: { anchor: "__container__", align: HorizontalAlign.Center } | ||
| 242 | + }) | ||
| 243 | + } | ||
| 244 | + Column(){ | ||
| 245 | + Column(){ | ||
| 214 | Row() { | 246 | Row() { |
| 215 | Scroll(this.scroller) { | 247 | Scroll(this.scroller) { |
| 216 | Row() { | 248 | Row() { |
| @@ -224,12 +256,14 @@ export struct MultiPictureDetailPageComponent { | @@ -224,12 +256,14 @@ export struct MultiPictureDetailPageComponent { | ||
| 224 | .fontFamily('PingFang SC-Medium') | 256 | .fontFamily('PingFang SC-Medium') |
| 225 | .fontWeight(500) | 257 | .fontWeight(500) |
| 226 | .lineHeight(28) | 258 | .lineHeight(28) |
| 227 | - Span(`/${this.contentDetailData.photoList.length}`) | 259 | + Span(`/${this.contentDetailData?.photoList?.length}`) |
| 228 | .fontSize(14) | 260 | .fontSize(14) |
| 229 | .fontFamily('PingFang SC-Medium') | 261 | .fontFamily('PingFang SC-Medium') |
| 230 | .fontWeight(500) | 262 | .fontWeight(500) |
| 231 | .lineHeight(19) | 263 | .lineHeight(19) |
| 232 | - }.fontColor(Color.White).margin(4) | 264 | + } |
| 265 | + .fontColor(Color.White) | ||
| 266 | + .margin(4) | ||
| 233 | 267 | ||
| 234 | Text(`${this.contentDetailData.newsTitle}`) | 268 | Text(`${this.contentDetailData.newsTitle}`) |
| 235 | .fontColor(Color.White) | 269 | .fontColor(Color.White) |
| @@ -260,54 +294,60 @@ export struct MultiPictureDetailPageComponent { | @@ -260,54 +294,60 @@ export struct MultiPictureDetailPageComponent { | ||
| 260 | } | 294 | } |
| 261 | } | 295 | } |
| 262 | .width('100%') | 296 | .width('100%') |
| 263 | - .margin({ | ||
| 264 | - top: 8, | ||
| 265 | - left: 18, | ||
| 266 | - bottom: 24, | ||
| 267 | - right: 18 | ||
| 268 | - }) | ||
| 269 | } | 297 | } |
| 270 | .scrollable(ScrollDirection.Vertical) | 298 | .scrollable(ScrollDirection.Vertical) |
| 271 | .scrollBarWidth(0) | 299 | .scrollBarWidth(0) |
| 272 | .height(px2vp(this.titleHeight)) | 300 | .height(px2vp(this.titleHeight)) |
| 301 | + .align(Alignment.Bottom) | ||
| 273 | } | 302 | } |
| 274 | - .id('e_swiper_titles') | ||
| 275 | - .alignRules({ | ||
| 276 | - bottom: { anchor: "__container__", align: VerticalAlign.Bottom }, | ||
| 277 | - middle: { anchor: "__container__", align: HorizontalAlign.Center } | 303 | + OperRowListView({ |
| 304 | + contentDetailData: this.contentDetailData, | ||
| 278 | }) | 305 | }) |
| 279 | - .height(px2vp(this.titleHeight) + 64) | ||
| 280 | - | 306 | + .width('100%') |
| 307 | + .height(56) | ||
| 308 | + .border({ width: { top: 0.5 }, color: '#FFFFFF' }) | ||
| 281 | } | 309 | } |
| 282 | - if (this.netStatus !== undefined) { | ||
| 283 | - EmptyComponent({ | ||
| 284 | - emptyType: this.netStatus, emptyButton: true, retry: () => { | ||
| 285 | - this.getContentDetailData() | 310 | + .visibility(!this.showDownload ? Visibility.Visible : Visibility.None) |
| 311 | + Column(){ | ||
| 312 | + Row() { | ||
| 313 | + Flex({ | ||
| 314 | + direction: FlexDirection.Row, | ||
| 315 | + justifyContent: FlexAlign.SpaceBetween | ||
| 316 | + }) { | ||
| 317 | + Text() { | ||
| 318 | + Span(`${this.swiperIndex + 1}`) | ||
| 319 | + .fontSize(24) | ||
| 320 | + .fontFamily('PingFang SC-Medium') | ||
| 321 | + .fontWeight(500) | ||
| 322 | + .lineHeight(28) | ||
| 323 | + Span(`/${this.contentDetailData?.photoList?.length}`) | ||
| 324 | + .fontSize(14) | ||
| 325 | + .fontFamily('PingFang SC-Medium') | ||
| 326 | + .fontWeight(500) | ||
| 327 | + .lineHeight(19) | ||
| 286 | } | 328 | } |
| 287 | - }) | ||
| 288 | - .id('e_empty_content') | ||
| 289 | - .alignRules({ | ||
| 290 | - center: { anchor: "__container__", align: VerticalAlign.Center }, | ||
| 291 | - middle: { anchor: "__container__", align: HorizontalAlign.Center } | 329 | + .fontColor(Color.White) |
| 330 | + .margin(4) | ||
| 331 | + | ||
| 332 | + ImageDownloadComponent({ url: this.contentDetailData.photoList?.[this.swiperIndex].picPath }) | ||
| 333 | + .margin({ | ||
| 334 | + top: 8, | ||
| 335 | + left: 18, | ||
| 336 | + bottom: 24, | ||
| 337 | + right: 18 | ||
| 292 | }) | 338 | }) |
| 293 | } | 339 | } |
| 294 | - OperRowListView({ | ||
| 295 | - contentDetailData: this.contentDetailData, | ||
| 296 | - }) | 340 | + } |
| 341 | + .width('100%') | ||
| 342 | + } | ||
| 343 | + .visibility(this.showDownload ? Visibility.Visible : Visibility.None) | ||
| 344 | + } | ||
| 345 | + .zIndex(10) | ||
| 346 | + .id('e_swiper_bottom') | ||
| 297 | .alignRules({ | 347 | .alignRules({ |
| 298 | bottom: { anchor: "__container__", align: VerticalAlign.Bottom }, | 348 | bottom: { anchor: "__container__", align: VerticalAlign.Bottom }, |
| 299 | middle: { anchor: "__container__", align: HorizontalAlign.Center } | 349 | middle: { anchor: "__container__", align: HorizontalAlign.Center } |
| 300 | }) | 350 | }) |
| 301 | - .width('100%') | ||
| 302 | - .height(56) | ||
| 303 | - .margin({ | ||
| 304 | - top: 16, | ||
| 305 | - left: 16, | ||
| 306 | - right: 16, | ||
| 307 | - bottom: 0 | ||
| 308 | - }) | ||
| 309 | - .border({ width: { top: 0.5 }, color: '#FFFFFF' }) | ||
| 310 | - .id('e_oper_row') | ||
| 311 | } | 351 | } |
| 312 | 352 | ||
| 313 | getContentDetailData() { | 353 | getContentDetailData() { |
-
Please register or login to post a comment