|
|
|
@ -2,7 +2,7 @@
|
|
|
|
|
* @Author: ch
|
|
|
|
|
* @Date: 2022-03-26 14:32:03
|
|
|
|
|
* @LastEditors: ch
|
|
|
|
|
* @LastEditTime: 2022-05-17 16:22:51
|
|
|
|
|
* @LastEditTime: 2022-05-19 14:05:29
|
|
|
|
|
* @Description: file content
|
|
|
|
|
-->
|
|
|
|
|
<template>
|
|
|
|
@ -48,6 +48,7 @@
|
|
|
|
|
<script>
|
|
|
|
|
import {MSG_TYPE} from '@/common/dicts/im';
|
|
|
|
|
import {MsbWebSkt, createUUID} from '@/common/utils';
|
|
|
|
|
import {MsbSktCreateSession, MsbSktGetHistoryMsg, MsbSktSetRead} from '@/common/utils/webSkt';
|
|
|
|
|
import {ApiGetOrderDetail} from '@/common/api/order';
|
|
|
|
|
import {ApiGetGoodsDetail} from '@/common/api/goods';
|
|
|
|
|
import UiButton from '@/components/UiButton.vue';
|
|
|
|
@ -112,7 +113,6 @@ export default {
|
|
|
|
|
this.$store.commit('SET_SESSION_MSG_ID',this.sessionId);
|
|
|
|
|
this.getHistoryMsg();
|
|
|
|
|
this.readMsg();
|
|
|
|
|
this.heartMsg();
|
|
|
|
|
}else{
|
|
|
|
|
this.createSessionMain();
|
|
|
|
|
}
|
|
|
|
@ -123,80 +123,40 @@ export default {
|
|
|
|
|
* 创建会话主体
|
|
|
|
|
* 如果是从商品或订单进来,需要创建会话
|
|
|
|
|
*/
|
|
|
|
|
createSessionMain(){
|
|
|
|
|
|
|
|
|
|
MsbWebSkt.send({
|
|
|
|
|
data : JSON.stringify({
|
|
|
|
|
traceId : createUUID(),
|
|
|
|
|
traceType : '21',
|
|
|
|
|
content : {
|
|
|
|
|
storeId : 1
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
success:()=>{
|
|
|
|
|
// 不能这样啊啊啊啊
|
|
|
|
|
setTimeout(()=>{
|
|
|
|
|
this.getHistoryMsg();
|
|
|
|
|
this.readMsg();
|
|
|
|
|
this.heartMsg();
|
|
|
|
|
},1000)
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
/**
|
|
|
|
|
* 发送心跳
|
|
|
|
|
*/
|
|
|
|
|
heartMsg(){
|
|
|
|
|
MsbWebSkt.send({
|
|
|
|
|
data : JSON.stringify({
|
|
|
|
|
traceId : createUUID(),
|
|
|
|
|
traceType : '22',
|
|
|
|
|
content : {
|
|
|
|
|
storeId : 1
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
complete: () =>{
|
|
|
|
|
setTimeout(()=>{
|
|
|
|
|
this.heartMsg();
|
|
|
|
|
},5000)
|
|
|
|
|
async createSessionMain(){
|
|
|
|
|
await MsbSktCreateSession({
|
|
|
|
|
content : {
|
|
|
|
|
storeId : 1
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
this.getHistoryMsg();
|
|
|
|
|
this.readMsg();
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
/**
|
|
|
|
|
* 获取历史消息
|
|
|
|
|
*/
|
|
|
|
|
getHistoryMsg(){
|
|
|
|
|
async getHistoryMsg(){
|
|
|
|
|
this.loading = true;
|
|
|
|
|
const lastMsg = this.msgData?.length ? this.msgData[0] : {};
|
|
|
|
|
MsbWebSkt.send({
|
|
|
|
|
data : JSON.stringify({
|
|
|
|
|
traceId : createUUID(),
|
|
|
|
|
traceType : "23",
|
|
|
|
|
content: {
|
|
|
|
|
sessionId : this.$store.state.sessionMsgId,
|
|
|
|
|
topMessageId : lastMsg.id || null
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
await MsbSktGetHistoryMsg({
|
|
|
|
|
content : {
|
|
|
|
|
sessionId : this.$store.state.sessionMsgId,
|
|
|
|
|
topMessageId : lastMsg.id || null
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
this.loading = false;
|
|
|
|
|
},
|
|
|
|
|
/**
|
|
|
|
|
* 已读消息
|
|
|
|
|
*/
|
|
|
|
|
readMsg(){
|
|
|
|
|
MsbWebSkt.send({
|
|
|
|
|
data : JSON.stringify({
|
|
|
|
|
traceId : createUUID(),
|
|
|
|
|
traceType : "6",
|
|
|
|
|
content: {
|
|
|
|
|
sessionId : this.$store.state.sessionMsgId
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
// 计算页头消息数
|
|
|
|
|
const count = this.$store.state.sessionMsgCount - this.curSessionData.unreadCount;
|
|
|
|
|
// 计算会话列表消息数
|
|
|
|
|
this.curSessionData.unreadCount = 0;
|
|
|
|
|
this.$store.commit('SET_SESSION_MSG_COUNT', count)
|
|
|
|
|
MsbSktSetRead({
|
|
|
|
|
content: {
|
|
|
|
|
sessionId : this.$store.state.sessionMsgId
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
/**
|
|
|
|
|
* 从订单页进来查询订单信息
|
|
|
|
|