目录
兼容性:企业微信 PC 2.3.0 开始支持
使用系统浏览器打开指定 URL,支持传入 oauth2 链接,从而实现在系统浏览器内免登录的效果。
ww.openDefaultBrowser({
url: 'https://work.weixin.qq.com/'
})
属性 | 类型 | 必填 | 说明 | |
---|---|---|---|---|
url | string | 是 | 在默认浏览器打开的 URL 若 URL 为 oauth2 链接,跳转时将附带上 code 参数 | |
success | Function | 否 | 成功回调 | |
fail | Function | 否 | 失败回调 | |
cancel | Function | 否 | 取消回调 | |
complete | Function | 否 | 完成回调 |
Promise<Object>
属性 | 类型 | 必填 | 说明 | |
---|---|---|---|---|
errMsg | string | 是 | 通用错误信息 | |
errCode | number | 是 | 通用错误码 |
wx.invoke('openDefaultBrowser', {
'url': "https://open.weixin.qq.com/connect/oauth2/authorize?appid=CORPID&redirect_uri=REDIRECT_URI&response_type=code&scope=SCOPE&agentid=AGENTID&state=STATE#wechat_redirect", // 在默认浏览器打开redirect_uri,并附加code参数;也可以直接指定要打开的url,此时不会附带上code参数。
}, function(res){
if(res.err_msg != "openDefaultBrowser:ok"){
//错误处理
}
});