diff --git a/Touchkebao/src/pages/pc/ckbox/weChat/components/SidebarMenu/FriendsCicle/index.tsx b/Touchkebao/src/pages/pc/ckbox/weChat/components/SidebarMenu/FriendsCicle/index.tsx index 0890e8d3..59f5147a 100644 --- a/Touchkebao/src/pages/pc/ckbox/weChat/components/SidebarMenu/FriendsCicle/index.tsx +++ b/Touchkebao/src/pages/pc/ckbox/weChat/components/SidebarMenu/FriendsCicle/index.tsx @@ -1,4 +1,4 @@ -import React, { useState, useEffect } from "react"; +import React, { useState } from "react"; import { Avatar, Button, Collapse, Spin, Modal } from "antd"; import { useWebSocketStore } from "@/store/module/websocket/websocket"; import { @@ -6,13 +6,13 @@ import { ChromeOutlined, MessageOutlined, LoadingOutlined, - AppstoreOutlined, CloseOutlined, } from "@ant-design/icons"; import { InfiniteScroll } from "antd-mobile"; import styles from "./index.module.scss"; import { FriendsCircleItem, PaginationParams } from "./index.data"; import { useCkChatStore } from "@/store/module/ckchat/ckchat"; +import { useWeChatStore } from "@/store/module/weChat/weChat"; // 模拟朋友圈数据 const mockFriendsCircleData: FriendsCircleItem[] = [ @@ -101,7 +101,8 @@ const FriendsCircle: React.FC = () => { const currentKf = useCkChatStore(state => state.kfUserList.find(kf => kf.id === state.kfSelected), ); - console.log(currentKf); + const { clearMomentCommon } = useWeChatStore(); + const MomentCommon = useWeChatStore(state => state.MomentCommon); // 状态管理 const [myCircleData, setMyCircleData] = useState([]); @@ -222,6 +223,7 @@ const FriendsCircle: React.FC = () => { // 处理折叠面板展开/收起 const handleCollapseChange = (keys: string | string[]) => { + clearMomentCommon(); const keyArray = Array.isArray(keys) ? keys : [keys]; setExpandedKeys(keyArray); @@ -402,12 +404,12 @@ const FriendsCircle: React.FC = () => { ); }; - const renderMyFriendsCircle = () => { + const renderMomentCommon = () => { return (
- {myCircleData.length > 0 ? ( + {MomentCommon.length > 0 ? ( <> - {myCircleData.map(item => ( + {MomentCommon.map(item => (
{renderNormalItem(item, false)}
@@ -435,39 +437,6 @@ const FriendsCircle: React.FC = () => { ); }; - const renderFriendsSquare = () => { - return ( -
- {squareData.length > 0 ? ( - <> - {squareData.map(item => ( -
- {renderNormalItem(item, true)} -
- ))} - - {squareLoading && ( -
- } /> 加载中... -
- )} -
- - ) : squareLoading ? ( -
- } /> 加载中... -
- ) : ( -

暂无朋友圈广场内容

- )} -
- ); - }; - const collapseItems = [ { key: "1", @@ -481,7 +450,7 @@ const FriendsCircle: React.FC = () => { 我的朋友圈
), - children: renderMyFriendsCircle(), + children: renderMomentCommon(), }, { key: "2", @@ -491,7 +460,7 @@ const FriendsCircle: React.FC = () => { 朋友圈广场 ), - children: renderFriendsSquare(), + children: renderMomentCommon(), }, ]; @@ -502,6 +471,7 @@ const FriendsCircle: React.FC = () => { items={collapseItems} className={styles.collapseContainer} ghost + accordion activeKey={expandedKeys} onChange={handleCollapseChange} /> diff --git a/Touchkebao/src/store/module/weChat/weChat.data.ts b/Touchkebao/src/store/module/weChat/weChat.data.ts index c087b41e..4e0f1233 100644 --- a/Touchkebao/src/store/module/weChat/weChat.data.ts +++ b/Touchkebao/src/store/module/weChat/weChat.data.ts @@ -1,30 +1,32 @@ import { ChatRecord, ContractData, weChatGroup } from "@/pages/pc/ckbox/data"; import { FriendsCircleItem } from "@/pages/pc/ckbox/weChat/components/SidebarMenu/FriendsCicle/index.data"; - // 微信聊天相关的类型定义 export interface WeChatState { // 当前选中的联系人/群组 currentContract: ContractData | weChatGroup | null; - - // 当前聊天用户的消息列表(只存储当前聊天用户的消息) - currentMessages: ChatRecord[]; - // 清空当前联系人 + // CurrentContact 相关方法 clearCurrentContact: () => void; - // 消息加载状态 - messagesLoading: boolean; - isLoadingData: boolean; - currentGroupMembers: any[]; - - // 朋友圈数据 - MomentOfKf: FriendsCircleItem[]; // 客服自己的朋友圈 - MomentOfSquare: FriendsCircleItem[]; // 朋友圈广场 - MomentOfFriend: FriendsCircleItem[]; // 好友的朋友圈 - - // Actions setCurrentContact: ( contract: ContractData | weChatGroup, isExist?: boolean, ) => void; + + // 当前聊天用户的消息列表(只存储当前聊天用户的消息) + currentMessages: ChatRecord[]; + // 消息加载状态 + messagesLoading: boolean; + isLoadingData: boolean; + currentGroupMembers: any[]; + MomentCommon: FriendsCircleItem[]; + // MomentCommon 相关方法 + clearMomentCommon: () => void; + addMomentCommon: (moment: FriendsCircleItem) => void; + updateMomentCommon: (moments: FriendsCircleItem[]) => void; + + MomentCommonLoading: boolean; + // MomentCommon 相关方法 + updateMomentCommonLoading: (loading: boolean) => void; + loadChatMessages: (Init: boolean, To?: number) => Promise; SearchMessage: (params: { From: number; @@ -37,13 +39,4 @@ export interface WeChatState { setVideoUrl: (messageId: number, videoUrl: string) => void; addMessage: (message: ChatRecord) => void; receivedMsg: (message: ChatRecord) => void; - - // 朋友圈相关方法 - setMomentOfKf: (moments: FriendsCircleItem[]) => void; - setMomentOfSquare: (moments: FriendsCircleItem[]) => void; - setMomentOfFriend: (moments: FriendsCircleItem[]) => void; - addMomentOfKf: (moments: FriendsCircleItem[]) => void; - addMomentOfSquare: (moments: FriendsCircleItem[]) => void; - addMomentOfFriend: (moments: FriendsCircleItem[]) => void; - clearAllMoments: () => void; } diff --git a/Touchkebao/src/store/module/weChat/weChat.ts b/Touchkebao/src/store/module/weChat/weChat.ts index 7979911a..c17e02a0 100644 --- a/Touchkebao/src/store/module/weChat/weChat.ts +++ b/Touchkebao/src/store/module/weChat/weChat.ts @@ -24,9 +24,12 @@ export const useWeChatStore = create()( messagesLoading: false, isLoadingData: false, currentGroupMembers: [], - MomentOfKf: [], //客服自己的朋友圈 - MomentOfSquare: [], //朋友圈广场 - MomentOfFriend: [], //好友的朋友圈 + MomentCommon: [], + MomentCommonLoading: false, + // MomentCommon 相关方法 + updateMomentCommonLoading: (loading: boolean) => { + set({ MomentCommonLoading: loading }); + }, //============方法列表============ //清空当前联系人 @@ -274,43 +277,19 @@ export const useWeChatStore = create()( }); }, - // 朋友圈相关方法 - setMomentOfKf: moments => { - set({ MomentOfKf: moments }); + // MomentCommon 相关方法 + clearMomentCommon: () => { + set({ MomentCommon: [] }); }, - setMomentOfSquare: moments => { - set({ MomentOfSquare: moments }); - }, - - setMomentOfFriend: moments => { - set({ MomentOfFriend: moments }); - }, - - addMomentOfKf: moments => { + addMomentCommon: moment => { set(state => ({ - MomentOfKf: [...state.MomentOfKf, ...moments], + MomentCommon: [...state.MomentCommon, moment], })); }, - addMomentOfSquare: moments => { - set(state => ({ - MomentOfSquare: [...state.MomentOfSquare, ...moments], - })); - }, - - addMomentOfFriend: moments => { - set(state => ({ - MomentOfFriend: [...state.MomentOfFriend, ...moments], - })); - }, - - clearAllMoments: () => { - set({ - MomentOfKf: [], - MomentOfSquare: [], - MomentOfFriend: [], - }); + updateMomentCommon: moments => { + set({ MomentCommon: moments }); }, }), { diff --git a/Touchkebao/src/store/module/websocket/msgManage.ts b/Touchkebao/src/store/module/websocket/msgManage.ts index 05781cdb..99884efe 100644 --- a/Touchkebao/src/store/module/websocket/msgManage.ts +++ b/Touchkebao/src/store/module/websocket/msgManage.ts @@ -80,52 +80,6 @@ const messageHandlers: Record = { // setVideoUrl(message.friendMessageId, message.url); }, - // 朋友圈数据响应处理 - CmdFetchMomentResult: message => { - console.log("朋友圈数据响应", message); - const { wechatFriendId, wechatAccountId, result, isTimeline, seq } = - message; - const { - setMomentOfKf, - setMomentOfSquare, - setMomentOfFriend, - addMomentOfKf, - addMomentOfSquare, - addMomentOfFriend, - } = useWeChatStore.getState(); - - if (result && Array.isArray(result)) { - // 判断是否为第一页数据(通过seq或数据长度) - const isFirstPage = result.length > 0; - - // 根据wechatFriendId和isTimeline参数判断朋友圈类型 - if (wechatFriendId === 0) { - if (isTimeline) { - // 朋友圈广场 - if (isFirstPage) { - setMomentOfSquare(result); - } else { - addMomentOfSquare(result); - } - } else { - // 客服自己的朋友圈 - if (isFirstPage) { - setMomentOfKf(result); - } else { - addMomentOfKf(result); - } - } - } else { - // 指定好友的朋友圈 - if (isFirstPage) { - setMomentOfFriend(result); - } else { - addMomentOfFriend(result); - } - } - } - }, - // 可以继续添加更多处理器... };