WXL (wul)
7 天以前 57c1e943c1e20c57ff69945216a133a5ec2127f7
src/components/CallButton/index.vue
@@ -37,16 +37,16 @@
    },
  },
  data() {
    const randomNum = Math.floor(Math.random() * 11) + 1000; // 内部定义
    const randomNum = Math.floor(Math.random() * 20) + 1000; // 内部定义
    return {
      isCalling: false,
      callStatus: "idle", // idle, calling, connected, ended
      sipStatus: "未连接",
      sipStatusClass: "status-disconnected",
      sipConfig: {
        wsUrl: "wss://192.168.10.124:7443",
        sipUri: `${randomNum}` + "@192.168.10.124",
        password: "Smartor@2023",
        wsUrl: "wss://192.170.66.107:7443",
        sipUri: `${randomNum}` + "@192.170.66.107",
        password: "heskj@1234",
        displayName: "Web 小龙",
      },
    };
@@ -61,6 +61,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}`;
    },
@@ -69,6 +78,8 @@
    },
  },
  mounted() {
    console.log('当前分机号',this.sipConfig);
    sipService.init(this.sipConfig);
    sipService.onStatusChange = (status) => {
      this.sipStatus = status.text;
@@ -92,6 +103,12 @@
      }
      try {
        // 先检查是否可以呼叫
        const { canCall, reason } = sipService.canMakeCall();
        if (!canCall) {
          this.$message.warning(reason);
          return;
        }
        this.callStatus = "calling";
        this.isCalling = true;