wansfa hace 1 año
padre
commit
96a0dc5437

+ 1 - 2
src/api/qw/login.js

@@ -30,11 +30,10 @@ export function getQwUser(deviceId) {
 
 //企微退出登录
 export function qwLoginOut(deviceId) {
-  let data={deviceId:deviceId};
   return request({
     url: '/qw/login/ban',
     method: 'post',
-    data:data 
+    data:deviceId 
   })
 }
 

+ 1 - 0
src/components/LemonUI/components/editor.vue

@@ -386,6 +386,7 @@ gap = 10px;
     align-items center
     justify-content space-between
     padding 0 5px
+    box-shadow 0px -1px 0px rgba(171,169,169,0.3)
   +e(tool-left){
     display flex
   }

+ 5 - 3
src/utils/WebsocketHeartbeat.js

@@ -14,6 +14,7 @@
 
     function WebsocketHeartbeat({
         url, 
+        userId,
         pingTimeout = 15000,
         pongTimeout = 10000,
         reconnectTimeout = 2000,
@@ -21,6 +22,7 @@
     }){
         this.opts ={
             url: url,
+            userId:userId,
             pingTimeout: pingTimeout,
             pongTimeout: pongTimeout,
             reconnectTimeout: reconnectTimeout,
@@ -34,7 +36,6 @@
         this.onopen = () => {};
         this.onmessage = () => {};
         this.onreconnect = () => {};
-    
         this.createWebSocket();
     }
     WebsocketHeartbeat.prototype.createWebSocket = function(){
@@ -80,7 +81,8 @@
         }, this.opts.reconnectTimeout);
     };
     WebsocketHeartbeat.prototype.send = function(msg){
-        this.ws.send(msg);
+        let msgBean={'cmd':this.opts.pingMsg,'userId':this.opts.userId,'msg':msg};
+        this.ws.send(JSON.stringify(msgBean));
     };
     //心跳检测
     WebsocketHeartbeat.prototype.heartCheck = function(){
@@ -92,7 +94,7 @@
         this.pingTimeoutId = setTimeout(() => {
             //这里发送一个心跳,后端收到后,返回一个心跳消息,
             //onmessage拿到返回的心跳就说明连接正常
-            this.ws.send(this.opts.pingMsg);
+            this.send(this.opts.pingMsg);
             //如果超过一定时间还没重置,说明后端主动断开了
             this.pongTimeoutId = setTimeout(() => {
                 //如果onclose会执行reconnect,我们执行ws.close()就行了.如果直接执行reconnect 会触发onclose导致重连两次

+ 4 - 3
src/utils/webSocket.js

@@ -3,7 +3,7 @@ import WebsocketHeartbeat from "./WebsocketHeartbeat";
 
 var server = "";  
 if (process.env.NODE_ENV === 'development') {
-    server = "ws://localhost:8209/imserver/r:";
+    server = "ws://localhost:7018/imserver/r:";
 }else{
     server = "wss://company.yjf.runtzh.com/imserver/r:";  
 }
@@ -21,8 +21,9 @@ export default {
                 //this.socket = new WebSocket(server+uid);
                 this.socket=new WebsocketHeartbeat({
                     url: server+uid,
-                    pingTimeout: 25000,
-                    pongTimeout: 20000
+                    userId:'r:'+uid,
+                    pingTimeout: 15000,
+                    pongTimeout: 10000
                 });
                 let that=this;
                 // this.socket.onopen = function () {

+ 29 - 1
src/views/qw/qwAccounts/index.vue

@@ -53,6 +53,12 @@
             icon="el-icon-edit"
             @click="handleUpdateDevice(scope.row)"
           >更新设备</el-button>
+           <el-button
+            size="mini"
+            type="text"
+            icon="el-icon-offline"
+            @click="handleOffLine(scope.row)"
+          >强制下线</el-button>
         </template>
       </el-table-column>
       
@@ -85,8 +91,9 @@
 
 <script>
 import { listAccount, getAccount, delAccount, addAccount, auditAccount, exportAccount,updateDevice } from "@/api/qw/account";
-// import { getCompanyList } from "@/api/company/company";
+import { qwLoginOut } from "@/api/qw/login";
 
+import store from "@/store";
 export default {
   name: "Account",
   data() {
@@ -232,6 +239,14 @@ export default {
         this.title = "账号审核";
       });
     },
+
+   qwLoginOut(deviceId) {
+      qwLoginOut(deviceId).then(response => {
+         this.msgSuccess("操作成功");
+         this.getList();
+      });
+    },
+  
    /** 提交按钮 */
    submitForm() {
       this.$refs["form"].validate(valid => {
@@ -274,6 +289,19 @@ export default {
           this.msgSuccess("变更成功");
         }).catch(function() {});
     },
+    handleOffLine(row){
+      const id = row.id || this.ids
+      this.$confirm('确定强制下线吗?', "警告", {
+          confirmButtonText: "确定",
+          cancelButtonText: "取消",
+          type: "warning"
+        }).then(function() {
+            qwLoginOut(row.deviceId);
+        }).then(() => {
+          this.getList();
+          this.msgSuccess("操作成功");
+        }).catch(function() {});
+    },
     /** 导出按钮操作 */
     handleExport() {
       const queryParams = this.queryParams;

+ 3 - 5
src/views/qw/qwChat/qq.vue

@@ -312,9 +312,7 @@ export default {
     };
   },
   created(){
-    
-    //  this.$store.dispatch('qwLoginOut').then(() => {
-    //  });
+  
   },
   mounted() {
     this.qwUser=store.getters.qwUser;
@@ -453,9 +451,9 @@ export default {
                   const IMUI = this.$refs.IMUI;
                   this.qwIm.socket.onmessage = function(res) {
                        var data=JSON.parse(res.data);
-                        console.log("收到服务端内容", JSON.stringify(data));
+                       //console.log("收到服务端内容", JSON.stringify(data));
                         if(data.cmd=="heartbeat"){ //收到心跳数据不处理
-                            console.log("收到心跳数据 heartbeat");
+                            console.log("heartbeat");
                         }
                         if(data.cmd=="offline"){
                             that.$message.error('企微号已下线');

+ 12 - 9
src/views/qw/qwLogin/index.vue

@@ -21,7 +21,6 @@
               </div>
             </div>
 
-
           </el-card>
 
         </el-col>
@@ -66,12 +65,16 @@ export default {
     };
   },
   created() {
-
+      
   },
   mounted () {
       // 初始化
       //this.initSocket(this.companyUser.userId);
       //console.log("userId:"+JSON.stringify(this.companyUser));
+      console.log("qxj process:"+JSON.stringify(process));
+      if (process.env.NODE_ENV === 'development') {
+            this.qwForm.account = "1261818888";
+       }
   },
   methods: {
     handleLogin() {
@@ -165,13 +168,13 @@ export default {
                             that.showQRCode=false;
                             that.showVerifyCode=true;
                         }
-                        if(data.cmd=="offline"){
-                            that.loginTips="获取验证码";
-                            that.showQRCode=true;
-                            that.showVerifyCode=false;
-                            that.$store.dispatch('qwLoginOut').then(() => {
-                            });
-                        }
+                        // if(data.cmd=="offline"){
+                        //     that.loginTips="获取验证码";
+                        //     that.showQRCode=true;
+                        //     that.showVerifyCode=false;
+                        //     that.$store.dispatch('qwLoginOut').then(() => {
+                        //     });
+                        // }
                   };
                   // 监听socket重连
                   this.qwIm.socket.onreconnect = function(res) {