|
@@ -5,7 +5,7 @@ Component({
|
|
|
* 组件的属性列表
|
|
|
*/
|
|
|
properties: {
|
|
|
-
|
|
|
+
|
|
|
},
|
|
|
|
|
|
/**
|
|
@@ -22,6 +22,7 @@ Component({
|
|
|
|
|
|
|
|
|
attached() {
|
|
|
+
|
|
|
this.callback = (user={}) => {
|
|
|
console.warn('---user---', user,'---user---')
|
|
|
if (user.action === 'stopCall' && this.hasEnter) {
|
|
@@ -39,6 +40,7 @@ Component({
|
|
|
if (user.noMute) {
|
|
|
this.unpublishLocalAudio()
|
|
|
} else {
|
|
|
+
|
|
|
this.publishLocalAudio()
|
|
|
// }
|
|
|
}
|
|
@@ -52,13 +54,18 @@ Component({
|
|
|
getApp().addVoicePropsListener(this.callback)
|
|
|
},
|
|
|
detached() {
|
|
|
+
|
|
|
console.log('detached')
|
|
|
getApp().removeVoicePropsListener(this.callback)
|
|
|
// this.trtcRoomContext.exitRoom()
|
|
|
this.hasEnter = false
|
|
|
},
|
|
|
pageLifetimes: {
|
|
|
+
|
|
|
show() {
|
|
|
+ // wx.showToast({
|
|
|
+ // title: 'show',
|
|
|
+ // })
|
|
|
this.setData({show: true})
|
|
|
// this.trtcRoomContext = this.selectComponent('#trtcroom')
|
|
|
// if (getApp().globalData.audioUser) {
|
|
@@ -69,6 +76,7 @@ Component({
|
|
|
// }
|
|
|
},
|
|
|
hide() {
|
|
|
+
|
|
|
clearTimeout(this.time)
|
|
|
this.setData({show: false})
|
|
|
},
|
|
@@ -78,6 +86,7 @@ Component({
|
|
|
*/
|
|
|
methods: {
|
|
|
enterAudioRoom(user, noEnter) {
|
|
|
+
|
|
|
// if (this.hasEnter) {
|
|
|
// return
|
|
|
// }
|
|
@@ -105,7 +114,7 @@ Component({
|
|
|
this.trtcRoomContext.on(EVENT.LOCAL_JOIN, (event) => {
|
|
|
// 进房成功后发布本地音频流和视频流
|
|
|
console.error('进入房间')
|
|
|
-
|
|
|
+
|
|
|
this.successEnter = true
|
|
|
if(user.role=='leader'){
|
|
|
if (user.noMute) {
|
|
@@ -142,28 +151,30 @@ Component({
|
|
|
this.hasEnter = false
|
|
|
})
|
|
|
let timer = null
|
|
|
- timer = setInterval(() => {
|
|
|
- if (!this.successEnter) {
|
|
|
- this.trtcRoomContext.enterRoom({
|
|
|
- roomID: getApp().globalData.roomId
|
|
|
- }).then(() => {
|
|
|
- console.log('成功进入房间')
|
|
|
- }).catch((res) => {
|
|
|
- console.error('room joinRoom 进房失败:', res)
|
|
|
- this.hasEnter = false
|
|
|
- })
|
|
|
- } else {
|
|
|
- clearInterval(timer)
|
|
|
- timer = null
|
|
|
- }
|
|
|
- }, 3000);
|
|
|
+ // timer = setInterval(() => {
|
|
|
+ // if (!this.successEnter) {
|
|
|
+ // this.trtcRoomContext.enterRoom({
|
|
|
+ // roomID: getApp().globalData.roomId
|
|
|
+ // }).then(() => {
|
|
|
+ // console.log('成功进入房间')
|
|
|
+ // }).catch((res) => {
|
|
|
+ // console.error('room joinRoom 进房失败:', res)
|
|
|
+ // this.hasEnter = false
|
|
|
+ // })
|
|
|
+ // } else {
|
|
|
+ // clearInterval(timer)
|
|
|
+ // timer = null
|
|
|
+ // }
|
|
|
+ // }, 3000);
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
unpublishLocalAudio () {
|
|
|
+
|
|
|
this.trtcRoomContext && this.trtcRoomContext.unpublishLocalAudio()
|
|
|
},
|
|
|
publishLocalAudio () {
|
|
|
+
|
|
|
this.trtcRoomContext && this.trtcRoomContext.publishLocalAudio()
|
|
|
}
|
|
|
}
|