|
@@ -18,31 +18,39 @@
|
|
|
等待连接...
|
|
等待连接...
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
- <!-- <div v-if="!getCameraFailText" style="position: fixed; z-index: 100; top: 50%; height: 50px; display: flex; flex-direction: column; align-items: center; justify-content: center;">
|
|
|
|
|
- <div>摄像头信息:</div>
|
|
|
|
|
- <div class="cell" v-for="(item,index) in cameraList" :key="index">{{ item.label +':'+ item.deviceId }}</div>
|
|
|
|
|
- </div>
|
|
|
|
|
- <div v-else style="position: fixed; z-index: 100; top: 50%; height: 50px; display: flex; flex-direction: column; align-items: center; justify-content: center;">
|
|
|
|
|
- <div>摄像头获取失败信息:{{getCameraFailText}}</div>
|
|
|
|
|
|
|
+ <!-- <div v-if="!getCameraFailText" style="position: fixed; z-index: 100; top: 50%; height: 50px; display: flex; flex-direction: column; align-items: center; justify-content: center;">
|
|
|
|
|
+ <div>摄像头信息:</div>
|
|
|
|
|
+ <div class="cell" v-for="(item,index) in cameraList" :key="index">{{ item.label +':'+ item.deviceId }}</div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div v-else style="position: fixed; z-index: 100; top: 50%; height: 50px; display: flex; flex-direction: column; align-items: center; justify-content: center;">
|
|
|
|
|
+ <div>摄像头获取失败信息:{{getCameraFailText}}</div>
|
|
|
</div> -->
|
|
</div> -->
|
|
|
<!-- 控制栏 -->
|
|
<!-- 控制栏 -->
|
|
|
- <div class="control-bar">
|
|
|
|
|
|
|
+ <div class="control-bar">
|
|
|
<button class="control-btn" :class="{ active: !muteMicrophone }" @click="openCloseMicrophone">
|
|
<button class="control-btn" :class="{ active: !muteMicrophone }" @click="openCloseMicrophone">
|
|
|
<i class="iconfont" :class="{'icon-microphone-off': muteMicrophone, 'icon-microphone-on': !muteMicrophone }"></i>
|
|
<i class="iconfont" :class="{'icon-microphone-off': muteMicrophone, 'icon-microphone-on': !muteMicrophone }"></i>
|
|
|
</button>
|
|
</button>
|
|
|
<button class="control-btn" :class="{ active: !muteCamera }" @click="openCloseCamera">
|
|
<button class="control-btn" :class="{ active: !muteCamera }" @click="openCloseCamera">
|
|
|
<i class="iconfont" :class="{ 'icon-camera-off': !muteCamera, 'icon-camera-on': muteCamera }"></i>
|
|
<i class="iconfont" :class="{ 'icon-camera-off': !muteCamera, 'icon-camera-on': muteCamera }"></i>
|
|
|
</button>
|
|
</button>
|
|
|
- <!-- <button class="control-btn" :class="{ active: useSpeaker }" @click="openCloseSpeaker">
|
|
|
|
|
- <i class="iconfont" :class="{'icon-speaker-off': !useSpeaker , 'icon-speaker-on': useSpeaker }"></i>
|
|
|
|
|
- </button> -->
|
|
|
|
|
- <button class="control-btn active" @click="switchCamera">
|
|
|
|
|
- <i class="iconfont icon-switch1"></i>
|
|
|
|
|
|
|
+ <button class="control-btn active" @click="switchCamera">
|
|
|
|
|
+ <i class="iconfont icon-switch1"></i>
|
|
|
|
|
+ </button>
|
|
|
|
|
+ <button class="control-btn message-btn" :class="{ active: showIMPanel }" @click="toggleIM">
|
|
|
|
|
+ <i class="iconfont">💬</i>
|
|
|
</button>
|
|
</button>
|
|
|
<button class="control-btn hangup-btn" @click="exitCall">
|
|
<button class="control-btn hangup-btn" @click="exitCall">
|
|
|
<i class="iconfont icon-dianhua"></i>
|
|
<i class="iconfont icon-dianhua"></i>
|
|
|
</button>
|
|
</button>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
+
|
|
|
|
|
+ <!-- 图文消息面板 -->
|
|
|
|
|
+ <chat-panel
|
|
|
|
|
+ ref="chatPanel"
|
|
|
|
|
+ :show="showIMPanel"
|
|
|
|
|
+ :config="chatConfig"
|
|
|
|
|
+ @close="showIMPanel = false"
|
|
|
|
|
+ />
|
|
|
</div>
|
|
</div>
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
@@ -54,42 +62,46 @@
|
|
|
logoutTIM,
|
|
logoutTIM,
|
|
|
openCloseMicrophone, // 开关麦可风
|
|
openCloseMicrophone, // 开关麦可风
|
|
|
openCloseCamera, // 开关摄像头
|
|
openCloseCamera, // 开关摄像头
|
|
|
- openCloseSpeaker, // 开关扬声器
|
|
|
|
|
|
|
+ openCloseSpeaker, // 开关扬声器
|
|
|
getCamera // 获取摄像头列表
|
|
getCamera // 获取摄像头列表
|
|
|
} from './tim-h5-adapter';
|
|
} from './tim-h5-adapter';
|
|
|
|
|
+ import ChatPanel from '@/components/chat-panel/chat-panel.vue';
|
|
|
|
|
|
|
|
export default {
|
|
export default {
|
|
|
- props: {
|
|
|
|
|
- config: {
|
|
|
|
|
- type: Object,
|
|
|
|
|
- default: () => ({
|
|
|
|
|
- sdkAppID: '',
|
|
|
|
|
- userID: '',
|
|
|
|
|
- userSig: '',
|
|
|
|
|
- template: '',
|
|
|
|
|
- debugMode: false,
|
|
|
|
|
-
|
|
|
|
|
- // 是否开启调试模式
|
|
|
|
|
- enableIM: false,
|
|
|
|
|
-
|
|
|
|
|
- // 是否开启 IM
|
|
|
|
|
- patID: '',
|
|
|
|
|
-
|
|
|
|
|
- frUserID: '',
|
|
|
|
|
- toUserID: '',
|
|
|
|
|
- doctorName: '',
|
|
|
|
|
- patName: '',
|
|
|
|
|
- isTextChat: ''
|
|
|
|
|
- })
|
|
|
|
|
- }
|
|
|
|
|
- },
|
|
|
|
|
- watch: {
|
|
|
|
|
- config: {
|
|
|
|
|
- handler(newValue) {
|
|
|
|
|
- console.log('config newValue', newValue)
|
|
|
|
|
- },
|
|
|
|
|
- deep: true
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ components: {
|
|
|
|
|
+ ChatPanel
|
|
|
|
|
+ },
|
|
|
|
|
+ props: {
|
|
|
|
|
+ config: {
|
|
|
|
|
+ type: Object,
|
|
|
|
|
+ default: () => ({
|
|
|
|
|
+ sdkAppID: '',
|
|
|
|
|
+ userID: '',
|
|
|
|
|
+ userSig: '',
|
|
|
|
|
+ template: '',
|
|
|
|
|
+ debugMode: false,
|
|
|
|
|
+
|
|
|
|
|
+ // 是否开启调试模式
|
|
|
|
|
+ enableIM: false,
|
|
|
|
|
+
|
|
|
|
|
+ // 是否开启 IM
|
|
|
|
|
+ patID: '',
|
|
|
|
|
+
|
|
|
|
|
+ frUserID: '',
|
|
|
|
|
+ toUserID: '',
|
|
|
|
|
+ doctorName: '',
|
|
|
|
|
+ patName: '',
|
|
|
|
|
+ isTextChat: ''
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ watch: {
|
|
|
|
|
+ config: {
|
|
|
|
|
+ handler(newValue) {
|
|
|
|
|
+ console.log('config newValue', newValue)
|
|
|
|
|
+ },
|
|
|
|
|
+ deep: true
|
|
|
|
|
+ }
|
|
|
},
|
|
},
|
|
|
data() {
|
|
data() {
|
|
|
return {
|
|
return {
|
|
@@ -101,35 +113,48 @@
|
|
|
remoteStreams: {}, // 远程流
|
|
remoteStreams: {}, // 远程流
|
|
|
muteMicrophone: false, // 是否静音麦克风
|
|
muteMicrophone: false, // 是否静音麦克风
|
|
|
muteCamera: false, // 是否关闭摄像头
|
|
muteCamera: false, // 是否关闭摄像头
|
|
|
- useSpeaker: true, // 是否使用扬声器
|
|
|
|
|
- useCamera: 0, // 使用摄像头 0:前置摄像头 1:后置摄像头
|
|
|
|
|
- cameraList: [], // 摄像头列表
|
|
|
|
|
- getCameraFailText: ''
|
|
|
|
|
|
|
+ useSpeaker: true, // 是否使用扬声器
|
|
|
|
|
+ useCamera: 0, // 使用摄像头 0:前置摄像头 1:后置摄像头
|
|
|
|
|
+ cameraList: [], // 摄像头列表
|
|
|
|
|
+ getCameraFailText: '',
|
|
|
|
|
+ showIMPanel: false // IM 消息面板显示/隐藏
|
|
|
};
|
|
};
|
|
|
},
|
|
},
|
|
|
|
|
+ computed: {
|
|
|
|
|
+ chatConfig() {
|
|
|
|
|
+ return {
|
|
|
|
|
+ admID: this.config.admID || '',
|
|
|
|
|
+ frUserID: this.config.frUserID || '',
|
|
|
|
|
+ toUserID: this.config.toUserID || '',
|
|
|
|
|
+ doctorName: this.config.doctorName || '',
|
|
|
|
|
+ patName: this.config.patName || '',
|
|
|
|
|
+ patID: this.config.patID || ''
|
|
|
|
|
+ };
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
|
|
|
- onLoad(options) {
|
|
|
|
|
- console.log('room 组件onload', this.config)
|
|
|
|
|
|
|
+ onLoad(options) {
|
|
|
|
|
+ console.log('room 组件onload', this.config)
|
|
|
// 从选项中获取参数
|
|
// 从选项中获取参数
|
|
|
this.userId = this.config.userID;
|
|
this.userId = this.config.userID;
|
|
|
this.roomID = this.config.roomID;
|
|
this.roomID = this.config.roomID;
|
|
|
this.sdkAppID = this.config.sdkAppID || 0; // 实际应用中需要替换为真实的 SDKAppID
|
|
this.sdkAppID = this.config.sdkAppID || 0; // 实际应用中需要替换为真实的 SDKAppID
|
|
|
- this.userSig = this.config.userSig || ''; // 实际应用中需要从服务端获取
|
|
|
|
|
-
|
|
|
|
|
- if(!this.userId) {
|
|
|
|
|
- uni.showToast({
|
|
|
|
|
- icon: "error",
|
|
|
|
|
- title: '用户ID不存在,请重试!'
|
|
|
|
|
- })
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
- if(!this.roomID) {
|
|
|
|
|
- uni.showToast({
|
|
|
|
|
- icon: "error",
|
|
|
|
|
- title: '房间号不存在,请重试!'
|
|
|
|
|
- })
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ this.userSig = this.config.userSig || ''; // 实际应用中需要从服务端获取
|
|
|
|
|
+
|
|
|
|
|
+ if(!this.userId) {
|
|
|
|
|
+ uni.showToast({
|
|
|
|
|
+ icon: "error",
|
|
|
|
|
+ title: '用户ID不存在,请重试!'
|
|
|
|
|
+ })
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ if(!this.roomID) {
|
|
|
|
|
+ uni.showToast({
|
|
|
|
|
+ icon: "error",
|
|
|
|
|
+ title: '房间号不存在,请重试!'
|
|
|
|
|
+ })
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
// 初始化 TIM 和 TRTC
|
|
// 初始化 TIM 和 TRTC
|
|
|
// this.initCall();
|
|
// this.initCall();
|
|
@@ -144,9 +169,9 @@
|
|
|
/**
|
|
/**
|
|
|
* 初始化通话
|
|
* 初始化通话
|
|
|
*/
|
|
*/
|
|
|
- async initCall(config) {
|
|
|
|
|
- const _this = this
|
|
|
|
|
- console.log('config === ', config)
|
|
|
|
|
|
|
+ async initCall(config) {
|
|
|
|
|
+ const _this = this
|
|
|
|
|
+ console.log('config === ', config)
|
|
|
try {
|
|
try {
|
|
|
// 初始化 TIM
|
|
// 初始化 TIM
|
|
|
await initTIM({
|
|
await initTIM({
|
|
@@ -161,24 +186,26 @@
|
|
|
// 监听远程流移除事件
|
|
// 监听远程流移除事件
|
|
|
window.addEventListener('remote-stream-removed', this.handleRemoteStreamRemoved);
|
|
window.addEventListener('remote-stream-removed', this.handleRemoteStreamRemoved);
|
|
|
// 监听 TIM SDK 就绪事件
|
|
// 监听 TIM SDK 就绪事件
|
|
|
- window.addEventListener('tim-sdk-ready', this.handleSDKReady);
|
|
|
|
|
-
|
|
|
|
|
- // 初始化 TRTC 并加入房间
|
|
|
|
|
- await initTRTC({
|
|
|
|
|
- sdkAppID: config.sdkAppID,
|
|
|
|
|
- roomId: config.roomID,
|
|
|
|
|
- userId: config.userID,
|
|
|
|
|
- userSig: config.userSig,
|
|
|
|
|
- }).then(res => {
|
|
|
|
|
- console.log('trtcClient===', res.trtcClient)
|
|
|
|
|
- _this.getCamera() // 获取摄像头列表
|
|
|
|
|
- _this.localStream = res.localStream
|
|
|
|
|
|
|
+ window.addEventListener('tim-sdk-ready', this.handleSDKReady);
|
|
|
|
|
+ // 监听 IM 新消息事件 → 自动打开面板并刷新
|
|
|
|
|
+ window.addEventListener('tim-message-received', this.onIMNewMessage);
|
|
|
|
|
+
|
|
|
|
|
+ // 初始化 TRTC 并加入房间
|
|
|
|
|
+ await initTRTC({
|
|
|
|
|
+ sdkAppID: config.sdkAppID,
|
|
|
|
|
+ roomId: config.roomID,
|
|
|
|
|
+ userId: config.userID,
|
|
|
|
|
+ userSig: config.userSig,
|
|
|
|
|
+ }).then(res => {
|
|
|
|
|
+ console.log('trtcClient===', res.trtcClient)
|
|
|
|
|
+ _this.getCamera() // 获取摄像头列表
|
|
|
|
|
+ _this.localStream = res.localStream
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
// 设置本地流
|
|
// 设置本地流
|
|
|
- // this.localStream = true;
|
|
|
|
|
- setTimeout(() => {
|
|
|
|
|
- _this.bindLocalStream(); // 延迟一下再绑定本地流,确保元素已经渲染
|
|
|
|
|
|
|
+ // this.localStream = true;
|
|
|
|
|
+ setTimeout(() => {
|
|
|
|
|
+ _this.bindLocalStream(); // 延迟一下再绑定本地流,确保元素已经渲染
|
|
|
}, 500)
|
|
}, 500)
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
console.error('初始化通话失败:', error);
|
|
console.error('初始化通话失败:', error);
|
|
@@ -234,27 +261,27 @@
|
|
|
* 绑定本地流到 video 元素
|
|
* 绑定本地流到 video 元素
|
|
|
*/
|
|
*/
|
|
|
async bindLocalStream() {
|
|
async bindLocalStream() {
|
|
|
- const videoElement = document.getElementById(`local-video-box`);
|
|
|
|
|
|
|
+ const videoElement = document.getElementById(`local-video-box`);
|
|
|
console.log('bindLocalStream videoElement:', videoElement)
|
|
console.log('bindLocalStream videoElement:', videoElement)
|
|
|
if (videoElement) {
|
|
if (videoElement) {
|
|
|
// 在实际的 TRTC SDK 中,会有方法将流绑定到 video 元素
|
|
// 在实际的 TRTC SDK 中,会有方法将流绑定到 video 元素
|
|
|
// 这里只是示例,具体实现需要根据实际的 SDK 方法调整
|
|
// 这里只是示例,具体实现需要根据实际的 SDK 方法调整
|
|
|
console.log('绑定本地流到DOM', this.localStream);
|
|
console.log('绑定本地流到DOM', this.localStream);
|
|
|
- // 例如: stream.play(`local-video-${this.userId}`);
|
|
|
|
|
- try {
|
|
|
|
|
- // await localStream.initialize();
|
|
|
|
|
- console.log('初始化本地流成功');
|
|
|
|
|
- this.localStream.play('local-video-box');
|
|
|
|
|
- this.localStream.on('error', error => {
|
|
|
|
|
- console.log(error)
|
|
|
|
|
- const errorCode = error.getCode();
|
|
|
|
|
- if (errorCode === 0x4043) {
|
|
|
|
|
- // PLAY_NOT_ALLOWED,引导用户手势操作并调用 stream.resume 恢复音视频播放
|
|
|
|
|
- // stream.resume()
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
- } catch (error) {
|
|
|
|
|
- console.error('初始化本地流失败 ' + error);
|
|
|
|
|
|
|
+ // 例如: stream.play(`local-video-${this.userId}`);
|
|
|
|
|
+ try {
|
|
|
|
|
+ // await localStream.initialize();
|
|
|
|
|
+ console.log('初始化本地流成功');
|
|
|
|
|
+ this.localStream.play('local-video-box');
|
|
|
|
|
+ this.localStream.on('error', error => {
|
|
|
|
|
+ console.log(error)
|
|
|
|
|
+ const errorCode = error.getCode();
|
|
|
|
|
+ if (errorCode === 0x4043) {
|
|
|
|
|
+ // PLAY_NOT_ALLOWED,引导用户手势操作并调用 stream.resume 恢复音视频播放
|
|
|
|
|
+ // stream.resume()
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ console.error('初始化本地流失败 ' + error);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
@@ -268,18 +295,18 @@
|
|
|
// 在实际的 TRTC SDK 中,会有方法将流绑定到 video 元素
|
|
// 在实际的 TRTC SDK 中,会有方法将流绑定到 video 元素
|
|
|
// 这里只是示例,具体实现需要根据实际的 SDK 方法调整
|
|
// 这里只是示例,具体实现需要根据实际的 SDK 方法调整
|
|
|
console.log('绑定远程流到元素:', userId);
|
|
console.log('绑定远程流到元素:', userId);
|
|
|
- // 例如:
|
|
|
|
|
- stream.play(`remote-video-box`);
|
|
|
|
|
- stream.on('error', error => {
|
|
|
|
|
- console.log(error)
|
|
|
|
|
- const errorCode = error.getCode();
|
|
|
|
|
- if (errorCode === 0x4043) {
|
|
|
|
|
- // PLAY_NOT_ALLOWED,引导用户手势操作并调用 stream.resume 恢复音视频播放
|
|
|
|
|
- // stream.resume()
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // 例如:
|
|
|
|
|
+ stream.play(`remote-video-box`);
|
|
|
|
|
+ stream.on('error', error => {
|
|
|
|
|
+ console.log(error)
|
|
|
|
|
+ const errorCode = error.getCode();
|
|
|
|
|
+ if (errorCode === 0x4043) {
|
|
|
|
|
+ // PLAY_NOT_ALLOWED,引导用户手势操作并调用 stream.resume 恢复音视频播放
|
|
|
|
|
+ // stream.resume()
|
|
|
|
|
+ }
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
- },
|
|
|
|
|
|
|
+ },
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -306,41 +333,41 @@
|
|
|
console.error('开关摄像头失败:', error);
|
|
console.error('开关摄像头失败:', error);
|
|
|
this.muteCamera = !this.muteCamera;
|
|
this.muteCamera = !this.muteCamera;
|
|
|
}
|
|
}
|
|
|
- },
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 切换摄像头
|
|
|
|
|
- */
|
|
|
|
|
- async switchCamera() {
|
|
|
|
|
- try {
|
|
|
|
|
- if(this.cameraList.length > 1) {
|
|
|
|
|
- this.useCamera = this.useCamera ? 0 : 1;
|
|
|
|
|
- let cameraId = this.cameraList[this.useCamera].deviceId;
|
|
|
|
|
- this.localStream.switchDevice('video', cameraId).then(() => {
|
|
|
|
|
- console.log('切换摄像头成功');
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- } catch (error) {
|
|
|
|
|
- console.error('切换摄像头失败:', error);
|
|
|
|
|
- }
|
|
|
|
|
- },
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- // 获取摄像头
|
|
|
|
|
- async getCamera() {
|
|
|
|
|
- try {
|
|
|
|
|
- await getCamera().then(devices => {
|
|
|
|
|
- console.log(devices)
|
|
|
|
|
- this.setData({
|
|
|
|
|
- cameraList: devices
|
|
|
|
|
- })
|
|
|
|
|
- }).catch(error => {
|
|
|
|
|
- this.getCameraFailText = JSON.stringify(error)
|
|
|
|
|
- })
|
|
|
|
|
- } catch (error) {
|
|
|
|
|
- console.error('切换摄像头失败:', error);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 切换摄像头
|
|
|
|
|
+ */
|
|
|
|
|
+ async switchCamera() {
|
|
|
|
|
+ try {
|
|
|
|
|
+ if(this.cameraList.length > 1) {
|
|
|
|
|
+ this.useCamera = this.useCamera ? 0 : 1;
|
|
|
|
|
+ let cameraId = this.cameraList[this.useCamera].deviceId;
|
|
|
|
|
+ this.localStream.switchDevice('video', cameraId).then(() => {
|
|
|
|
|
+ console.log('切换摄像头成功');
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ console.error('切换摄像头失败:', error);
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ // 获取摄像头
|
|
|
|
|
+ async getCamera() {
|
|
|
|
|
+ try {
|
|
|
|
|
+ await getCamera().then(devices => {
|
|
|
|
|
+ console.log(devices)
|
|
|
|
|
+ this.setData({
|
|
|
|
|
+ cameraList: devices
|
|
|
|
|
+ })
|
|
|
|
|
+ }).catch(error => {
|
|
|
|
|
+ this.getCameraFailText = JSON.stringify(error)
|
|
|
|
|
+ })
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ console.error('切换摄像头失败:', error);
|
|
|
|
|
+ }
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -365,6 +392,10 @@
|
|
|
window.removeEventListener('remote-stream-added', this.handleRemoteStreamAdded);
|
|
window.removeEventListener('remote-stream-added', this.handleRemoteStreamAdded);
|
|
|
window.removeEventListener('remote-stream-removed', this.handleRemoteStreamRemoved);
|
|
window.removeEventListener('remote-stream-removed', this.handleRemoteStreamRemoved);
|
|
|
window.removeEventListener('tim-sdk-ready', this.handleSDKReady);
|
|
window.removeEventListener('tim-sdk-ready', this.handleSDKReady);
|
|
|
|
|
+ window.removeEventListener('tim-message-received', this.onIMNewMessage);
|
|
|
|
|
+
|
|
|
|
|
+ // 关闭 IM 面板
|
|
|
|
|
+ this.showIMPanel = false;
|
|
|
|
|
|
|
|
// 退出房间
|
|
// 退出房间
|
|
|
await exitRoom();
|
|
await exitRoom();
|
|
@@ -382,13 +413,43 @@
|
|
|
console.error('退出通话失败:', error);
|
|
console.error('退出通话失败:', error);
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 切换 IM 消息面板
|
|
|
|
|
+ */
|
|
|
|
|
+ toggleIM() {
|
|
|
|
|
+ this.showIMPanel = !this.showIMPanel;
|
|
|
|
|
+ // 打开面板时主动触发加载历史消息
|
|
|
|
|
+ if (this.showIMPanel) {
|
|
|
|
|
+ this.$nextTick(() => {
|
|
|
|
|
+ if (this.$refs.chatPanel) {
|
|
|
|
|
+ this.$refs.chatPanel.getChatData('bottom');
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 接收到新 IM 消息 → 打开面板并刷新
|
|
|
|
|
+ */
|
|
|
|
|
+ onIMNewMessage(event) {
|
|
|
|
|
+ console.log('[H5-TRTC] 收到新 IM 消息', event);
|
|
|
|
|
+ // 自动打开面板
|
|
|
|
|
+ this.showIMPanel = true;
|
|
|
|
|
+ // 通知 chat-panel 刷新消息列表
|
|
|
|
|
+ this.$nextTick(() => {
|
|
|
|
|
+ if (this.$refs.chatPanel) {
|
|
|
|
|
+ this.$refs.chatPanel.getChatData('bottom');
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
},
|
|
},
|
|
|
};
|
|
};
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|
|
|
-<style scoped>
|
|
|
|
|
- .bg-red {
|
|
|
|
|
- background-color: #ff3300;
|
|
|
|
|
|
|
+<style scoped>
|
|
|
|
|
+ .bg-red {
|
|
|
|
|
+ background-color: #ff3300;
|
|
|
}
|
|
}
|
|
|
.video-call-container {
|
|
.video-call-container {
|
|
|
width: 100%;
|
|
width: 100%;
|
|
@@ -467,7 +528,7 @@
|
|
|
width: 56px;
|
|
width: 56px;
|
|
|
height: 56px;
|
|
height: 56px;
|
|
|
border-radius: 50%;
|
|
border-radius: 50%;
|
|
|
- color: #fff;
|
|
|
|
|
|
|
+ color: #fff;
|
|
|
background-color: #f75c45;
|
|
background-color: #f75c45;
|
|
|
display: flex;
|
|
display: flex;
|
|
|
justify-content: center;
|
|
justify-content: center;
|
|
@@ -480,15 +541,26 @@
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
.control-btn.active {
|
|
.control-btn.active {
|
|
|
- background-color: #fff;
|
|
|
|
|
|
|
+ background-color: #fff;
|
|
|
color: #0369fe;
|
|
color: #0369fe;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
.hangup-btn {
|
|
.hangup-btn {
|
|
|
- background-color: #f75c45;
|
|
|
|
|
|
|
+ background-color: #f75c45;
|
|
|
transform: rotate(135deg);
|
|
transform: rotate(135deg);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /* 消息按钮:默认白底,激活蓝底 */
|
|
|
|
|
+ .message-btn {
|
|
|
|
|
+ background-color: #fff;
|
|
|
|
|
+ color: #0369fe;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ .message-btn.active {
|
|
|
|
|
+ background-color: #0369fe;
|
|
|
|
|
+ color: #fff;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/* 图标字体样式 */
|
|
/* 图标字体样式 */
|
|
|
.iconfont {
|
|
.iconfont {
|
|
|
font-size: 28px;
|
|
font-size: 28px;
|