DynamicDetailComponent.ets
3.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
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))
}
}
}