瀏覽代碼

Merge remote-tracking branch 'origin/openIm' into openIm

xdd 2 周之前
父節點
當前提交
60e4a171bb

+ 26 - 0
src/api/collection.js

@@ -0,0 +1,26 @@
+import request from '@/utils/request'
+
+//查询初诊单列表
+export function list(query) {
+  return request({
+    url: '/app/collection/getCollectionList',
+    method: 'get',
+    params: query
+  })
+}
+
+// 查询用户采集详情
+export function detail(id) {
+  return request({
+    url: '/app/collection/detail/' + id,
+    method: 'get'
+  })
+}
+
+export function doctorConfirm(data) {
+  return request({
+    url: '/app/collection/doctorConfirm',
+    method: 'put',
+    data: data
+  })
+}

+ 8 - 0
src/api/inquiryOrder.js

@@ -132,5 +132,13 @@ export function getInquiryOrderMsgList(query) {
   })
 }
 
+export function closeOrder(orderId) {
+  return request({
+    url: '/app/inquiryOrder/closeOrder',
+    method: 'post',
+    data: orderId
+  })
+}
+
 
 

+ 633 - 596
src/components/message/trtc-calling/calling-index.vue

@@ -76,655 +76,692 @@
 
 
 <script>
-  import { v4 as uuidv4 } from 'uuid';
-  import { mapGetters, mapState } from 'vuex';
-  import { formatDuration } from '@/utils/formatDuration';
-  import { CALL_TYPE } from '@/constant/call';
-  import { getOpenIM } from '@/utils/openIM';
-  import Trtc,{createLocalAudioTrack,createLocalVideoTrack} from '@/utils/trtc';
-  import beCalledSound from '@/assets/audio/beCalled.mp3';
-  export default {
-    name: 'CallLayer',
-    data() {
-      return {
-        acceptToken: '',
-        acceptURL: '',
-        acceptRoomID: '',
-        faceImages:"",
-        nickName:"",
-        callType: '',
-        inviteID: '',
-        inviteData: {},
-        sponsor: '',
-        callingUserList: [],
-        isCamOn: true,
-        isMicOn: true,
-        start: 0,
-        duration: 0,
-        dialling: false,
-        calling: false,
-        isDialled: false,
-        invitedUserInfo: [],
-        room: null,
-        localTracks: [],
-        remoteUsers: [],
-        OpenIM: null,
-        durationTimer: null,
-        defaultAvatar: 'https://imgcache.qq.com/open/qcloud/video/act/webim-avatar/avatar-3.png',
-        isInvitedMicOn: true,
-        ringtone: null,
-        ringtoneType: '',
-      };
+import { v4 as uuidv4 } from 'uuid';
+import { mapGetters, mapState } from 'vuex';
+import { formatDuration } from '@/utils/formatDuration';
+import { CALL_TYPE } from '@/constant/call';
+import { getOpenIM } from '@/utils/openIM';
+import Trtc,{createLocalAudioTrack,createLocalVideoTrack} from '@/utils/trtc';
+import beCalledSound from '@/assets/audio/beCalled.mp3';
+export default {
+  name: 'CallLayer',
+  data() {
+    return {
+      acceptToken: '',
+      acceptURL: '',
+      acceptRoomID: '',
+      faceImages:"",
+      nickName:"",
+      callType: '',
+      inviteID: '',
+      inviteData: {},
+      sponsor: '',
+      callingUserList: [],
+      isCamOn: true,
+      isMicOn: true,
+      start: 0,
+      duration: 0,
+      dialling: false,
+      calling: false,
+      isDialled: false,
+      invitedUserInfo: [],
+      room: null,
+      localTracks: [],
+      remoteUsers: [],
+      OpenIM: null,
+      durationTimer: null,
+      defaultAvatar: 'https://imgcache.qq.com/open/qcloud/video/act/webim-avatar/avatar-3.png',
+      isInvitedMicOn: true,
+      ringtone: null,
+      ringtoneType: '',
+    };
+  },
+  computed: {
+    CALL_TYPE() {
+      return CALL_TYPE;
     },
-    computed: {
-      CALL_TYPE() {
-        return CALL_TYPE;
-      },
-      ...mapGetters(['toAccount', 'currentConversationType']),
-      ...mapState({
-        currentConversation: state => state.conversation.currentConversation,
-        currentUserProfile: state => state.imuser.currentUserProfile,
-        callingInfo: state => state.conversation.callingInfo,
-        userID: state => state.imuser.userID,
-      }),
-      formatDurationStr() {
-        return formatDuration(this.duration);
-      },
-      myAvatar() {
-        console.log("我的相关信息",this.currentUserProfile)
-        return this.currentUserProfile.faceURL || this.defaultAvatar
-      },
-      myNick() {
-        return this.currentUserProfile.nickname || this.userID
-      }
+    ...mapGetters(['toAccount', 'currentConversationType']),
+    ...mapState({
+      currentConversation: state => state.conversation.currentConversation,
+      currentUserProfile: state => state.imuser.currentUserProfile,
+      callingInfo: state => state.conversation.callingInfo,
+      userID: state => state.imuser.userID,
+    }),
+    formatDurationStr() {
+      return formatDuration(this.duration);
     },
-    created() {
-      this.OpenIM = getOpenIM();
-      //document.addEventListener('click', this.initAudio, { once: true })
-      this.setupEventListeners();
+    myAvatar() {
+      console.log("我的相关信息",this.currentUserProfile)
+      return this.currentUserProfile.faceURL || this.defaultAvatar
     },
-    beforeDestroy() {
-      this.cleanup();
+    myNick() {
+      return this.currentUserProfile.nickname || this.userID
+    }
+  },
+  created() {
+    this.OpenIM = getOpenIM();
+    //document.addEventListener('click', this.initAudio, { once: true })
+    this.setupEventListeners();
+  },
+  beforeDestroy() {
+    this.cleanup();
+  },
+  methods: {
+
+    micHandler() { // 是否打开麦克风
+      if (this.isMicOn) {
+        this.toggleMic()
+        this.isMicOn = false
+      } else {
+        this.toggleMic()
+        this.isMicOn = true
+      }
+    },
+    // 初始化事件监听
+    setupEventListeners() {
+      this.OpenIM.on('OnReceiveNewInvitation', this.handleNewInvitation);
+      this.OpenIM.on('OnInviteeAccepted', this.handleInviteeAccepted);
+      this.OpenIM.on('OnInviteeRejected', this.handleInviteeRejected);
+      this.OpenIM.on('OnInvitationTimeout', this.handleInvitationTimeout);
+      this.OpenIM.on('OnHangUp', this.handleHangUp);
+
+      this.$bus.$on('video-call', () => this.startCall('video'));
+      this.$bus.$on('audio-call', () => this.startCall('audio'));
     },
-    methods: {
 
-      micHandler() { // 是否打开麦克风
-        if (this.isMicOn) {
-          this.toggleMic()
-          this.isMicOn = false
-        } else {
-          this.toggleMic()
-          this.isMicOn = true
-        }
-      },
-      // 初始化事件监听
-      setupEventListeners() {
-        this.OpenIM.on('OnReceiveNewInvitation', this.handleNewInvitation);
-        this.OpenIM.on('OnInviteeAccepted', this.handleInviteeAccepted);
-        this.OpenIM.on('OnInviteeRejected', this.handleInviteeRejected);
-        this.OpenIM.on('OnInvitationTimeout', this.handleInvitationTimeout);
-        this.OpenIM.on('OnHangUp', this.handleHangUp);
-
-        this.$bus.$on('video-call', () => this.startCall('video'));
-        this.$bus.$on('audio-call', () => this.startCall('audio'));
-      },
-
-      // 清理资源
-      cleanup() {
-        //this.stopRingtone();
-        clearInterval(this.durationTimer);
+    // 清理资源
+    cleanup() {
+      //this.stopRingtone();
+      clearInterval(this.durationTimer);
 
-        if (this.room) {
-          this.room.disconnect();
-          this.room = null;
-        }
+      if (this.room) {
+        this.room.disconnect();
+        this.room = null;
+      }
 
-        this.OpenIM.off('OnReceiveNewInvitation', this.handleNewInvitation);
-        this.OpenIM.off('OnInviteeAccepted', this.handleInviteeAccepted);
-        this.OpenIM.off('OnInviteeRejected', this.handleInviteeRejected);
-        this.OpenIM.off('OnInvitationTimeout', this.handleInvitationTimeout);
-        this.OpenIM.off('OnHangUp', this.handleHangUp);
-
-        this.$bus.$off('video-call');
-        this.$bus.$off('audio-call');
-      },
-
-      // 播放铃声
-      initAudio(type = 'callee') {
-        try {
-          const audio = new Audio(beCalledSound);
-          audio.play().catch(err => {
-            console.warn("播放声音失败", err);
-          });
-          this.ringtone = new Audio(beCalledSound);
-          this.ringtone.loop = true;
-          this.ringtone.preload = 'auto';
-          this.ringtoneType = type;
+      this.OpenIM.off('OnReceiveNewInvitation', this.handleNewInvitation);
+      this.OpenIM.off('OnInviteeAccepted', this.handleInviteeAccepted);
+      this.OpenIM.off('OnInviteeRejected', this.handleInviteeRejected);
+      this.OpenIM.off('OnInvitationTimeout', this.handleInvitationTimeout);
+      this.OpenIM.off('OnHangUp', this.handleHangUp);
 
-          this.ringtone.addEventListener('error', (e) => {
-            console.error('音频加载错误:', e);
-          });
+      this.$bus.$off('video-call');
+      this.$bus.$off('audio-call');
+    },
 
-          this.ringtone.play().catch((err) => {
-            console.warn('播放铃声失败,可能未解锁音频权限:', err);
-          });
-        } catch (e) {
-          console.error('音频初始化失败:', e);
-        }
-      },
-      playRingtone() {
-        if (!this.ringtone) {
-          this.initAudio()
-        }
+    // 播放铃声
+    initAudio(type = 'callee') {
+      try {
+        const audio = new Audio(beCalledSound);
+        audio.play().catch(err => {
+          console.warn("播放声音失败", err);
+        });
+        this.ringtone = new Audio(beCalledSound);
+        this.ringtone.loop = true;
+        this.ringtone.preload = 'auto';
+        this.ringtoneType = type;
 
-        this.ringtone.loop = true
-        this.ringtone.play().catch(e => {
-          console.error('播放被阻止:', e)
-          // 可以在这里显示"点击允许音频"的提示
-        })
-      },
-      stopRingtone() {
-        if (this.ringtone) {
-          this.ringtone.pause();
-          this.ringtone.currentTime = 0;
-          this.ringtone = null;
-          this.ringtoneType = '';
-        }
-      },
-
-      // 处理新邀请
-      async handleNewInvitation(data) {
-        console.log("返回的参数data", data)
-        this.inviteID = data.data.inviteID
-        this.inviteData = data.data.invitation
-        this.callType = data.data.invitation.mediaType
-        this.sponsor = data.data.participant.userInfo.nickname
-        this.isDialled = true
-
-        // ✅ 提前预热权限(耗时 1-2 秒,提前做)
-        this.prewarmMediaPermission()
-
-        // ✅ 提前执行 signalingAccept,拿到 token/url(非真正入会)
-        try {
-          const res = await this.OpenIM.signalingAccept({
-            opUserID: this.userID,
-            invitation: this.inviteData
-          });
-          this.acceptToken = res.data.token
-          this.acceptURL = res.data.liveURL
-          this.acceptRoomID = this.inviteData.roomID
-        } catch (err) {
-          console.error("提前 accept 接口失败", err)
-        }
+        this.ringtone.addEventListener('error', (e) => {
+          console.error('音频加载错误:', e);
+        });
 
-        document.addEventListener('click', () => {
-          this.initAudio('callee');
-        }, { once: true })
+        this.ringtone.play().catch((err) => {
+          console.warn('播放铃声失败,可能未解锁音频权限:', err);
+        });
+      } catch (e) {
+        console.error('音频初始化失败:', e);
+      }
+    },
+    playRingtone() {
+      if (!this.ringtone) {
+        this.initAudio()
+      }
 
-        this.updateInvitedUserInfo(data.data.invitation.inviteeUserIDList)
-      },
+      this.ringtone.loop = true
+      this.ringtone.play().catch(e => {
+        console.error('播放被阻止:', e)
+        // 可以在这里显示"点击允许音频"的提示
+      })
+    },
+    stopRingtone() {
+      if (this.ringtone) {
+        this.ringtone.pause();
+        this.ringtone.currentTime = 0;
+        this.ringtone = null;
+        this.ringtoneType = '';
+      }
+    },
 
-      // 更新被邀请用户信息
-      async updateInvitedUserInfo(userIDs) {
-        const users = await Promise.all(
-          userIDs.map(userID => this.OpenIM.getUsersInfo([userID]))
-        );
-        console.log("查询的用户信息",users)
-        this.invitedUserInfo = users.map(user => ({
-          userID: user.userID,
-          nickname: user.nickname,
-          avatar: user.faceURL,
-          isMicOn: true
-        }));
-      },
-
-      // 发起通话
-      async startCall(type) {
-        console.log("发起通话",this.toAccount)
-        if (this.calling || this.dialling) return;
-
-        try {
-          this.callType = type;
-          console.log("通话方式",this.callType)
-          this.dialling = true;
-          const roomId = uuidv4();
-
-          // 1. 先发送邀请,等待被叫方响应(这里需要监听被叫方的接受事件)
-          const { token, liveURL, roomID, inviteID } = await this.sendCallInvitation(roomId, type);
-          this.initAudio('caller');
-          this.inviteID = inviteID; // 保存 inviteID,等待对方接听后再 joinRoom
-          this.roomToken = token;
-          this.roomURL = liveURL;
-          this.roomID = roomID;
-          console.log("生成的token和url",this.roomToken, this.roomURL)
-        } catch (error) {
-          console.error('发起通话失败:', error);
-          this.resetCallState();
-        }
-      },
-      // 被叫方接受邀请后,主叫方和被叫方都调用
-      /*async joinRoom(roomID,roomToken,roomURL) {
-        console.log(roomID)
-        const callData = {
-          // 移除外层 operationID(SDK 会自动添加)
-          invitation: {
-            inviterUserID: this.userID,
-            inviteeUserIDList: ["D79"],
-            groupID: '',
-            roomID: roomID,
-            timeout: 60,
-            mediaType: this.callType,
-            sessionType: 1,
-            platformID: 5
-          },
-          offlinePushInfo: {
-            title: 'You have a call invitation',
-            desc: 'You have a call invitation',
-            ex: '',
-            iOSPushSound: '',
-            iOSBadgeCount: true
-          }
-        };
-        const res = await this.OpenIM.signalingAccept(callData);
-        console.log(res)
-        if (res.errCode !== 0) {
-          console.error("获取房间 token 失败:", res.errMsg);
-          return;
-        }
-        this.room = await Trtc.joinRoom(roomToken, roomURL, this.userID, roomID, {
-          video: this.callType === 'video',
-          audio: true
+    // 处理新邀请
+    async handleNewInvitation(data) {
+      console.log("返回的参数data", data)
+      this.inviteID = data.data.inviteID
+      this.inviteData = data.data.invitation
+      this.callType = data.data.invitation.mediaType
+      this.sponsor = data.data.participant.userInfo.nickname
+      this.isDialled = true
+
+      // 提前预热权限(耗时 1-2 秒,提前做)
+      this.prewarmMediaPermission()
+
+      // 提前执行 signalingAccept,拿到 token/url(非真正入会)
+      try {
+        const res = await this.OpenIM.signalingAccept({
+          opUserID: this.userID,
+          invitation: this.inviteData
         });
+        this.acceptToken = res.data.token
+        this.acceptURL = res.data.liveURL
+        this.acceptRoomID = this.inviteData.roomID
+      } catch (err) {
+        console.error("提前 accept 接口失败", err)
+      }
 
-        this.setupRoomListeners();
-        if (this.callType === 'video'){
-          await this.publishLocalVideo();
-          await this.publishLocalAudio();
-        }
-      },*/
-
-      // 发送通话邀请
-      async sendCallInvitation(roomId, type) {
-        console.log(" this.callingInfo.memberList", this.userID)
-        const callData = {
-          invitation: {
-            inviterUserID: this.userID,
-            inviteeUserIDList: [this.toAccount],
-            groupID: '',
-            roomID: roomId,
-            timeout: 60,
-            mediaType: this.callType,
-            sessionType: 1,
-            platformID: 5
-          },
-          offlinePushInfo: {
-            title: '来电提示',
-            desc: this.callType === 'video'? '视频通话':'语音通话',
-            ex: '',
-            iOSPushSound: '',
-            iOSBadgeCount: true
-          }
-        };
-        console.log("callData",callData)
-        const res = await this.OpenIM.signalingInvite(callData);
-        this.inviteID = res.data.inviteID;
-        console.log("sendCallInvitation返回值",res)
-        return {
-          token: res.data.token,
-          liveURL: res.data.liveURL,
-          roomID: res.data.roomID,
-          inviteID: res.data.inviteID,
-        };
-      },
-      // 设置房间事件监听
-      setupRoomListeners() {
-        console.log("触发setupRoomListeners")
-        /*this.room.on('participantConnected', participant => {
-          console.log('participantConnected:', participant.identity);
-          if (!this.callingUserList.includes(participant.identity)) {
-            this.callingUserList = [...this.callingUserList, participant.identity];
-            this.updateParticipantInfo(participant.identity);
-          }
-        });
+      document.addEventListener('click', () => {
+        this.initAudio('callee');
+      }, { once: true })
 
-        this.room.on('trackSubscribed', (track, participant) => {
-          console.log('trackSubscribed:', track.kind, participant.identity);
-          this.attachRemoteTrack(track, participant);
-        });*/
+      this.updateInvitedUserInfo(data.data.invitation.inviteeUserIDList)
+    },
 
-        this.room.on('trackPublished', publication => {
-          console.log('trackPublished:', publication.trackKind);
-        });
-      },
-      async prewarmMediaPermission() {
-        try {
-          const stream = await navigator.mediaDevices.getUserMedia({ audio: true, video: this.callType === 'video' });
-          stream.getTracks().forEach(track => track.stop()); // 不播放,只为触发授权
-          console.log("预热媒体权限成功");
-        } catch (err) {
-          console.warn("权限预热失败:", err);
+    // 更新被邀请用户信息
+    async updateInvitedUserInfo(userIDs) {
+      const users = await Promise.all(
+        userIDs.map(userID => this.OpenIM.getUsersInfo([userID]))
+      );
+      console.log("查询的用户信息",users)
+      this.invitedUserInfo = users.map(user => ({
+        userID: user.userID,
+        nickname: user.nickname,
+        avatar: user.faceURL,
+        isMicOn: true
+      }));
+    },
+
+    // 发起通话
+    async startCall(type) {
+      console.log("发起通话",this.toAccount)
+      if (this.calling || this.dialling) return;
+
+      try {
+        this.callType = type;
+        console.log("通话方式",this.callType)
+        this.dialling = true;
+        const roomId = uuidv4();
+
+        // 1. 先发送邀请,等待被叫方响应(这里需要监听被叫方的接受事件)
+        const { token, liveURL, roomID, inviteID } = await this.sendCallInvitation(roomId, type);
+        this.initAudio('caller');
+        this.inviteID = inviteID; // 保存 inviteID,等待对方接听后再 joinRoom
+        this.roomToken = token;
+        this.roomURL = liveURL;
+        this.roomID = roomID;
+        console.log("生成的token和url",this.roomToken, this.roomURL)
+      } catch (error) {
+        console.error('发起通话失败:', error);
+        this.resetCallState();
+      }
+    },
+    // 被叫方接受邀请后,主叫方和被叫方都调用
+    /*async joinRoom(roomID,roomToken,roomURL) {
+      console.log(roomID)
+      const callData = {
+        // 移除外层 operationID(SDK 会自动添加)
+        invitation: {
+          inviterUserID: this.userID,
+          inviteeUserIDList: ["D79"],
+          groupID: '',
+          roomID: roomID,
+          timeout: 60,
+          mediaType: this.callType,
+          sessionType: 1,
+          platformID: 5
+        },
+        offlinePushInfo: {
+          title: 'You have a call invitation',
+          desc: 'You have a call invitation',
+          ex: '',
+          iOSPushSound: '',
+          iOSBadgeCount: true
         }
-      },
-      async onAcceptClick() {
-        try {
-          await this.prewarmMediaPermission(); // 权限预热(防止卡住)
-          await this.accept();                 // 原来的接听逻辑
-        } catch (e) {
-          console.error("接听过程异常:", e);
+      };
+      const res = await this.OpenIM.signalingAccept(callData);
+      console.log(res)
+      if (res.errCode !== 0) {
+        console.error("获取房间 token 失败:", res.errMsg);
+        return;
+      }
+      this.room = await Trtc.joinRoom(roomToken, roomURL, this.userID, roomID, {
+        video: this.callType === 'video',
+        audio: true
+      });
+
+      this.setupRoomListeners();
+      if (this.callType === 'video'){
+        await this.publishLocalVideo();
+        await this.publishLocalAudio();
+      }
+    },*/
+
+    // 发送通话邀请
+    async sendCallInvitation(roomId, type) {
+      console.log(" this.callingInfo.memberList", this.userID)
+      const callData = {
+        invitation: {
+          inviterUserID: this.userID,
+          inviteeUserIDList: [this.toAccount],
+          groupID: '',
+          roomID: roomId,
+          timeout: 60,
+          mediaType: this.callType,
+          sessionType: 1,
+          platformID: 5
+        },
+        offlinePushInfo: {
+          title: '来电提示',
+          desc: this.callType === 'video'? '视频通话':'语音通话',
+          ex: '',
+          iOSPushSound: '',
+          iOSBadgeCount: true
         }
-      },
-      // 发布本地视频
-      async publishLocalVideo() {
-        const devices = await navigator.mediaDevices.enumerateDevices();
-        const hasCam = devices.some(d => d.kind === 'videoinput');
-        if (!hasCam) {
-          console.warn('无可用摄像头,跳过视频轨道发布');
-          return;
+      };
+      console.log("callData",callData)
+      const res = await this.OpenIM.signalingInvite(callData);
+      this.inviteID = res.data.inviteID;
+      console.log("sendCallInvitation返回值",res)
+      return {
+        token: res.data.token,
+        liveURL: res.data.liveURL,
+        roomID: res.data.roomID,
+        inviteID: res.data.inviteID,
+      };
+    },
+    // 设置房间事件监听
+    setupRoomListeners() {
+      console.log("触发setupRoomListeners")
+      /*this.room.on('participantConnected', participant => {
+        console.log('participantConnected:', participant.identity);
+        if (!this.callingUserList.includes(participant.identity)) {
+          this.callingUserList = [...this.callingUserList, participant.identity];
+          this.updateParticipantInfo(participant.identity);
         }
+      });
+
+      this.room.on('trackSubscribed', (track, participant) => {
+        console.log('trackSubscribed:', track.kind, participant.identity);
+        this.attachRemoteTrack(track, participant);
+      });*/
+
+      this.room.on('trackPublished', publication => {
+        console.log('trackPublished:', publication.trackKind);
+      });
+    },
+    async prewarmMediaPermission() {
+      try {
+        const stream = await navigator.mediaDevices.getUserMedia({ audio: true, video: this.callType === 'video' });
+        stream.getTracks().forEach(track => track.stop()); // 不播放,只为触发授权
+        console.log("预热媒体权限成功");
+      } catch (err) {
+        console.warn("权限预热失败:", err);
+      }
+    },
+    async onAcceptClick() {
+      try {
+        await this.prewarmMediaPermission(); // 权限预热(防止卡住)
+        await this.accept();                 // 原来的接听逻辑
+      } catch (e) {
+        console.error("接听过程异常:", e);
+      }
+    },
+    // 发布本地视频
+    async publishLocalVideo() {
+      const localContainer = document.getElementById('local');
+      if (!localContainer) return;
+
+      // 确保容器有尺寸
+      localContainer.style.width = '320px';
+      localContainer.style.height = '240px';
+      localContainer.style.backgroundColor = 'black';
+      localContainer.innerHTML = '';
+
+      const devices = await navigator.mediaDevices.enumerateDevices();
+      const hasCam = devices.some(d => d.kind === 'videoinput');
+
+      if (!hasCam) {
+        console.warn('无可用摄像头,显示蓝色占位');
+        this.showBluePlaceholder(localContainer, '无摄像头');
+        return;
+      }
+
+      try {
         const videoTrack = await createLocalVideoTrack();
         await this.room.localParticipant.publishTrack(videoTrack);
         this.localTracks.push(videoTrack);
 
         // 挂载本地视频轨道
-        const localContainer = document.getElementById('local');
-        if (localContainer) {
-          // 清空容器
-          localContainer.innerHTML = '';
-          const videoEl = document.createElement('video');
-          videoEl.autoplay = true;
-          videoEl.muted = true; // 本地视频静音避免回声
-          videoEl.playsInline = true;
-          videoEl.style.width = '100%';
-          videoEl.style.height = '100%';
-          localContainer.appendChild(videoEl);
-          videoTrack.attach(videoEl);
-        }
-      },
+        const videoEl = document.createElement('video');
+        videoEl.autoplay = true;
+        videoEl.muted = true;
+        videoEl.playsInline = true;
+        videoEl.style.width = '100%';
+        videoEl.style.height = '100%';
+        localContainer.appendChild(videoEl);
+        videoTrack.attach(videoEl);
+      } catch (err) {
+        console.error('本地视频初始化失败:', err);
+        //this.showBluePlaceholder(localContainer, '摄像头不可用');
+      }
+    },
+    // 渲染蓝色占位
+    showBluePlaceholder(container, text = '') {
+      const placeholder = document.createElement('div');
+      placeholder.style.width = '100%';
+      placeholder.style.height = '100%';
+      placeholder.style.backgroundColor = 'blue';
+      placeholder.style.display = 'flex';
+      placeholder.style.alignItems = 'center';
+      placeholder.style.justifyContent = 'center';
+      placeholder.style.color = '#fff';
+      placeholder.style.fontSize = '18px';
+      placeholder.innerText = text;
+      container.innerHTML = ''; // 清空容器
+      container.appendChild(placeholder);
+    },
 
-      async publishLocalAudio() {
-        const devices = await navigator.mediaDevices.enumerateDevices();
-        const hasMic = devices.some(d => d.kind === 'audioinput');
-        if (!hasMic) {
-          console.warn('无可用麦克风,跳过音频轨道发布');
-          return;
-        }
-        const audioTrack = await createLocalAudioTrack();
-        await this.room.localParticipant.publishTrack(audioTrack);
-        this.localTracks.push(audioTrack);
-      },
-
-      // 接听通话
-      async accept() {
-        this.stopRingtone()
-        try {
-          console.time("joinRoom");
-
-          this.room = await Trtc.joinRoom(
-            this.acceptToken,
-            this.acceptURL,
-            this.userID,
-            (track, participant) => {
-              this.updateParticipantInfo(participant.identity)
-              this.attachRemoteTrack(track, participant)
-            }
-          )
-
-          console.timeEnd("joinRoom");
-          console.log("Room 对象:", this.room);
-
-          this.setupRoomListeners();
-          this.isDialled = false;
-          this.calling = true;
-          this.startCallTimer();
-        } catch (error) {
-          console.error('接听失败:', error);
-          this.resetCallState();
+    async publishLocalAudio() {
+      const devices = await navigator.mediaDevices.enumerateDevices();
+      const hasMic = devices.some(d => d.kind === 'audioinput');
+      if (!hasMic) {
+        console.warn('无可用麦克风,跳过音频轨道发布');
+        return;
+      }
+      const audioTrack = await createLocalAudioTrack();
+      await this.room.localParticipant.publishTrack(audioTrack);
+      this.localTracks.push(audioTrack);
+    },
+
+    // 接听通话
+    async accept() {
+      this.stopRingtone()
+      try {
+        console.time("joinRoom");
+
+        this.room = await Trtc.joinRoom(
+          this.acceptToken,
+          this.acceptURL,
+          this.userID,
+          (track, participant) => {
+            this.updateParticipantInfo(participant.identity)
+            this.attachRemoteTrack(track, participant)
+          }
+        )
+
+        console.timeEnd("joinRoom");
+        console.log("Room 对象:", this.room);
+
+        this.setupRoomListeners();
+        this.isDialled = false;
+        this.calling = true;
+        this.startCallTimer();
+        // 接听后挂载本地音视频
+        if (this.callType === 'video') {
+          await this.publishLocalVideo()
         }
-      },
-
-      // 拒绝通话
-      async reject() {
-        this.stopRingtone();
-        try {
-          console.log('接收到的邀请数据:', this.inviteData);
-          //this.stopRingtone();
-          await this.OpenIM.signalingReject({
+        await this.publishLocalAudio()
+      } catch (error) {
+        console.error('接听失败:', error);
+        this.resetCallState();
+      }
+    },
+
+    // 拒绝通话
+    async reject() {
+      this.stopRingtone();
+      try {
+        console.log('接收到的邀请数据:', this.inviteData);
+        //this.stopRingtone();
+        await this.OpenIM.signalingReject({
+          opUserID: this.userID,      // 当前用户ID
+          invitation: this.inviteData //  完整 invitation 对象
+        });
+        this.resetCallState();
+      } catch (error) {
+        console.error('拒绝失败:', error);
+        //message.error(t('toast.rejectFailed'));
+      }
+    },
+
+    // 挂断通话
+    async hangUp() {
+      console.log("接听还是拨打",this.inviteData)
+      console.log("接听还是拨打",this.dialling,this.calling)
+      this.stopRingtone();
+      try {
+        if (this.dialling) {
+          await this.OpenIM.signalingCancel({
+            opUserID: this.userID,      // 当前用户ID
+            invitation: this.inviteData //  完整 invitation 对象
+          });
+        } else if (this.calling) {
+          await this.OpenIM.signalingHungUp({
             opUserID: this.userID,      // 当前用户ID
             invitation: this.inviteData //  完整 invitation 对象
           });
-          this.resetCallState();
-        } catch (error) {
-          console.error('拒绝失败:', error);
-          //message.error(t('toast.rejectFailed'));
         }
-      },
-
-      // 挂断通话
-      async hangUp() {
-        console.log("接听还是拨打",this.inviteData)
-        console.log("接听还是拨打",this.dialling,this.calling)
-        this.stopRingtone();
-        try {
-          if (this.dialling) {
-            await this.OpenIM.signalingCancel({
-              opUserID: this.userID,      // 当前用户ID
-              invitation: this.inviteData //  完整 invitation 对象
-            });
-          } else if (this.calling) {
-            await this.OpenIM.signalingHungUp({
-              opUserID: this.userID,      // 当前用户ID
-              invitation: this.inviteData //  完整 invitation 对象
-            });
-          }
 
-          // 离开房间
-          if (Trtc) {
-            await Trtc.leaveRoom();
-            await this.sleep(500)
-          }
+        // 离开房间
+        if (Trtc) {
+          await Trtc.leaveRoom();
+          await this.sleep(500)
+        }
 
-          this.resetCallState();
+        this.resetCallState();
 
-        } catch (error) {
-          console.error('挂断失败:', error);
-          //message.error(t('toast.hangUpFailed'));
+      } catch (error) {
+        console.error('挂断失败:', error);
+        //message.error(t('toast.hangUpFailed'));
+      }
+    },
+    sleep(ms) {
+      return new Promise(resolve => setTimeout(resolve, ms))
+    },
+    // 防抖处理
+    handleDebounce(func, wait) {
+      if (this.timeout) clearTimeout(this.timeout)
+      this.timeout = setTimeout(() => {
+        func()
+      }, wait)
+    },
+    // 开始通话计时
+    startCallTimer() {
+      this.start = Date.now();
+      this.durationTimer = setInterval(() => {
+        this.duration = Math.floor((Date.now() - this.start) / 1000);
+      }, 1000);
+    },
+
+    // 重置通话状态
+    resetCallState() {
+      clearInterval(this.durationTimer);
+      this.duration = 0;
+      this.dialling = false;
+      this.calling = false;
+      this.isDialled = false;
+      this.localTracks = [];
+      this.remoteUsers = [];
+      this.callingUserList = [];
+      this.inviteID = '';
+      this.inviteData = {};
+      this.roomToken = '';
+      this.roomURL = '';
+      this.roomID = '';
+      this.room = null;
+      this.acceptToken = '';
+      this.acceptURL = '';
+      this.acceptRoomID = '';
+    },
+
+    // 切换摄像头状态
+    async toggleCamera() {
+      try {
+        this.isCamOn = !this.isCamOn;
+        const videoTrack = this.localTracks.find(t => t.kind === 'video');
+        if (videoTrack) {
+          this.isCamOn ? await videoTrack.unmute() : await videoTrack.mute();
         }
-      },
-      sleep(ms) {
-        return new Promise(resolve => setTimeout(resolve, ms))
-      },
-      // 防抖处理
-      handleDebounce(func, wait) {
-        if (this.timeout) clearTimeout(this.timeout)
-        this.timeout = setTimeout(() => {
-          func()
-        }, wait)
-      },
-      // 开始通话计时
-      startCallTimer() {
-        this.start = Date.now();
-        this.durationTimer = setInterval(() => {
-          this.duration = Math.floor((Date.now() - this.start) / 1000);
-        }, 1000);
-      },
-
-      // 重置通话状态
-      resetCallState() {
-        clearInterval(this.durationTimer);
-        this.duration = 0;
-        this.dialling = false;
-        this.calling = false;
-        this.isDialled = false;
-        this.localTracks = [];
-        this.remoteUsers = [];
-        this.callingUserList = [];
-        this.inviteID = '';
-        this.inviteData = {};
-        this.roomToken = '';
-        this.roomURL = '';
-        this.roomID = '';
-        this.room = null;
-        this.acceptToken = '';
-        this.acceptURL = '';
-        this.acceptRoomID = '';
-      },
-
-      // 切换摄像头状态
-      async toggleCamera() {
-        try {
-          this.isCamOn = !this.isCamOn;
-          const videoTrack = this.localTracks.find(t => t.kind === 'video');
-          if (videoTrack) {
-            this.isCamOn ? await videoTrack.unmute() : await videoTrack.mute();
-          }
-        } catch (error) {
-          console.error('切换摄像头失败:', error);
-          this.isCamOn = !this.isCamOn;
+      } catch (error) {
+        console.error('切换摄像头失败:', error);
+        this.isCamOn = !this.isCamOn;
+      }
+    },
+
+    // 切换麦克风状态
+    async toggleMic() {
+      try {
+        this.isMicOn = !this.isMicOn;
+        const audioTrack = this.localTracks.find(t => t.kind === 'audio');
+        if (audioTrack) {
+          this.isMicOn ? await audioTrack.unmute() : await audioTrack.mute();
         }
-      },
-
-      // 切换麦克风状态
-      async toggleMic() {
-        try {
-          this.isMicOn = !this.isMicOn;
-          const audioTrack = this.localTracks.find(t => t.kind === 'audio');
-          if (audioTrack) {
-            this.isMicOn ? await audioTrack.unmute() : await audioTrack.mute();
+      } catch (error) {
+        console.error('切换麦克风失败:', error);
+        this.isMicOn = !this.isMicOn;
+      }
+    },
+
+    // 处理参与者接受邀请
+    async handleInviteeAccepted(data) {
+      if (data.inviteID !== this.inviteID) return
+      this.stopRingtone()
+      this.inviteData = data.data.invitation
+      try {
+        // joinRoom,发布本地轨道 & 挂载远端轨道都在这里完成
+        this.room = await Trtc.joinRoom(
+          this.roomToken,
+          this.roomURL,
+          this.userID,
+          (track, participant) => {
+            this.updateParticipantInfo(participant.identity)
+            this.attachRemoteTrack(track, participant)
           }
-        } catch (error) {
-          console.error('切换麦克风失败:', error);
-          this.isMicOn = !this.isMicOn;
-        }
-      },
-
-      // 处理参与者接受邀请
-      async handleInviteeAccepted(data) {
-        if (data.inviteID !== this.inviteID) return
-        this.stopRingtone()
-        this.inviteData = data.data.invitation
-        try {
-          // joinRoom,发布本地轨道 & 挂载远端轨道都在这里完成
-          this.room = await Trtc.joinRoom(
-            this.roomToken,
-            this.roomURL,
-            this.userID,
-            (track, participant) => {
-              this.updateParticipantInfo(participant.identity)
-              this.attachRemoteTrack(track, participant)
-            }
-          )
-          console.log("Room 对象:", this.room);
-          this.setupRoomListeners();
-          this.calling = true
-          this.dialling = false
-          this.isDialled = false
-          this.startCallTimer()
-        } catch (err) {
-          console.error('主叫方 joinRoom 出错', err)
+        )
+        console.log("Room 对象:", this.room);
+        this.setupRoomListeners();
+        this.calling = true
+        this.dialling = false
+        this.isDialled = false
+        this.startCallTimer()
+        // 加上本地轨道挂载
+        if (this.callType === 'video') {
+          await this.publishLocalVideo()
         }
-      },
+        await this.publishLocalAudio()
+      } catch (err) {
+        console.error('主叫方 joinRoom 出错', err)
+      }
+    },
 
 
-      // 处理参与者拒绝邀请
-      handleInviteeRejected(data) {
-        console.log(123456789)
-        this.stopRingtone();
-        if (data.inviteID === this.inviteID) {
-          this.invitedUserInfo = this.invitedUserInfo.filter(
-            user => user.userID !== data.data.invitation.inviteeUserID
-          );
-        }
-      },
-
-      // 处理邀请超时
-      handleInvitationTimeout(data) {
-        this.stopRingtone();
-        if (data.inviteID === this.inviteID) {
-          //message.warning(t('toast.callTimeout'));
-          this.resetCallState();
-        }
-      },
+    // 处理参与者拒绝邀请
+    handleInviteeRejected(data) {
+      console.log(123456789)
+      this.stopRingtone();
+      if (data.inviteID === this.inviteID) {
+        this.invitedUserInfo = this.invitedUserInfo.filter(
+          user => user.userID !== data.data.invitation.inviteeUserID
+        );
+      }
+    },
 
-      // 处理挂断
-      handleHangUp(data) {
+    // 处理邀请超时
+    handleInvitationTimeout(data) {
+      this.stopRingtone();
+      if (data.inviteID === this.inviteID) {
+        //message.warning(t('toast.callTimeout'));
+        this.resetCallState();
+      }
+    },
 
-        this.stopRingtone();
-        if (data.inviteID === this.inviteID) {
-          //message.info(t('toast.callEnded'));
-          this.resetCallState();
-        }
-      },
+    // 处理挂断
+    handleHangUp(data) {
 
-      // 更新参与者信息
-      updateParticipantInfo(userID) {
-        if (!this.callingUserList.includes(userID)) {
-          this.callingUserList.push(userID); // ✅ 先 push
-        }
-        this.OpenIM.getUsersInfo([userID])
-          .then(({ data }) => {
-            console.log("查询用户信息",data)
-            this.faceImages = data[0].faceURL
-            this.nickName = data[0].nickname
-            console.log("更新参与者信息", this.invitedUserInfo)
-            const user = this.invitedUserInfo.find(u => u.userID === userID);
-            console.log(this.faceImages)
-            console.log(this.nickName)
-            if (!user) {
-              this.invitedUserInfo.push({
-                userID,
-                nickname: this.nickName,
-                avatar: this.faceImages,
-                isMicOn: true
-              });
-            }
-
-            // data: 查询到的用户信息列表
-          })
-          .catch(({ errCode, errMsg }) => {
-            // 调用失败attachRemoteTrack
-          });
+      this.stopRingtone();
+      if (data.inviteID === this.inviteID) {
+        //message.info(t('toast.callEnded'));
+        this.resetCallState();
+      }
+    },
 
-      },
+    // 更新参与者信息
+    updateParticipantInfo(userID) {
+      if (!this.callingUserList.includes(userID)) {
+        this.callingUserList.push(userID); // ✅ 先 push
+      }
+      this.OpenIM.getUsersInfo([userID])
+        .then(({ data }) => {
+          console.log("查询用户信息",data)
+          this.faceImages = data[0].faceURL
+          this.nickName = data[0].nickname
+          console.log("更新参与者信息", this.invitedUserInfo)
+          const user = this.invitedUserInfo.find(u => u.userID === userID);
+          console.log(this.faceImages)
+          console.log(this.nickName)
+          if (!user) {
+            this.invitedUserInfo.push({
+              userID,
+              nickname: this.nickName,
+              avatar: this.faceImages,
+              isMicOn: true
+            });
+          }
 
-      // 附加远端轨道
-      attachRemoteTrack(track, participant, retryCount = 0) {
-        const kind = track.kind;
-        const uid = participant.identity;
+          // data: 查询到的用户信息列表
+        })
+        .catch(({ errCode, errMsg }) => {
+          // 调用失败attachRemoteTrack
+        });
 
-        if (kind === 'audio') {
-          const audioEl = document.createElement('audio');
-          audioEl.autoplay = true;
-          audioEl.playsInline = true;
-          track.attach(audioEl);
-          document.body.appendChild(audioEl); // 直接挂到 body,避免容器找不到
-          return;
-        }
+    },
+
+    // 附加远端轨道
+    attachRemoteTrack(track, participant, retryCount = 0) {
+      const kind = track.kind;
+      const uid = participant.identity;
+
+      if (kind === 'audio') {
+        const audioEl = document.createElement('audio');
+        audioEl.autoplay = true;
+        audioEl.playsInline = true;
+        track.attach(audioEl);
+        document.body.appendChild(audioEl); // 直接挂到 body,避免容器找不到
+        return;
+      }
 
-        if (kind === 'video') {
-          const containerId = `video-${uid}`;
-          let container = document.getElementById(containerId);
+      if (kind === 'video') {
+        const containerId = `video-${uid}`;
+        let container = document.getElementById(containerId);
 
-          if (!container) {
-            if (retryCount < 20) {
-              setTimeout(() => this.attachRemoteTrack(track, participant, retryCount + 1), 200);
-              return;
-            }
-            console.warn(`找不到容器: ${containerId}`);
+        if (!container) {
+          if (retryCount < 20) {
+            setTimeout(() => this.attachRemoteTrack(track, participant, retryCount + 1), 200);
             return;
           }
-
-          container.innerHTML = '';
-          const videoEl = document.createElement('video');
-          videoEl.autoplay = true;
-          videoEl.playsInline = true;
-          videoEl.style.width = '100%';
-          videoEl.style.height = '100%';
-          container.appendChild(videoEl);
-          track.attach(videoEl);
+          console.warn(`找不到容器: ${containerId}`);
+          return;
         }
+
+        container.innerHTML = '';
+        const videoEl = document.createElement('video');
+        videoEl.autoplay = true;
+        videoEl.playsInline = true;
+        videoEl.style.width = '100%';
+        videoEl.style.height = '100%';
+        container.appendChild(videoEl);
+        track.attach(videoEl);
       }
     }
-  };
+  }
+};
 </script>
 
 <style lang="stylus" scoped>

+ 13 - 0
src/router/index.js

@@ -173,6 +173,19 @@ export const constantRoutes = [
       }
     ]
   },
+  {
+    path: '/collection',
+    component: Layout,
+    redirect: 'noredirect',
+    children: [
+      {
+        path: 'Index',
+        component: (resolve) => require(['@/views/collection/index'], resolve),
+        name: '用户信息采集',
+        meta: { title: '用户信息采集', icon: 'form', affix: false }
+      }
+    ]
+  },
   {
     path: '/follow',
     component: Layout,

+ 76 - 79
src/utils/trtc.js

@@ -6,52 +6,43 @@ import {
   createLocalVideoTrack,
 } from 'livekit-client'
 
+console.log("Room 构造函数:", Room)
+
 class Trtc {
   constructor() {
     this.room = null
     this.localTracks = []
   }
 
+  // 安全 attach 远端轨道
+  attachTrack(track, participant) {
+    const container = document.getElementById('video-' + participant.identity)
+    if (!container) return
+
+    // 已经 attach 过就跳过,避免闪屏
+    if (track.attachedElements.length > 0) return
+
+    const element = track.attach()
+    element.style.width = '100%'
+    element.style.height = '100%'
+    element.style.objectFit = 'cover'
+    container.appendChild(element)
+  }
+
   async joinRoom(token, url, userId, onRemoteTrack) {
     try {
+      // 如果已有房间,先退出
       if (this.room) {
-        this.leaveRoom()
+        await this.leaveRoom()
       }
 
       this.room = new Room()
 
-      // 挂载远端轨道(带 DOM 等待机制)
-      const attachRemoteTrack = (track, participant) => {
-        const id = 'video-' + participant.identity
-        const maxRetry = 20
-        let retry = 0
-
-        const tryAttach = () => {
-          const container = document.getElementById(id)
-          if (container) {
-            console.log(`📺 正在挂载视频到容器: ${id}`)
-            container.innerHTML = ''
-            const element = track.attach()
-            element.style.width = '100%'
-            element.style.height = '100%'
-            element.style.objectFit = 'cover'
-            container.appendChild(element)
-          } else if (retry < maxRetry) {
-            retry++
-            setTimeout(tryAttach, 200)
-          } else {
-            console.warn(`❌ 超时未找到远端容器: ${id}`)
-          }
-        }
-
-        tryAttach()
-      }
-
       // 监听远端轨道
       this.room.on(RoomEvent.TrackSubscribed, (track, publication, participant) => {
         console.log('📡 TrackSubscribed:', track.kind, participant.identity)
         if (track.kind === 'video' || track.kind === 'audio') {
-          attachRemoteTrack(track, participant)
+          this.attachTrack(track, participant)
           if (typeof onRemoteTrack === 'function') {
             onRemoteTrack(track, participant)
           }
@@ -60,21 +51,25 @@ class Trtc {
 
       // 检查设备
       this.localTracks = []
-      const devices = await navigator.mediaDevices.enumerateDevices()
-      const hasMic = devices.some(d => d.kind === 'audioinput')
-      const hasCam = devices.some(d => d.kind === 'videoinput')
-
-      if (hasMic || hasCam) {
-        this.localTracks = await createLocalTracks({
-          audio: hasMic,
-          video: hasCam,
-        })
-        console.log('🎥 本地轨道列表:', this.localTracks)
+      if (navigator.mediaDevices && navigator.mediaDevices.enumerateDevices) {
+        const devices = await navigator.mediaDevices.enumerateDevices()
+        const hasMic = devices.some(d => d.kind === 'audioinput')
+        const hasCam = devices.some(d => d.kind === 'videoinput')
+
+        if (hasMic || hasCam) {
+          this.localTracks = await createLocalTracks({
+            audio: hasMic,
+            video: hasCam,
+          })
+          console.log('本地轨道列表:', this.localTracks)
+        } else {
+          console.warn('未检测到摄像头或麦克风,将以静默方式加入房间')
+        }
       } else {
-        console.warn('未检测到摄像头或麦克风,将以静默方式加入房间')
+        console.warn('当前环境不支持 mediaDevices,将以纯接收模式加入房间')
       }
 
-      console.log('🟢 发起连接到 LiveKit ...', url)
+      console.log('发起连接到 LiveKit ...', url)
 
       // 监听连接状态
       const connectedPromise = new Promise((resolve, reject) => {
@@ -82,36 +77,39 @@ class Trtc {
           reject(new Error('连接 LiveKit 超时'))
         }, 15000)
 
-        this.room.once(RoomEvent.Connected, () => {
-          clearTimeout(timeout)
-          console.log('✅ 成功连接到 LiveKit 房间')
-          resolve()
-
-          // ✅ 主动挂载已有轨道
-          if (this.room.participants && typeof this.room.participants.values === 'function') {
-            for (const participant of this.room.participants.values()) {
-              participant.tracks.forEach(publication => {
-                if (publication.isSubscribed && publication.track) {
-                  console.log('🟡 主动挂载已有远端轨道:', publication.track.kind)
-                  attachRemoteTrack(publication.track, participant)
-                  if (typeof onRemoteTrack === 'function') {
-                    onRemoteTrack(publication.track, participant)
+        try {
+          this.room.once(RoomEvent.Connected, () => {
+            clearTimeout(timeout)
+            console.log('成功连接到 LiveKit 房间')
+            resolve()
+
+            // 主动挂载已有轨道
+            if (this.room.participants && typeof this.room.participants.values === 'function') {
+              for (const participant of this.room.participants.values()) {
+                participant.tracks.forEach(publication => {
+                  if (publication.isSubscribed && publication.track) {
+                    this.attachTrack(publication.track, participant)
+                    if (typeof onRemoteTrack === 'function') {
+                      onRemoteTrack(publication.track, participant)
+                    }
                   }
-                }
-              })
+                })
+              }
             }
-          }
-        })
+          })
 
-        this.room.once(RoomEvent.ConnectionError, (err) => {
-          clearTimeout(timeout)
-          console.error('❌ LiveKit 连接错误:', err)
-          reject(err)
-        })
+          this.room.once(RoomEvent.ConnectionError, (err) => {
+            clearTimeout(timeout)
+            console.error('LiveKit 连接错误:', err)
+            reject(err)
+          })
+        } catch (e) {
+          console.error('LiveKit连接失败:', e)
+        }
       })
 
       this.room.on(RoomEvent.Disconnected, () => {
-        console.warn('⚠️ 与 LiveKit 断开连接')
+        console.warn('与 LiveKit 断开连接')
       })
 
       // 发起连接
@@ -123,13 +121,13 @@ class Trtc {
 
       // 发布本地轨道
       for (const track of this.localTracks) {
-        console.log('📤 正在发布轨道:', track.kind)
+        console.log('正在发布轨道:', track.kind)
         await this.room.localParticipant.publishTrack(track)
       }
 
       return this.room
     } catch (err) {
-      console.error('🚨 joinRoom 出错:', err)
+      console.error('joinRoom 出错:', err)
       throw err
     }
   }
@@ -140,32 +138,31 @@ class Trtc {
 
   async leaveRoom() {
     if (this.room) {
-      console.log("🔴 Trtc 离开房间");
+      console.log("Trtc 离开房间")
 
       // 停止并释放本地轨道
       this.localTracks.forEach(track => {
         try {
-          track.stop();
-          track.detach();
+          track.stop()
+          track.detach()
         } catch (e) {
-          console.warn("轨道释放失败:", e);
+          console.warn("轨道释放失败:", e)
         }
-      });
+      })
 
       try {
-        await this.room.disconnect(); // ✅ 等待断开完成
+        await this.room.disconnect()
       } catch (e) {
-        console.error("房间断开异常:", e);
+        console.error("房间断开异常:", e)
       }
 
-      this.room = null;
-      this.localTracks = [];
+      this.room = null
+      this.localTracks = []
     } else {
-      console.warn("⚠️ leaveRoom 时 room 为 null");
+      this.room = null
+      console.warn("离开房间 时 room 为 null")
     }
   }
-
-
 }
 
 export {

+ 225 - 0
src/views/collection/index.vue

@@ -0,0 +1,225 @@
+<template>
+    <div class="app-container">
+        <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
+            <el-form-item label="患者姓名" prop="userName">
+                <el-input v-model="queryParams.userName" placeholder="请输入患者姓名" clearable size="small"
+                    @keyup.enter.native="handleQuery" />
+            </el-form-item>
+            <el-form-item label="医生确认" prop="doctorConfirm">
+                <el-select v-model="queryParams.doctorConfirm" placeholder="请选择" clearable size="small">
+                    <el-option label="未确认" value="0" />
+                    <el-option label="已确认" value="1" />
+                </el-select>
+            </el-form-item>
+            <el-form-item label="患者确认" prop="userConfirm">
+                <el-select v-model="queryParams.userConfirm" placeholder="请选择" clearable size="small">
+                    <el-option label="未确认" value="0" />
+                    <el-option label="已确认" value="1" />
+                </el-select>
+            </el-form-item>
+            <el-form-item>
+                <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
+                <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
+            </el-form-item>
+        </el-form>
+
+        <el-table v-loading="loading" border :data="list" @selection-change="handleSelectionChange">
+            <el-table-column type="selection" width="55" align="center" />
+            <el-table-column label="患者姓名" align="center" prop="userName" />
+            <el-table-column label="患者补充说明" :show-overflow-tooltip="true" align="center" prop="userAdvice"></el-table-column>
+            <el-table-column label="患者确认状态" align="center" prop="userConfirm">
+                <template slot-scope="scope">
+                    <el-tag v-if="scope.row.userConfirm == 0">未确认</el-tag>
+                    <el-tag type="success" v-if="scope.row.userConfirm == 1">已确认</el-tag>
+                </template>
+            </el-table-column>
+            <el-table-column label="医生确认状态" align="center" prop="doctorConfirm">
+                <template slot-scope="scope">
+                    <el-tag v-if="scope.row.doctorConfirm == 0">未确认</el-tag>
+                    <el-tag type="success" v-if="scope.row.doctorConfirm == 1">已确认</el-tag>
+                </template>
+            </el-table-column>
+            <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
+                <template slot-scope="scope">
+                    <el-button size="mini" type="text" @click="handleDetial(scope.row)">详情</el-button>
+                    <el-button size="mini" type="text" @click="handleAdvice(scope.row)">建议</el-button>
+                </template>
+            </el-table-column>
+        </el-table>
+        <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum"
+            :limit.sync="queryParams.pageSize" @pagination="getList" />
+
+        <el-dialog title="采集信息详情" :visible.sync="collectionOpen" width="1000px" append-to-body>
+            <el-form ref="collectionForm" :model="collectionForm" label-width="110px">
+                <div v-for="(answer, index) in collectionForm.answers">
+                    <div style="margin-bottom: 20px;margin-top: 20px;">
+                        <span style="font-size: 15px;font-weight: bold;    margin-left: 31px">{{ answer.title }}</span>
+                    </div>
+                    <div style="margin-left: 31px;">
+                        <el-radio-group :disabled="true" v-model="collectionForm.answers[index].value">
+                            <el-radio v-for="dict in answer.options" :label="dict.value">{{ dict.name }}</el-radio>
+                        </el-radio-group>
+                    </div>
+                </div>
+            </el-form>
+            <div slot="footer" class="dialog-footer">
+                <el-button @click="cancel">关 闭</el-button>
+            </div>
+        </el-dialog>
+
+        <el-dialog title="医生建议"  :visible.sync="open" width="1000px" append-to-body>
+            <el-form ref="form" :rules="rules" :model="form" label-width="110px">
+                <el-form-item label="建议" prop="doctorAdvice">
+                    <el-input v-model="form.doctorAdvice" type="textarea" placeholder="请输入内容" />
+                </el-form-item>
+            </el-form>
+            <div slot="footer" class="dialog-footer">
+                <el-button type="primary" @click="submitForm">确 认</el-button>
+                <el-button @click="cancelAdvice">关 闭</el-button>
+            </div>
+        </el-dialog>
+    </div>
+</template>
+
+<script>
+import { list, detail, doctorConfirm } from "@/api/collection.js";
+export default {
+    name: "collection",
+    data() {
+        return {
+            queryParams: {
+                pageNum: 1,
+                pageSize: 10,
+            },
+            // 遮罩层
+            loading: true,
+            // 导出遮罩层
+            exportLoading: false,
+            // 选中数组
+            ids: [],
+            // 非单个禁用
+            single: true,
+            // 非多个禁用
+            multiple: true,
+            // 显示搜索条件
+            showSearch: true,
+            // 总条数
+            total: 0,
+            list: [],
+            // 弹出层标题
+            title: "",
+            // 是否显示弹出层
+            open: false,
+            queryParams: {
+                pageNum: 1,
+                pageSize: 10,
+                type: "0",
+            },
+            // 表单参数
+            form: {},
+            // 表单校验
+            rules: {
+                doctorAdvice:[{ required: true, message: '请输入医生建议', trigger: 'blur' },]
+
+            },
+            collectionForm: {
+                answers:[]
+            },
+            collectionOpen : false,
+        }
+    },
+    created() {
+        this.getList();
+    },
+
+    methods: {
+        submitForm() {
+            this.$refs["form"].validate(valid => {
+                if (valid) {
+                    // fill(this.form).then(res => {
+                    //     this.msgSuccess("填写成功");
+                    //     this.open = false;
+                    //     this.getList();
+                    // })
+                }
+            });
+        },
+        handleAdvice(row){
+            this.form={};
+            this.open = true;
+            this.form.id = row.id;
+        },
+        cancelAdvice(){
+            this.open = false;
+            this.reset();
+        },
+        submitForm(){
+            this.$refs["form"].validate(valid => {
+                if (valid) {
+                    doctorConfirm(this.form).then(res => {
+                        this.msgSuccess("填写成功");
+                        this.open = false;
+                        this.getList();
+                    })
+                }
+            });
+        },
+        handleDetial(row) {
+            detail(row.id).then(res => {
+                this.collectionForm = res.data;
+
+            })
+            this.collectionOpen = true;
+        },
+        // handleFill(row) {
+        //     detail(row.id).then(res => {
+        //         this.form = res.data
+        //     })
+        //     this.open = true;
+        // },
+        getList() {
+            this.loading = true;
+            list(this.queryParams).then(response => {
+                this.list = response.data.list;
+                this.total = response.data.total;
+                this.loading = false;
+            });
+        },
+
+        // 取消按钮
+        cancel() {
+            this.collectionOpen = false;
+            this.restCollection();
+        },
+        restCollection(){
+            this.collectionForm = {
+                answers:[]
+            };
+            this.resetForm("collectionForm");
+        },
+        // 表单重置
+        reset() {
+            this.form = {
+            };
+            this.resetForm("form");
+        },
+        /** 搜索按钮操作 */
+        handleQuery() {
+            this.queryParams.pageNum = 1;
+            this.getList();
+        },
+        /** 重置按钮操作 */
+        resetQuery() {
+            this.resetForm("queryForm");
+            this.handleQuery();
+        },
+        // 多选框选中数据
+        handleSelectionChange(selection) {
+            this.ids = selection.map(item => item.patientId)
+            this.single = selection.length !== 1
+            this.multiple = !selection.length
+        }
+    }
+
+};
+</script>

+ 21 - 1
src/views/order/inquiryOrder/index.vue

@@ -115,6 +115,14 @@
                 icon="el-icon-share"
             >继续问诊
           </el-button>
+          <el-button
+            v-if="scope.row.status==1"
+            size="mini"
+            type="text"
+            @click="handleCloseOrder(scope.row)"
+            icon="el-icon-share"
+          >关闭订单
+          </el-button>
           <el-button
             size="mini"
             type="text"
@@ -146,7 +154,7 @@
 </template>
 
 <script>
-import { getOrderUserPhone,getCompanyList,getInquiryOrderList,receiveOrder,refuseOrder } from "@/api/inquiryOrder";
+import { getOrderUserPhone,getCompanyList,getInquiryOrderList,receiveOrder,refuseOrder,closeOrder } from "@/api/inquiryOrder";
 import inquiryOrderDetails from '../../components/order/inquiryOrderDetails.vue';
 import msgDetails from '@/views/components/msg/followMsgDetails.vue';
 import way from '@/utils/way.js';
@@ -230,6 +238,8 @@ export default {
       { dictValue: "2", dictLabel: '待接诊' },
       { dictValue: "3", dictLabel: '问诊中' },
       { dictValue: "4", dictLabel: '已结束' },
+      { dictValue: "1", dictLabel: '待支付' },
+      { dictValue: "-1", dictLabel: '已取消' },
       ],
       inquiryTypeOptions:[],
       inquiryPayOptions:[],
@@ -267,6 +277,16 @@ export default {
     handleContinue(){
       way.$emit('open',1);
     },
+    handleCloseOrder(row){
+      console.log(row)
+      closeOrder(row.orderId).then(response => {
+        this.$message({
+          message: "关闭成功",
+          type: "success"
+        });
+        this.getList();
+      })
+    },
     followMsg(row){
       const userId = row.userId;
       const followDoctorId =row.doctorId;