Commit a971c771 authored by 卢均锐's avatar 卢均锐

feat: 修改调起im方法

parent a2e06d5c
import React from 'react';
import { Button, notification, message } from 'antd';
import { GlobalConfig } from '@/global/config'
import { PublicApi } from '@/services/api';
import { REQUEST_HEADER, TOP_DOMAIN, ENTERPRISE_CENTER_URL, ICHANNEL_CENTER_URL } from '@/constants';
import { REQUEST_HEADER, TOP_DOMAIN, ENTERPRISE_CENTER_URL, CHANNEL_CENTER_URL, ICHANNEL_CENTER_URL } from '@/constants';
import { getAuth } from '@/utils/auth';
const DOMAIN = `.${TOP_DOMAIN}`;//document.domain
......@@ -11,14 +12,20 @@ const COOKIEPREFIX = 'CHATROOM_';
// 主动调起聊天室 mmeberId 为接收人的memberId
export const toChatRoom = (memberId: string = '', shopType: number = 1) => {
let _curUserInfo = getAuth();
let _curUserInfo: any = getAuth();
if (!memberId) {
document.cookie = `${COOKIEPREFIX}userToken=${_curUserInfo.token};path=/;domain=${DOMAIN}`;
document.cookie = `${COOKIEPREFIX}userMemberId=${_curUserInfo.memberId};path=/;domain=${DOMAIN}`;
document.cookie = `${COOKIEPREFIX}userMemberType=${_curUserInfo.memberType};path=/;domain=${DOMAIN}`;
document.cookie = `${COOKIEPREFIX}userUserId=${_curUserInfo.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}`;
document.cookie = `${COOKIEPREFIX}channelRootRoute=${GlobalConfig.channelRootRoute};path=/;domain=${DOMAIN}`;
document.cookie = `${COOKIEPREFIX}ichannelRootRoute=${GlobalConfig.ichannelRootRoute};path=/;domain=${DOMAIN}`;
document.cookie = `${COOKIEPREFIX}shopRootRoute=shop;path=/;domain=${DOMAIN}`;
window.open(CHATROOM_URL);
return;
}
......@@ -39,10 +46,16 @@ export const toChatRoom = (memberId: string = '', shopType: number = 1) => {
document.cookie = `${COOKIEPREFIX}curUserId=${_userId};path=/;domain=${DOMAIN}`;
document.cookie = `${COOKIEPREFIX}userToken=${_curUserInfo.token};path=/;domain=${DOMAIN}`;
document.cookie = `${COOKIEPREFIX}userMemberId=${_curUserInfo.memberId};path=/;domain=${DOMAIN}`;
document.cookie = `${COOKIEPREFIX}userMemberType=${_curUserInfo.memberType};path=/;domain=${DOMAIN}`;
document.cookie = `${COOKIEPREFIX}userUserId=${_curUserInfo.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}`;
document.cookie = `${COOKIEPREFIX}channelRootRoute=${GlobalConfig.channelRootRoute};path=/;domain=${DOMAIN}`;
document.cookie = `${COOKIEPREFIX}ichannelRootRoute=${GlobalConfig.ichannelRootRoute};path=/;domain=${DOMAIN}`;
document.cookie = `${COOKIEPREFIX}shopRootRoute=shop;path=/;domain=${DOMAIN}`;
window.open(CHATROOM_URL);
} else {
message.error('该会员底下没有客服!');
......@@ -59,7 +72,7 @@ interface NotificationChatRoomProps {
// 被动从websocket调起聊天室
export const notificationChatRoom = (props: NotificationChatRoomProps) => {
const { detail } = props
const _curUserInfo = getAuth();
const _curUserInfo: any = getAuth();
const close = () => {
console.log(
'Notification was closed. Either the close button was clicked or duration time elapsed.',
......@@ -70,10 +83,16 @@ export const notificationChatRoom = (props: NotificationChatRoomProps) => {
<Button type="primary" size="small" onClick={() => {
document.cookie = `${COOKIEPREFIX}userToken=${_curUserInfo.token};path=/;domain=${DOMAIN}`;
document.cookie = `${COOKIEPREFIX}userMemberId=${_curUserInfo.memberId};path=/;domain=${DOMAIN}`;
document.cookie = `${COOKIEPREFIX}userMemberType=${_curUserInfo.memberType};path=/;domain=${DOMAIN}`;
document.cookie = `${COOKIEPREFIX}userUserId=${_curUserInfo.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}`;
document.cookie = `${COOKIEPREFIX}channelRootRoute=${GlobalConfig.channelRootRoute};path=/;domain=${DOMAIN}`;
document.cookie = `${COOKIEPREFIX}ichannelRootRoute=${GlobalConfig.ichannelRootRoute};path=/;domain=${DOMAIN}`;
document.cookie = `${COOKIEPREFIX}shopRootRoute=shop;path=/;domain=${DOMAIN}`;
window.open(CHATROOM_URL);
notification.close(key)
}}>
......
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