ImageAndTextPageComponent.ets 3.2 KB
import { ContentDetailDTO } from 'wdBean';
import DetailViewModel from '../viewmodel/DetailViewModel';
import { ImageAndTextWebComponent } from './ImageAndTextWebComponent';

@Component
export struct ImageAndTextPageComponent {

  scroller: Scroller = new Scroller();
  @State relId: string= ''
  @State contentId: string= ''
  @State relType: string= ''
  @State detailData: ContentDetailDTO = {} as ContentDetailDTO

  build(){
    RelativeContainer() {
      RelativeContainer(){
        Image($r('app.media.icon_ren_min_ri_bao'))
          .width(70)
          .height(28)
          .alignRules({top:{anchor: "__container__", align: VerticalAlign.Top},
                       left:{anchor: "__container__", align: HorizontalAlign.Start}})

        Text(this.detailData.publishTime)
          .fontColor($r('app.color.color_B0B0B0'))
          .fontSize($r('app.float.font_size_13'))
          .alignRules({top:{anchor: "__container__", align: VerticalAlign.Top},
            right:{anchor: "__container__", align: HorizontalAlign.End}})
      }
      .width('100%')
      .id('image_text_detail_top')
      .alignRules({top:{anchor: "__container__", align: VerticalAlign.Top}})

      Image($r('app.media.line'))
        .width('100%')
        .height(6)
        .objectFit(ImageFit.Contain)
        .id('image_text_detail_top_line')
        .alignRules({top:{anchor: "image_text_detail_top", align: VerticalAlign.Bottom}})
        .margin({top: 10})

      Scroll(this.scroller) {
        Column() {
          ImageAndTextWebComponent({detailData: this.detailData})
        }
        .width('100%')
      }
      .scrollable(ScrollDirection.Vertical)
      .scrollBar(BarState.Off)
      .alignRules({top:{anchor: "image_text_detail_top_line", align: VerticalAlign.Bottom}})
      .id('image_text_detail_content')

      RelativeContainer(){
        Image($r('app.media.icon_arrow_left'))
          .width(24)
          .height(24)
          .alignRules({left:{anchor: "__container__", align: HorizontalAlign.Start},
            center:{anchor: "__container__", align: VerticalAlign.Center}})

        Row(){
          Image($r('app.media.icon_comment'))
            .width(24)
            .height(24)
            .margin({left: 24})

          Image($r('app.media.icon_star'))
            .width(24)
            .height(24)
            .margin({left: 24})

          Image($r('app.media.icon_listen'))
            .width(24)
            .height(24)
            .margin({left: 24})

          Image($r('app.media.icon_forward'))
            .width(24)
            .height(24)
            .margin({left: 24})
        }
        .alignItems(VerticalAlign.Center)
        .alignRules({right:{anchor: "__container__", align: HorizontalAlign.End},
          center:{anchor: "__container__", align: VerticalAlign.Center}})

      }
      .width('100%')
      .height(56)
      .alignRules({bottom:{anchor: "__container__", align: VerticalAlign.Bottom}})


    }
    .width('100%')
    .height('100%')
    .padding({left: 16, right: 16})
    .backgroundColor(Color.White)
  }

  async aboutToAppear() {
    let detailBean = await DetailViewModel.getDetailPageData(this.relId, this.contentId, this.relType)
    this.detailData = detailBean;
  }

  aboutToDisappear() {

  }

}