目录
兼容性:企业微信 3.0.24 开始支持
获取当前页面打开场景。
ww.getContext()
属性 | 类型 | 必填 | 说明 | |
---|---|---|---|---|
success | Function | 否 | 成功回调 | |
fail | Function | 否 | 失败回调 | |
cancel | Function | 否 | 取消回调 | |
complete | Function | 否 | 完成回调 |
Promise<Object>
属性 | 类型 | 必填 | 说明 | |||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
errMsg | string | 是 | 通用错误信息 | |||||||||||||||||||||||||||||||||||||||||
errCode | number | 是 | 通用错误码 | |||||||||||||||||||||||||||||||||||||||||
entry | string | 是 | 进入页面的场景类型 | |||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||
shareTicket | string | 否 | 从设置了 |
调用该接口可以判断用户是从哪个入口打开页面,从而决定是否可以调用客户联系相关的接口。
wx.invoke('getContext', {
}, function(res){
if(res.err_msg == "getContext:ok"){
entry = res.entry ; //返回进入H5页面的入口类型,目前有normal、contact_profile、single_chat_tools、group_chat_tools、chat_attachment
shareTicket = res.shareTicket; //可用于调用getShareInfo接口
}else {
//错误处理
}
});