zhangli vor 4 Jahren
Ursprung
Commit
83e7b52993

+ 79 - 1
pagesMedia/liveDetail.vue

@@ -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>

+ 87 - 1
pagesMedia/pickVideo.vue

@@ -6,6 +6,12 @@
 			<view>不希望其他人打扰</view>
 		</view>
 		<u-top-tips ref="uTips"></u-top-tips>
+		<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 style="display:none" class="text_box_bottom">{{user_name}}</text>
+			</view>
+		</view>
 	</view>
 </template>
 
@@ -35,10 +41,24 @@
 					template: '' // 必要参数 组件模版,支持的值 1v1 grid custom ,注意:不支持动态修改, iOS 不支持 pusher 动态渲染
 				},
 				showTipToast: false,
-				options: null
+				options: null,
+				btn_left:0,
+				btn_top:0,
+				title:"测试",
+				user_name:'123',
+				head_img:"../static/images/loginLogo.png"
 			}
 		},
 		onLoad() {
+			let menuButtonObject = wx.getMenuButtonBoundingClientRect();
+			 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 +124,20 @@
 				const TRTC_EVENT = this.trtcComponent.EVENT;
 				this.timestamp = []; // 初始化事件订阅
 				this.trtcComponent.on(TRTC_EVENT.LOCAL_JOIN, event => {
+					if(this.trtcComponent.getRemoteUserList().lenth>0){
+						var userId=this.trtcComponent.getRemoteUserList()[0].userID;
+						NET.request(API.getMainInfo + userId, {}, 'GET').then(res => {
+							this.setData({
+								head_img:res.data.headimg,
+								title:res.data.nickname
+							})
+						}).catch(error => {
+							this.$refs.uTips.show({
+								title: '获取个人信息失败',
+								type: 'warning',
+							})
+						})
+					}
 					console.log('* room LOCAL_JOIN', event); // 进房成功,触发该事件后可以对本地视频和音频进行设置
 
 					if (this.options.localVideo === true || this.options.template === '1v1') {
@@ -120,6 +154,18 @@
 					console.log('* room ERROR', event);
 				}); // 远端用户进房
 				this.trtcComponent.on(TRTC_EVENT.REMOTE_USER_JOIN, event => {
+					var userId=this.trtcComponent.getRemoteUserList()[0].userID;
+					NET.request(API.getMainInfo + userId, {}, 'GET').then(res => {
+						this.setData({
+							head_img:res.data.headimg,
+							title:res.data.nickname
+						})
+					}).catch(error => {
+						this.$refs.uTips.show({
+							title: '获取个人信息失败',
+							type: 'warning',
+						})
+					})
 					console.log('* room REMOTE_USER_JOIN ---  room.vue', event, this.trtcComponent.getRemoteUserList(), this.template);
 					this.timestamp.push(new Date()); // 1v1视频通话时限制人数为两人的简易逻辑,建议通过后端实现房间人数管理
 					// 2人以上同时进行通话请选择网格布局
@@ -143,6 +189,10 @@
 					}
 				}); // 远端用户退出
 				this.trtcComponent.on(TRTC_EVENT.REMOTE_USER_LEAVE, event => {
+					this.setData({
+						head_img:"../static/images/loginLogo.png",
+						title:''
+					})
 					console.log('* room REMOTE_USER_LEAVE', event, this.trtcComponent.getRemoteUserList());
 					if (this.template === '1v1') {
 						this.timestamp = [];
@@ -243,5 +293,41 @@
 			padding: 20rpx 0;
 			font-size: 32rpx;
 		}
+		.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: 34rpx;
+		  width: 100%;
+		  display: block;
+		  height: 30rpx;
+		  float: left;
+		  margin-top: 19rpx;
+		}
+		.text_box_bottom{
+		  font-size: 22rpx;
+		  float: left;
+		  margin-top: 10rpx;
+		}
 	}
 </style>

+ 1 - 0
pagesMedia/trtc-room/template/1v1/1v1.css

@@ -33,6 +33,7 @@
   padding: 40rpx;
   display: flex;
   flex-direction: column;
+  display: none;
 }
 .template-1v1 .loading-img {
   height: 200rpx;

+ 4 - 4
pagesMedia/trtc-room/trtc-room.vue

@@ -163,7 +163,7 @@
 									></image>
 								</view>
 								<view class="btn-normal" @tap="toggleFullscreenFun" :data-user-i-d="item.userID" :data-stream-type="item.streamType">
-									<image src="../../static/components/trtc-room/static/fullscreen.png"></image>
+									<!-- <image src="../../static/components/trtc-room/static/fullscreen.png"></image> -->
 								</view>
 							</view>
 							<progress class="volume-progress" :percent="item.volume" stroke-width="4"></progress>
@@ -206,9 +206,9 @@
 								@bgmcomplete="pusherBGMCompleteHandlerFun"
 							></live-pusher>
 							<view class="operation-bar">
-								<view class="btn-normal" @tap="switchMemberListPanelFun"><image src="../../static/components/trtc-room/static/list.png"></image></view>
+								<view class="btn-normal" @tap="switchMemberListPanelFun"><i<!-- mage src="../../static/components/trtc-room/static/list.png"></image></view>
 								<view class="btn-normal" @tap="switchSettingPanelFun"><image src="../../static/components/trtc-room/static/setting.png"></image></view>
-								<view class="btn-normal btn-hangup" @tap="hangUpFun"><image src="../../static/components/trtc-room/static/hangup.png"></image></view>
+								<view class="btn-normal btn-hangup" @tap="hangUpFun"><image --> src="../../static/components/trtc-room/static/hangup.png"></image></view>
 							</view>
 						</view>
 						<view :class="'panel memberlist-panel ' + (panelName === 'memberlist-panel' ? '' : 'none')">
@@ -291,7 +291,7 @@
 									</view>
 									<view class="setting-option">
 										<view class="label">切换摄像头</view>
-										<view class="btn-normal" @tap="switchCamera"><image src="../../static/components/trtc-room/static/switch.png"></image></view>
+										<!-- <view class="btn-normal" @tap="switchCamera"><image src="../../static/components/trtc-room/static/switch.png"></image></view> -->
 									</view>
 									<view class="setting-option">
 										<view class="label">开启美颜</view>