|
|
@@ -93,10 +93,8 @@
|
|
|
"
|
|
|
>
|
|
|
<el-badge
|
|
|
- v-if="scope.row.unread !== 0 && scope.row.unread"
|
|
|
- :value="scope.row.unread"
|
|
|
+ v-if="scope.row.unread"
|
|
|
is-dot
|
|
|
- :max="99"
|
|
|
class="item"
|
|
|
>
|
|
|
<img
|
|
|
@@ -332,22 +330,36 @@
|
|
|
margin: 23px 0 0 0;
|
|
|
"
|
|
|
></div>
|
|
|
- <div>
|
|
|
- <img
|
|
|
- src="../../../static/images/realTime/7.png"
|
|
|
- alt=""
|
|
|
- class=""
|
|
|
- />
|
|
|
+ <div
|
|
|
+ style="
|
|
|
+ width: 45px;
|
|
|
+ height: 45px;
|
|
|
+ border-radius: 10px;
|
|
|
+ line-height: 45px;
|
|
|
+ text-align: center;
|
|
|
+ font-size: 16px;
|
|
|
+ background-image: linear-gradient(#a7fbc6, #60fba5);
|
|
|
+ color: #fff;
|
|
|
+ "
|
|
|
+ >
|
|
|
+ 我
|
|
|
</div>
|
|
|
</div>
|
|
|
<!-- you -->
|
|
|
<div v-else-if="item.is_right == false" class="list_msgBox2">
|
|
|
- <div>
|
|
|
- <img
|
|
|
- src="../../../static/images/realTime/6.png"
|
|
|
- alt=""
|
|
|
- class=""
|
|
|
- />
|
|
|
+ <div
|
|
|
+ style="
|
|
|
+ width: 45px;
|
|
|
+ height: 45px;
|
|
|
+ border-radius: 10px;
|
|
|
+ line-height: 45px;
|
|
|
+ text-align: center;
|
|
|
+ font-size: 16px;
|
|
|
+ background-image: linear-gradient(#addbff, #5cacff);
|
|
|
+ color: #fff;
|
|
|
+ "
|
|
|
+ >
|
|
|
+ {{ getUserObj.real_name.slice(0, 1) }}
|
|
|
</div>
|
|
|
|
|
|
<div
|
|
|
@@ -508,7 +520,7 @@ export default {
|
|
|
dialogVisible(val) {
|
|
|
if (val == false) {
|
|
|
this.msgList = [];
|
|
|
- }
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
// 音视频弹框
|
|
|
@@ -522,18 +534,33 @@ export default {
|
|
|
|
|
|
// 给表格文本消息增加提示,数据从webscoket中获取
|
|
|
tableData(val) {
|
|
|
+ var that = this
|
|
|
for (var i = 0; i < val.length; i++) {
|
|
|
let sdhkj = val[i];
|
|
|
for (var k = 0; k < this.websockMsgList.length; k++) {
|
|
|
let sdjaks = this.websockMsgList[k];
|
|
|
- // if (sdhkj.user_id == sdjaks.user_id) {
|
|
|
- if (sdhkj.real_name == sdjaks.real_name) {
|
|
|
- this.tableData[i].unread = sdjaks.unread;
|
|
|
+ if (sdhkj.real_name == sdjaks.real_name && sdjaks.unread !== 0 && sdjaks.unread) {
|
|
|
+ this.tableData[i]['unread'] = sdjaks.unread
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
- // 测试
|
|
|
+ deep: true,
|
|
|
+
|
|
|
+ // websocket列表变化
|
|
|
+ websockMsgList(val) {
|
|
|
+ // var that = this
|
|
|
+ // for (var i = 0; i < this.tableData.length; i++) {
|
|
|
+ // let sdhkj = this.tableData[i];
|
|
|
+ // for (var k = 0; k < val.length; k++) {
|
|
|
+ // let sdjaks = val[k];
|
|
|
+ // if (sdhkj.real_name == sdjaks.real_name && sdjaks.unread !== 0 && sdjaks.unread) {
|
|
|
+ // this.tableData[i]['unread'] = sdjaks.unread
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ this.userListData(); // 获取右侧用户列表
|
|
|
+ },
|
|
|
},
|
|
|
//方法集合
|
|
|
methods: {
|
|
|
@@ -630,6 +657,7 @@ export default {
|
|
|
// 文本消息
|
|
|
msgAxios(data) {
|
|
|
this.getUserObj = data;
|
|
|
+ this.redtf = data
|
|
|
this.userName = localStorage.getItem("usernme");
|
|
|
console.log(this.userName);
|
|
|
this.tltData = "与" + data.real_name + "的对话";
|
|
|
@@ -643,16 +671,16 @@ export default {
|
|
|
},
|
|
|
};
|
|
|
this.websock.send(JSON.stringify(obj)); // 获取聊天记录
|
|
|
- var readObj = {};
|
|
|
- readObj = {
|
|
|
- action: "read",
|
|
|
- send_user_id: data.user_id,
|
|
|
- data: {
|
|
|
- msg_status: false,
|
|
|
- msg_info: "",
|
|
|
- },
|
|
|
- };
|
|
|
- this.websock.send(JSON.stringify(readObj)); // 消息已读
|
|
|
+ // var readObj = {};
|
|
|
+ // readObj = {
|
|
|
+ // action: "read",
|
|
|
+ // send_user_id: data.user_id,
|
|
|
+ // data: {
|
|
|
+ // msg_status: false,
|
|
|
+ // msg_info: "",
|
|
|
+ // },
|
|
|
+ // };
|
|
|
+ // this.websock.send(JSON.stringify(readObj)); // 消息已读
|
|
|
this.dialogVisible = true;
|
|
|
},
|
|
|
|
|
|
@@ -815,8 +843,9 @@ export default {
|
|
|
this.start(); //开启心跳
|
|
|
};
|
|
|
this.websock.onmessage = (event) => {
|
|
|
- // console.log("WebSocket:消息");
|
|
|
var data = JSON.parse(event.data);
|
|
|
+ console.log("WebSocket:消息---------------------------", data);
|
|
|
+
|
|
|
if (data.action == "none") {
|
|
|
// 获取聊天记录
|
|
|
var datArr = data.data; // 总数据
|
|
|
@@ -840,7 +869,8 @@ export default {
|
|
|
var obj = {};
|
|
|
obj = {
|
|
|
action: "list",
|
|
|
- recv_user_id: this.getUserObj.user_id,
|
|
|
+ // recv_user_id: this.getUserObj.user_id,
|
|
|
+ recv_user_id: "",
|
|
|
data: {
|
|
|
msg_status: false,
|
|
|
msg_info: "",
|
|
|
@@ -869,6 +899,9 @@ export default {
|
|
|
this.videoVisible = true;
|
|
|
}
|
|
|
});
|
|
|
+ } else if (data.action == "ok") {
|
|
|
+ // 心跳机制 - 当前状态是websocket连接没有问题
|
|
|
+ this.start(); // 心跳机制
|
|
|
}
|
|
|
};
|
|
|
this.websock.onerror = (event) => {
|
|
|
@@ -886,13 +919,11 @@ export default {
|
|
|
console.log("WebSocket:已关闭");
|
|
|
console.log(event);
|
|
|
console.log(that.timeoutnum);
|
|
|
- // if (that.timeoutnum !== null) {
|
|
|
- setTimeout(() => {
|
|
|
- that.websock.close(); // 先关闭
|
|
|
- clearTimeout(that.timeoutObj); //清除时间
|
|
|
- that.reconnect(); // 重连
|
|
|
- }, 5000);
|
|
|
- // }
|
|
|
+ setTimeout(() => {
|
|
|
+ // that.websock.close(); // 先关闭
|
|
|
+ clearTimeout(that.timeoutObj); //清除时间
|
|
|
+ that.reconnect(); // 重连
|
|
|
+ }, 5000);
|
|
|
};
|
|
|
}
|
|
|
},
|
|
|
@@ -1010,39 +1041,28 @@ export default {
|
|
|
self.timeoutObj = setTimeout(function () {
|
|
|
//这里发送一个心跳,后端收到后,返回一个心跳消息,
|
|
|
console.log("心跳中。。。", self.websock.readyState);
|
|
|
- // if (self.websock.readyState == 1) {
|
|
|
- // //如果连接正常
|
|
|
- // self.websock.send(
|
|
|
- // JSON.stringify({
|
|
|
- // data: {
|
|
|
- // action: "list",
|
|
|
- // recv_user_id: '',
|
|
|
- // data: {
|
|
|
- // msg_status: false,
|
|
|
- // msg_info: "",
|
|
|
- // },
|
|
|
- // },
|
|
|
- // })
|
|
|
- // );
|
|
|
- // } else {
|
|
|
- // //否则重连
|
|
|
- // self.reconnect();
|
|
|
- // }
|
|
|
- //如果连接正常
|
|
|
- var obj1 = {};
|
|
|
- obj1 = {
|
|
|
- action: "list",
|
|
|
- recv_user_id: "",
|
|
|
- data: {
|
|
|
- msg_status: false,
|
|
|
- msg_info: "",
|
|
|
- },
|
|
|
- };
|
|
|
- self.websock.send(JSON.stringify(obj1));
|
|
|
- // self.serverTimeoutObj = setTimeout(function () {
|
|
|
- // //超时关闭
|
|
|
- // self.websock.close();
|
|
|
- // }, self.timeout);
|
|
|
+ if (self.websock.readyState == 1) {
|
|
|
+ //如果连接正常
|
|
|
+ var obj1 = {};
|
|
|
+ obj1 = {
|
|
|
+ action: "keepalive",
|
|
|
+ recv_user_id: "",
|
|
|
+ data: {
|
|
|
+ msg_status: false,
|
|
|
+ msg_info: "",
|
|
|
+ },
|
|
|
+ };
|
|
|
+ self.websock.send(JSON.stringify(obj1));
|
|
|
+ } else {
|
|
|
+ //否则重连
|
|
|
+ self.reconnect();
|
|
|
+ }
|
|
|
+ self.serverTimeoutObj = setTimeout(function () {
|
|
|
+ //超时关闭
|
|
|
+ console.log("又进入了?");
|
|
|
+ self.websock.close();
|
|
|
+ self.reconnect(); // 重连
|
|
|
+ }, self.timeout);
|
|
|
}, self.timeout);
|
|
|
},
|
|
|
reset() {
|
|
|
@@ -1050,7 +1070,7 @@ export default {
|
|
|
var that = this;
|
|
|
clearTimeout(that.timeoutObj); //清除时间
|
|
|
clearTimeout(that.serverTimeoutObj); //清除时间
|
|
|
- // that.start(); //重启心跳
|
|
|
+ that.start(); //重启心跳
|
|
|
},
|
|
|
|
|
|
// 重连机制
|
|
|
@@ -1058,7 +1078,6 @@ export default {
|
|
|
var that = this;
|
|
|
console.log("进入重连了");
|
|
|
clearTimeout(that.timeoutObj); //清除时间
|
|
|
- var that = this;
|
|
|
if (that.lockReconnect) {
|
|
|
return;
|
|
|
}
|