最近在用企业微信打通自建应用,自动登录比较简单,但是通过JS-SDK实现自建应用发起审批时一直不顺利,我后端使用的是盛派企业微信SDK,前端是Vue3,体验是太坑了
由于版本区别,我用的如下这个版本

首先是环境注入
1、没有任何提示,不知道状态,只能发布到线上测试,后面突然有提示了
2、提示:agentConfig:fail_invalid,我检查了几次,参数正常,后来卸载sdk,重新安装后好了

然后是自建应用发起审批权限检测:thirdPartyOpenPage,提示我没有权限,检查过很多配置都没问题,第二天准备放弃时,又发布了一遍好了,没有动任何代码

代码示例:
ww.register({
corpId: wxConfig.corpId, // 必填,当前用户企业所属企业ID
agentId: wxConfig.corpAgentId,
jsApiList: ['thirdPartyOpenPage'],
getConfigSignature,
getAgentConfigSignature,
onAgentConfigSuccess(res) {
alert('AgentConfig配置成功:' + JSON.stringify(res))
console.log(res,'agentConfig 成功回调')
},
onAgentConfigFail(res) {
alert('AgentConfig配置失败:' + JSON.stringify(res))
console.log(res,'agentConfig 失败回调')
}
})
async function getConfigSignature() {
return {
timestamp: wxConfig.jsApiUiPackage.timestamp,
nonceStr: wxConfig.jsApiUiPackage.nonceStr,
signature: wxConfig.jsApiUiPackage.signature
}
}
async function getAgentConfigSignature() {
return {
timestamp: wxConfig.agentJsApiUiPackage.timestamp,
nonceStr: wxConfig.agentJsApiUiPackage.nonceStr,
signature: wxConfig.agentJsApiUiPackage.signature
}
}