张善主

feat(动态详情):UI页面绘制

@@ -14,7 +14,12 @@ export struct DynamicDetailComponent { @@ -14,7 +14,12 @@ export struct DynamicDetailComponent {
14 private contentId: string = '' 14 private contentId: string = ''
15 private relType: string = '' 15 private relType: string = ''
16 //出参 16 //出参
17 - @State contentDetailData: ContentDetailDTO[] = [] as ContentDetailDTO[] 17 + @State contentDetailData: ContentDetailDTO = {} as ContentDetailDTO
  18 + //变量
  19 + /**
  20 + * 默认未关注 点击去关注
  21 + */
  22 + private followStatus: boolean = false;
18 23
19 24
20 async aboutToAppear() { 25 async aboutToAppear() {
@@ -27,15 +32,95 @@ export struct DynamicDetailComponent { @@ -27,15 +32,95 @@ export struct DynamicDetailComponent {
27 build() { 32 build() {
28 Row() { 33 Row() {
29 Column(){ 34 Column(){
30 - Text("this is a test!") 35 + //logo、日期
  36 + Row() {
  37 + Image($r('app.media.ic_article_rmh'))
  38 + .width(80)
  39 + .height(28)
  40 + .margin({ left: 16 })
  41 + Blank()
  42 + Text("2023年03月14日 08:16")
  43 + .fontColor($r('app.color.color_B0B0B0'))
  44 + .fontSize(12)
  45 + .lineHeight(28)
  46 + .margin({ right: 16 })
31 } 47 }
  48 + .height(48)
  49 + .width('100%')
  50 + //分割线
  51 + Image($r('app.media.ic_news_detail_division'))
  52 + .width('100%')
  53 + .height(7)
  54 + .margin({left: 16, right: 16} )
  55 + //号主信息
  56 + Row() {
  57 + //头像
  58 + Stack() {
  59 + Image(this.contentDetailData.rmhInfo?.rmhHeadUrl)
  60 + .alt(this.contentDetailData.rmhInfo?.userType=='1'?$r('app.media.default_head'):$r('app.media.icon_default_head_mater'))
  61 + .width('32')
  62 + .height('32')
  63 + .objectFit(ImageFit.Cover)
  64 + .borderRadius(16)
  65 + Image($r('app.media.icon_border_test'))
  66 + .width('48')
  67 + .height('48')
  68 + .objectFit(ImageFit.Cover)
  69 + .borderRadius(24)
32 } 70 }
33 - 71 + .width(48)
  72 + .height(48)
  73 + .alignContent(Alignment.Center)
  74 + Column(){
  75 + //昵称
  76 + Text("this.contentDetailData.rmhInfo?.rmhName")
  77 + .fontSize(14)
  78 + .fontColor($r('app.color.color_222222'))
  79 + .fontWeight(FontWeight.Medium)
  80 + .margin({ left: 5 })
  81 + //简介
  82 + Text("this.contentDetailData.rmhInfo?.rmhDesc")
  83 + .fontSize(14)
  84 + .fontColor($r('app.color.color_B0B0B0'))
  85 + .fontWeight(FontWeight.Medium)
  86 + .margin({ left: 5 })
  87 + }
  88 + if (!this.followStatus) {
  89 + Text('关注')
  90 + .width(60)
  91 + .height(24)
  92 + .textAlign(TextAlign.Center)
  93 + .fontSize($r('app.float.font_size_12'))
  94 + .borderRadius($r('app.float.button_border_radius'))
  95 + .backgroundColor($r('app.color.color_ED2800'))
  96 + .fontColor($r('app.color.color_fff'))
  97 + .onClick(() => {
  98 + // this.handleAccention(this.item, 1)
  99 + })
  100 + } else {
  101 + Text('已关注')
  102 + .width(60)
  103 + .height(24)
  104 + .borderWidth(1)
  105 + .textAlign(TextAlign.Center)
  106 + .fontSize($r('app.float.font_size_12'))
  107 + .borderRadius($r('app.float.button_border_radius'))
  108 + .borderColor($r('app.color.color_CCCCCC'))
  109 + .fontColor($r('app.color.color_CCCCCC'))
  110 + .onClick(() => {
  111 + // this.handleAccention(this.item, 0)
  112 + })
  113 + }
  114 + }
  115 + .width('100%')
  116 + }
  117 + }
  118 + .backgroundColor('#FFFFFFFF')
34 } 119 }
35 private async getContentDetailData() { 120 private async getContentDetailData() {
36 try { 121 try {
37 let data = await MultiPictureDetailViewModel.getDetailData(this.relId, this.contentId, this.relType) 122 let data = await MultiPictureDetailViewModel.getDetailData(this.relId, this.contentId, this.relType)
38 - this.contentDetailData = data; 123 + this.contentDetailData = data[0];
39 console.log('动态详情',JSON.stringify(this.contentDetailData)) 124 console.log('动态详情',JSON.stringify(this.contentDetailData))
40 } catch (exception) { 125 } catch (exception) {
41 console.log('请求失败',JSON.stringify(exception)) 126 console.log('请求失败',JSON.stringify(exception))