|
@@ -28,14 +28,19 @@ class LiveroomService extends CrudService {
|
|
|
}
|
|
|
|
|
|
async personcount(data) {
|
|
|
- const { number, name, userid } = data;
|
|
|
+ const { number, name, userid, type } = data;
|
|
|
// 取出已经进入直播的用户列表
|
|
|
let list = await this.app.redis.get(`liveroom${number}`);
|
|
|
if (list) {
|
|
|
console.log(_.cloneDeep(list));
|
|
|
// 已经开始直播,并且有人观看
|
|
|
list = JSON.parse(list);
|
|
|
- list = JSON.stringify(_.uniqBy(list.push({ name, userid }), 'userid'));
|
|
|
+ if (!type) {
|
|
|
+ list = _.uniqBy(list.push({ name, userid }), 'userid');
|
|
|
+ } else {
|
|
|
+ list = list.filter(f => f.userid !== userid);
|
|
|
+ }
|
|
|
+ list = JSON.stringify(list);
|
|
|
} else {
|
|
|
// 还没有人进直播
|
|
|
list = JSON.stringify([{ name, userid }]);
|