fix(weChat): 修正群聊ID赋值错误并优化初始化流程
- 将wechatChatroomId从contact.chatroomId改为contact.id以修复赋值错误 - 调整chatInitAPIdata中的初始化顺序,先获取群列表再处理唯一ID - 修改getUniqueWechatAccountIds函数参数以支持群组数据
This commit is contained in:
@@ -17,7 +17,11 @@ import {
|
||||
|
||||
import { useUserStore } from "@/store/module/user";
|
||||
|
||||
import { KfUserListData } from "@/pages/pc/ckbox/data";
|
||||
import {
|
||||
KfUserListData,
|
||||
ContractData,
|
||||
weChatGroup,
|
||||
} from "@/pages/pc/ckbox/data";
|
||||
|
||||
import { WechatGroup } from "./api";
|
||||
const { login2 } = useUserStore.getState();
|
||||
@@ -30,9 +34,16 @@ export const chatInitAPIdata = async () => {
|
||||
//获取联系人列表
|
||||
asyncContractList(contractList);
|
||||
|
||||
//获取群列表
|
||||
const groupList = await getAllGroupList();
|
||||
|
||||
await asyncWeChatGroup(groupList);
|
||||
|
||||
// 提取不重复的wechatAccountId组
|
||||
const uniqueWechatAccountIds: number[] =
|
||||
getUniqueWechatAccountIds(contractList);
|
||||
const uniqueWechatAccountIds: number[] = getUniqueWechatAccountIds(
|
||||
contractList,
|
||||
groupList,
|
||||
);
|
||||
|
||||
//获取控制终端列表
|
||||
const kfUserList: KfUserListData[] =
|
||||
@@ -41,11 +52,6 @@ export const chatInitAPIdata = async () => {
|
||||
//获取用户列表
|
||||
await asyncKfUserList(kfUserList);
|
||||
|
||||
//获取群列表
|
||||
const groupList = await getAllGroupList();
|
||||
|
||||
await asyncWeChatGroup(groupList);
|
||||
|
||||
//获取标签列表
|
||||
const countLables = await getCountLables();
|
||||
await asyncCountLables(countLables);
|
||||
@@ -209,7 +215,10 @@ export const getAllContactList = async () => {
|
||||
};
|
||||
|
||||
// 提取不重复的wechatAccountId组
|
||||
export const getUniqueWechatAccountIds = contacts => {
|
||||
export const getUniqueWechatAccountIds = (
|
||||
contacts: ContractData[],
|
||||
groupList: weChatGroup[],
|
||||
) => {
|
||||
if (!contacts || !Array.isArray(contacts) || contacts.length === 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ export const useWeChatStore = create<WeChatState>()(
|
||||
};
|
||||
|
||||
if ("chatroomId" in contact && contact.chatroomId) {
|
||||
params.wechatChatroomId = contact.chatroomId;
|
||||
params.wechatChatroomId = contact.id;
|
||||
} else {
|
||||
params.wechatFriendId = contact.id;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user