Commit 5806a28f authored by 前端-黄佳鑫's avatar 前端-黄佳鑫
parents d4ec8de0 155a3d61
...@@ -12,90 +12,93 @@ const COOKIEPREFIX = 'CHATROOM_'; ...@@ -12,90 +12,93 @@ const COOKIEPREFIX = 'CHATROOM_';
// 主动调起聊天室 mmeberId 为接收人的memberId // 主动调起聊天室 mmeberId 为接收人的memberId
export const toChatRoom = (memberId: string = '', shopType: number = 1) => { export const toChatRoom = (memberId: string = '', shopType: number = 1) => {
if (!memberId) { if (!memberId) {
document.cookie = `${COOKIEPREFIX}curMemberId="";path=/;domain=${DOMAIN}`; document.cookie = `${COOKIEPREFIX}curMemberId="";path=/;domain=${DOMAIN}`;
document.cookie = `${COOKIEPREFIX}curUserId="";path=/;domain=${DOMAIN}`; document.cookie = `${COOKIEPREFIX}curUserId="";path=/;domain=${DOMAIN}`;
document.cookie = `${COOKIEPREFIX}shopType=${shopType};path=/;domain=${DOMAIN}`;
document.cookie = `${COOKIEPREFIX}ENTERPRISE_CENTER_URL=${ENTERPRISE_CENTER_URL};path=/;domain=${DOMAIN}`;
document.cookie = `${COOKIEPREFIX}CHANNEL_CENTER_URL=${CHANNEL_CENTER_URL};path=/;domain=${DOMAIN}`;
document.cookie = `${COOKIEPREFIX}ICHANNEL_CENTER_URL=${ICHANNEL_CENTER_URL};path=/;domain=${DOMAIN}`;
document.cookie = `${COOKIEPREFIX}origin=${window.location.origin};path=/;domain=${DOMAIN}`;
window.open(CHATROOM_URL);
return;
}
const _params: any = {
memberId
}
PublicApi.getMessageImHistorySession(_params).then(res => {
if (res.code === 1000) {
let _userId = '';
const _list = res.data;
if (_list.length > 0) {
for (var i = 0; i < _list.length; i++) {
if (_list[i].userList.length > 0) {
_userId = _list[i].userList[0].userId;
break;
}
}
}
if (_userId) {
document.cookie = `${COOKIEPREFIX}curMemberId=${memberId};path=/;domain=${DOMAIN}`;
document.cookie = `${COOKIEPREFIX}curUserId=${_userId};path=/;domain=${DOMAIN}`;
document.cookie = `${COOKIEPREFIX}shopType=${shopType};path=/;domain=${DOMAIN}`; document.cookie = `${COOKIEPREFIX}shopType=${shopType};path=/;domain=${DOMAIN}`;
document.cookie = `${COOKIEPREFIX}ENTERPRISE_CENTER_URL=${ENTERPRISE_CENTER_URL};path=/;domain=${DOMAIN}`; document.cookie = `${COOKIEPREFIX}ENTERPRISE_CENTER_URL=${ENTERPRISE_CENTER_URL};path=/;domain=${DOMAIN}`;
document.cookie = `${COOKIEPREFIX}CHANNEL_CENTER_URL=${CHANNEL_CENTER_URL};path=/;domain=${DOMAIN}`; document.cookie = `${COOKIEPREFIX}CHANNEL_CENTER_URL=${CHANNEL_CENTER_URL};path=/;domain=${DOMAIN}`;
document.cookie = `${COOKIEPREFIX}ICHANNEL_CENTER_URL=${ICHANNEL_CENTER_URL};path=/;domain=${DOMAIN}`; document.cookie = `${COOKIEPREFIX}ICHANNEL_CENTER_URL=${ICHANNEL_CENTER_URL};path=/;domain=${DOMAIN}`;
document.cookie = `${COOKIEPREFIX}origin=${window.location.origin};path=/;domain=${DOMAIN}`; document.cookie = `${COOKIEPREFIX}origin=${window.location.origin};path=/;domain=${DOMAIN}`;
window.open(CHATROOM_URL); window.open(CHATROOM_URL);
return; } else {
message.error('该会员底下没有客服!');
}
} }
PublicApi.getMessageImHistorySession({ memberId: memberId }).then(res => { })
if (res.code === 1000) {
let _userId = '';
const _list = res.data;
if (_list.length > 0) {
for (var i = 0; i < _list.length; i++) {
if (_list[i].userList.length > 0) {
_userId = _list[i].userList[0].userId;
break;
}
}
}
if (_userId) {
document.cookie = `${COOKIEPREFIX}curMemberId=${memberId};path=/;domain=${DOMAIN}`;
document.cookie = `${COOKIEPREFIX}curUserId=${_userId};path=/;domain=${DOMAIN}`;
document.cookie = `${COOKIEPREFIX}shopType=${shopType};path=/;domain=${DOMAIN}`;
document.cookie = `${COOKIEPREFIX}ENTERPRISE_CENTER_URL=${ENTERPRISE_CENTER_URL};path=/;domain=${DOMAIN}`;
document.cookie = `${COOKIEPREFIX}CHANNEL_CENTER_URL=${CHANNEL_CENTER_URL};path=/;domain=${DOMAIN}`;
document.cookie = `${COOKIEPREFIX}ICHANNEL_CENTER_URL=${ICHANNEL_CENTER_URL};path=/;domain=${DOMAIN}`;
document.cookie = `${COOKIEPREFIX}origin=${window.location.origin};path=/;domain=${DOMAIN}`;
window.open(CHATROOM_URL);
} else {
message.error('该会员底下没有客服!');
}
}
})
} }
// 被动从websocket调起聊天室 // 被动从websocket调起聊天室
export const notificationChatRoom = (content: any) => { export const notificationChatRoom = (content: any) => {
const _curUserInfo: any = getAuth(); const _curUserInfo: any = getAuth();
const close = () => { const close = () => {
console.log( console.log(
'Notification was closed. Either the close button was clicked or duration time elapsed.', 'Notification was closed. Either the close button was clicked or duration time elapsed.',
);
};
const key = `open${Date.now()}`;
const btn = (
<Button type="primary" size="small" onClick={() => {
document.cookie = `${COOKIEPREFIX}curMemberId=${content.desc.fromMemberId};path=/;domain=${DOMAIN}`;
document.cookie = `${COOKIEPREFIX}curUserId=${content.desc.fromUserId};path=/;domain=${DOMAIN}`;
document.cookie = `${COOKIEPREFIX}shopType=${content.desc.shopType};path=/;domain=${DOMAIN}`;
document.cookie = `${COOKIEPREFIX}ENTERPRISE_CENTER_URL=${ENTERPRISE_CENTER_URL};path=/;domain=${DOMAIN}`;
document.cookie = `${COOKIEPREFIX}CHANNEL_CENTER_URL=${CHANNEL_CENTER_URL};path=/;domain=${DOMAIN}`;
document.cookie = `${COOKIEPREFIX}ICHANNEL_CENTER_URL=${ICHANNEL_CENTER_URL};path=/;domain=${DOMAIN}`;
document.cookie = `${COOKIEPREFIX}origin=${window.location.origin};path=/;domain=${DOMAIN}`;
window.open(CHATROOM_URL);
notification.close(key)
}}>
查看
</Button>
); );
let _text = ''; };
if (content.data.text) { const key = `open${Date.now()}`;
_text = content.data.text; const btn = (
} else if (content.data.img) { <Button type="primary" size="small" onClick={() => {
_text = '[图片]'; document.cookie = `${COOKIEPREFIX}curMemberId=${content.desc.fromMemberId};path=/;domain=${DOMAIN}`;
} else if (content.data.file) { document.cookie = `${COOKIEPREFIX}curUserId=${content.desc.fromUserId};path=/;domain=${DOMAIN}`;
_text = '[文件]'; document.cookie = `${COOKIEPREFIX}shopType=${content.desc.shopType};path=/;domain=${DOMAIN}`;
} else if (content.data.order) { document.cookie = `${COOKIEPREFIX}ENTERPRISE_CENTER_URL=${ENTERPRISE_CENTER_URL};path=/;domain=${DOMAIN}`;
_text = '[订单]'; document.cookie = `${COOKIEPREFIX}CHANNEL_CENTER_URL=${CHANNEL_CENTER_URL};path=/;domain=${DOMAIN}`;
} else if (content.data.goods) { document.cookie = `${COOKIEPREFIX}ICHANNEL_CENTER_URL=${ICHANNEL_CENTER_URL};path=/;domain=${DOMAIN}`;
_text = '[商品]'; document.cookie = `${COOKIEPREFIX}origin=${window.location.origin};path=/;domain=${DOMAIN}`;
} else if (content.data.sale) { window.open(CHATROOM_URL);
_text = '[售后]'; notification.close(key)
} }}>
notification.open({ 查看
message: '你收到一条消息', </Button>
description: <Typography.Text ellipsis>{_text}</Typography.Text>, );
btn, let _text = '';
key, if (content.data.text) {
duration: 10, _text = content.data.text;
onClose: close, } else if (content.data.img) {
}); _text = '[图片]';
} else if (content.data.file) {
_text = '[文件]';
} else if (content.data.order) {
_text = '[订单]';
} else if (content.data.goods) {
_text = '[商品]';
} else if (content.data.sale) {
_text = '[售后]';
}
notification.open({
message: '你收到一条消息',
description: <Typography.Text style={{ width: 200 }} ellipsis>{_text}</Typography.Text>,
btn,
key,
duration: 10,
onClose: close,
});
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment