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

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

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

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

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

Loading…
Cancel
Save