Commit 32e5791c authored by chenqikuai's avatar chenqikuai

fix: 那点击聊天的时候那怎么交互

parent 05e1ca51
......@@ -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) {
connect();
chatAuthCheck(connect)
} else if (newMark === eLoginType.logout) {
connectionState.connection?.disconnect();
}
......@@ -100,13 +100,13 @@ export default defineComponent({
onMounted(() => {
if (getUserMsg()) {
connect();
chatAuthCheck(connect)
}
})
watch(() => connectionState.error, () => {
if (connectionState.error) {
connect();
chatAuthCheck(connect);
}
})
......
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) {
next()
if (userMsg.role === eRole.user) next()
else if (userMsg.role === eRole.staff) {
if (to.name === 'ChatList') {
chatAuthCheck(
() => {
next()
},
() => {
Toast('由于您现在是不在岗状态所以无法进入聊天!')
},
)
}
}
} else {
next({ name: 'Login' })
}
......
import baseAxios from '../index'
export function getStaffOnDutyStatus() {
return baseAxios<boolean>({
url: '/staff/on_duty',
method: 'get',
})
}
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()
}
}
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