WXL (wul)
22 小时以前 66cc734e81fe0497d88e0951b6aee9c9c8342f2c
src/components/CallButton/index.vue
@@ -62,6 +62,15 @@
      };
      return statusMap[this.callStatus];
    },
    countdownText() {
      if (this.sipStatus !== "已注册") return "";
      const { canCall, reason } = sipService.canMakeCall();
      if (!canCall && reason.includes("等待")) {
        return reason;
      }
      return "";
    },
    callStatusClass() {
      return `status-${this.callStatus}`;
    },
@@ -70,13 +79,7 @@
    },
  },
  mounted() {
    // 测试
    const ws = new WebSocket("wss://9.208.5.18:7443");
    ws.onopen = () => console.log("WebSocket 连接成功");
    ws.onerror = (e) => console.error("WebSocket 错误:", e);
    // 初始化SIP连接
    console.log('当前分机号',this.sipConfig);
    sipService.init(this.sipConfig);
    sipService.onStatusChange = (status) => {
@@ -101,15 +104,40 @@
      }
      try {
        // 先检查是否可以呼叫
        const { canCall, reason } = sipService.canMakeCall();
        if (!canCall) {
          const { canCall, reason } = sipService.canMakeCall();
          //this.$message.warning(reason);
          //return;
        }
        this.callStatus = "calling";
        this.isCalling = true;
        console.log("开始呼叫:", sipService);
        await sipService.makeCall(this.phoneNumber);
        await sipService.makeCall("0"+this.phoneNumber);
      } catch (error) {
        console.error("呼叫失败:", error);
        this.callStatus = "ended";
        this.isCalling = false;
        this.$message.error(`呼叫失败: ${error.message}`);
        let registrationTime = Date.now(); // 记录注销成功时间
        console.log(registrationTime, "呼叫失败时间");
        console.error("呼叫失败1:", error);
        // this.callStatus = "ended";
        // this.isCalling = false;
        //this.$message.error(`呼叫失败: ${error.message}`);
          try {
          // 先检查是否可以呼叫
          const { canCall, reason } = sipService.canMakeCall();
          if (!canCall) {
            const { canCall, reason } = sipService.canMakeCall();
          }
          this.callStatus = "calling";
          this.isCalling = true;
          console.log("开始呼叫:", sipService);
          await sipService.makeCall("0"+this.phoneNumber);
        } catch (error) {
           this.callStatus = "ended";
           this.isCalling = false;
        }
      }
    },