Commit 23a41a63 by 杨铁龙
parents 1f7c7ff4 d1f6c56f
...@@ -3,21 +3,17 @@ ...@@ -3,21 +3,17 @@
:modal="false" :modal="false"
:before-close="close" :before-close="close"
:visible="value" :visible="value"
custom-class="hide-header show-close padding-0 width-auto" :show-close="false"
custom-class="transparent"
width="90%"
> >
<div class="d-flex flex-column"> <div class="d-flex flex-column">
<div class="preview-title text-center">图片预览</div> <div class="d-flex justify-content-center">
<img v-if="file" :src="file.url" />
<div class="d-flex justify-content-center" style="min-width: 300px"> <i class="el-icon-close" @click="close"></i>
<img v-if="file" :src="file.url" :style="style" />
</div> </div>
<div class="d-flex justify-content-center actions"> <div class="d-flex justify-content-center actions">
<span
class="d-flex align-items-center justify-content-center"
@click="set2Default"
>1:1</span
>
<a <a
class="d-flex align-items-center justify-content-center" class="d-flex align-items-center justify-content-center"
:href="file.url" :href="file.url"
...@@ -31,77 +27,68 @@ ...@@ -31,77 +27,68 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import { Component, Model, Prop, Vue } from "vue-property-decorator"; import { Component, Model, Prop, Vue } from "vue-property-decorator";
@Component({ components: {} })
export default class ImagePreview extends Vue {
@Model("update")
private value!: boolean;
@Prop() @Component({ components: {} })
private file!: { name: string; url: string }; export default class ImagePreview extends Vue {
@Model("update")
private value!: boolean;
private style: { @Prop()
"max-height": number | string; private file!: { name: string; url: string };
"max-width": number | string;
} = {
"max-height": "300px",
"max-width": "600px",
};
private close() { private close() {
setTimeout( this.$emit("update", false);
() => }
(this.style = { "max-height": "300px", "max-width": "600px" }),
300
);
this.$emit("update", false);
}
private set2Default() {
this.style = { "max-height": "1600px", "max-width": "1600px" };
}
private get getAttachment() { private get getAttachment() {
if (this.file) { if (this.file) {
return this.file.name; return this.file.name;
}
return "文件下载";
} }
return "文件下载";
} }
}
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
.preview-title { img {
font-size: 18px; max-width: 100%;
color: #333; max-height: 100%;
margin-bottom: 15px;
}
.actions { & + i {
margin: 15px 0; top: -25px;
right: 20px;
background-color: rgba(0, 0, 0, 0.5);
border-radius: 50%;
padding: 5px;
font-size: 40px;
color: #fff;
display: table;
position: relative;
z-index: 1;
cursor: pointer;
}
}
> span, .actions {
a { margin: 15px 0;
width: 30px;
height: 30px;
background-color: #7a7b7d;
color: #fff;
border-radius: 50%;
cursor: pointer;
i { a {
width: 50px;
height: 50px;
background-color: #7a7b7d;
color: #fff; color: #fff;
font-size: 20px; border-radius: 50%;
} cursor: pointer;
& + span { i {
margin-left: 15px; color: #fff;
} font-size: 30px;
} }
> a { & + span {
margin-left: 15px; margin-left: 15px;
}
}
} }
}
</style> </style>
...@@ -78,12 +78,7 @@ ...@@ -78,12 +78,7 @@
/> />
<avatar <avatar
v-if="!isQuestionAnswerMessage && !isWithdrawMessage" v-if="!isQuestionAnswerMessage && !isWithdrawMessage"
:src=" :src="avatar || defaultAvatar"
chatRole === 'admin' ||
chatRole === 'customer-service'
? defaultAvatar
: avatar
"
shape="circle" shape="circle"
/> />
</div> </div>
...@@ -224,8 +219,8 @@ ...@@ -224,8 +219,8 @@
@chatStore.State(ChatStore.STATE_CHAT_CURRENT_USER_UID) @chatStore.State(ChatStore.STATE_CHAT_CURRENT_USER_UID)
private readonly chatMyId!: ChatStore.STATE_CHAT_CURRENT_USER_UID; private readonly chatMyId!: ChatStore.STATE_CHAT_CURRENT_USER_UID;
@chatStore.Getter(ChatStore.STATE_CURRENT_CHAT_MEMBERS) @chatStore.State(ChatStore.STATE_ALL_HISTORY_CHAT_MEMBERS)
private readonly allChatMembers!: ChatStore.STATE_CURRENT_CHAT_MEMBERS; private readonly allChatMembers!: ChatStore.STATE_ALL_HISTORY_CHAT_MEMBERS;
@chatStore.Getter(ChatStore.GETTER_CURRENT_CHAT_PRESENT_MEMBERS) @chatStore.Getter(ChatStore.GETTER_CURRENT_CHAT_PRESENT_MEMBERS)
private readonly chatMembers!: ChatStore.GETTER_CURRENT_CHAT_PRESENT_MEMBERS; private readonly chatMembers!: ChatStore.GETTER_CURRENT_CHAT_PRESENT_MEMBERS;
...@@ -403,7 +398,10 @@ ...@@ -403,7 +398,10 @@
if (this.chatMembers) { if (this.chatMembers) {
const t = this.chatMembers.find((i) => i.eid === this.data.eid); const t = this.chatMembers.find((i) => i.eid === this.data.eid);
if (t) { if (t) {
const name = this.getFilterUsername(t.alias_name || t.name); const name = this.getFilterUsername(
t.alias_name as string,
t.name
);
if (name) { if (name) {
return name; return name;
} }
...@@ -413,15 +411,18 @@ ...@@ -413,15 +411,18 @@
return this.refetchUsername; return this.refetchUsername;
} }
private getFilterUsername(name: string) { private getFilterUsername(name1: string, name2: string) {
const backend = Xim.isBackend();
if ( if (
this.currentChat && this.currentChat &&
this.currentChat.catalog === "福利宝" && this.currentChat.catalog === "福利宝" &&
this.chatRole === "customer-service" this.chatRole === "customer-service"
) { ) {
return `采购顾问 ${name}`; return backend && name1
? `采购顾问 ${name1}(${name2})`
: `采购顾问 ${name1 || name2}`;
} }
return name; return backend && name1 ? `${name1}(${name2})` : name1 || name2;
} }
private get avatar() { private get avatar() {
...@@ -615,7 +616,14 @@ ...@@ -615,7 +616,14 @@
if (this.data && this.data.eid) { if (this.data && this.data.eid) {
ChatUserInfoService.getUserInfo(this.data.eid).then((r) => { ChatUserInfoService.getUserInfo(this.data.eid).then((r) => {
if (r) { if (r) {
this.refetchUsername = r.alias_name || r.name || r.phone; if (Xim.isBackend() && r.alias_name) {
this.refetchUsername = `${r.alias_name}(${
r.name || r.phone
})`;
} else {
this.refetchUsername =
r.alias_name || r.name || r.phone;
}
r.icon && (this.refetchUserIcon = r.icon); r.icon && (this.refetchUserIcon = r.icon);
} }
}); });
......
...@@ -3,17 +3,17 @@ import { UniplatSdk } from "uniplat-sdk"; ...@@ -3,17 +3,17 @@ import { UniplatSdk } from "uniplat-sdk";
import { ImEnvironment } from "../model"; import { ImEnvironment } from "../model";
export const enum Product { export const enum Product {
Default = 'default', Default = "default",
QqxbWeixin = 'qqxb-weixin', QqxbWeixin = "qqxb-weixin",
QqxbApp = 'qqxb-app', QqxbApp = "qqxb-app",
Fulibao = 'fulibao', Fulibao = "fulibao",
HrManager = 'hr-manager', HrManager = "hr-manager",
Hrs100 = 'hrs100', Hrs100 = "hrs100",
HrsApp = 'hrs-app', HrsApp = "hrs-app",
BiJie = 'bi-jie', BiJie = "bi-jie",
Cashier = 'cashier', Cashier = "cashier",
Uniplat = "uniplat", Uniplat = "uniplat",
DeShengJiuYeBao = 'de-sheng-jiu-ye-bao' DeShengJiuYeBao = "de-sheng-jiu-ye-bao",
} }
const enum ProductTable { const enum ProductTable {
...@@ -88,33 +88,40 @@ class WebMonitor { ...@@ -88,33 +88,40 @@ class WebMonitor {
public useSdk(sdk: UniplatSdk, options: SdkMonitorOption) { public useSdk(sdk: UniplatSdk, options: SdkMonitorOption) {
this.envir = options.envir; this.envir = options.envir;
this.product = options.product; this.product = options.product;
sdk.events.addUniversalErrorResponseCallback((r: AxiosResponse<any>) => { sdk.events.addUniversalErrorResponseCallback(
if (this.enable()) { (r: AxiosResponse<any>) => {
const msg: string[] = []; if (this.enable()) {
msg.push(`URL: ${decodeURIComponent(r.config.url as string)}`); const msg: string[] = [];
msg.push(`Token: ${sdk.global.jwtToken}`); msg.push(
const header = r.config.headers; `URL: ${decodeURIComponent(r.config.url as string)}`
if (header) { );
msg.push(`CurrentOrg: ${header.CurrentOrg}`); msg.push(`Token: ${sdk.global.jwtToken}`);
msg.push(`Scenes: ${header.Scenes}`); const header = r.config.headers;
} if (header) {
msg.push(`CurrentOrg: ${header.CurrentOrg}`);
msg.push(`Scenes: ${header.Scenes}`);
}
options && options &&
options.userAgent && options.userAgent &&
msg.push(`UserAgent: ${window.navigator.userAgent}`); msg.push(`UserAgent: ${window.navigator.userAgent}`);
r.config && r.config.params && msg.push(`Params: ${r.config.params}`); r.config &&
r.config && r.config.data && msg.push(`Payload: ${JSON.stringify(r.config.data)}`); r.config.params &&
msg.push(`Params: ${JSON.stringify(r.config.params)}`);
r.config &&
r.config.data &&
msg.push(`Payload: ${JSON.stringify(r.config.data)}`);
msg.push( msg.push(
`Exception: ${((r.data.error as string) || "").substring( `Exception: ${(
0, (r.data.error as string) || ""
500 ).substring(0, 500)}`
)}` );
);
r && r.config && this.error(msg.join("\n")); r && r.config && this.error(msg.join("\n"));
}
} }
}); );
} }
} }
......
...@@ -159,6 +159,7 @@ export default { ...@@ -159,6 +159,7 @@ export default {
[ChatStore.STATE_CHAT_MY_UID]: null, [ChatStore.STATE_CHAT_MY_UID]: null,
[ChatStore.STATE_CHAT_SOURCE]: ServiceType.Frontend, [ChatStore.STATE_CHAT_SOURCE]: ServiceType.Frontend,
[ChatStore.STATE_CURRENT_CHAT_MEMBERS]: null, [ChatStore.STATE_CURRENT_CHAT_MEMBERS]: null,
[ChatStore.STATE_ALL_HISTORY_CHAT_MEMBERS]: null,
[ChatStore.STATE_CURRENT_CHAT_TITLE]: "", [ChatStore.STATE_CURRENT_CHAT_TITLE]: "",
[ChatStore.STATE_FUNC_SCROLL_TO_BOTTOM]: () => true, [ChatStore.STATE_FUNC_SCROLL_TO_BOTTOM]: () => true,
[ChatStore.STATE_FUNC_ON_NEW_MSG]: () => true, [ChatStore.STATE_FUNC_ON_NEW_MSG]: () => true,
...@@ -881,7 +882,7 @@ export default { ...@@ -881,7 +882,7 @@ export default {
commit(ChatStore.MUTATION_CLEAR_CHAT_MSG_HISTORY); commit(ChatStore.MUTATION_CLEAR_CHAT_MSG_HISTORY);
commit(ChatStore.MUTATION_SAVE_CURRENT_CHAT_ID, chatId); commit(ChatStore.MUTATION_SAVE_CURRENT_CHAT_ID, chatId);
await getChatModelInfo( getChatModelInfo(
wantedChatRoom.model_name, wantedChatRoom.model_name,
wantedChatRoom.obj_id, wantedChatRoom.obj_id,
wantedChatRoom.detail_name wantedChatRoom.detail_name
...@@ -895,13 +896,13 @@ export default { ...@@ -895,13 +896,13 @@ export default {
ChatStore.MUTATION_SAVE_CURRENT_CHAT_UNIPLAT_ID, ChatStore.MUTATION_SAVE_CURRENT_CHAT_UNIPLAT_ID,
info.uniplatId info.uniplatId
); );
dispatch(ChatStore.ACTION_GET_CHAT_MEMBERS);
}) })
.catch(console.error); .catch(console.error);
commit(ChatStore.MUTATION_INITING_CHAT); commit(ChatStore.MUTATION_INITING_CHAT);
removeRegisterChatEvents.forEach((k) => k()); removeRegisterChatEvents.forEach((k) => k());
removeRegisterChatEvents = []; removeRegisterChatEvents = [];
try { try {
await dispatch(ChatStore.ACTION_GET_CHAT_MEMBERS);
await Promise.all([ await Promise.all([
dispatch(ChatStore.ACTION_REGISTER_EVENT), dispatch(ChatStore.ACTION_REGISTER_EVENT),
dispatch(ChatStore.ACTION_GET_CHAT_MESSAGES), dispatch(ChatStore.ACTION_GET_CHAT_MESSAGES),
...@@ -937,7 +938,7 @@ export default { ...@@ -937,7 +938,7 @@ export default {
const getChatMembersResult = await xim.fetchChatMembers(chatId); const getChatMembersResult = await xim.fetchChatMembers(chatId);
if (!getChatMembersResult) return; if (!getChatMembersResult) return;
const chatMembers = getChatMembersResult.args[0] as ChatMember[]; const chatMembers = getChatMembersResult.args[0] as ChatMember[];
let newChatMembers = await Promise.all( const all = await Promise.all(
chatMembers.map(async (member) => { chatMembers.map(async (member) => {
let result: NonNullable<ChatStore.STATE_CURRENT_CHAT_MEMBERS>[number]; let result: NonNullable<ChatStore.STATE_CURRENT_CHAT_MEMBERS>[number];
try { try {
...@@ -956,7 +957,8 @@ export default { ...@@ -956,7 +957,8 @@ export default {
return result; return result;
}) })
); );
newChatMembers = newChatMembers.filter((it) => !it.is_exited); (<any>state)[ChatStore.STATE_ALL_HISTORY_CHAT_MEMBERS] = all;
const newChatMembers = all.filter((it) => !it.is_exited);
const member = newChatMembers.find( const member = newChatMembers.find(
(it) => (it) =>
it.eid === it.eid ===
...@@ -969,6 +971,7 @@ export default { ...@@ -969,6 +971,7 @@ export default {
commit(ChatStore.MUTATION_CHAT_UPDATE_IS_MEMBER, false); commit(ChatStore.MUTATION_CHAT_UPDATE_IS_MEMBER, false);
commit(ChatStore.MUTATION_CHAT_UPDATE_USER_TYPE, "0"); commit(ChatStore.MUTATION_CHAT_UPDATE_USER_TYPE, "0");
} }
commit( commit(
ChatStore.MUTATION_SAVE_CURRENT_CHAT_MEMBERS, ChatStore.MUTATION_SAVE_CURRENT_CHAT_MEMBERS,
unique(newChatMembers, function (item, all) { unique(newChatMembers, function (item, all) {
......
...@@ -73,6 +73,11 @@ export namespace ChatStore { ...@@ -73,6 +73,11 @@ export namespace ChatStore {
| readonly (dto.ChatMember & dto.ChatMemberExtraInfo)[] | readonly (dto.ChatMember & dto.ChatMemberExtraInfo)[]
| null; | null;
export const STATE_ALL_HISTORY_CHAT_MEMBERS = "当前会话历史所有参与者";
export type STATE_ALL_HISTORY_CHAT_MEMBERS =
| readonly (dto.ChatMember & dto.ChatMemberExtraInfo)[]
| null;
export const STATE_CURRENT_CHAT_TITLE = "会话标题"; export const STATE_CURRENT_CHAT_TITLE = "会话标题";
export type STATE_CURRENT_CHAT_TITLE = string; export type STATE_CURRENT_CHAT_TITLE = string;
......
...@@ -88,7 +88,7 @@ export async function getChatModelInfo( ...@@ -88,7 +88,7 @@ export async function getChatModelInfo(
} }
) as ChatModelInfoData; ) as ChatModelInfoData;
let removing = []; const removing = [];
for (const item of waitingAction) { for (const item of waitingAction) {
if (item.key === key) { if (item.key === key) {
item.resolve(o); item.resolve(o);
......
import { UniplatSdk } from "uniplat-sdk"; import { UniplatSdk } from "uniplat-sdk";
import Chat from "../xim"; import Chat from "../xim";
export type UserMapping = { export interface ChatUserSummaryInfo {
[eid: string]: { name: string;
name: string; phone: string;
phone: string; icon: string;
icon: string; alias_name: string;
alias_name: string; }
};
}; export type UserMapping = { [eid: string]: ChatUserSummaryInfo };
const userMapping: UserMapping = {}; const userMapping: UserMapping = {};
...@@ -25,6 +25,12 @@ interface UserInfo { ...@@ -25,6 +25,12 @@ interface UserInfo {
export const getUserMapping = () => userMapping; export const getUserMapping = () => userMapping;
const loadingKeys = new Set<string>();
let waitingAction: {
key: string;
resolve: (d: ChatUserSummaryInfo) => void;
}[] = [];
export class ChatUserInfoService { export class ChatUserInfoService {
public static async getUserInfo(eid: string, sdk?: UniplatSdk) { public static async getUserInfo(eid: string, sdk?: UniplatSdk) {
if (userMapping[eid]) { if (userMapping[eid]) {
...@@ -33,6 +39,15 @@ export class ChatUserInfoService { ...@@ -33,6 +39,15 @@ export class ChatUserInfoService {
if (!+eid || +eid < 0) { if (!+eid || +eid < 0) {
return { name: "", phone: "", icon: "", alias_name: "" }; return { name: "", phone: "", icon: "", alias_name: "" };
} }
if (loadingKeys.has(eid)) {
return new Promise<ChatUserSummaryInfo>((resolve) =>
waitingAction.push({ key: eid, resolve })
);
}
loadingKeys.add(eid);
const info = await (sdk || Chat.getSdk()) const info = await (sdk || Chat.getSdk())
.domainService( .domainService(
"passport", "passport",
...@@ -47,6 +62,21 @@ export class ChatUserInfoService { ...@@ -47,6 +62,21 @@ export class ChatUserInfoService {
alias_name: info.alias_name, alias_name: info.alias_name,
}; };
userMapping[eid] = data; userMapping[eid] = data;
const removing = [];
for (const item of waitingAction) {
if (item.key === eid) {
item.resolve(data);
removing.push(item.key);
}
}
for (const item of removing) {
waitingAction = waitingAction.filter((i) => i.key !== item);
}
loadingKeys.delete(eid);
return data; return data;
} }
......
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 sign in to comment