Browse Source

发送消息

rkljw 19 hours ago
parent
commit
5d06ea0be5
2 changed files with 14 additions and 13 deletions
  1. 10 9
      src/layout/components/Chat/ChatPanel.vue
  2. 4 4
      src/utils/baseUrl.js

+ 10 - 9
src/layout/components/Chat/ChatPanel.vue

@@ -1897,7 +1897,7 @@
         //console.log(message)
         //发送消息
         let that = this;
-        if (this.ws && wsService.getReadyState === WebSocket.OPEN) {
+        if (wsService.getReadyState() === WebSocket.OPEN) {
           //打开左侧loading防止重复点击
           this.hallLeftLoading = true;
           wsService.send(JSON.stringify(message));
@@ -2518,7 +2518,7 @@
   
           console.log(message)
           //发送消息
-          if (this.ws && wsService.getReadyState === WebSocket.OPEN) {
+          if (wsService.getReadyState() === WebSocket.OPEN) {
             wsService.send(message);
           }
           //关闭分享弹出框
@@ -2823,7 +2823,7 @@
           };
           // console.log("websocket发送消息:",wsService.getReadyState,WebSocket.OPEN)
           //发送消息
-          console.log("发送消息前的状态:",wsService.getReadyState() ,"==========" ,WebSocket.OPEN,message)
+          // console.log("发送消息前的状态:",wsService.getReadyState() ,"==========" ,WebSocket.OPEN,message)
           if (wsService.getReadyState() === WebSocket.OPEN) {
             wsService.send(message);
           }
@@ -2842,8 +2842,9 @@
             content:this.sendMessage.img.imgUrl,//用户发发送的消息
             msg_type:2,//消息类型 1:文本 2:图片 3:文件 4:好友卡片 5:系统消息;6:加群卡片
           };
-          if (this.ws && wsService.getReadyState === WebSocket.OPEN) {
-            this.ws.send(JSON.stringify(message));
+          // console.log("发送图片消息前的状态:",wsService.getReadyState(),WebSocket.OPEN)
+          if (wsService.getReadyState() === WebSocket.OPEN) {
+            wsService.send(JSON.stringify(message));
             //发送完毕清除选择的图片
             this.sendMessage.img.imgUrl='';
           }
@@ -2866,8 +2867,8 @@
             content:fileInfoString,//用户发发送的消息
             msg_type:3,//消息类型 1:文本 2:图片 3:文件 4:好友卡片 5:系统消息;6:加群卡片
           };
-          if (this.ws && wsService.getReadyState === WebSocket.OPEN) {
-            this.ws.send(JSON.stringify(message));
+          if (wsService.getReadyState() === WebSocket.OPEN) {
+            wsService.send(JSON.stringify(message));
             //发送完毕清除选择的文件
             this.sendMessage.file.fileUrl='';
           }
@@ -2931,8 +2932,8 @@
   
           console.log(message)
           //发送消息
-          if (this.ws && wsService.getReadyState === WebSocket.OPEN) {
-            this.ws.send(JSON.stringify(message));
+          if (wsService.getReadyState() === WebSocket.OPEN) {
+            wsService.send(JSON.stringify(message));
           }
           //关闭分享弹出框
           this.userCardWindowStatus = false;

+ 4 - 4
src/utils/baseUrl.js

@@ -7,17 +7,17 @@ const URL = {
   //baseUrl: 'http://adminpre.bjzxtw.org.cn:9501',//pre环境域名
 
   webUrl: 'adminpre.bjzxtw.org.cn',//管理系统地址,如果用户因为某种原因以外退出,需要一个userurl用于请求接口
-  baseUrl: 'https://apipre1.bjzxtw.org.cn',//pre环境域名2
-  //baseUrl: 'http://192.168.1.201:9501',//刘佳伟本地环境
+  // baseUrl: 'https://apipre1.bjzxtw.org.cn',//pre环境域名2
+  baseUrl: 'http://192.168.1.201:9501',//刘佳伟本地环境
   //baseUrl:'http://192.168.1.115:9501',//冯蕊的本地环境
   //baseUrl: 'http://192.168.1.129:9501',//刘剑的本地环境
-  //WebsocketUrl: 'ws://192.168.1.201:9506',//刘佳伟 -- websocket地址
+  WebsocketUrl: 'ws://192.168.1.201:9506',//刘佳伟 -- websocket地址
   // WebsocketUrl: 'ws://192.168.1.127:9506'//刘剑 -- websocket地址
   //WebsocketUrl: 'ws://183.131.25.186:9506',//测试环境ip -- websocket地址
   //WebsocketUrl: 'ws://admindev.bjzxtw.org.cn:9506',//测试环境域名
   //WebsocketUrl: 'ws://116.131.8.26:9506'//pre环境ip -- websocket地址
   //WebsocketUrl: 'ws://adminpre.bjzxtw.org.cn:9506'//pre环境域名 -- websocket地址
-  WebsocketUrl: 'wss://apipre1.bjzxtw.org.cn',//pre环境域名 -- websocket地址
+  // WebsocketUrl: 'wss://apipre1.bjzxtw.org.cn',//pre环境域名 -- websocket地址
   //WebsocketUrl: 'ws://103.105.201.2:9506'//正式环境ip -- websocket地址
   //WebsocketUrl: 'wss://flzxw.bjzxtw.org.cn'//正式环境域名 wss可用 -- websocket地址
   WebCloginUrl: 'https://apipre1.bjzxtw.org.cn/api/loginapi', //单点登录地址