在微信app内h5页面通过selectEnterpriseContact接口调用企业微信的通讯录,通讯录打开后,选择完用户,点确定后回调函数没执行,没任何反应通讯录就关闭了。把h5放在企业微信内使用,通讯录选择后可以正常执行回调函数。
export const selectEnterpriseContact = (optioin: any) => {
return new Promise((resolve, reject) => {
wx.invoke("selectEnterpriseContact", {
"fromDepartmentId": 0,
"mode": optioin?.mode ? optioin?.mode : 'single',
"type": ["user"],
"selectedDepartmentIds": [],
"selectedUserIds": []
}, function (res: any) {
if (res?.err_msg == "selectEnterpriseContact:ok" || res?.errMsg == "selectEnterpriseContact:ok") {
if (typeof res.result == 'string') {
res.result = JSON.parse(res.result)
}
const departmentIds = [];
const userIds = [];
var selectedDepartmentList = res.result.departmentList;
for (var i = 0; i < selectedDepartmentList.length; i++) {
var department = selectedDepartmentList[i];
departmentIds.push(department.id);
}
var selectedUserList = res.result.userList;
for (var i = 0; i < selectedUserList.length; i++) {
var user = selectedUserList[i];
userIds.push(user.id);
}
const selected = {
departmentIds,
userIds,
}
resolve(selected);
} else {
reject(res?.err_msg || res?.errMsg);
}
})
})