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

feat: im拆分cookie,暂时固定传入memberId

parent 6e6fff31
......@@ -7,26 +7,40 @@ import { PublicApi } from '@/services/api';
import { SHOP_TYPE } from '@/constants';
import { getAuth } from '@/utils/auth';
const DOMAIN = {...BASE_CONFIG}.global.siteInfo.siteUrl.replace('www','');//document.domain
const CHATROOM_URL = `http://chatroom${DOMAIN}/chatRoom`;
const DOMAIN = '.lingxidev.com';//document.domain
// const DOMAIN = {...BASE_CONFIG}.global.siteInfo.siteUrl.replace('www','');//document.domain
const CHATROOM_URL = `http://im${DOMAIN}/chatRoom`;
const COOKIEPREFIX = 'CHATROOM_';
// 主动调起聊天室 mmeberId 为接收人的memberId
export const toChatRoom = (memberId: string = '', shopType: number = 1) => {
const _curUserInfo = getAuth();
if(!memberId){
document.cookie = `${COOKIEPREFIX}userInfo=${JSON.stringify(_curUserInfo)};path=/;domain=${DOMAIN}`;
let _curUserInfo = getAuth();
if (!memberId) {
document.cookie = `${COOKIEPREFIX}userToken=${_curUserInfo.token};path=/;domain=${DOMAIN}`;
document.cookie = `${COOKIEPREFIX}userMemberId=${_curUserInfo.memberId};path=/;domain=${DOMAIN}`;
document.cookie = `${COOKIEPREFIX}userUserId=${_curUserInfo.userId};path=/;domain=${DOMAIN}`;
document.cookie = `${COOKIEPREFIX}shopType=${shopType};path=/;domain=${DOMAIN}`;
window.open(CHATROOM_URL);
return;
}
PublicApi.getMessageImHistorySession({ memberId: memberId, currMemberId: String(_curUserInfo.memberId) }).then(res => {
PublicApi.getMessageImHistorySession({ memberId: 70 }).then(res => {
if (res.code === 1000) {
const _userId = res.data.data?.[0]?.userList?.[0]?.userId
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}curMemberId=${70};path=/;domain=${DOMAIN}`;
document.cookie = `${COOKIEPREFIX}curUserId=${_userId};path=/;domain=${DOMAIN}`;
document.cookie = `${COOKIEPREFIX}userInfo=${JSON.stringify(_curUserInfo)};path=/;domain=${DOMAIN}`;
document.cookie = `${COOKIEPREFIX}userToken=${_curUserInfo.token};path=/;domain=${DOMAIN}`;
document.cookie = `${COOKIEPREFIX}userMemberId=${_curUserInfo.memberId};path=/;domain=${DOMAIN}`;
document.cookie = `${COOKIEPREFIX}userUserId=${_curUserInfo.userId};path=/;domain=${DOMAIN}`;
document.cookie = `${COOKIEPREFIX}shopType=${shopType};path=/;domain=${DOMAIN}`;
window.open(CHATROOM_URL);
} else {
......@@ -53,7 +67,9 @@ export const notificationChatRoom = (props: NotificationChatRoomProps) => {
const key = `open${Date.now()}`;
const btn = (
<Button type="primary" size="small" onClick={() => {
document.cookie = `${COOKIEPREFIX}userInfo=${JSON.stringify(_curUserInfo)};path=/;domain=${DOMAIN}`;
document.cookie = `${COOKIEPREFIX}userToken=${_curUserInfo.token};path=/;domain=${DOMAIN}`;
document.cookie = `${COOKIEPREFIX}userMemberId=${_curUserInfo.memberId};path=/;domain=${DOMAIN}`;
document.cookie = `${COOKIEPREFIX}userUserId=${_curUserInfo.userId};path=/;domain=${DOMAIN}`;
document.cookie = `${COOKIEPREFIX}shopType=${shopType};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