PlayerEndView.ets
5.62 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
import { ContentDetailDTO, LiveDetailsBean, LiveRoomDataBean, postBatchAttentionStatusParams, } from 'wdBean/Index'
import { MultiPictureDetailViewModel } from 'wdComponent/src/main/ets/viewmodel/MultiPictureDetailViewModel'
import { SpConstants } from 'wdConstant/Index'
import { ContentDetailRequest, postInteractAccentionOperateParams } from 'wdDetailPlayApi/Index'
import { NumberFormatterUtils, DateTimeUtils, SPHelper } from 'wdKit/Index'
import { WDRouterPage, WDRouterRule } from 'wdRouter/Index'
import { router } from '@kit.ArkUI'
const TAG = 'PlayerEndView'
@Preview
@Component
export struct PlayerEndView {
// @Consume liveDetailsBean: LiveDetailsBean
@Consume contentDetailData: ContentDetailDTO
@Consume liveRoomDataBean: LiveRoomDataBean
@State duration: string = ''
@State followStatus: String = '0';
private onBack: () => void = () => {
}
aboutToAppear(): void {
const sn =
DateTimeUtils.parseDate(this.contentDetailData.liveInfo.startTime, DateTimeUtils.PATTERN_DATE_TIME_HYPHEN)
const en = DateTimeUtils.parseDate(this.contentDetailData.liveInfo.endTime, DateTimeUtils.PATTERN_DATE_TIME_HYPHEN)
const sd = DateTimeUtils.getDuration(sn, en)
this.duration = DateTimeUtils.secondToTime(sd / 1000)
this.getBatchAttentionStatus()
}
/**
* 查询当前登录用户是否关注作品号主
* */
async getBatchAttentionStatus() {
try {
const params: postBatchAttentionStatusParams = {
creatorIds: [{ creatorId: this.contentDetailData?.rmhInfo?.rmhId ?? '' }]
}
let data = await MultiPictureDetailViewModel.getBatchAttentionStatus(params)
this.followStatus = data[0]?.status;
console.log(TAG, `followStatus:${JSON.stringify(this.followStatus)}`)
} catch (exception) {
}
}
/**
* 关注号主
*/
async handleAccention() {
// 未登录,跳转登录
const user_id = await SPHelper.default.get(SpConstants.USER_ID, '')
if (!user_id) {
WDRouterRule.jumpWithPage(WDRouterPage.loginPage)
return
}
// TODO:直播间没有携带人民号信息
const params2: postInteractAccentionOperateParams = {
attentionUserType: this.contentDetailData?.rmhInfo?.userType || '', //被关注用户类型(1 普通用户 2 视频号 3 矩阵号)
attentionUserId: this.contentDetailData?.rmhInfo?.userId || '', // 被关注用户号主id
attentionCreatorId: this.contentDetailData?.rmhInfo?.rmhId || '', // 被关注用户号主id
status: this.followStatus == '0' ? 1 : 0,
}
ContentDetailRequest.postInteractAccentionOperate(params2).then(res => {
console.log('关注号主==', JSON.stringify(res.data))
if (this.followStatus == '1') {
this.followStatus = '0'
} else {
this.followStatus = '1'
}
}).catch(() => {
AlertDialog.show({ message: '关注失败' })
})
}
build() {
Column() {
Text('直播已结束').fontWeight(500)
.fontSize(20)
.fontColor(Color.White)
.padding({ bottom: 40, top: 120 })
Stack() {
Column() {
Text(this.contentDetailData?.rmhInfo?.rmhName)
.fontWeight(400)
.fontSize(18)
.fontColor(Color.White)
.padding({ top: 52 })
Text(this.contentDetailData?.rmhInfo?.rmhDesc || '')
.fontWeight(400)
.fontSize(13)
.fontColor('#B2FFFFFF')
.padding({ top: 8 })
Row() {
Column() {
Text(this.duration).fontWeight(600).fontSize(24).fontColor(Color.White)
Text('时长').fontWeight(400).fontSize(13).fontColor(Color.White)
}
Text('').width(1).height(32).margin({ left: 36, right: 36 }).backgroundColor('#33FFFFFF')
Column() {
Text(NumberFormatterUtils.formatNumberWithWan(this.liveRoomDataBean?.pv || ''))
.fontWeight(600)
.fontSize(24)
.fontColor(Color.White)
Text('观看人数').fontWeight(400).fontSize(13).fontColor(Color.White)
}
}
.padding({ top: 16 })
Row() {
Text(this.followStatus == '0' ? '关注' : '已关注')
.fontWeight(400)
.fontSize(16)
.fontColor(Color.White)
.padding({
top: 8,
bottom: 8,
left: 122,
right: 122
})
.backgroundColor(this.followStatus == '0' ? '#FFED2800' : Color.Grey)
.borderRadius(4)
.onClick(() => {
this.handleAccention()
})
}
.padding({ top: 24 })
}
.width(307)
.height(254)
.backgroundColor('#999999')
.borderRadius(4)
Image(this.contentDetailData.rmhInfo?.rmhHeadUrl)
.width(80)
.height(80)
.borderRadius(40)
.borderWidth(1)
.borderColor(Color.White)
.borderStyle(BorderStyle.Solid)
.position({ x: '50%', y: 0 })
.markAnchor({ x: '50%', y: '50%' })
}
.width(307)
.padding({ top: 40 })
Blank()
// 返回按钮
Row() {
Image($r('app.media.icon_arrow_left_white'))
.width(24)
.height(24)
.aspectRatio(1)
.interpolation(ImageInterpolation.High)
.hoverEffect(HoverEffect.Scale)
.margin({ bottom: 30 ,left:14})
.onClick(() => {
if (this.onBack) {
this.onBack()
}
router.back();
})
}.width('100%')
}
.height('100%')
.width('100%')
}
}