Przeglądaj źródła

fix 修复直播切回看不到的问题

tiedan 4 lat temu
rodzic
commit
5eaa707034

+ 4 - 2
app.json

@@ -1,8 +1,10 @@
 {
   "pages": [
-  
-    "pages/index/index",
     "pages/welcome/welcome",
+    "pages/index/index",
+  
+
+    
     
     
     

+ 1 - 0
components/trtc-room/controller/user-controller.js

@@ -345,6 +345,7 @@ class UserController {
     this.streamList = []
     this.userList = []
     this.userMap.clear()
+    
     return {
       userList: this.userList,
       streamList: this.streamList,

+ 11 - 5
components/trtc-room/model/pusher.js

@@ -20,13 +20,19 @@ class Pusher {
   reset() {
     console.log('Pusher reset', this.pusherContext)
     if (this.pusherContext) {
-      console.log('Pusher pusherContext.stop()')
-      this.pusherContext.stop()
+      // 2020/09/23 安卓端华为小米机型发现,安卓原生返回键,退房失败。
+      // 会触发detached生命周期,调用到该方法,puhserContext.stop()调用不成功,但是清空url后,客户端调用的退房方法就会不生效
+      // 这里做出改动,只有stop调用成功后,才会清空url,保持组件卸载流程的完整性,调用不成功的情况将由微信客户端兜底清除
+      this.pusherContext.stop({
+        success: () => {
+          console.log('Pusher pusherContext.stop()')
+          Object.assign(this, DEFAULT_PUSHER_CONFIG, {
+            isVisible: true,
+          })
+        },
+      })
       this.pusherContext = null
     }
-    Object.assign(this, DEFAULT_PUSHER_CONFIG, {
-      isVisible: true,
-    })
   }
 }
 export default Pusher

+ 34 - 2
pages/zbDetails/zbDetails.js

@@ -5,6 +5,7 @@ const COS = require('../../utils/cos-wx-v5.js');
 const util = require('../../utils/util.js');
 Page({
   data: {
+    scrollTop:0,
     rtcConfig: {
       sdkAppID: 1400404379, // 必要参数 开通实时音视频服务创建应用后分配的 sdkAppID
       userID: '', // 必要参数 用户 ID 可以由您的帐号系统指定
@@ -126,6 +127,7 @@ Page({
           //   currentTime: currentTime
           // })
           console.log(chatContent, "我是收到消息的数组")
+         // _this.toViewBottomFun();
           _this.setData({
             chatContent: chatContent,
             bottom: 'scrollBottom'
@@ -490,7 +492,7 @@ Page({
 
 
 
-
+    
 
     this.trtcRoomContext.enterRoom({
       roomID: Number(this.data.roomIdandcourseId) //课程id
@@ -504,7 +506,19 @@ Page({
   //   })
   //   console.log(this.data.roomIdandcourseId)
   // },
-
+  toViewBottomFun: function() {
+    // 设置屏幕自动滚动到最后一条消息处
+    let that = this;
+    wx.createSelectorQuery().select('#chatcon').boundingClientRect(function(rect) {
+      wx.pageScrollTo({
+        scrollTop: rect.height,
+        duration: 100 // 滑动速度
+      })
+      that.setData({
+        scrollTop: rect.height - that.data.scrollTop+100
+      });
+    }).exec();
+  },
   async onShow() {
     let pages = getCurrentPages();
     let currentPage = pages[pages.length - 1];
@@ -608,6 +622,24 @@ Page({
     console.log("zbdetail-onUnload")
     this.trtcRoomContext.unpublishLocalVideo();
     this.trtcRoomContext.unpublishLocalAudio();
+   
+
+    this.trtcRoomContext.unsubscribeRemoteAudio({
+      userID: "0"
+    }).then(() => {
+      console.log("音频取消订阅")
+    })
+
+    // this.trtcRoomContext.unsubscribeRemoteVideo({
+    //   userID: "0"
+    // }).then(() => {
+    //   console.log("视频取消订阅")
+    // })
+
+   
     this.offTim();
+
+
+    
   }
 })

+ 3 - 3
pages/zbDetails/zbDetails.wxml

@@ -4,8 +4,8 @@
 		<view class="area">
 		
 			<view class="chatbox">
-				<scroll-view scroll-y="true" style="width:100%;height:100%" bindscrolltoupper="upper" bindscrolltolower="lower" bindscroll="scroll" scroll-into-view="{{bottom}}" scroll-top="{{scrollTop}}">
-					<view style="padding:30rpx">
+				<scroll-view scroll-y="true" style="width:100%;height:100%" bindscrolltoupper="upper" bindscrolltolower="lower" bindscroll="scroll" scroll-into-view="{{bottom}}" >
+					<view style="padding:30rpx" id="chatcon">
 						<view wx:for="{{chatContent}}" wx:for-index="idx" wx:for-item="item" wx:key="idx" class="chat_text">
 							<view style="color:rgba(102,102,102);font-size:25rpx">{{item.currentTime}}</view>
 							<text style="color:#eb3f33">{{item.nick}} : </text>{{item.payload.text}}
@@ -13,7 +13,7 @@
 							<!--    <text style="color:#eb3f33;"> {{item.nick}} : </text> <text style="font-weight:500;"> {{item.payload.text}} </text> -->
 						</view>
 					</view>
-					<view id="scrollBottom" style="height:10rpx"></view>
+					<view id="scrollBottom" style="height:100rpx"></view>
 				</scroll-view>
 			</view>
 			<view class="puthands_box">

+ 1 - 1
utils/util.js

@@ -1,5 +1,5 @@
 const globalData = {
-  version:'3.1.5',
+  version:'3.2.0',
 
   imgUrl:'https://edu-mp-img-1254259530.cos.ap-nanjing.myqcloud.com',
   //publicUrl: 'https://sqdx.jiaxintech.com'//测试地址