feature/1.0.1-im-ch
ch 3 years ago
parent 4e55bc7c94
commit 0cf30a999f

@ -2,7 +2,7 @@
* @Author: ch
* @Date: 2022-05-11 11:45:08
* @LastEditors: ch
* @LastEditTime: 2022-05-16 20:06:16
* @LastEditTime: 2022-05-19 14:07:03
* @Description: file content
-->
<template>
@ -46,6 +46,7 @@
</template>
<script>
import {MsbWebSkt, createUUID} from '@/common/utils';
import {MsbSktSendMsg} from '@/common/utils/webSkt';
import {MSG_TYPE} from '@/common/dicts/im';
import {Request} from '@/common/utils';
import {ApiPutUser} from '@/common/api/account';
@ -115,7 +116,7 @@ export default {
/**
* 统一发送函数
*/
send(val, type){
async send(val, type){
let payload = {};
switch(type){
case MSG_TYPE.CUSTOM :
@ -130,18 +131,14 @@ export default {
break;
}
MsbWebSkt.send({
data : JSON.stringify({
traceId : createUUID(),
traceType : '20',
content: {
toSessionId : this.$store.state.sessionMsgId,
payload : payload,
toId : 1,
type : type
}
})
});
let res = await MsbSktSendMsg({
content: {
toSessionId : this.$store.state.sessionMsgId,
payload : payload,
toId : 1,
type : type
}
})
this.msgCtx = '';
this.focus = false;
this.$nextTick(() => {

@ -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
}
})
},
/**
* 从订单页进来查询订单信息

@ -2,7 +2,7 @@
* @Author: ch
* @Date: 2022-03-23 17:27:21
* @LastEditors: ch
* @LastEditTime: 2022-05-17 22:25:52
* @LastEditTime: 2022-05-19 11:24:09
* @Description: file content
-->
<template>
@ -145,13 +145,13 @@ export default {
this.showSkuPopup = true
},
service(){
// this.$Router.push({
// path : '/messageChat',
// query: {
// goodsId : this.goods.id
// }
// })
uni.$u.toast('客服休息中,遇到喜欢的宝贝就下单吧~')
this.$Router.push({
path : '/messageChat',
query: {
goodsId : this.goods.id
}
})
// uni.$u.toast('~')
}
}

@ -2,7 +2,7 @@
* @Author: ch
* @Date: 2022-03-22 15:36:46
* @LastEditors: ch
* @LastEditTime: 2022-05-17 20:03:12
* @LastEditTime: 2022-05-19 11:15:05
* @Description: file content
-->
<template>
@ -32,6 +32,7 @@
</template>
<script>
import { IsPhone,MsbWebSkt, MsbWebSktInit, createUUID } from '@/common/utils';
import { MsbSktInit, MsbSktGetSessionList} from '@/common/utils/webSkt';
import { ApiGetCode, ApiPostLogin } from '@/common/api/index';
import { ApiPostThirdInfo } from '@/common/api/wx';
import UiButton from '../components/UiButton.vue';
@ -113,26 +114,14 @@ export default {
});
}
MsbWebSktInit().then(()=>{
MsbWebSkt.send({
data : JSON.stringify({
traceId : createUUID(),
traceType : "1",
content: { sysId : "1"}
})
});
setInterval(()=>{
MsbWebSkt.send({
data : JSON.stringify({
traceId : createUUID(),
traceType : "0",
content: { text : "ping"}
})
})
}, 5000);
})
MsbSktInit().then(() => {
MsbSktGetSessionList({
traceType : 1,
content: { sysId : 1}
});
});
this.goBack();
},
/**

Loading…
Cancel
Save