|
@@ -1,6 +1,12 @@
|
|
|
<template>
|
|
|
<view class="container">
|
|
|
<trtc-room ref="trtc-component" :config="rtcConfig"> </trtc-room>
|
|
|
+ <view class="top_box" :style="{ top: btn_top, left: btn_left}">
|
|
|
+ <image class="top_box_img" :src="head_img"></image>
|
|
|
+ <view class="top_box_text">
|
|
|
+ <text class="text_box_top">{{title}}</text><text class="text_box_bottom">{{user_name}}</text>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
<view class="popup-flip" @click="changeCamera()">
|
|
|
<view class="iconfont iconFill"></view>
|
|
|
</view>
|
|
@@ -62,7 +68,12 @@
|
|
|
template: '' // 必要参数 组件模版,支持的值 1v1 grid custom ,注意:不支持动态修改, iOS 不支持 pusher 动态渲染
|
|
|
},
|
|
|
showTipToast: false,
|
|
|
- options: {}
|
|
|
+ options: {},
|
|
|
+ btn_left:0,
|
|
|
+ btn_top:0,
|
|
|
+ title:"",
|
|
|
+ user_name:'0',
|
|
|
+ head_img:"../static/images/loginLogo.png"
|
|
|
}
|
|
|
},
|
|
|
onLoad(options) {
|
|
@@ -91,6 +102,19 @@
|
|
|
})
|
|
|
},
|
|
|
onReady() {
|
|
|
+ var that=this;
|
|
|
+
|
|
|
+ let menuButtonObject = wx.getMenuButtonBoundingClientRect();
|
|
|
+ let userData = uni.getStorageSync("userData")
|
|
|
+ wx.getSystemInfo({
|
|
|
+ success: res => {
|
|
|
+ this.setData({
|
|
|
+ btn_left: res.windowWidth - menuButtonObject.right+'rpx',
|
|
|
+ btn_top:menuButtonObject.top+menuButtonObject.height+14+'rpx'
|
|
|
+ })
|
|
|
+ },
|
|
|
+ })
|
|
|
+
|
|
|
wx.setKeepScreenOn({
|
|
|
keepScreenOn: true
|
|
|
}); // 获取 rtcroom 实例
|
|
@@ -104,6 +128,10 @@
|
|
|
userID: uni.getStorageSync("userData").userId,
|
|
|
template: "grid",
|
|
|
});
|
|
|
+ this.setData({
|
|
|
+ head_img:res.data.imgUrl,
|
|
|
+ title:res.data.liveName
|
|
|
+ })
|
|
|
}).catch(res => {
|
|
|
this.$refs.uTips.show({
|
|
|
title: '获取直播设置参数失败',
|
|
@@ -221,6 +249,10 @@
|
|
|
const TRTC_EVENT = this.trtcComponent.EVENT;
|
|
|
this.timestamp = []; // 初始化事件订阅
|
|
|
this.trtcComponent.on(TRTC_EVENT.LOCAL_JOIN, event => {
|
|
|
+ let user_list=this.trtcComponent.getRemoteUserList();
|
|
|
+ this.setData({
|
|
|
+ user_name:user_list.length
|
|
|
+ })
|
|
|
console.log('* room LOCAL_JOIN', event); // 进房成功,触发该事件后可以对本地视频和音频进行设置
|
|
|
if (this.options.localVideo === true || this.options.template === '1v1') {
|
|
|
this.trtcComponent.publishLocalVideo();
|
|
@@ -234,8 +266,14 @@
|
|
|
});
|
|
|
this.trtcComponent.on(TRTC_EVENT.ERROR, event => {
|
|
|
console.log('* room ERROR', event);
|
|
|
+
|
|
|
}); // 远端用户进房
|
|
|
this.trtcComponent.on(TRTC_EVENT.REMOTE_USER_JOIN, event => {
|
|
|
+ let user_list=this.trtcComponent.getRemoteUserList();
|
|
|
+ this.setData({
|
|
|
+ user_name:user_list.length
|
|
|
+ })
|
|
|
+
|
|
|
console.log('* room REMOTE_USER_JOIN --- room.vue', event, this.trtcComponent.getRemoteUserList(), this.template);
|
|
|
this.timestamp.push(new Date()); // 1v1视频通话时限制人数为两人的简易逻辑,建议通过后端实现房间人数管理
|
|
|
// 2人以上同时进行通话请选择网格布局
|
|
@@ -259,6 +297,10 @@
|
|
|
}
|
|
|
}); // 远端用户退出
|
|
|
this.trtcComponent.on(TRTC_EVENT.REMOTE_USER_LEAVE, event => {
|
|
|
+ let user_list=this.trtcComponent.getRemoteUserList();
|
|
|
+ this.setData({
|
|
|
+ user_name:user_list.length
|
|
|
+ })
|
|
|
console.log('* room REMOTE_USER_LEAVE', event, this.trtcComponent.getRemoteUserList());
|
|
|
if (this.template === '1v1') {
|
|
|
this.timestamp = [];
|
|
@@ -505,5 +547,41 @@
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ .top_box{
|
|
|
+ width: 304rpx;
|
|
|
+ height: 86rpx;
|
|
|
+ position: absolute;
|
|
|
+ z-index: 100;
|
|
|
+ background:rgba(0, 0, 0, 0.4);
|
|
|
+ border-radius: 100px;
|
|
|
+ top: 182rpx;
|
|
|
+ left: 30rpx;
|
|
|
+ }
|
|
|
+ .top_box_img{
|
|
|
+ width: 86rpx;
|
|
|
+ height: 86rpx;
|
|
|
+ border-radius: 100rpx;
|
|
|
+ float: left;
|
|
|
+ }
|
|
|
+ .top_box_text{
|
|
|
+ float: left;
|
|
|
+ color: #fff;
|
|
|
+ margin-left: 30rpx;
|
|
|
+ width: 180rpx;
|
|
|
+ padding-top: 2rpx;
|
|
|
+ }
|
|
|
+ .text_box_top{
|
|
|
+ font-size: 28rpx;
|
|
|
+ width: 100%;
|
|
|
+ display: block;
|
|
|
+ height: 30rpx;
|
|
|
+ float: left;
|
|
|
+ margin-top: 6rpx;
|
|
|
+ }
|
|
|
+ .text_box_bottom{
|
|
|
+ font-size: 22rpx;
|
|
|
+ float: left;
|
|
|
+ margin-top: 10rpx;
|
|
|
+ }
|
|
|
}
|
|
|
</style>
|