feat(聊天窗口): 支持群聊消息获取功能
修改api接口参数和组件逻辑,使聊天窗口能够处理群聊消息
This commit is contained in:
@@ -25,7 +25,8 @@ export function clearUnreadCount(params) {
|
|||||||
//获取聊天记录-2 获取列表
|
//获取聊天记录-2 获取列表
|
||||||
export function getMessages(params: {
|
export function getMessages(params: {
|
||||||
wechatAccountId: number;
|
wechatAccountId: number;
|
||||||
wechatFriendId: number;
|
wechatFriendId?: number;
|
||||||
|
wechatChatroomId?: number;
|
||||||
From: number;
|
From: number;
|
||||||
To: number;
|
To: number;
|
||||||
Count: number;
|
Count: number;
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ import {
|
|||||||
TeamOutlined,
|
TeamOutlined,
|
||||||
StarOutlined,
|
StarOutlined,
|
||||||
} from "@ant-design/icons";
|
} from "@ant-design/icons";
|
||||||
import { ChatRecord, ContractData } from "@/pages/pc/ckbox/data";
|
import { ChatRecord, ContractData, weChatGroup } from "@/pages/pc/ckbox/data";
|
||||||
import { clearUnreadCount, getMessages } from "@/pages/pc/ckbox/api";
|
import { clearUnreadCount, getMessages } from "@/pages/pc/ckbox/api";
|
||||||
import styles from "./ChatWindow.module.scss";
|
import styles from "./ChatWindow.module.scss";
|
||||||
import { useWebSocketStore, WebSocketMessage } from "@/store/module/websocket";
|
import { useWebSocketStore, WebSocketMessage } from "@/store/module/websocket";
|
||||||
@@ -46,7 +46,7 @@ const { Header, Content, Footer } = Layout;
|
|||||||
const { TextArea } = Input;
|
const { TextArea } = Input;
|
||||||
|
|
||||||
interface ChatWindowProps {
|
interface ChatWindowProps {
|
||||||
contract: ContractData;
|
contract: ContractData | weChatGroup;
|
||||||
onSendMessage: (message: string) => void;
|
onSendMessage: (message: string) => void;
|
||||||
showProfile?: boolean;
|
showProfile?: boolean;
|
||||||
onToggleProfile?: () => void;
|
onToggleProfile?: () => void;
|
||||||
@@ -72,14 +72,19 @@ const ChatWindow: React.FC<ChatWindowProps> = ({
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
clearUnreadCount([contract.id]).then(() => {
|
clearUnreadCount([contract.id]).then(() => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
getMessages({
|
const params: any = {
|
||||||
wechatAccountId: contract.wechatAccountId,
|
wechatAccountId: contract.wechatAccountId,
|
||||||
wechatFriendId: contract.id,
|
|
||||||
From: 1,
|
From: 1,
|
||||||
To: +new Date() + 1000,
|
To: +new Date() + 1000,
|
||||||
Count: 100,
|
Count: 100,
|
||||||
olderData: true,
|
olderData: true,
|
||||||
})
|
};
|
||||||
|
if (contract.groupId == 1) {
|
||||||
|
params.wechatFriendId = contract.id;
|
||||||
|
} else {
|
||||||
|
params.wechatChatroomId = contract.id;
|
||||||
|
}
|
||||||
|
getMessages(params)
|
||||||
.then(msg => {
|
.then(msg => {
|
||||||
setMessages(msg);
|
setMessages(msg);
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user