jssdk chooseImage 没有回调
发布于 6 年前 作者 yongcai 943 次浏览 来自 问答
  • 当前 Bug 的表现(可附上截图)

  • 小程序内嵌 web-view 和 普通的 webview

  • jssdk 调用 chooseImage ,选择相册图片,没有回调(success 与 fail 都没有)

  • 拍照可以,但选择不可以

  • 机型是 iphone 5s IOS10.3.3

  • 预期表现

可以选择图片

  • 复现路径
function wechatImageHandler() {
    let wx = window.wx;
    return new Promise((resolve, reject) => {
        let config = {
            debug: false,
            jsApiList: ['chooseImage', 'getLocalImgData'],
            appId: WECHAT_SIGN.appId,
            nonceStr: WECHAT_SIGN.nonceStr,
            signature: WECHAT_SIGN.signature,
            timestamp: WECHAT_SIGN.timestamp,
        };
 
        wx.config(config);
        wx.ready(() => {
            alert("choose");
            wx.chooseImage({
                count: 1, // 默认9
                sizeType: ['compressed'], // 可以指定是原图还是压缩图,默认二者都有
                sourceType: ["album", "camera"], // 可以指定来源是相册还是相机,默认二者都有
                success: function (tempFilePaths) {
                    alert("chooseSuccess");
                    let localId = tempFilePaths.localIds[0];
                    wx.getLocalImgData({
                        localId: localId,
                        success: function (res) {
                            alert("getSuccess");
                            let base64SplitArray = res.localData.split(",");
                            // 微信 sdk 转换出来的 base64 格式是 jgp,此处做个兼容
                            base64SplitArray[0] = base64SplitArray[0].replace("image/jgp", "image/jpeg");
                            let base64String = base64SplitArray.join(",");
 
                            resolve(base64String);
                        },
                        fail: function (res) {
                            reject();
                        }
                    });
                },
                fail(res) {
                    alert("fail")
                }
            });
        });
    });
}
  • 提供一个最简复现 Demo
  • 你们的 jssdk demo

http://203.195.235.76/jssdk/

3 回复

麻烦给个相关的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html),我们定位下问题

你好,请问你的签名是小程序的还是公众号的?

回到顶部