DynamicDetailComponent.ets 3.99 KB
import { Logger } from 'wdKit';
import { MultiPictureDetailViewModel } from '../viewmodel/MultiPictureDetailViewModel';
import { ContentDetailDTO } from 'wdBean';
import media from '@ohos.multimedia.media';
import { OperRowListView } from './view/OperRowListView';
import { WDPlayerController } from 'wdPlayer/Index';

const TAG = 'DynamicDetailComponent'
@Preview
@Component
export struct DynamicDetailComponent {
  //入参
  private relId: string = ''
  private contentId: string = ''
  private relType: string = ''
  //出参
  @State contentDetailData: ContentDetailDTO = {} as ContentDetailDTO
  //变量
  /**
   * 默认未关注 点击去关注
   */
  private  followStatus: boolean = false;


  async aboutToAppear() {
    await this.getContentDetailData()
  }
  onPageHide() {

  }

  build() {
    Row() {
      Column(){
        //logo、日期
        Row() {
          Image($r('app.media.ic_article_rmh'))
            .width(80)
            .height(28)
            .margin({ left: 16 })
          Blank()
          Text("2023年03月14日 08:16")
            .fontColor($r('app.color.color_B0B0B0'))
            .fontSize(12)
            .lineHeight(28)
            .margin({ right: 16 })
        }
        .height(48)
        .width('100%')
        //分割线
        Image($r('app.media.ic_news_detail_division'))
            .width('100%')
            .height(7)
            .margin({left: 16, right: 16} )
        //号主信息
        Row() {
          //头像
          Stack() {
            Image(this.contentDetailData.rmhInfo?.rmhHeadUrl)
              .alt(this.contentDetailData.rmhInfo?.userType=='1'?$r('app.media.default_head'):$r('app.media.icon_default_head_mater'))
              .width('32')
              .height('32')
              .objectFit(ImageFit.Cover)
              .borderRadius(16)
            Image($r('app.media.icon_border_test'))
              .width('48')
              .height('48')
              .objectFit(ImageFit.Cover)
              .borderRadius(24)
          }
          .width(48)
          .height(48)
          .alignContent(Alignment.Center)
          Column(){
            //昵称
            Text("this.contentDetailData.rmhInfo?.rmhName")
              .fontSize(14)
              .fontColor($r('app.color.color_222222'))
              .fontWeight(FontWeight.Medium)
              .margin({ left: 5 })
            //简介
            Text("this.contentDetailData.rmhInfo?.rmhDesc")
              .fontSize(14)
              .fontColor($r('app.color.color_B0B0B0'))
              .fontWeight(FontWeight.Medium)
              .margin({ left: 5 })
          }
          if (!this.followStatus) {
            Text('关注')
              .width(60)
              .height(24)
              .textAlign(TextAlign.Center)
              .fontSize($r('app.float.font_size_12'))
              .borderRadius($r('app.float.button_border_radius'))
              .backgroundColor($r('app.color.color_ED2800'))
              .fontColor($r('app.color.color_fff'))
              .onClick(() => {
                // this.handleAccention(this.item, 1)
              })
          } else {
            Text('已关注')
              .width(60)
              .height(24)
              .borderWidth(1)
              .textAlign(TextAlign.Center)
              .fontSize($r('app.float.font_size_12'))
              .borderRadius($r('app.float.button_border_radius'))
              .borderColor($r('app.color.color_CCCCCC'))
              .fontColor($r('app.color.color_CCCCCC'))
              .onClick(() => {
                // this.handleAccention(this.item, 0)
              })
          }
        }
        .width('100%')
      }
    }
    .backgroundColor('#FFFFFFFF')
  }
  private async getContentDetailData() {
    try {
      let data = await MultiPictureDetailViewModel.getDetailData(this.relId, this.contentId, this.relType)
      this.contentDetailData = data[0];
      console.log('动态详情',JSON.stringify(this.contentDetailData))
    } catch (exception) {
    console.log('请求失败',JSON.stringify(exception))
    }
  }
}