获取群聊信息
使用场景
本例介绍如何在宜搭中如何获取钉钉群聊信息。
实现功能
创建页面


配置数据源及变量
参考接口文档:查询群信息

- 选择连接器 -> 会话群

- 选择执行动作 -> 获取群会话信息

- 移动端访问二维码变量

实现功能
PC端访问,显示二维码缺省页
参考文档:实用工具 - 页面引导
查询群聊信息


export function onGetChatInfo() {
if (!this.utils.isMobile()) {
this.utils.toast({
title: '请在手机端使用该工具',
type: 'notice',
});
}
window.dd.biz.chat.chooseConversationByCorpId({
corpId: window.pageConfig.corpId, // 企业id, 必须是用户所属的企业的corpid
isAllowCreateGroup: false, // true(默认): 可创建新群聊;false: 不可创建新群聊
filterNotOwnerGroup: false, // true(默认): 群主为登录人的群聊 false: 当前组织下登录人所在群聊
onSuccess: (result) => {
const { title, chatId, openConversationId } = result;
this.$('textField_lm5z2wnd').setValue(title);
this.$('textField_lm5yvk6d').setValue(chatId);
this.$('textField_lm5yvk6f').setValue(openConversationId);
if (chatId) {
this.dataSourceMap.getChatInfo.load({
inputs: JSON.stringify({
chatid: chatId,
}),
}).then(async (content) => {
content = JSON.parse(content);
const { result = {} } = content.Body;
const { chat_info = {} } = result;
const { useridlist = [] } = chat_info;
this.$('numberField_lm5zr96c').setValue(useridlist.length);
}).catch((error) => {
this.utils.toast({
type: 'error',
title: `群信息查询失败${error.message}`,
});
});
}
},
onFail: () => { },
});
}
实现效果
PC端访问

移动端访问
- 选择群聊 -> 自动获取所选群信息


在线试玩
本文档对您是否有帮助?