收藏
回答

jssdk chooseImage 没有回调

框架类型 问题类型 操作系统 操作系统版本 手机型号 微信版本
小程序 Bug iOS IOS10.3.3 iphone 5s 6.7.1

- 当前 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 个回答

登录 后发表内容