Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
jinfa-platform
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
黄庭坚
jinfa-platform
Commits
c67617c4
Commit
c67617c4
authored
Jun 25, 2021
by
卢均锐
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: im拆分cookie,暂时固定传入memberId
parent
6e6fff31
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
10 deletions
+26
-10
im.tsx
src/utils/im.tsx
+26
-10
No files found.
src/utils/im.tsx
View file @
c67617c4
...
...
@@ -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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment