Commit f2fd5722 by Sixong.Zhu

Merge branch 'master' into pre

parents 7abbf4ee f99c45d2
...@@ -13,10 +13,7 @@ ...@@ -13,10 +13,7 @@
> >
{{ getCurrentInputingPeople }}正在输入 {{ getCurrentInputingPeople }}正在输入
</div> </div>
<messages <messages class="flex-fill" @open-message="openMessage" />
class="flex-fill"
@open-pay-message="openPayMessage"
/>
<slot name="chat-right-panel"></slot> <slot name="chat-right-panel"></slot>
</div> </div>
<div <div
...@@ -31,7 +28,7 @@ ...@@ -31,7 +28,7 @@
class="chat-input flex-none h-100" class="chat-input flex-none h-100"
v-if="hasInput" v-if="hasInput"
> >
<message-input @error="onError" /> <message-input @error="onError" @sent="onMessageSent" />
</div> </div>
</div> </div>
</div> </div>
...@@ -44,6 +41,7 @@ ...@@ -44,6 +41,7 @@
import messages from "@/customer-service/components/message-list.vue"; import messages from "@/customer-service/components/message-list.vue";
import { ChatStore, chatStore } from "@/customer-service/store/model"; import { ChatStore, chatStore } from "@/customer-service/store/model";
import Chat from "@/customer-service/xim"; import Chat from "@/customer-service/xim";
import { CustomerServiceEvent } from "../event";
@Component({ components: { MessageInput, messages } }) @Component({ components: { MessageInput, messages } })
export default class ChatRoom extends Vue { export default class ChatRoom extends Vue {
...@@ -70,6 +68,11 @@ ...@@ -70,6 +68,11 @@
@chatStore.State(ChatStore.STATE_CHAT_CURRENT_IS_CHAT_ERROR) @chatStore.State(ChatStore.STATE_CHAT_CURRENT_IS_CHAT_ERROR)
private readonly chatError!: ChatStore.STATE_CHAT_CURRENT_IS_CHAT_ERROR; private readonly chatError!: ChatStore.STATE_CHAT_CURRENT_IS_CHAT_ERROR;
@chatStore.Getter(ChatStore.GETTER_CURRENT_CURRENT_CHAT)
private readonly currentChat!: ChatStore.GETTER_CURRENT_CURRENT_CHAT;
private setting = 0;
private get hasInput() { private get hasInput() {
return this.isChatMember && this.chatError !== this.chatId; return this.isChatMember && this.chatError !== this.chatId;
} }
...@@ -128,8 +131,23 @@ ...@@ -128,8 +131,23 @@
this.chatBox.clientHeight - this.refTop.clientHeight + "px"); this.chatBox.clientHeight - this.refTop.clientHeight + "px");
} }
private openPayMessage(id: number) { private openMessage(o: any) {
this.$emit("open-pay-message", id); CustomerServiceEvent.emit(this, o);
}
private onMessageSent() {
if (this.setting) {
clearTimeout(this.setting);
}
this.setting = setTimeout(
() =>
this.currentChat &&
Chat.setRead(
this.currentChat.model_name,
this.currentChat.obj_id
),
300
);
} }
} }
</script> </script>
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
import BaseMessage from "./index"; import BaseMessage from "./index";
import Chat from "@/customer-service/xim"; import Chat from "@/customer-service/xim";
import { ChatStore, chatStore } from "@/customer-service/store/model"; import { ChatStore, chatStore } from "@/customer-service/store/model";
import { CustomerServiceEvent, MessageEvent } from "@/customer-service/event";
@Component({ components: {} }) @Component({ components: {} })
export default class Index extends BaseMessage { export default class Index extends BaseMessage {
...@@ -112,7 +113,11 @@ ...@@ -112,7 +113,11 @@
private view() { private view() {
this.isChatMember && this.isChatMember &&
this.$emit("open-pay-message", this.payData.paymentId); CustomerServiceEvent.open(
this,
MessageEvent.PayMessage,
+this.payData.paymentId
);
} }
} }
</script> </script>
......
<template>
<div class="position-message" @click="openPosition">
<div class="d-flex justify-content-between align-items-center">
<span class="d-flex align-items-center">
<span class="title">{{ title }}</span>
<span
v-for="item in tags"
:key="item.title"
:style="{ 'background-color': item.color }"
class="tag"
>{{ item.title }}</span
>
</span>
<span class="salary">{{ salary }}</span>
</div>
<div class="summary">
<span v-for="item in summary" :key="item">{{ item }}</span>
</div>
<div class="msg-content" v-html="positionBody"></div>
<div class="msg-tail d-flex justify-content-between">
<span v-for="item in tail" :key="item" class="text-truncate">{{
item
}}</span>
</div>
</div>
</template>
<script lang="ts">
import { CustomerServiceEvent, MessageEvent } from "@/customer-service/event";
import { PositionMessage } from "@/customer-service/xim/models/chat";
import { Component } from "vue-property-decorator";
import BaseMessage from "./index";
@Component({ components: {} })
export default class Index extends BaseMessage {
private get positionData() {
return this.messageBody.msg as PositionMessage;
}
private get title() {
return this.positionData.title;
}
private get tags() {
return this.positionData.tags;
}
private get salary() {
return this.positionData.salary;
}
private get positionBody() {
return this.positionData.post_require;
}
private get summary() {
return [
this.positionData.address,
this.positionData.education_require,
this.positionData.recruit_count,
];
}
private get tail() {
return [
this.positionData.company_name,
this.positionData.business_scope,
];
}
private openPosition() {
CustomerServiceEvent.open(
this,
MessageEvent.PositionMessage,
this.positionData.post_id
);
}
}
</script>
<style lang="less" scoped>
.position-message {
border: 1px solid #ccc;
border-radius: 10px;
padding: 10px;
max-width: 300px;
cursor: pointer;
}
.title {
font-size: 16px;
font-weight: 500;
}
.tag {
border-radius: 4px;
padding: 0 2px;
margin-left: 10px;
color: #fff;
font-size: 12px;
}
.salary {
color: #e87005;
margin-left: 50px;
}
.summary {
border-bottom: 1px solid #f0f0f0;
margin: 6px -10px 10px -10px;
font-size: 12px;
color: #999;
padding: 0 10px 8px 10px;
span + span {
margin-left: 20px;
}
}
.msg-content {
line-height: 1.4;
}
.msg-tail {
margin: 15px -10px 0 -10px;
padding: 10px 10px 0 10px;
border-top: 1px solid #f0f0f0;
span {
max-width: 200px;
}
}
</style>
\ No newline at end of file
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
:shape="shape" :shape="shape"
@open="open" @open="open"
@withdraw="refresh" @withdraw="refresh"
@open-pay-message="openPayMessage" @open-message="openMessage"
/> />
</div> </div>
</template> </template>
...@@ -49,6 +49,7 @@ ...@@ -49,6 +49,7 @@
import { ChatStore, chatStore } from "@/customer-service/store/model"; import { ChatStore, chatStore } from "@/customer-service/store/model";
import { dbController } from "../database"; import { dbController } from "../database";
import { getLastMessageId } from "../store"; import { getLastMessageId } from "../store";
import { CustomerServiceEvent } from "../event";
@Component({ components: { message, ImagePreview, VideoPreview } }) @Component({ components: { message, ImagePreview, VideoPreview } })
export default class MessageList extends Vue { export default class MessageList extends Vue {
...@@ -415,8 +416,8 @@ ...@@ -415,8 +416,8 @@
this.fetchNewMsg(); this.fetchNewMsg();
} }
private openPayMessage(id: number) { private openMessage(o: any) {
this.$emit("open-pay-message", id); CustomerServiceEvent.emit(this, o);
} }
} }
</script> </script>
......
...@@ -69,7 +69,7 @@ ...@@ -69,7 +69,7 @@
v-if="messageComponent" v-if="messageComponent"
v-model="data" v-model="data"
@open="openFile" @open="openFile"
@open-pay-message="openPayMessage" @open-message="openMessage"
/> />
<avatar <avatar
v-if="!isQuestionAnswerMessage && !isWithdrawMessage" v-if="!isQuestionAnswerMessage && !isWithdrawMessage"
...@@ -164,11 +164,13 @@ ...@@ -164,11 +164,13 @@
import PurchasePlanMessage from "./message-item/purchase-plan-message.vue"; import PurchasePlanMessage from "./message-item/purchase-plan-message.vue";
import MyWelfareMessage from "./message-item/my-welfare-message.vue"; import MyWelfareMessage from "./message-item/my-welfare-message.vue";
import QuestionAnswerMessage from "./message-item/question-answer-message.vue"; import QuestionAnswerMessage from "./message-item/question-answer-message.vue";
import PositionMessage from "./message-item/position-message.vue";
import PayMessage from "./message-item/pay-message.vue"; import PayMessage from "./message-item/pay-message.vue";
import NotifyMessage from "./message-item/notify-message.vue"; import NotifyMessage from "./message-item/notify-message.vue";
import { ChatRole } from "@/customer-service/model"; import { ChatRole } from "@/customer-service/model";
import { getUserMapping } from "../utils/user-info"; import { getUserMapping } from "../utils/user-info";
import Xim from "@/customer-service/xim"; import Xim from "@/customer-service/xim";
import { CustomerServiceEvent } from "../event";
const twoMinutes = 2 * 60 * 1000; const twoMinutes = 2 * 60 * 1000;
const twoHours = 2 * 60 * 60 * 1000; const twoHours = 2 * 60 * 60 * 1000;
...@@ -191,6 +193,7 @@ ...@@ -191,6 +193,7 @@
[dto.MessageType.RefundV1, "pay-message"], [dto.MessageType.RefundV1, "pay-message"],
[dto.MessageType.PayResult, "notify-message"], [dto.MessageType.PayResult, "notify-message"],
[dto.MessageType.Notify, "notify-message"], [dto.MessageType.Notify, "notify-message"],
[dto.MessageType.Position, "position-message"],
]); ]);
@Component({ @Component({
...@@ -209,6 +212,7 @@ ...@@ -209,6 +212,7 @@
ActionMessage, ActionMessage,
PayMessage, PayMessage,
NotifyMessage, NotifyMessage,
PositionMessage,
}, },
}) })
export default class Message extends Vue { export default class Message extends Vue {
...@@ -535,8 +539,8 @@ ...@@ -535,8 +539,8 @@
document.body.click(); document.body.click();
} }
private openPayMessage(id: number) { private openMessage(o: any) {
this.$emit("open-pay-message", id); CustomerServiceEvent.emit(this, o);
} }
} }
</script> </script>
......
...@@ -16,6 +16,8 @@ class ChatCacheDatabaseController { ...@@ -16,6 +16,8 @@ class ChatCacheDatabaseController {
private setuping = false; private setuping = false;
private setupError = false; private setupError = false;
public readonly historyOrderModelName = 'order_info';
private waitSetupCompleted() { private waitSetupCompleted() {
return new Promise<void>((resolve, reject) => { return new Promise<void>((resolve, reject) => {
const checker = () => { const checker = () => {
......
export const enum MessageEvent {
Default = "open-message",
PayMessage = "pay-message",
PositionMessage = "position-message",
}
export class CustomerServiceEvent {
public static open(vue: Vue, type: MessageEvent, model: any) {
return this.emit(vue, { type, model });
}
public static emit(vue: Vue, o: { type: MessageEvent; model: any }) {
return vue.$emit(MessageEvent.Default, o);
}
}
...@@ -121,6 +121,7 @@ export const enum MessageType { ...@@ -121,6 +121,7 @@ export const enum MessageType {
RefundV1 = "grefund", RefundV1 = "grefund",
Refund = "grefund2", Refund = "grefund2",
Card = "card", Card = "card",
Position = "position",
} }
export const enum MessageHandled { export const enum MessageHandled {
......
import { Chat } from "../xim/models/chat"; import { Chat } from "../xim/models/chat";
import { GeneralOrderDirection } from './order-product';
export interface ChatGroup extends Chat { export interface ChatGroup extends Chat {
children?: ChatGroup[]; children?: ChatGroup[];
...@@ -58,7 +59,11 @@ export interface OrderTableListItem { ...@@ -58,7 +59,11 @@ export interface OrderTableListItem {
lastMsgContent: string; lastMsgContent: string;
lastMsgTime: string; lastMsgTime: string;
unreadCount: number; unreadCount: number;
PayPaymentNum?: string | number; //付款笔数 /**
* 付款笔数
*/
PayPaymentNum?: string | number;
product: GeneralOrderDirection;
} }
export const orderPredict = { export const orderPredict = {
...@@ -82,6 +87,7 @@ export const orderPredict = { ...@@ -82,6 +87,7 @@ export const orderPredict = {
lastMsgTime: "UniplatLastMsgTime", lastMsgTime: "UniplatLastMsgTime",
unreadCount: 0, unreadCount: 0,
PayPaymentNum: "PayPaymentNum", PayPaymentNum: "PayPaymentNum",
product: 'ProductId#product.Code'
}; };
export const enum PayStatus { export const enum PayStatus {
......
...@@ -15,7 +15,7 @@ import { getChatModelInfo } from "../utils/chat-info"; ...@@ -15,7 +15,7 @@ import { getChatModelInfo } from "../utils/chat-info";
import { getUserInfo } from "../utils/user-info"; import { getUserInfo } from "../utils/user-info";
import Chat from "../xim"; import Chat from "../xim";
import { Chat as ChatType, Message } from "../xim/models/chat"; import { Chat as ChatType, Message } from "../xim/models/chat";
import xim, { ChatNotifyListener } from "../xim/xim"; import xim, { ChatNotifyListener, Xim } from "../xim/xim";
import { decodeJwt } from "uniplat-sdk"; import { decodeJwt } from "uniplat-sdk";
import { ChatStatus, ChatStore, ChatStoreState } from "./model"; import { ChatStatus, ChatStore, ChatStoreState } from "./model";
...@@ -32,7 +32,7 @@ function uniqueMessages( ...@@ -32,7 +32,7 @@ function uniqueMessages(
messages: NonNullable<ChatStore.STATE_CHAT_MSG_HISTORY> messages: NonNullable<ChatStore.STATE_CHAT_MSG_HISTORY>
) { ) {
const arr = [...messages]; const arr = [...messages];
return unique(arr, function(item, all) { return unique(arr, function (item, all) {
return all.findIndex((k) => k.id === item.id); return all.findIndex((k) => k.id === item.id);
}); });
} }
...@@ -366,7 +366,7 @@ export default { ...@@ -366,7 +366,7 @@ export default {
state[ChatStore.STATE_CHAT_SENDING_MESSAGES] = [...current]; state[ChatStore.STATE_CHAT_SENDING_MESSAGES] = [...current];
} }
}, },
[ChatStore.MUTATION_SAVE_CURRENT_CHAT_INPUTING]: (function() { [ChatStore.MUTATION_SAVE_CURRENT_CHAT_INPUTING]: (function () {
const setTimeoutId: { [key: string]: number } = {}; const setTimeoutId: { [key: string]: number } = {};
return ( return (
state: ChatStoreState, state: ChatStoreState,
...@@ -480,7 +480,9 @@ export default { ...@@ -480,7 +480,9 @@ export default {
items items
); );
} }
dispatch(ChatStore.ACTION_REBUILD_UNREAD_MESSAGE_COUNT).finally(resolve); dispatch(
ChatStore.ACTION_REBUILD_UNREAD_MESSAGE_COUNT
).finally(resolve);
}) })
.catch(reject); .catch(reject);
}); });
...@@ -508,7 +510,9 @@ export default { ...@@ -508,7 +510,9 @@ export default {
ChatStore.MUTATION_SAVE_CHAT_LIST, ChatStore.MUTATION_SAVE_CHAT_LIST,
items items
); );
dispatch(ChatStore.ACTION_REBUILD_UNREAD_MESSAGE_COUNT).finally(resolve); dispatch(
ChatStore.ACTION_REBUILD_UNREAD_MESSAGE_COUNT
).finally(resolve);
}) })
.catch(reject); .catch(reject);
}); });
...@@ -547,8 +551,8 @@ export default { ...@@ -547,8 +551,8 @@ export default {
p: { chat: number; unread: number } p: { chat: number; unread: number }
) { ) {
const list = state[ChatStore.STATE_MY_CHAT_ROOM_LIST] as ChatType[]; const list = state[ChatStore.STATE_MY_CHAT_ROOM_LIST] as ChatType[];
const t = list.find(i => i.id === p.chat) const t = list.find((i) => i.id === p.chat);
t && (t.unread_msg_count = p.unread) t && (t.unread_msg_count = p.unread);
return dbController return dbController
.updateChat4UnreadCount(p.chat, p.unread) .updateChat4UnreadCount(p.chat, p.unread)
.then(() => .then(() =>
...@@ -557,7 +561,9 @@ export default { ...@@ -557,7 +561,9 @@ export default {
}, },
async [ChatStore.ACTION_GET_CHAT_MESSAGES]({ state, commit, getters }) { async [ChatStore.ACTION_GET_CHAT_MESSAGES]({ state, commit, getters }) {
const chatId = state[ChatStore.STATE_CHAT_CURRENT_CHAT_ID]; const chatId = state[ChatStore.STATE_CHAT_CURRENT_CHAT_ID];
const chat = getters[ChatStore.GETTER_CURRENT_CURRENT_CHAT] as ChatType; const chat = getters[
ChatStore.GETTER_CURRENT_CURRENT_CHAT
] as ChatType;
const isMember = state[ChatStore.STATE_CHAT_CURRENT_IS_CHAT_MEMBER]; const isMember = state[ChatStore.STATE_CHAT_CURRENT_IS_CHAT_MEMBER];
if (!chatId) return; if (!chatId) return;
let data: Message[] = []; let data: Message[] = [];
...@@ -614,7 +620,7 @@ export default { ...@@ -614,7 +620,7 @@ export default {
dbController.appendMessages(chatId, data); dbController.appendMessages(chatId, data);
return data; return data;
}, },
async[ChatStore.ACTION_GET_CHAT_MESSAGES_AFTER_SPECIFIC_ID]( async [ChatStore.ACTION_GET_CHAT_MESSAGES_AFTER_SPECIFIC_ID](
{ state, commit, getters }, { state, commit, getters },
msgId: Parameters<ChatStore.ACTION_GET_CHAT_MESSAGES_AFTER_SPECIFIC_ID>[0] msgId: Parameters<ChatStore.ACTION_GET_CHAT_MESSAGES_AFTER_SPECIFIC_ID>[0]
) { ) {
...@@ -639,7 +645,7 @@ export default { ...@@ -639,7 +645,7 @@ export default {
dbController.appendMessages(chatId, data); dbController.appendMessages(chatId, data);
return data; return data;
}, },
async[ChatStore.ACTION_SEND_MESSAGE]( async [ChatStore.ACTION_SEND_MESSAGE](
{ state, dispatch, getters, commit }, { state, dispatch, getters, commit },
params: Parameters<ChatStore.ACTION_SEND_MESSAGE>[0] params: Parameters<ChatStore.ACTION_SEND_MESSAGE>[0]
) { ) {
...@@ -667,7 +673,7 @@ export default { ...@@ -667,7 +673,7 @@ export default {
return Promise.reject(error); return Promise.reject(error);
} }
}, },
async[ChatStore.ACTION_GET_FRESH_MESSAGE]({ async [ChatStore.ACTION_GET_FRESH_MESSAGE]({
state, state,
dispatch, dispatch,
commit, commit,
...@@ -687,7 +693,7 @@ export default { ...@@ -687,7 +693,7 @@ export default {
await preCacheImgs(newMsgsArr); await preCacheImgs(newMsgsArr);
commit(ChatStore.MUTATION_SCROLL_TO_BOTTOM); commit(ChatStore.MUTATION_SCROLL_TO_BOTTOM);
}, },
async[ChatStore.ACTION_CREATE_NEW_CHAT_BY_SERVICE_MAN]( async [ChatStore.ACTION_CREATE_NEW_CHAT_BY_SERVICE_MAN](
{ commit, dispatch }, { commit, dispatch },
params: Parameters<ChatStore.ACTION_CREATE_NEW_CHAT_BY_SERVICE_MAN>[0] params: Parameters<ChatStore.ACTION_CREATE_NEW_CHAT_BY_SERVICE_MAN>[0]
) { ) {
...@@ -704,7 +710,7 @@ export default { ...@@ -704,7 +710,7 @@ export default {
); );
return { chatId, catalog }; return { chatId, catalog };
}, },
async[ChatStore.ACTION_CREATE_NEW_CHAT_BY_CLIENT]( async [ChatStore.ACTION_CREATE_NEW_CHAT_BY_CLIENT](
{ commit, dispatch }, { commit, dispatch },
params: Parameters<ChatStore.ACTION_CREATE_NEW_CHAT_BY_CLIENT>[0] params: Parameters<ChatStore.ACTION_CREATE_NEW_CHAT_BY_CLIENT>[0]
) { ) {
...@@ -722,7 +728,7 @@ export default { ...@@ -722,7 +728,7 @@ export default {
dispatch(ChatStore.ACTION_GET_MY_CHAT_LIST); dispatch(ChatStore.ACTION_GET_MY_CHAT_LIST);
return chatId; return chatId;
}, },
async[ChatStore.ACTION_REGISTER_EVENT]({ async [ChatStore.ACTION_REGISTER_EVENT]({
dispatch, dispatch,
commit, commit,
state, state,
...@@ -732,7 +738,10 @@ export default { ...@@ -732,7 +738,10 @@ export default {
const onNewMsg = (e: Message) => { const onNewMsg = (e: Message) => {
const thenAction = () => { const thenAction = () => {
if (e.type === MessageType.Withdraw) { if (e.type === MessageType.Withdraw) {
commit(ChatStore.MUTATION_WITHDRAW, e.msg.startsWith('[') ? JSON.parse(e.msg) : [+e.msg]); commit(
ChatStore.MUTATION_WITHDRAW,
e.msg.startsWith("[") ? JSON.parse(e.msg) : [+e.msg]
);
} }
const scroll = () => const scroll = () =>
state[ChatStore.STATE_FUNC_ON_NEW_MSG](e); state[ChatStore.STATE_FUNC_ON_NEW_MSG](e);
...@@ -746,7 +755,10 @@ export default { ...@@ -746,7 +755,10 @@ export default {
}; };
if (e.type === MessageType.Withdraw) { if (e.type === MessageType.Withdraw) {
dbController dbController
.removeMessage(e.chat_id, e.msg.startsWith('[') ? JSON.parse(e.msg) : [+e.msg]) .removeMessage(
e.chat_id,
e.msg.startsWith("[") ? JSON.parse(e.msg) : [+e.msg]
)
.finally(() => thenAction()); .finally(() => thenAction());
} else { } else {
thenAction(); thenAction();
...@@ -813,7 +825,7 @@ export default { ...@@ -813,7 +825,7 @@ export default {
xim.on("chat_notify", "read", onMsgRead); xim.on("chat_notify", "read", onMsgRead);
xim.on("chat_notify", "user.input", onInputing); xim.on("chat_notify", "user.input", onInputing);
}, },
async[ChatStore.ACTION_SAVE_CURRENT_CHAT_ID_VERSION]( async [ChatStore.ACTION_SAVE_CURRENT_CHAT_ID_VERSION](
{ state, commit, dispatch }, { state, commit, dispatch },
chatId: ChatStore.STATE_CHAT_CURRENT_CHAT_ID chatId: ChatStore.STATE_CHAT_CURRENT_CHAT_ID
) { ) {
...@@ -878,8 +890,9 @@ export default { ...@@ -878,8 +890,9 @@ export default {
commit(ChatStore.MUTATION_INITING_CHAT_DONE); commit(ChatStore.MUTATION_INITING_CHAT_DONE);
commit(ChatStore.MUTATION_SCROLL_TO_BOTTOM); commit(ChatStore.MUTATION_SCROLL_TO_BOTTOM);
(<any>state)[ChatStore.STATE_CHAT_CURRENT_IS_CHAT_ERROR] = null; (<any>state)[ChatStore.STATE_CHAT_CURRENT_IS_CHAT_ERROR] = null;
Chat.setRead(wantedChatRoom.model_name, wantedChatRoom.obj_id);
}, },
async[ChatStore.ACTION_CLEAR_CURRENT_CHAT_DATA]({ commit, state }) { async [ChatStore.ACTION_CLEAR_CURRENT_CHAT_DATA]({ commit, state }) {
commit(ChatStore.MUTATION_CLEAR_CURRENT_CHAT_ID); commit(ChatStore.MUTATION_CLEAR_CURRENT_CHAT_ID);
commit(ChatStore.MUTATION_CLEAR_MYSELF_ID); commit(ChatStore.MUTATION_CLEAR_MYSELF_ID);
commit(ChatStore.MUTATION_CLEAR_CHAT_MSG_HISTORY); commit(ChatStore.MUTATION_CLEAR_CHAT_MSG_HISTORY);
...@@ -887,7 +900,7 @@ export default { ...@@ -887,7 +900,7 @@ export default {
commit(ChatStore.MUTATION_CLEAR_CURRENT_CHAT_MEMBERS); commit(ChatStore.MUTATION_CLEAR_CURRENT_CHAT_MEMBERS);
(<any>state)[ChatStore.STATE_CHAT_CURRENT_IS_CHAT_ERROR] = null; (<any>state)[ChatStore.STATE_CHAT_CURRENT_IS_CHAT_ERROR] = null;
}, },
async[ChatStore.ACTION_GET_CHAT_MEMBERS]({ commit, state }) { async [ChatStore.ACTION_GET_CHAT_MEMBERS]({ commit, state }) {
const chatId = state[ChatStore.STATE_CHAT_CURRENT_CHAT_ID]; const chatId = state[ChatStore.STATE_CHAT_CURRENT_CHAT_ID];
if (!chatId) return; if (!chatId) return;
const getChatMembersResult = await xim.fetchChatMembers(chatId); const getChatMembersResult = await xim.fetchChatMembers(chatId);
...@@ -925,12 +938,12 @@ export default { ...@@ -925,12 +938,12 @@ export default {
} }
commit( commit(
ChatStore.MUTATION_SAVE_CURRENT_CHAT_MEMBERS, ChatStore.MUTATION_SAVE_CURRENT_CHAT_MEMBERS,
unique(newChatMembers, function(item, all) { unique(newChatMembers, function (item, all) {
return all.findIndex((k) => k.eid === item.eid); return all.findIndex((k) => k.eid === item.eid);
}) })
); );
}, },
async[ChatStore.ACTION_TERINATE_CHAT]({ state, dispatch }) { async [ChatStore.ACTION_TERINATE_CHAT]({ state, dispatch }) {
const v = state[ChatStore.STATE_CHAT_CURRENT_CHAT_VERSION]; const v = state[ChatStore.STATE_CHAT_CURRENT_CHAT_VERSION];
if (v == null) return; if (v == null) return;
const id = Number( const id = Number(
...@@ -958,7 +971,7 @@ export default { ...@@ -958,7 +971,7 @@ export default {
firstChat.chat_id firstChat.chat_id
); );
}, },
async[ChatStore.ACTION_CHAT_START_RECEPTION]({ getters, dispatch }) { async [ChatStore.ACTION_CHAT_START_RECEPTION]({ getters, dispatch }) {
const currentChat = getters[ const currentChat = getters[
ChatStore.GETTER_CURRENT_CURRENT_CHAT ChatStore.GETTER_CURRENT_CURRENT_CHAT
] as ChatType; ] as ChatType;
...@@ -982,7 +995,7 @@ export default { ...@@ -982,7 +995,7 @@ export default {
); );
}); });
}, },
async[ChatStore.ACTION_CHAT_FINISH_RECEPTION]({ getters, dispatch }) { async [ChatStore.ACTION_CHAT_FINISH_RECEPTION]({ getters, dispatch }) {
const currentChat = getters[ const currentChat = getters[
ChatStore.GETTER_CURRENT_CURRENT_CHAT ChatStore.GETTER_CURRENT_CURRENT_CHAT
] as ChatType; ] as ChatType;
...@@ -999,7 +1012,7 @@ export default { ...@@ -999,7 +1012,7 @@ export default {
.finishChat() .finishChat()
.finally(() => dispatch(ChatStore.ACTION_GET_CHAT_MEMBERS)); .finally(() => dispatch(ChatStore.ACTION_GET_CHAT_MEMBERS));
}, },
async[ChatStore.ACTION_CHAT_USER_EXIT]({ getters, dispatch }) { async [ChatStore.ACTION_CHAT_USER_EXIT]({ getters, dispatch }) {
const currentChat = getters[ const currentChat = getters[
ChatStore.GETTER_CURRENT_CURRENT_CHAT ChatStore.GETTER_CURRENT_CURRENT_CHAT
] as ChatType; ] as ChatType;
...@@ -1017,7 +1030,7 @@ export default { ...@@ -1017,7 +1030,7 @@ export default {
.userExitChat() .userExitChat()
.finally(() => dispatch(ChatStore.ACTION_GET_CHAT_MEMBERS)); .finally(() => dispatch(ChatStore.ACTION_GET_CHAT_MEMBERS));
}, },
async[ChatStore.ACTION_CHAT_CS_EXIT]({ getters, dispatch }) { async [ChatStore.ACTION_CHAT_CS_EXIT]({ getters, dispatch }) {
const currentChat = getters[ const currentChat = getters[
ChatStore.GETTER_CURRENT_CURRENT_CHAT ChatStore.GETTER_CURRENT_CURRENT_CHAT
] as ChatType; ] as ChatType;
...@@ -1035,7 +1048,7 @@ export default { ...@@ -1035,7 +1048,7 @@ export default {
.csExitChat() .csExitChat()
.finally(() => dispatch(ChatStore.ACTION_GET_CHAT_MEMBERS)); .finally(() => dispatch(ChatStore.ACTION_GET_CHAT_MEMBERS));
}, },
async[ChatStore.ACTION_CHAT_ADD_MEMBERS]( async [ChatStore.ACTION_CHAT_ADD_MEMBERS](
{ getters, dispatch }, { getters, dispatch },
uids: Parameters<ChatStore.ACTION_CHAT_ADD_MEMBERS>[0] uids: Parameters<ChatStore.ACTION_CHAT_ADD_MEMBERS>[0]
) { ) {
...@@ -1055,7 +1068,7 @@ export default { ...@@ -1055,7 +1068,7 @@ export default {
.addMember(uids.map((id) => +id)) .addMember(uids.map((id) => +id))
.finally(() => dispatch(ChatStore.ACTION_GET_CHAT_MEMBERS)); .finally(() => dispatch(ChatStore.ACTION_GET_CHAT_MEMBERS));
}, },
async[ChatStore.ACTION_CHAT_REMOVE_MEMBER]( async [ChatStore.ACTION_CHAT_REMOVE_MEMBER](
{ getters, dispatch }, { getters, dispatch },
uids: Parameters<ChatStore.ACTION_CHAT_REMOVE_MEMBER>[0] uids: Parameters<ChatStore.ACTION_CHAT_REMOVE_MEMBER>[0]
) { ) {
...@@ -1075,7 +1088,7 @@ export default { ...@@ -1075,7 +1088,7 @@ export default {
.removeMember(uids.map((id) => +id)) .removeMember(uids.map((id) => +id))
.finally(() => dispatch(ChatStore.ACTION_GET_CHAT_MEMBERS)); .finally(() => dispatch(ChatStore.ACTION_GET_CHAT_MEMBERS));
}, },
async[ChatStore.ACTION_CHAT_ADD_CS]( async [ChatStore.ACTION_CHAT_ADD_CS](
{ getters, dispatch }, { getters, dispatch },
uids: Parameters<ChatStore.ACTION_CHAT_ADD_CS>[0] uids: Parameters<ChatStore.ACTION_CHAT_ADD_CS>[0]
) { ) {
...@@ -1095,7 +1108,7 @@ export default { ...@@ -1095,7 +1108,7 @@ export default {
.addCs(uids.map((id) => Number(id))) .addCs(uids.map((id) => Number(id)))
.finally(() => dispatch(ChatStore.ACTION_GET_CHAT_MEMBERS)); .finally(() => dispatch(ChatStore.ACTION_GET_CHAT_MEMBERS));
}, },
async[ChatStore.ACTION_CHAT_REMOVE_CS]( async [ChatStore.ACTION_CHAT_REMOVE_CS](
{ getters, dispatch }, { getters, dispatch },
uids: Parameters<ChatStore.ACTION_CHAT_REMOVE_CS>[0] uids: Parameters<ChatStore.ACTION_CHAT_REMOVE_CS>[0]
) { ) {
......
...@@ -146,7 +146,9 @@ class Chat { ...@@ -146,7 +146,9 @@ class Chat {
return Promise.resolve(uri); return Promise.resolve(uri);
} }
return new Promise<void>((resolve, reject) => { return new Promise<void>((resolve, reject) => {
xim.open(uri, this.token).catch(reject).finally(() => { xim.open(uri, this.token)
.catch(reject)
.finally(() => {
this.registerXimEvent(); this.registerXimEvent();
if (xim.isConnected()) { if (xim.isConnected()) {
resolve(); resolve();
...@@ -203,6 +205,15 @@ class Chat { ...@@ -203,6 +205,15 @@ class Chat {
public getAvatar() { public getAvatar() {
return this.defaultAvatar; return this.defaultAvatar;
} }
public setRead(model: string, obj: string) {
if (this.isBackend()) {
const sdk = this.getSdk();
if (sdk) {
sdk.getAxios().post(`/general/xim/model/${model}/${obj}/read`);
}
}
}
} }
export default new Chat(); export default new Chat();
...@@ -219,6 +219,19 @@ export interface PayMessageBody { ...@@ -219,6 +219,19 @@ export interface PayMessageBody {
totalMoney?: string; totalMoney?: string;
} }
export interface PositionMessage {
title: string;
tags: { title: string; color: string }[];
salary: string;
address: string;
education_require: string;
recruit_count: string;
post_require: string;
company_name: string;
business_scope: string;
post_id: number;
}
export interface CsUser { export interface CsUser {
id: number; id: number;
oid: string; oid: string;
......
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