LiveModel.ets
3.33 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
import HashMap from '@ohos.util.HashMap';
import { HttpUrlUtils, ResponseDTO } from 'wdNetwork';
import { HttpRequest } from 'wdNetwork/src/main/ets/http/HttpRequest';
import { Logger } from 'wdKit';
import { LiveDetailsBean, LiveRoomBean } from 'wdBean/Index';
const TAG = 'LiveModel'
export class LiveModel {
/**
* 直播内容详情
* @param contentId
* @param relId 关系id
* @param relType 关系类型;1.频道关系;2.专题关系;
* @returns
*/
getLiveDetails(contentId: string, relId: string, relType: string) {
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return new Promise<Array<LiveDetailsBean>>((success, fail) => {
HttpRequest.get<ResponseDTO<Array<LiveDetailsBean>>>(
HttpUrlUtils.getLiveDetailsUrl() + `?relId=${relId}&relType=${relType}&contentId=${contentId}`,
headers).then((data: ResponseDTO<Array<LiveDetailsBean>>) => {
if (!data || !data.data) {
fail("数据为空")
return
}
if (data.code != 0) {
fail(data.message)
return
}
success(data.data)
}, (error: Error) => {
fail(error.message)
Logger.debug(TAG + ":error ", error.toString())
})
})
}
/**
* 获取直播详情页面直播间数据列表
* @param pageNum
* @param mLiveId
* @param liveId
* @param pageSize
* @returns
*/
getLiveList(pageNum: number, mLiveId: string, liveId: string, pageSize: number) {
let params: Record<string, string> = {};
params['pageNum'] = pageNum + ''
params['mLiveId'] = mLiveId
params['liveId'] = liveId
params['pageSize'] = pageSize + ''
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return new Promise<LiveRoomBean>((success, fail) => {
HttpRequest.post<ResponseDTO<LiveRoomBean>>(
HttpUrlUtils.getLiveListUrl(),
params,
headers).then((data: ResponseDTO<LiveRoomBean>) => {
if (!data || !data.data) {
fail("数据为空")
return
}
if (data.code != 0) {
fail(data.message)
return
}
success(data.data)
}, (error: Error) => {
fail(error.message)
Logger.debug(TAG + ":error ", error.toString())
})
})
}
/**
* 获取直播详情页面大家聊数据列表
* @param pageNum
* @param mLiveId
* @param liveId
* @param pageSize
* @returns
*/
getLiveChatList(pageNum: number, mLiveId: string, liveId: string, pageSize: number) {
let params: Record<string, string> = {};
params['pageNum'] = pageNum + ''
params['mLiveId'] = mLiveId
params['liveId'] = liveId
params['pageSize'] = pageSize + ''
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return new Promise<LiveRoomBean>((success, fail) => {
HttpRequest.post<ResponseDTO<LiveRoomBean>>(
HttpUrlUtils.getLiveChatListUrl(),
params,
headers).then((data: ResponseDTO<LiveRoomBean>) => {
if (!data || !data.data) {
fail("数据为空")
return
}
if (data.code != 0) {
fail(data.message)
return
}
success(data.data)
}, (error: Error) => {
fail(error.message)
Logger.debug(TAG + ":error ", error.toString())
})
})
}
}