Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fns_front_2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chenqikuai
fns_front_2
Commits
32e5791c
Commit
32e5791c
authored
Oct 14, 2021
by
chenqikuai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 那点击聊天的时候那怎么交互
parent
05e1ca51
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
5 deletions
+45
-5
App.vue
src/App.vue
+4
-4
index.ts
src/router/index.ts
+16
-1
index.ts
src/service/StaffService/index.ts
+8
-0
authCheck.ts
src/utils/authCheck.ts
+17
-0
No files found.
src/App.vue
View file @
32e5791c
...
...
@@ -18,13 +18,13 @@ import { getMasterIdFromDisplayMsg, getTargetIdFromDisplayMsg } from "./utils/ch
import
isChattingWith
from
"./utils/isChattingWith"
;
import
{
ChatMessageTypes
}
from
"@/types/chatMessageTypes"
import
{
chatCardTimeStamp
}
from
"./store/chatCardStore"
;
import
{
getVisitorId
}
from
"./utils/visitorId"
;
import
{
getUserMsg
}
from
"./utils/userMsg"
;
import
{
chatLoginActionMark
,
eLoginType
}
from
"./store/chatStore"
;
import
{
Toast
}
from
"vant"
;
import
router
from
"./router"
;
import
{
useRoute
}
from
"vue-router"
;
import
Bridge
from
'@/utils/jsBridge2'
import
{
chatAuthCheck
}
from
"./utils/authCheck"
;
export
default
defineComponent
({
...
...
@@ -69,7 +69,7 @@ export default defineComponent({
watch
(
chatLoginActionMark
,
(
newMark
)
=>
{
if
(
newMark
===
eLoginType
.
login
)
{
c
onnect
();
c
hatAuthCheck
(
connect
)
}
else
if
(
newMark
===
eLoginType
.
logout
)
{
connectionState
.
connection
?.
disconnect
();
}
...
...
@@ -100,13 +100,13 @@ export default defineComponent({
onMounted
(()
=>
{
if
(
getUserMsg
())
{
c
onnect
();
c
hatAuthCheck
(
connect
)
}
})
watch
(()
=>
connectionState
.
error
,
()
=>
{
if
(
connectionState
.
error
)
{
c
onnect
(
);
c
hatAuthCheck
(
connect
);
}
})
...
...
src/router/index.ts
View file @
32e5791c
import
{
eRole
}
from
'@/types/roleType'
import
{
chatAuthCheck
}
from
'@/utils/authCheck'
import
{
getUserMsg
}
from
'@/utils/userMsg'
import
{
Toast
}
from
'vant'
import
{
createRouter
,
createWebHistory
,
RouteRecordRaw
}
from
'vue-router'
const
routes
:
Array
<
RouteRecordRaw
>
=
[
...
...
@@ -36,7 +39,7 @@ const routes: Array<RouteRecordRaw> = [
path
:
'/chatList'
,
name
:
'ChatList'
,
meta
:
{
needAuth
:
true
needAuth
:
true
,
},
component
:
()
=>
import
(
...
...
@@ -233,7 +236,19 @@ router.beforeEach((to, from, next) => {
const
userMsg
=
getUserMsg
()
if
(
to
.
meta
.
needAuth
)
{
if
(
!!
userMsg
)
{
if
(
userMsg
.
role
===
eRole
.
user
)
next
()
else
if
(
userMsg
.
role
===
eRole
.
staff
)
{
if
(
to
.
name
===
'ChatList'
)
{
chatAuthCheck
(
()
=>
{
next
()
},
()
=>
{
Toast
(
'由于您现在是不在岗状态所以无法进入聊天!'
)
},
)
}
}
}
else
{
next
({
name
:
'Login'
})
}
...
...
src/service/StaffService/index.ts
0 → 100644
View file @
32e5791c
import
baseAxios
from
'../index'
export
function
getStaffOnDutyStatus
()
{
return
baseAxios
<
boolean
>
({
url
:
'/staff/on_duty'
,
method
:
'get'
,
})
}
src/utils/authCheck.ts
View file @
32e5791c
import
router
from
'@/router'
import
{
getStaffOnDutyStatus
}
from
'@/service/StaffService'
import
{
eRole
}
from
'@/types/roleType'
import
{
getUserMsg
}
from
'./userMsg'
export
function
authCheck
(
cb
:
Function
)
{
...
...
@@ -9,3 +11,18 @@ export function authCheck(cb: Function) {
})
}
}
export
async
function
chatAuthCheck
(
cb
:
Function
,
cb2
?:
Function
)
{
const
msg
=
getUserMsg
()
if
(
msg
?.
role
===
eRole
.
user
)
return
true
else
if
(
msg
?.
role
===
eRole
.
staff
)
{
const
ret
=
await
getStaffOnDutyStatus
()
if
(
ret
.
code
===
200
&&
ret
.
data
)
{
cb
()
}
else
{
cb2
&&
cb2
()
}
}
else
{
cb2
&&
cb2
()
}
}
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