Jelajahi Sumber

T人加exitRoom api

gemercheung 2 tahun lalu
induk
melakukan
581d68fddc
1 mengubah file dengan 21 tambahan dan 9 penghapusan
  1. 21 9
      socket.js

+ 21 - 9
socket.js

@@ -57,7 +57,7 @@ export default {
   joinUrl() {
 
     let url = this.data.url;
-    
+
     //隐藏部分
     // if (this.data.url && /smobile.html/.test(this.data.url)) {
     //   const newUrl = this.data.url.replace('smobile.html', 'shop.html')
@@ -618,17 +618,19 @@ export default {
         const roomId = data.roomId
         // debugger
         if (socketOptions.userId == userId && this.options.roomId == roomId) {
+          this.exitRoom();
           wx.showToast({
-            title: '您已被踢出房间',
+            title: '您已被踢出房间!',
             icon: 'none',
-            complete: () => {}
+            complete: () => {
+              setTimeout(() => {
+                that.socketStop();
+                wx.switchTab({
+                  url: '/pages/index/index',
+                })
+              }, 1000)
+            }
           })
-          setTimeout(() => {
-            that.socketStop();
-            wx.switchTab({
-              url: '/pages/index/index',
-            })
-          }, 1000)
         }
       }
     });
@@ -965,6 +967,16 @@ export default {
     }
 
   },
+
+  exitRoomApi() {
+    const roomId = this.data.socketOptions.roomId;
+    const role = this.role;
+    util.request(api.exitRoom, {
+      businessId: roomId
+    }, 'POST', 'application/json');
+
+
+  },
   async exit() {
     // this.stopCall()
     getApp().globalData.rtcParams = []