企微H5踩坑记录-WECOM

266 阅读1分钟

用的是2024.08出的WECOM

  1. 关于ww.register,由于做的是第三方应用的h5,所以必填字段:corpId,agentId,jsApiList,getAgentConfigSignature。(getConfigSignature这个场景下可以不填,试过了)
  2. 关于ww.register的getAgentConfigSignature签名(getConfigSignature应该可以cv):jsapi_ticket后端给,noncestr、timestamp前端可自己生成,url直接拿形参的用(签名校验工具:work.weixin.qq.com/api/jsapisi…
  3. h5可以直接在电脑客户端企微调试,链接:developer.work.weixin.qq.com/document/pa…
  4. 每次从入口进入H5,路由进入的还是上次退出时的页面,并不是重启走重定向
  5. 注册jssdk时,电脑端可以同时注册和使用其他api,但手机端必须在注册后使用
  6. jsAPI鉴权,sha1加密用的是插件js-sha1,尝试了写在本地sha1加密(如下代码),本地浏览器是好的,去企微测就报错了'digest undefine'
const hashMessage = async () => {
    try {
        const msgUint8 = new TextEncoder().encode(message.value); // encode as (utf-8) Uint8Array
        const hashBuffer = await crypto.subtle.digest('SHA-1', msgUint8); // hash the message
        const hashArray = Array.from(new Uint8Array(hashBuffer)); // convert buffer to byte array
        const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join(''); // convert bytes to hex string
        hash.value = hashHex;
    } catch (e) {
        console.error(e);
    }
}

后面等遇到再更新吧