Showing
4 changed files
with
75 additions
and
24 deletions
@@ -26,17 +26,6 @@ exports.index = (req, res, next) => { | @@ -26,17 +26,6 @@ exports.index = (req, res, next) => { | ||
26 | }).catch(next); | 26 | }).catch(next); |
27 | }; | 27 | }; |
28 | 28 | ||
29 | -let mockData = { | ||
30 | - living: 2, | ||
31 | - audience_num: 300, | ||
32 | - like_num: '12.3万', | ||
33 | - duration: '01:23', | ||
34 | - master_name: 'MR.SHEN', | ||
35 | - title: '有货潮流新品节正式开幕', | ||
36 | - live_start_time: 1471485267668, | ||
37 | - pic: '/img/live.png' | ||
38 | -}; | ||
39 | - | ||
40 | exports.main = (req, res, next) => { | 29 | exports.main = (req, res, next) => { |
41 | const isReplay = /^\/live\/replay\//.test(req.path); | 30 | const isReplay = /^\/live\/replay\//.test(req.path); |
42 | const id = req.params.id; | 31 | const id = req.params.id; |
@@ -169,23 +169,39 @@ const fetchLiveInfo = (roomID) => { | @@ -169,23 +169,39 @@ const fetchLiveInfo = (roomID) => { | ||
169 | d.background_pic = helpers.image(d.background_pic, 640, 968); | 169 | d.background_pic = helpers.image(d.background_pic, 640, 968); |
170 | d.pic = helpers.image(d.pic, 640, 968); | 170 | d.pic = helpers.image(d.pic, 640, 968); |
171 | d.master_pic = helpers.image(d.master_pic, 180, 180); | 171 | d.master_pic = helpers.image(d.master_pic, 180, 180); |
172 | - d.humanTime = _formatTime(d.live_start_time * 1000); | 172 | + d.humanTime = _formatTime(d.starting_time * 1000); // 预告 开始时间 |
173 | d.video_src = d.hls_downstream_address; | 173 | d.video_src = d.hls_downstream_address; |
174 | 174 | ||
175 | - let durationH = parseInt(d.live_last_time / 3600, 10); // 1h =3600s | ||
176 | - let durationM = parseInt((d.live_last_time - durationH * 3600) / 60, 10); | ||
177 | - let duration = [durationH, durationM]; | 175 | + let duration = moment.duration(d.live_last_time, 's'); |
176 | + let durationH = duration.hours(); | ||
177 | + let durationM = duration.minutes(); | ||
178 | + let durationS = duration.seconds(); | ||
178 | 179 | ||
179 | - duration.forEach((val, index) => { | ||
180 | - if (val < 10) { | ||
181 | - duration[index] = `0${val}`; | 180 | + [durationH, durationM, durationS].forEach((item, index, arr) => { |
181 | + if (item < 10) { | ||
182 | + arr[index] = `0${item}`; | ||
182 | } else { | 183 | } else { |
183 | - duration[index] = '' + val; | 184 | + arr[index] = String(item); |
184 | } | 185 | } |
185 | }); | 186 | }); |
186 | 187 | ||
188 | + | ||
189 | + // let durationH = parseInt(d.live_last_time / 3600, 10); // 1h =3600s | ||
190 | + // let durationM = parseInt((d.live_last_time - durationH * 3600) / 60, 10); | ||
191 | + // let duration = [durationH, durationM]; | ||
192 | + | ||
193 | + // duration.forEach((val, index) => { | ||
194 | + // if (val < 10) { | ||
195 | + // duration[index] = `0${val}`; | ||
196 | + // } else { | ||
197 | + // duration[index] = '' + val; | ||
198 | + // } | ||
199 | + // }); | ||
200 | + | ||
201 | + | ||
202 | + | ||
187 | // 自定义数据 | 203 | // 自定义数据 |
188 | - d.duration = `${duration[0]} : ${duration[1]}`; | 204 | + d.duration = `${durationH}:${durationM}:${durationS}`; |
189 | d.canPlay = d.living === 1; | 205 | d.canPlay = d.living === 1; |
190 | d.notBegin = d.living === 0; | 206 | d.notBegin = d.living === 0; |
191 | d.atEnd = d.living === 2; | 207 | d.atEnd = d.living === 2; |
@@ -531,12 +531,13 @@ function send_heart_beat() { | @@ -531,12 +531,13 @@ function send_heart_beat() { | ||
531 | 531 | ||
532 | function insert_msg(obj) { | 532 | function insert_msg(obj) { |
533 | var $ul = $('#live_chat_ul'); | 533 | var $ul = $('#live_chat_ul'); |
534 | + var msg_html | ||
534 | if (obj.avatar == '' || obj.avatar == undefined) { | 535 | if (obj.avatar == '' || obj.avatar == undefined) { |
535 | var rand = Math.floor(Math.random() * 5) + 1; | 536 | var rand = Math.floor(Math.random() * 5) + 1; |
536 | - obj.avatar = site_url + '/img/activity/live/live/head_' + rand + '.png'; | ||
537 | - } | ||
538 | - var msg_html = '<div class="live-item2"><div class="live-item2-head">' + | ||
539 | - '<img src="' + obj.avatar + '?imageMogr2/thumbnail/50x50"></div>' + | 537 | + // obj.avatar = site_url + '/img/activity/live/live/head_' + rand + '.png'; |
538 | + | ||
539 | + msg_html = '<div class="live-item2"><div class="live-item2-head">' + | ||
540 | + '<img class="avatar' + rand + '"></div>' + | ||
540 | '<div class="live-item2_1">' + | 541 | '<div class="live-item2_1">' + |
541 | '<span class="live-replay">@' + obj.name + '</span>'+ | 542 | '<span class="live-replay">@' + obj.name + '</span>'+ |
542 | '<div class="live-item2_2">' + | 543 | '<div class="live-item2_2">' + |
@@ -544,6 +545,27 @@ function insert_msg(obj) { | @@ -544,6 +545,27 @@ function insert_msg(obj) { | ||
544 | '</div>' + | 545 | '</div>' + |
545 | '</div>' + | 546 | '</div>' + |
546 | '</div>'; | 547 | '</div>'; |
548 | + } else { | ||
549 | + obj.avatar = obj.avatar.replace(/(\{width}|\{height}|\{mode})/g, function($0) { | ||
550 | + const dict = { | ||
551 | + '{width}': width, | ||
552 | + '{height}': height, | ||
553 | + '{mode}': mode || 2 | ||
554 | + }; | ||
555 | + | ||
556 | + return dict[$0]; | ||
557 | + }) | ||
558 | + | ||
559 | + msg_html = '<div class="live-item2"><div class="live-item2-head">' + | ||
560 | + '<img src="' + obj.avatar + '"></div>' + | ||
561 | + '<div class="live-item2_1">' + | ||
562 | + '<span class="live-replay">@' + obj.name + '</span>'+ | ||
563 | + '<div class="live-item2_2">' + | ||
564 | + obj.msg + | ||
565 | + '</div>' + | ||
566 | + '</div>' + | ||
567 | + '</div>'; | ||
568 | + } | ||
547 | var li = document.createElement('li'); | 569 | var li = document.createElement('li'); |
548 | li.innerHTML = msg_html; | 570 | li.innerHTML = msg_html; |
549 | if ($ul.children().length >= 4) { | 571 | if ($ul.children().length >= 4) { |
@@ -118,6 +118,30 @@ | @@ -118,6 +118,30 @@ | ||
118 | } | 118 | } |
119 | 119 | ||
120 | .live-wrapper { | 120 | .live-wrapper { |
121 | + .avatar1 { | ||
122 | + background-image: resolve('activity/live/live/head_1.png'); | ||
123 | + } | ||
124 | + .avatar2 { | ||
125 | + background-image: resolve('activity/live/live/head_2.png'); | ||
126 | + } | ||
127 | + .avatar3 { | ||
128 | + background-image: resolve('activity/live/live/head_3.png'); | ||
129 | + } | ||
130 | + .avatar4 { | ||
131 | + background-image: resolve('activity/live/live/head_4.png'); | ||
132 | + } | ||
133 | + .avatar5 { | ||
134 | + background-image: resolve('activity/live/live/head_5.png'); | ||
135 | + } | ||
136 | + | ||
137 | + .avatar1, | ||
138 | + .avatar2, | ||
139 | + .avatar3, | ||
140 | + .avatar4, | ||
141 | + .avatar5{ | ||
142 | + background-position: center center; | ||
143 | + background-size: contain; | ||
144 | + } | ||
121 | .float-layer { | 145 | .float-layer { |
122 | height: 128px; | 146 | height: 128px; |
123 | background: rgba(68, 68, 68, 0.95); | 147 | background: rgba(68, 68, 68, 0.95); |
-
Please register or login to post a comment