企业详情页面,数据转移之后,前端获取负责人,postMessage跨域请求
1. 前端发送postMessage
前端跨文档消息传递(postMessage), 通过type等于 REQUEST_ENT_CRM_INFO,发送请求。
window.parent.postMessage({
type: 'REQUEST_ENT_CRM_INFO',
pid: this.id,// 是企业的id
oid: this.loginPermissionInfo.oid, //当前用户登陆企业的oid
uid: this.loginPermissionInfo.uid, //当前用户的uid
ent_type: 'company',
}, "*")2. 前端接收返回的数据
前端接收消息传递(postMessage), 通过type等于 RESPONSE_ENT_CRM_INFO,接收返回的数据。
window.addEventListener('message', this.handleParentMessage);
handleParentMessage(event) {
if (event.data.type === 'RESPONSE_ENT_CRM_INFO') {
console.log('收到 企业返回的 信息:', event.data.result);
}
},
3. 返回格式:
event.data.result格式示例:

{
//buttonLabel为空不展示,不返回该字段,默认展示“负责人”
"buttonLabel": "负责人",
//buttonValue为空不展示,不返回该字段,默认将数组items中的name拼接成字符串,使用、分割
"buttonValue": "王欢",
//hasCallModule:判断isv 是否要对接外呼功能,
//false或者没有这个字段,pc端不展示拨打电话icon,app会展示拨打电话icon,调用原生拨打电话
"hasCallModule": true,
//enableCall:确定当前用户是否有拨号权限;
//有拨号权限,pc端和移动端都展示外呼图标,点击发送拨号事件;
//无拨号权限,pc端和移动端都不展示外呼图标
"enableCall": true,
//hasTransfer:false时不展示转移数据按钮,不返回该字段或者true时,展示转移按钮,hasTransfer为布尔值,可以不返回该字段,默认为true;
//联动判断:hasTransfer字段不返回,或者返回true,buttonLabel和buttonValue不存在对象中时,按钮展示转移数据,并可以转移,buttonLabel和buttonValue存在对象中时,展示buttonLabel:buttonValue,特殊说明,buttonValue存在对象中时,不允许为空
"hasTransfer": false,
"titles": [
{
"label": "负责人",
"name": "item_user",//name需要与items中展示的字段值的key保持一致
},
{
"label": "所属模块",
"name": "item_model"
},
{
"label": "所属对象",
"name": "item_title"
}
],
"items": [
{
"item_user": "客户公海",
"item_model": "客户公海",
"item_title": "重庆胜峰家具有限公司"
}
]
}文档更新时间: 2026-01-08 18:17 作者:张永丰