Commit 8760c44c authored by zhangyajun's avatar zhangyajun
Browse files

feat: 弹框聊天

Showing with 2371 additions and 2305 deletions
+2371 -2305
This diff is collapsed.
This diff is collapsed.
......@@ -16,11 +16,14 @@ import EventBus from '@/utils/mitt';
import { ACTIVE_CHAT } from '@/components/chat-module/events';
import { useInit } from '@/views/chat-views/hooks/useInit';
import { API_getUserInfo, API_createRoom } from '@/api/im/index';
import { socket_sendMessage } from '@/components/chat-module/msgUtils/socketAction';
import { v4 as uuidv4 } from 'uuid';
const props = defineProps({
userInfo: Object,
token: String,
env: String,
to_uniq_id: String,
to_message: String,
});
useInit(props);
const imStore = useUserImStore();
......@@ -50,6 +53,9 @@ const createRoomFn = (id: string) => {
chatLoading.value = true;
Promise.all([getUserInfo(id), createRoom(id)])
.then(res => {
if (id !== props.to_uniq_id) {
return;
}
const createUser = Object.assign(res[0], {
total: 0,
room_type: 0,
......@@ -68,11 +74,37 @@ const createRoomFn = (id: string) => {
});
allRoomList.value = [createUser];
roomList.value = [createUser];
nextTick(() => {
EventBus.emit(ACTIVE_CHAT, {
room_id: res[1],
debugger;
if (props.to_message) {
socket_sendMessage({
cmd: 'send',
body: {
uniq_id: imStore.user_im_id,
room_id: res[1],
msg: JSON.stringify({
msg: `<p>${props.to_message}</p>`,
msg_text: props.to_message,
msg_delta: {
ops: [
{
insert: props.to_message,
},
],
},
}),
msg_type: 'html_new',
custom_id: uuidv4(),
},
});
});
}
setTimeout(
() => {
EventBus.emit(ACTIVE_CHAT, {
room_id: res[1],
});
},
props.to_message ? 20 : 0,
);
})
.finally(() => {
chatLoading.value = false;
......
Supports Markdown
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