张善主

feat(动态详情):页面搭建

  1 +import { Logger } from 'wdKit';
  2 +import { MultiPictureDetailViewModel } from '../viewmodel/MultiPictureDetailViewModel';
  3 +import { ContentDetailDTO } from 'wdBean';
  4 +import media from '@ohos.multimedia.media';
  5 +import { OperRowListView } from './view/OperRowListView';
  6 +import { WDPlayerController } from 'wdPlayer/Index';
  7 +
  8 +const TAG = 'DynamicDetailComponent'
  9 +@Preview
  10 +@Component
  11 +export struct DynamicDetailComponent {
  12 + //入参
  13 + private relId: string = ''
  14 + private contentId: string = ''
  15 + private relType: string = ''
  16 + //出参
  17 + @State contentDetailData: ContentDetailDTO[] = [] as ContentDetailDTO[]
  18 +
  19 +
  20 + async aboutToAppear() {
  21 + await this.getContentDetailData()
  22 + }
  23 + onPageHide() {
  24 +
  25 + }
  26 +
  27 + build() {
  28 + Row() {
  29 + Column(){
  30 + Text("this is a test!")
  31 + }
  32 + }
  33 +
  34 + }
  35 + private async getContentDetailData() {
  36 + try {
  37 + let data = await MultiPictureDetailViewModel.getDetailData(this.relId, this.contentId, this.relType)
  38 + this.contentDetailData = data;
  39 + console.log('动态详情',JSON.stringify(this.contentDetailData))
  40 + } catch (exception) {
  41 + console.log('请求失败',JSON.stringify(exception))
  42 + }
  43 + }
  44 +}
  1 +import { Logger } from 'wdKit';
  2 +import { AudioDetailComponent } from 'wdComponent';
  3 +import router from '@ohos.router';
  4 +import { Params, Action } from 'wdBean';
  5 +const TAG = 'DynamicDetailPage';
  6 +@Entry
  7 +@Component
  8 +struct DynamicDetailPage {
  9 +
  10 + @State relId: string = ''
  11 + @State contentId: string = ''
  12 + @State relType: string = ''
  13 +
  14 + build() {
  15 + Column() {
  16 + AudioDetailComponent({
  17 + relId: this.relId,
  18 + contentId: this.contentId,
  19 + relType: this.relType
  20 + })
  21 + }
  22 + .height('100%')
  23 + .width('100%')
  24 + .backgroundColor('#20272E')
  25 + }
  26 + aboutToAppear() {
  27 + let par:Action = router.getParams() as Action;
  28 + let params = par?.params;
  29 + this.relId = params?.extra?.relId || '';
  30 + this.relType = params?.extra?.relType || '';
  31 + this.contentId = params?.contentID || '';
  32 + }
  33 +}