Authored by 郝肖肖

'live-ctx'

@@ -72,9 +72,14 @@ module.exports = class extends global.yoho.BaseModel { @@ -72,9 +72,14 @@ module.exports = class extends global.yoho.BaseModel {
72 72
73 // 获取精选视频 73 // 获取精选视频
74 _getBestList() { 74 _getBestList() {
75 - return liveAPI.get('v1/living/best', {}, {  
76 - code: 200,  
77 - cache: false 75 + return this.get({
  76 + api: liveAPI,
  77 + url: 'v1/living/best',
  78 + data: {},
  79 + param: {
  80 + code: 200,
  81 + cache: false
  82 + }
78 }).then(result => { 83 }).then(result => {
79 let list = result && result.data || []; 84 let list = result && result.data || [];
80 85
@@ -107,9 +112,14 @@ module.exports = class extends global.yoho.BaseModel { @@ -107,9 +112,14 @@ module.exports = class extends global.yoho.BaseModel {
107 112
108 // 获取直播中所有视频 113 // 获取直播中所有视频
109 _getLivingList() { 114 _getLivingList() {
110 - return liveAPI.get('v1/living/listing', {}, {  
111 - code: 200,  
112 - cache: false 115 + return this.get({
  116 + api: liveAPI,
  117 + url: 'v1/living/listing',
  118 + data: {},
  119 + param: {
  120 + code: 200,
  121 + cache: false
  122 + }
113 }).then(result => { 123 }).then(result => {
114 return result && result.data || []; 124 return result && result.data || [];
115 }); 125 });
@@ -117,9 +127,14 @@ module.exports = class extends global.yoho.BaseModel { @@ -117,9 +127,14 @@ module.exports = class extends global.yoho.BaseModel {
117 127
118 // 获取直播预告列表 128 // 获取直播预告列表
119 _getPrelivingList() { 129 _getPrelivingList() {
120 - return liveAPI.get('v1/living/starting', {}, {  
121 - code: 200,  
122 - cache: false 130 + return this.get({
  131 + api: liveAPI,
  132 + url: 'v1/living/starting',
  133 + data: {},
  134 + param: {
  135 + code: 200,
  136 + cache: false
  137 + }
123 }).then(result => { 138 }).then(result => {
124 let list = result && result.data || []; 139 let list = result && result.data || [];
125 140
@@ -132,9 +147,14 @@ module.exports = class extends global.yoho.BaseModel { @@ -132,9 +147,14 @@ module.exports = class extends global.yoho.BaseModel {
132 147
133 // 获取回看列表 148 // 获取回看列表
134 _getRecordList() { 149 _getRecordList() {
135 - return liveAPI.get('v1/living/replaying', {}, {  
136 - code: 200,  
137 - cache: false 150 + return this.get({
  151 + api: liveAPI,
  152 + url: 'v1/living/replaying',
  153 + data: {},
  154 + param: {
  155 + code: 200,
  156 + cache: false
  157 + }
138 }).then(result => { 158 }).then(result => {
139 return result && result.data || []; 159 return result && result.data || [];
140 }); 160 });
@@ -153,39 +173,46 @@ module.exports = class extends global.yoho.BaseModel { @@ -153,39 +173,46 @@ module.exports = class extends global.yoho.BaseModel {
153 173
154 // 获取 回放视屏 信息 174 // 获取 回放视屏 信息
155 fetchReplayInfo(videoID) { 175 fetchReplayInfo(videoID) {
156 - let url = 'v1/living/detail';  
157 let data = { video_id: videoID }; 176 let data = { video_id: videoID };
158 - let options = { cache: true };  
159 -  
160 - return liveAPI.get(url, data, options)  
161 - .then(result => {  
162 - if (result && result.data) {  
163 - let d = result.data;  
164 -  
165 - d.background = helpers.image(d.background, 640, 968);  
166 - d.pic = helpers.image(d.pic, 640, 968);  
167 - d.master_pic = helpers.image(d.master_pic, 180, 180);  
168 - d.humanTime = _formatTime(data.live_start_time * 1000);  
169 - d.video_src = d.url;  
170 -  
171 - // 自定义数据  
172 - d.duration = '00:00:00'; // 回看时长 前端JS根据video获取  
173 - d.living = 3; // 重播 状态  
174 - d.canPlay = true;  
175 - d.atEnd = false;  
176 - d.isReplay = true;  
177 - }  
178 177
179 - return result || {};  
180 - }); 178 + return this.get({
  179 + api: liveAPI,
  180 + url: 'v1/living/detail',
  181 + data: data,
  182 + param: {
  183 + cache: true
  184 + }
  185 + }).then(result => {
  186 + if (result && result.data) {
  187 + let d = result.data;
  188 +
  189 + d.background = helpers.image(d.background, 640, 968);
  190 + d.pic = helpers.image(d.pic, 640, 968);
  191 + d.master_pic = helpers.image(d.master_pic, 180, 180);
  192 + d.humanTime = _formatTime(data.live_start_time * 1000);
  193 + d.video_src = d.url;
  194 +
  195 + // 自定义数据
  196 + d.duration = '00:00:00'; // 回看时长 前端JS根据video获取
  197 + d.living = 3; // 重播 状态
  198 + d.canPlay = true;
  199 + d.atEnd = false;
  200 + d.isReplay = true;
  201 + }
  202 +
  203 + return result || {};
  204 + });
181 } 205 }
182 206
183 // 获取 直播视屏 信息 207 // 获取 直播视屏 信息
184 fetchLiveInfo(roomID) { 208 fetchLiveInfo(roomID) {
185 - let url = 'v1/living/detail';  
186 let data = { room_id: roomID }; 209 let data = { room_id: roomID };
187 210
188 - return liveAPI.get(url, data).then(result => { 211 + return this.get({
  212 + api: liveAPI,
  213 + url: 'v1/living/detail',
  214 + data: data
  215 + }).then(result => {
189 if (result && result.data) { 216 if (result && result.data) {
190 let d = result.data; 217 let d = result.data;
191 218
@@ -216,18 +243,27 @@ module.exports = class extends global.yoho.BaseModel { @@ -216,18 +243,27 @@ module.exports = class extends global.yoho.BaseModel {
216 243
217 // 获取 直播 弹幕 host 244 // 获取 直播 弹幕 host
218 getBarrageHost(type) { 245 getBarrageHost(type) {
219 - return liveAPI.get('v1/system/gethosts', { type }); 246 + return this.get({
  247 + api: liveAPI,
  248 + url: 'v1/system/gethosts',
  249 + data: { type }
  250 + });
220 } 251 }
221 252
222 getReplyBarrage(videoID, startTime, timeInterval) { 253 getReplyBarrage(videoID, startTime, timeInterval) {
223 - const url = 'v1/living/getreplaybarrage';  
224 const data = { 254 const data = {
225 startTime, 255 startTime,
226 timeInterval, 256 timeInterval,
227 video_id: videoID 257 video_id: videoID
228 }; 258 };
229 - const options = { cache: true };  
230 259
231 - return liveAPI.get(url, data, options); 260 + return this.get({
  261 + api: liveAPI,
  262 + url: 'v1/living/getreplaybarrage',
  263 + data: data,
  264 + param: {
  265 + cache: true
  266 + }
  267 + });
232 } 268 }
233 }; 269 };