From 43017c316ab6a2e11305a7f016b12d13736e8cc1 Mon Sep 17 00:00:00 2001
From: WXL (wul) <wl_5969728@163.com>
Date: 星期二, 02 十二月 2025 17:33:33 +0800
Subject: [PATCH] 测试完成

---
 src/components/CallButton/index.vue |   45 +++++++++++++++++++++++++++++++++++++--------
 1 files changed, 37 insertions(+), 8 deletions(-)

diff --git a/src/components/CallButton/index.vue b/src/components/CallButton/index.vue
index 9894b01..c2bd148 100644
--- a/src/components/CallButton/index.vue
+++ b/src/components/CallButton/index.vue
@@ -11,10 +11,17 @@
 
     <!-- 鍛煎彨鎸夐挳 -->
     <button
-      :class="['call-btn', { calling: isCalling }]"
+      :class="[
+        'call-btn',
+        {
+          calling: isCalling,
+          registering: isRegistering,
+        },
+      ]"
       @click="startCall"
-      :disabled="isCalling || sipStatus !== '宸叉敞鍐�'"
+      :disabled="isButtonDisabled"
     >
+      <i v-if="isRegistering" class="el-icon-loading"></i>
       {{ callButtonText }}
     </button>
 
@@ -41,6 +48,7 @@
     const randomNum = Math.floor(Math.random() * 20) + 1000; // 瀹氫箟闅忔満鍒嗘満鍙�
     return {
       isCalling: false,
+      isRegistering: true, // 鍒濆涓烘敞鍐屼腑鐘舵��
       randomNum: randomNum,
       randomID: null,
       callStatus: "idle", // idle, calling, connected, ended
@@ -74,11 +82,17 @@
       }
       return "";
     },
-    callStatusClass() {
-      return `status-${this.callStatus}`;
+    isButtonDisabled() {
+      return (
+        this.isCalling || this.sipStatus !== "宸叉敞鍐�" || this.isRegistering
+      );
     },
     callButtonText() {
+      if (this.isRegistering) return "娉ㄥ唽涓�...";
       return this.isCalling ? "閫氳瘽涓�..." : "涓�閿懠鍙�";
+    },
+    callStatusClass() {
+      return `status-${this.callStatus}`;
     },
   },
   created() {
@@ -87,15 +101,24 @@
 
   async mounted() {
     await this.CallgetList();
+    this.isRegistering = true; // 寮�濮嬫敞鍐�
     sipService.init(this.sipConfig);
     // 璁剧疆鐘舵�佸洖璋�
     sipService.onStatusChange = (status) => {
       this.sipStatus = status.text;
       this.sipStatusClass = `status-${status.type}`;
-
+      // 娉ㄥ唽鎴愬姛鎴栧け璐ユ椂鍙栨秷鍔犺浇鐘舵��
+      if (status.type === "registered" || status.type === "failed") {
+        this.isRegistering = false;
+      }
+      // 娉ㄥ唽鎴愬姛
+      if (status.type === "registered") {
+        this.startCallsetState();
+      }
       // 澶勭悊娉ㄥ唽澶辫触鍜屾柇寮�杩炴帴鎯呭喌
       if (status.type === "failed" || status.type === "disconnected") {
         this.overCallsetState(); // 閲婃斁鍒嗘満鍙�
+        this.isRegistering = false;
       }
     };
 
@@ -107,6 +130,13 @@
       // 閫氱煡鐖剁粍浠堕�氳瘽鐘舵�佸彉鍖�
       this.$emit("call-status-change", status);
     };
+    // 娣诲姞娉ㄥ唽瓒呮椂澶勭悊
+    setTimeout(() => {
+      if (this.isRegistering && this.sipStatus !== "宸叉敞鍐�") {
+        this.isRegistering = false;
+        this.$message.warning("SIP娉ㄥ唽瓒呮椂锛岃妫�鏌ョ綉缁滆繛鎺�");
+      }
+    }, 10000); // 10绉掕秴鏃�
   },
   methods: {
     async startCall() {
@@ -127,7 +157,7 @@
         this.isCalling = true;
         console.log("寮�濮嬪懠鍙細", sipService);
 
-        await sipService.makeCall("0" + this.phoneNumber);
+        await sipService.makeCall(this.phoneNumber);
       } catch (error) {
         let registrationTime = Date.now(); // 璁板綍娉ㄩ攢鎴愬姛鏃堕棿
         console.log(registrationTime, "鍛煎彨澶辫触鏃堕棿");
@@ -160,10 +190,9 @@
         this.randomID = res.data[0].id;
         // 姝g‘璁剧疆 sipUri
         this.sipConfig.sipUri = `${this.randomNum}@192.168.10.124`;
-        this.startCallsetState();
       } catch (error) {
         console.error("鑾峰彇鍒嗘満鍙峰け璐�:", error);
-        this.updateStatus("failed", "鑾峰彇鍒嗘満鍙峰け璐�");
+        // this.updateStatus("failed", "鑾峰彇鍒嗘満鍙峰け璐�");
       }
     },
     async startCallsetState() {

--
Gitblit v1.9.3