Commit 7305f4b7 authored by chenqikuai's avatar chenqikuai

refactor: 通过role2判断角色,将管理员从原先的用户中区分出来。因为管理员可以聊天了。

原先通过role来判断角色,user包含客户和管理员,staff包含客户经理。现在由于管理员的功能等同于客户经理,所以通过角色分割更加明晰的role2来判断。role2中user是客户,staff是客户经理,manager是管理员
parent 43bb188f
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<div class="flex chatlistitem relative -mr-1"> <div class="flex chatlistitem relative -mr-1">
<div class="self-center mr-4 flex-shrink-0"> <div class="self-center mr-4 flex-shrink-0">
<img <img
v-if="userType === eRole.staff" v-if="userType !== eRole.user"
class="w-10 h-10 rounded-md object-cover" class="w-10 h-10 rounded-md object-cover"
src="@/assets/icons/avatar.png" src="@/assets/icons/avatar.png"
alt="avatar" alt="avatar"
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
<img <img
v-else-if="isRobootCard" v-else-if="isRobootCard"
class="w-10 h-10 rounded-md object-contain" class="w-10 h-10 rounded-md object-contain"
:class="{'filterGray': isDeleted}" :class="{ filterGray: isDeleted }"
src="@/assets/img/roboot.png" src="@/assets/img/roboot.png"
alt="avatar" alt="avatar"
/> />
...@@ -24,20 +24,44 @@ ...@@ -24,20 +24,44 @@
<div class="flex-grow right-box overflow-hidden pr-1"> <div class="flex-grow right-box overflow-hidden pr-1">
<div class="flex justify-between mt-5"> <div class="flex justify-between mt-5">
<div <div
class="id whitespace-nowrap overflow-hidden overflow-ellipsis flex-grow flex-shrink" class="
>{{ displayName }}</div> id
whitespace-nowrap
overflow-hidden overflow-ellipsis
flex-grow flex-shrink
"
>
{{ displayName }}
</div>
<div <div
class="txt whitespace-nowrap overflow-hidden overflow-ellipsis flex-shrink-0" class="
>{{ datetime && timestampFormat2(datetime) }}</div> txt
whitespace-nowrap
overflow-hidden overflow-ellipsis
flex-shrink-0
"
>
{{ datetime && timestampFormat2(datetime) }}
</div>
</div> </div>
<div class="flex justify-between mb-5 mt-1"> <div class="flex justify-between mb-5 mt-1">
<div <div class="overflow-hidden overflow-ellipsis whitespace-nowrap txt">
class="overflow-hidden overflow-ellipsis whitespace-nowrap txt" {{ latest_msg_content }}
>{{ latest_msg_content }}</div> </div>
<div <div
v-if="unReadMsgNum" v-if="unReadMsgNum"
class="dot flex items-center justify-center rounded-full flex-shrink-0 flex-grow-0 px-1" class="
>{{ unReadMsgNum }}</div> dot
flex
items-center
justify-center
rounded-full
flex-shrink-0 flex-grow-0
px-1
"
>
{{ unReadMsgNum }}
</div>
</div> </div>
</div> </div>
</div> </div>
...@@ -48,28 +72,27 @@ import { timestampFormat2 } from "@/utils/time"; ...@@ -48,28 +72,27 @@ import { timestampFormat2 } from "@/utils/time";
import { PropType } from "@vue/runtime-core"; import { PropType } from "@vue/runtime-core";
const props = defineProps({ const props = defineProps({
avatar_url: { type: String, default: '--' }, avatar_url: { type: String, default: "--" },
id: { type: String, default: '--' }, id: { type: String, default: "--" },
latest_msg_content: { type: String, default: '--' }, latest_msg_content: { type: String, default: "--" },
unReadMsgNum: { unReadMsgNum: {
type: Number, type: Number,
default: 10 default: 10,
}, },
displayName: String, displayName: String,
datetime: { datetime: {
type: Number, type: Number,
}, },
userType: { userType: {
type: Number as PropType<eRole> type: Number as PropType<eRole>,
}, },
isRobootCard: { isRobootCard: {
type: Boolean type: Boolean,
}, },
isDeleted: { isDeleted: {
type: Boolean type: Boolean,
} },
}) });
</script> </script>
<style lang="less"> <style lang="less">
.chatlistitem { .chatlistitem {
......
import { DisplayMessage } from '@/store/messagesStore' import { DisplayMessage } from "@/store/messagesStore";
import { ChatMessageTypes } from '@/types/chatMessageTypes' import { ChatMessageTypes } from "@/types/chatMessageTypes";
import { eRole } from '@/types/roleType' import { eRole } from "@/types/roleType";
import ChatDataService from '@/utils/ChatDataService' import ChatDataService from "@/utils/ChatDataService";
import { import {
getMasterIdFromDisplayMsg, getMasterIdFromDisplayMsg,
getTargetIdFromDisplayMsg, getTargetIdFromDisplayMsg,
} from '@/utils/chatutils' } from "@/utils/chatutils";
import { getUserMsg } from '@/utils/userMsg' import { getUserMsg } from "@/utils/userMsg";
import { iChatListCard, MyAppDatabase } from './index' import { iChatListCard, MyAppDatabase } from "./index";
export default class ChatListCardDB extends MyAppDatabase { export default class ChatListCardDB extends MyAppDatabase {
static instance: ChatListCardDB static instance: ChatListCardDB;
static getInstance() { static getInstance() {
if (!ChatListCardDB.instance) { if (!ChatListCardDB.instance) {
ChatListCardDB.instance = new ChatListCardDB() ChatListCardDB.instance = new ChatListCardDB();
} }
return ChatListCardDB.instance return ChatListCardDB.instance;
} }
saveCard(item: iChatListCard) { saveCard(item: iChatListCard) {
return this.chatListCard.add({ ...item }) return this.chatListCard.add({ ...item });
} }
deleteCard(masterId: string, targetId: string) { deleteCard(masterId: string, targetId: string) {
return this.chatListCard return this.chatListCard
.filter((item) => { .filter((item) => {
return item.masterId === masterId && targetId === item.targetId return item.masterId === masterId && targetId === item.targetId;
}) })
.delete() .delete();
} }
updateCard( updateCard(
...@@ -39,20 +39,22 @@ export default class ChatListCardDB extends MyAppDatabase { ...@@ -39,20 +39,22 @@ export default class ChatListCardDB extends MyAppDatabase {
) { ) {
this.chatListCard this.chatListCard
.filter((item) => { .filter((item) => {
return item.masterId === masterId && targetId === item.targetId return item.masterId === masterId && targetId === item.targetId;
}) })
.modify((item) => { .modify((item) => {
item.unreadMsgCount = count item.unreadMsgCount = count;
item.content = content item.content = content;
item.datetime = datetime item.datetime = datetime;
}) });
} }
getCardList(masterId: string) { getCardList(masterId: string) {
return this.chatListCard return this.chatListCard
.filter((item) => { .filter((item) => {
return item.masterId === masterId return item.masterId === masterId;
}).reverse().sortBy('datetime') })
.reverse()
.sortBy("datetime");
} }
async thePersonAlreadyInChatList(masterId: string, personId: string) { async thePersonAlreadyInChatList(masterId: string, personId: string) {
...@@ -60,38 +62,37 @@ export default class ChatListCardDB extends MyAppDatabase { ...@@ -60,38 +62,37 @@ export default class ChatListCardDB extends MyAppDatabase {
(await this.chatListCard (await this.chatListCard
.filter((i) => i.targetId === personId && i.masterId === masterId) .filter((i) => i.targetId === personId && i.masterId === masterId)
.count()) !== 0 .count()) !== 0
) );
} }
async updateNewestCard(data: { async updateNewestCard(data: {
msg: DisplayMessage msg: DisplayMessage;
isChattingWithTargetId: boolean isChattingWithTargetId: boolean;
}) { }) {
const { msg, isChattingWithTargetId } = data const { msg, isChattingWithTargetId } = data;
const targetId = getTargetIdFromDisplayMsg(msg) const targetId = getTargetIdFromDisplayMsg(msg);
const masterId = getMasterIdFromDisplayMsg(msg) const masterId = getMasterIdFromDisplayMsg(msg);
const cardItem = await this.chatListCard const cardItem = await this.chatListCard
.filter((item) => { .filter((item) => {
return item.masterId === masterId && item.targetId === targetId return item.masterId === masterId && item.targetId === targetId;
}) })
.first() .first();
let content: string let content: string;
if (msg.type === ChatMessageTypes.Card) { if (msg.type === ChatMessageTypes.Card) {
content = content =
ChatDataService.getInstance().extractCommonMsgContentFromMsg( ChatDataService.getInstance().extractCommonMsgContentFromMsg(
msg, msg,
getUserMsg()?.role as eRole, getUserMsg()?.role2 as eRole
) || '' ) || "";
} else { } else {
content = msg.content?.content || '[新消息]' content = msg.content?.content || "[新消息]";
} }
const unreadMsgCount = cardItem?.unreadMsgCount || 0 const unreadMsgCount = cardItem?.unreadMsgCount || 0;
console.log(data.msg, 'show msg when update newest card');
console.log(data.msg, "show msg when update newest card");
this.updateCard( this.updateCard(
masterId, masterId,
...@@ -99,18 +100,18 @@ export default class ChatListCardDB extends MyAppDatabase { ...@@ -99,18 +100,18 @@ export default class ChatListCardDB extends MyAppDatabase {
isChattingWithTargetId ? 0 : unreadMsgCount + 1, isChattingWithTargetId ? 0 : unreadMsgCount + 1,
content, content,
data.msg.datetime data.msg.datetime
) );
} }
async addNewCard(data: { async addNewCard(data: {
msg: DisplayMessage msg: DisplayMessage;
isChattingWithTargetId: boolean, isChattingWithTargetId: boolean;
isRobootCard?: boolean isRobootCard?: boolean;
}) { }) {
const content = data.msg.content?.content || '[新消息]' const content = data.msg.content?.content || "[新消息]";
const masterId = getMasterIdFromDisplayMsg(data.msg) const masterId = getMasterIdFromDisplayMsg(data.msg);
const targetId = getTargetIdFromDisplayMsg(data.msg) const targetId = getTargetIdFromDisplayMsg(data.msg);
console.log(data.msg, 'in addNewCard') console.log(data.msg, "in addNewCard");
this.saveCard({ this.saveCard({
masterId, masterId,
...@@ -120,36 +121,36 @@ export default class ChatListCardDB extends MyAppDatabase { ...@@ -120,36 +121,36 @@ export default class ChatListCardDB extends MyAppDatabase {
inChat: false, inChat: false,
datetime: data.msg.datetime, datetime: data.msg.datetime,
isRobootCard: data.isRobootCard, isRobootCard: data.isRobootCard,
}) });
} }
readMsg(masterId: string, targetId: string) { readMsg(masterId: string, targetId: string) {
return this.chatListCard return this.chatListCard
.filter((item) => { .filter((item) => {
return item.targetId === targetId && item.masterId === masterId return item.targetId === targetId && item.masterId === masterId;
}) })
.modify((item) => { .modify((item) => {
item.unreadMsgCount = 0 item.unreadMsgCount = 0;
}) });
} }
setChatStatus(masterId: string, targetId: string, isChat: boolean) { setChatStatus(masterId: string, targetId: string, isChat: boolean) {
return this.chatListCard return this.chatListCard
.filter((item) => { .filter((item) => {
return item.targetId === targetId && item.masterId === masterId return item.targetId === targetId && item.masterId === masterId;
}) })
.modify((item) => { .modify((item) => {
item.inChat = isChat item.inChat = isChat;
}) });
} }
async getChatStatus(masterId: string, targetId: string) { async getChatStatus(masterId: string, targetId: string) {
const ret = await this.chatListCard const ret = await this.chatListCard
.filter((item) => { .filter((item) => {
return item.targetId === targetId && item.masterId === masterId return item.targetId === targetId && item.masterId === masterId;
}) })
.first() .first();
return ret?.inChat return ret?.inChat;
} }
} }
...@@ -257,8 +257,11 @@ router.beforeEach((to, from, next) => { ...@@ -257,8 +257,11 @@ router.beforeEach((to, from, next) => {
const userMsg = getUserMsg(); const userMsg = getUserMsg();
if (to.meta.needAuth) { if (to.meta.needAuth) {
if (!!userMsg) { if (!!userMsg) {
if (userMsg.role === eRole.user) next(); if (userMsg.role2 === eRole.user) next();
else if (userMsg.role === eRole.staff) { else if (
userMsg.role2 === eRole.staff ||
userMsg.role2 === eRole.manager
) {
if (to.name === "ChatList") { if (to.name === "ChatList") {
chatAuthCheck( chatAuthCheck(
() => { () => {
......
import router from '@/router' import router from "@/router";
import { getStaffOnDutyStatus } from '@/service/StaffService' import { getStaffOnDutyStatus } from "@/service/StaffService";
import { eRole } from '@/types/roleType' import { eRole } from "@/types/roleType";
import { getUserMsg } from './userMsg' import { getUserMsg } from "./userMsg";
export function authCheck(cb: Function) { export function authCheck(cb: Function) {
if (getUserMsg()) cb() if (getUserMsg()) cb();
else { else {
router.push({ router.push({
name: 'Login', name: "Login",
}) });
} }
} }
...@@ -18,17 +18,15 @@ export function authCheck(cb: Function) { ...@@ -18,17 +18,15 @@ export function authCheck(cb: Function) {
* @param cb2 没有权限时回调 什么时候没有权限?本地无token,用户在其他地方登录,不在岗或被禁用了 * @param cb2 没有权限时回调 什么时候没有权限?本地无token,用户在其他地方登录,不在岗或被禁用了
*/ */
export async function chatAuthCheck(cb: Function, cb2?: Function) { export async function chatAuthCheck(cb: Function, cb2?: Function) {
const msg = getUserMsg() const msg = getUserMsg();
if (msg?.role === eRole.user) { if (msg?.role2 === eRole.user) {
cb() cb();
} else if (msg?.role === eRole.staff) { } else {
const ret = await getStaffOnDutyStatus() const ret = await getStaffOnDutyStatus();
if (ret.code === 200 && ret.data) { if (ret.code === 200 && ret.data) {
cb() cb();
} else { } else {
cb2 && cb2(ret.data) cb2 && cb2(ret.data);
} }
} else {
cb2 && cb2()
} }
} }
...@@ -16,13 +16,13 @@ export const getDisplayNamesFromAddress = async ( ...@@ -16,13 +16,13 @@ export const getDisplayNamesFromAddress = async (
let foundList = [] as any[]; let foundList = [] as any[];
let notFoundList = [] as any[]; let notFoundList = [] as any[];
if (user?.role === eRole.user) { if (user?.role2 === eRole.user) {
const ret = await ContactPersonService.getInstance().findByList( const ret = await ContactPersonService.getInstance().findByList(
addressList addressList
); );
foundList = ret.foundList; foundList = ret.foundList;
notFoundList = ret.notFoundList; notFoundList = ret.notFoundList;
} else if (user?.role === eRole.staff) { } else if (user?.role2 === eRole.staff || user?.role2 === eRole.manager) {
const ret = await UserInfoDBService.getInstance().findByList(addressList); const ret = await UserInfoDBService.getInstance().findByList(addressList);
foundList = ret.foundList; foundList = ret.foundList;
notFoundList = ret.notFoundList; notFoundList = ret.notFoundList;
...@@ -31,7 +31,7 @@ export const getDisplayNamesFromAddress = async ( ...@@ -31,7 +31,7 @@ export const getDisplayNamesFromAddress = async (
const fullList = foundList as unknown as any; const fullList = foundList as unknown as any;
if (notFoundList.length !== 0) { if (notFoundList.length !== 0) {
if (user?.role === eRole.user) { if (user?.role2 === eRole.user) {
const ret = await UserService.getInstance().staffInfo({ const ret = await UserService.getInstance().staffInfo({
addrs: notFoundList, addrs: notFoundList,
}); });
...@@ -40,7 +40,7 @@ export const getDisplayNamesFromAddress = async ( ...@@ -40,7 +40,7 @@ export const getDisplayNamesFromAddress = async (
ContactPersonService.getInstance().save(theoseNotFoundList); ContactPersonService.getInstance().save(theoseNotFoundList);
fullList.push(...theoseNotFoundList); fullList.push(...theoseNotFoundList);
} }
} else if (user?.role === eRole.staff) { } else if (user?.role2 === eRole.staff || user?.role2 === eRole.manager) {
const ret = await UserService.getInstance().userInfo({ const ret = await UserService.getInstance().userInfo({
addrs: notFoundList, addrs: notFoundList,
}); });
...@@ -126,13 +126,13 @@ export const getMsgFromAddress = async ( ...@@ -126,13 +126,13 @@ export const getMsgFromAddress = async (
let foundList = [] as any[]; let foundList = [] as any[];
let notFoundList = [] as any[]; let notFoundList = [] as any[];
if (user?.role === eRole.user) { if (user?.role2 === eRole.user) {
const ret = await ContactPersonService.getInstance().findByList( const ret = await ContactPersonService.getInstance().findByList(
addressList addressList
); );
foundList = ret.foundList; foundList = ret.foundList;
notFoundList = ret.notFoundList; notFoundList = ret.notFoundList;
} else if (user?.role === eRole.staff) { } else if (user?.role2 === eRole.staff || user?.role2 === eRole.manager) {
const ret = await UserInfoDBService.getInstance().findByList(addressList); const ret = await UserInfoDBService.getInstance().findByList(addressList);
foundList = ret.foundList; foundList = ret.foundList;
notFoundList = ret.notFoundList; notFoundList = ret.notFoundList;
...@@ -141,7 +141,7 @@ export const getMsgFromAddress = async ( ...@@ -141,7 +141,7 @@ export const getMsgFromAddress = async (
const fullList = foundList as unknown as any; const fullList = foundList as unknown as any;
if (notFoundList.length !== 0) { if (notFoundList.length !== 0) {
if (user?.role === eRole.user) { if (user?.role2 === eRole.user) {
const ret = await UserService.getInstance().staffInfo({ const ret = await UserService.getInstance().staffInfo({
addrs: notFoundList, addrs: notFoundList,
}); });
...@@ -150,7 +150,7 @@ export const getMsgFromAddress = async ( ...@@ -150,7 +150,7 @@ export const getMsgFromAddress = async (
ContactPersonService.getInstance().save(theoseNotFoundList); ContactPersonService.getInstance().save(theoseNotFoundList);
fullList.push(...theoseNotFoundList); fullList.push(...theoseNotFoundList);
} }
} else if (user?.role === eRole.staff) { } else if (user?.role2 === eRole.staff || user?.role2 === eRole.manager) {
const ret = await UserService.getInstance().userInfo({ const ret = await UserService.getInstance().userInfo({
addrs: notFoundList, addrs: notFoundList,
}); });
......
import Bridge from '@/utils/jsBridge2' import Bridge from "@/utils/jsBridge2";
import { Toast } from 'vant' import { Toast } from "vant";
import { enableLive } from '@/service/StaffService/index' import { enableLive } from "@/service/StaffService/index";
import { getCurrentUserAvatarUrl, getUserMsg } from './userMsg' import { getCurrentUserAvatarUrl, getUserMsg } from "./userMsg";
import { eRole } from '@/types/roleType' import { eRole } from "@/types/roleType";
export const sendLive = () => { export const sendLive = () => {
const avatarUrl = getCurrentUserAvatarUrl() const avatarUrl = getCurrentUserAvatarUrl();
const finalAvatarUrl = const finalAvatarUrl =
window.location.protocol + '//' + window.location.host + avatarUrl window.location.protocol + "//" + window.location.host + avatarUrl;
const USER_MSG = window.localStorage.getItem('USER_MSG') const USER_MSG = window.localStorage.getItem("USER_MSG");
let allow = false let allow = false;
let time_section = '' let time_section = "";
if (!USER_MSG) { if (!USER_MSG) {
Toast('请先登录') Toast("请先登录");
return return;
} else if (getUserMsg()?.role === eRole.user) { } else if (getUserMsg()?.role2 === eRole.user) {
new Bridge().bridge_live({ new Bridge().bridge_live({
phone: JSON.parse(window.localStorage.getItem('USER_MSG') as string) phone: JSON.parse(window.localStorage.getItem("USER_MSG") as string)
?.userInfo.phone, ?.userInfo.phone,
avatar: finalAvatarUrl, avatar: finalAvatarUrl,
allow, allow,
time_section, time_section,
}) });
return return;
} }
enableLive() enableLive()
.then((res) => { .then((res) => {
if (res.code === 200) { if (res.code === 200) {
allow = res.data.allow allow = res.data.allow;
time_section = res.data.time_section time_section = res.data.time_section;
} }
new Bridge().bridge_live({ new Bridge().bridge_live({
phone: JSON.parse(window.localStorage.getItem('USER_MSG') as string) phone: JSON.parse(window.localStorage.getItem("USER_MSG") as string)
?.userInfo.phone, ?.userInfo.phone,
avatar: finalAvatarUrl, avatar: finalAvatarUrl,
allow, allow,
time_section, time_section,
}) });
}) })
.catch(() => { .catch(() => {
new Bridge().bridge_live({ new Bridge().bridge_live({
phone: JSON.parse(window.localStorage.getItem('USER_MSG') as string) phone: JSON.parse(window.localStorage.getItem("USER_MSG") as string)
?.userInfo.phone, ?.userInfo.phone,
avatar: finalAvatarUrl, avatar: finalAvatarUrl,
allow, allow,
time_section, time_section,
}) });
}) });
} };
...@@ -31,9 +31,12 @@ export function deleteUserMsg() { ...@@ -31,9 +31,12 @@ export function deleteUserMsg() {
} }
export function getCurrentUserAvatarUrl() { export function getCurrentUserAvatarUrl() {
if (getUserMsg()?.role === eRole.staff) { if (
getUserMsg()?.role2 === eRole.staff ||
getUserMsg()?.role2 === eRole.manager
) {
return staffAvatarUrl; return staffAvatarUrl;
} else if (getUserMsg()?.role === eRole.user) { } else if (getUserMsg()?.role2 === eRole.user) {
return userAvatarUrl; return userAvatarUrl;
} else { } else {
return userAvatarUrl; return userAvatarUrl;
......
...@@ -369,7 +369,7 @@ export default defineComponent({ ...@@ -369,7 +369,7 @@ export default defineComponent({
const callPhone = ref(""); const callPhone = ref("");
const isUser = computed(() => { const isUser = computed(() => {
return getUserMsg()?.role === eRole.user; return getUserMsg()?.role2 === eRole.user;
}); });
return { return {
......
<template> <template>
<div> <div>
<div v-if="!hideDatetime" class="text-xs text-gray-400 text-center pb-2 pt-4">{{ time }}</div> <div
v-if="!hideDatetime"
class="text-xs text-gray-400 text-center pb-2 pt-4"
>
{{ time }}
</div>
<!-- 卡片消息 --> <!-- 卡片消息 -->
<ChatContentMessageCardVue v-if="type === 6" :from-myself="fromMyself" :content="content"></ChatContentMessageCardVue> <ChatContentMessageCardVue
v-if="type === 6"
:from-myself="fromMyself"
:content="content"
></ChatContentMessageCardVue>
<div <div
class="flex items-start flex-nowrap w-screen py-1.5" class="flex items-start flex-nowrap w-screen py-1.5"
:class="{ 'flex-row-reverse': fromMyself }" :class="{ 'flex-row-reverse': fromMyself }"
> >
<!-- 头像 --> <!-- 头像 -->
<q-avatar class="mx-4 min-w-chat-msg-avatar !rounded-md !w-10 !h-10" v-if="type !== 6"> <q-avatar
<img v-if="fromMyself && userType === eRole.user" :src="userAvatarUrl" /> class="mx-4 min-w-chat-msg-avatar !rounded-md !w-10 !h-10"
v-if="type !== 6"
>
<img
v-if="fromMyself && userType === eRole.user"
:src="userAvatarUrl"
/>
<img <img
v-if="fromMyself && userType === eRole.staff" v-if="fromMyself && userType !== eRole.user"
:src="staffAvatarUrl" :src="staffAvatarUrl"
class="object-contain" class="object-contain"
/> />
...@@ -26,7 +41,10 @@ ...@@ -26,7 +41,10 @@
class="object-contain" class="object-contain"
:class="{ filterGray: isRobootOffLine }" :class="{ filterGray: isRobootOffLine }"
/> />
<img v-else-if="!fromMyself && userType === eRole.staff" :src="userAvatarUrl" /> <img
v-else-if="!fromMyself && userType !== eRole.user"
:src="userAvatarUrl"
/>
</q-avatar> </q-avatar>
<!-- 消息气泡 --> <!-- 消息气泡 -->
...@@ -49,7 +67,10 @@ ...@@ -49,7 +67,10 @@
> >
<template #reference> <template #reference>
<!-- 文本消息 --> <!-- 文本消息 -->
<ChatContentMessageTextVue :from-myself="fromMyself" :content="content" /> <ChatContentMessageTextVue
:from-myself="fromMyself"
:content="content"
/>
</template> </template>
</van-popover> </van-popover>
</div> </div>
...@@ -73,7 +94,9 @@ ...@@ -73,7 +94,9 @@
/>--> />-->
<!-- 消息状态 --> <!-- 消息状态 -->
<div class="w-10 self-stretch flex flex-row justify-center items-center"> <div
class="w-10 self-stretch flex flex-row justify-center items-center"
>
<!-- 发送失败 --> <!-- 发送失败 -->
<div <div
v-if="state === 'failure'" v-if="state === 'failure'"
...@@ -109,13 +132,13 @@ import default_avatar_url from "@/assets/user_avatar.png"; ...@@ -109,13 +132,13 @@ import default_avatar_url from "@/assets/user_avatar.png";
import { messageStore } from "@/store/messagesStore"; import { messageStore } from "@/store/messagesStore";
import ChatContentMessageTextVue from "./ChatContentMessageText.vue"; import ChatContentMessageTextVue from "./ChatContentMessageText.vue";
import ChatContentMessageCardVue from "./ChatContentMessageCard.vue"; import ChatContentMessageCardVue from "./ChatContentMessageCard.vue";
import userAvatarUrl from "@/assets/icons/avatar.png" import userAvatarUrl from "@/assets/icons/avatar.png";
import staffAvatarUrl from "@/assets/icons/staff.png"; import staffAvatarUrl from "@/assets/icons/staff.png";
// import ChatContentMessageImageVue from "./ChatContentMessageImage.vue"; // import ChatContentMessageImageVue from "./ChatContentMessageImage.vue";
import { ChatMessageTypes } from "@/types/chatMessageTypes"; import { ChatMessageTypes } from "@/types/chatMessageTypes";
// import ChatContentMessageVideoVue from "./ChatContentMessageVideo.vue"; // import ChatContentMessageVideoVue from "./ChatContentMessageVideo.vue";
import { target } from "@/store/appCallerStore"; import { target } from "@/store/appCallerStore";
import { copyToClipboard } from 'quasar' import { copyToClipboard } from "quasar";
import { Toast } from "vant"; import { Toast } from "vant";
import ChatMessageDB from "@/db/ChatMessageDB"; import ChatMessageDB from "@/db/ChatMessageDB";
import { useRoute } from "vue-router"; import { useRoute } from "vue-router";
...@@ -123,7 +146,6 @@ import { clipboardValue } from "@/store/AppStore"; ...@@ -123,7 +146,6 @@ import { clipboardValue } from "@/store/AppStore";
import { getUserMsg } from "@/utils/userMsg"; import { getUserMsg } from "@/utils/userMsg";
import { eRole } from "@/types/roleType"; import { eRole } from "@/types/roleType";
export default defineComponent({ export default defineComponent({
components: { components: {
ChatContentMessageTextVue, ChatContentMessageTextVue,
...@@ -141,19 +163,23 @@ export default defineComponent({ ...@@ -141,19 +163,23 @@ export default defineComponent({
uuid: { type: String, required: true }, uuid: { type: String, required: true },
hideDatetime: Boolean, hideDatetime: Boolean,
uploadProgress: Object, uploadProgress: Object,
logid: { type: String, required: false, }, logid: { type: String, required: false },
isRobootOffLine: { type: Boolean, required: false } isRobootOffLine: { type: Boolean, required: false },
}, },
setup(props) { setup(props) {
const route = useRoute();
const route = useRoute()
/** 重发消息 */ /** 重发消息 */
const resend = () => { const resend = () => {
messageStore.sendMessage({ type: props.type, content: props.content, uuid: props.uuid, target: route.query.targetId as string }); messageStore.sendMessage({
type: props.type,
content: props.content,
uuid: props.uuid,
target: route.query.targetId as string,
});
}; };
const userType = getUserMsg()?.role const userType = getUserMsg()?.role2;
const abort = () => { const abort = () => {
messageStore.abortSendingMessage( messageStore.abortSendingMessage(
...@@ -169,45 +195,54 @@ export default defineComponent({ ...@@ -169,45 +195,54 @@ export default defineComponent({
); );
}); });
const textMsgActions = [ const textMsgActions = [
{ {
text: '删除', cb(data: { content: any, uuid: string, logid?: string, }) { text: "删除",
ChatMessageDB.getInstance().deleteMsg({ uuid: data.uuid, logid: data.logid }); cb(data: { content: any; uuid: string; logid?: string }) {
const index = messageStore.messages.findIndex(i => { ChatMessageDB.getInstance().deleteMsg({
return i.uuid === data.uuid uuid: data.uuid,
}) logid: data.logid,
});
const index = messageStore.messages.findIndex((i) => {
return i.uuid === data.uuid;
});
messageStore.appendingNewMessage.value = false; messageStore.appendingNewMessage.value = false;
messageStore.messages.splice(index, 1); messageStore.messages.splice(index, 1);
} },
}, },
{ {
text: '复制', cb(data: { content: any, uuid: string, logid: string }) { text: "复制",
cb(data: { content: any; uuid: string; logid: string }) {
clipboardValue.value = data.content.content; clipboardValue.value = data.content.content;
} },
} },
] ];
const onTextMsgSelect = (action: typeof textMsgActions[0]) => { const onTextMsgSelect = (action: typeof textMsgActions[0]) => {
action.cb({ action.cb({
content: props.content, content: props.content,
uuid: props.uuid, uuid: props.uuid,
logid: props.logid logid: props.logid,
}) });
}; };
const showPopOver = ref(false); const showPopOver = ref(false);
const handleTouchHoldItem = () => { const handleTouchHoldItem = () => {
showPopOver.value = true; showPopOver.value = true;
} };
const clickItem = () => { const clickItem = () => {
showPopOver.value = false; showPopOver.value = false;
} };
const isRoboot = computed(() => { const isRoboot = computed(() => {
return route.query.outlet return route.query.outlet;
}) });
return { return {
default_avatar_url, resend, isMedia, abort, ChatMessageTypes, handleTouchHoldItem, default_avatar_url,
resend,
isMedia,
abort,
ChatMessageTypes,
handleTouchHoldItem,
onTextMsgSelect, onTextMsgSelect,
textMsgActions, textMsgActions,
showPopOver, showPopOver,
...@@ -216,11 +251,10 @@ export default defineComponent({ ...@@ -216,11 +251,10 @@ export default defineComponent({
userType, userType,
userAvatarUrl, userAvatarUrl,
staffAvatarUrl, staffAvatarUrl,
isRoboot isRoboot,
}; };
}, },
}); });
</script> </script>
<style scoped> <style scoped>
.message_ { .message_ {
......
...@@ -8,25 +8,26 @@ ...@@ -8,25 +8,26 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import { defineComponent, PropType } from 'vue' import { defineComponent, PropType } from "vue";
import iconUrl from '@/assets/message_bank_card.png' import iconUrl from "@/assets/message_bank_card.png";
import { getUserMsg } from '@/utils/userMsg' import { getUserMsg } from "@/utils/userMsg";
import { eRole } from '@/types/roleType' import { eRole } from "@/types/roleType";
import { CHAT_CONST_LIST } from '@/config/chat' import { CHAT_CONST_LIST } from "@/config/chat";
export default defineComponent({ export default defineComponent({
props: { props: {
fromMyself: Boolean, fromMyself: Boolean,
content: { content: {
required: true, required: true,
type: Object as PropType<{ bank: string, name: string, account: string }>, type: Object as PropType<{ bank: string; name: string; account: string }>,
} },
}, },
setup(props) { setup(props) {
const isUser = getUserMsg()?.role === eRole.user const isUser = getUserMsg()?.role2 === eRole.user;
const sentence = CHAT_CONST_LIST.find(i => i.user.id === props?.content.bank) const sentence = CHAT_CONST_LIST.find(
return { iconUrl, isUser, sentence, CHAT_CONST_LIST } (i) => i.user.id === props?.content.bank
);
return { iconUrl, isUser, sentence, CHAT_CONST_LIST };
}, },
}) });
</script> </script>
...@@ -138,8 +138,7 @@ export default defineComponent({ ...@@ -138,8 +138,7 @@ export default defineComponent({
const handleSend = () => { const handleSend = () => {
console.log("handle send"); console.log("handle send");
const isStaff = getUserMsg()?.role === eRole.staff; const isUser = getUserMsg()?.role2 === eRole.user;
const isUser = getUserMsg()?.role === eRole.user;
if (isUser && route.query.outlet !== undefined) { if (isUser && route.query.outlet !== undefined) {
/* 当前角色是客户, /* 当前角色是客户,
......
...@@ -56,9 +56,7 @@ ...@@ -56,9 +56,7 @@
<div v-if="userType === eRole.user" class="tip"> <div v-if="userType === eRole.user" class="tip">
咨询客户经理后,可以在这里快捷查看消息哦! 咨询客户经理后,可以在这里快捷查看消息哦!
</div> </div>
<div v-else-if="userType === eRole.staff" class="tip"> <div v-else class="tip">客户咨询后,可以在这里快捷查看消息哦!</div>
客户咨询后,可以在这里快捷查看消息哦!
</div>
</div> </div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
...@@ -123,15 +121,15 @@ watch(chatCardTimeStamp, async () => { ...@@ -123,15 +121,15 @@ watch(chatCardTimeStamp, async () => {
}); });
const navBarTitle = computed(() => { const navBarTitle = computed(() => {
if (getUserMsg()?.role === eRole.user) { if (getUserMsg()?.role2 === eRole.user) {
return "我的客户经理"; return "我的客户经理";
} else if (getUserMsg()?.role === eRole.staff) { } else {
return "我的客户"; return "我的客户";
} }
}); });
const userType = computed(() => { const userType = computed(() => {
return getUserMsg()?.role; return getUserMsg()?.role2;
}); });
const actions = [ const actions = [
......
...@@ -115,15 +115,12 @@ export default defineComponent({ ...@@ -115,15 +115,12 @@ export default defineComponent({
return getUserMsg(); return getUserMsg();
}); });
const isUser = computed(() => { const isUser = computed(() => {
console.log("isuser", userMsg?.value?.role == eRole.user); return userMsg?.value?.role2 == eRole.user;
return userMsg?.value?.role == eRole.user;
}); });
let branchinfo = reactive({} as iNearbyOutLet); let branchinfo = reactive({} as iNearbyOutLet);
onMounted(async () => { onMounted(async () => {
state.loading = true; state.loading = true;
// const isUser = userMsg?.value?.role2 == eRole.user
if (isUser) { if (isUser) {
const ret = await AddressService.getInstance().getNearby({ const ret = await AddressService.getInstance().getNearby({
bank_code: Number(process.env.VUE_APP_BANK_CODE), bank_code: Number(process.env.VUE_APP_BANK_CODE),
......
import { eRole } from '@/types/roleType' import { eRole } from "@/types/roleType";
export default [ export default [
{ {
name: '首页', name: "首页",
routeName: 'Home', routeName: "Home",
icon: 'icon-shouye-tab-xuanze1', icon: "icon-shouye-tab-xuanze1",
icon1: 'icon-shouye-tab', icon1: "icon-shouye-tab",
roles: [eRole.user, eRole.staff, eRole.manager], roles: [eRole.user, eRole.staff, eRole.manager],
showNotLogin: true, showNotLogin: true,
}, },
{ {
name: '聊天', name: "聊天",
routeName: 'ChatList', routeName: "ChatList",
icon1: 'icon-liaotian', icon1: "icon-liaotian",
icon: 'icon-liaotian-dianji', icon: "icon-liaotian-dianji",
roles: [eRole.staff, eRole.user], roles: [eRole.staff, eRole.user, eRole.manager],
showNotLogin: true, showNotLogin: true,
}, },
{ {
name: '产品', name: "产品",
routeName: 'Loan', routeName: "Loan",
icon: 'icon-daikuan-tab-xuanze', icon: "icon-daikuan-tab-xuanze",
icon1: 'icon-daikuan-tab', icon1: "icon-daikuan-tab",
roles: [eRole.user, eRole.staff, eRole.manager], roles: [eRole.user, eRole.staff, eRole.manager],
showNotLogin: true, showNotLogin: true,
hideInReviewMode: true, hideInReviewMode: true,
}, },
{ {
name: '我的', name: "我的",
routeName: 'Mine', routeName: "Mine",
icon: 'icon-wode-tabdianji', icon: "icon-wode-tabdianji",
icon1: 'icon-wode-tab', icon1: "icon-wode-tab",
roles: [eRole.user, eRole.staff,eRole.manager], roles: [eRole.user, eRole.staff, eRole.manager],
showNotLogin: true, showNotLogin: true,
}, },
] ];
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