- 安卓手机微信8.0.7上传bug,调用wx.uploadImage无响应?
window.wx.uploadImage({ localId: localId.toString(), isShowProgressTips: 0, success: (res) => { console.log(res,'success'); }, fail: (err) => { console.log(err,'errrrrr') }, }); 安卓手机内即不执行success 也不执行 fail 微信版本:8.0.7 android: 11.0.0.139 js sdk: 1.6.0 大量用户反馈,已经严重影响用户操作
2021-07-07 - 调用wx.uploadImage 返回 "errMsg":"uploadImage:fail"
chooseImage = () => { this.localIds = []; this.tempVisits = []; this.imageNum = 0; this.serverIds = []; window.wx.chooseImage({ count: this.option.limit, success: (res) => { this.localIds = res.localIds; // ["wxLocalRe*://5645646454"] this.timeoutKey = setTimeout(this.startUpload, 200); }, fail: () => { this.reject('无选择图片权限'); }, }); } startUpload = async () => { this.option.startUpload(); try { await Promise.all(this.localIds.map((localId, index) => this.uploadImg(localId, index))) this.uploadSuccess(); } catch (error) { this.reject(error); } } uploadSuccess = () => { this.resolve && this.resolve({ serverIds: this.serverIds, localIds: this.tempVisits, }); }; uploadImg = (localId, index) => { return new Promise((resolve) => { const _img = document.createElement('img'); const load = (type) => { window.wx.uploadImage({ localId, isShowProgressTips: 0, success: (res) => { const uploadHandel = async () => { try { // 上报第三方下载链接 let uploadResult = await this.reportThirdUploadResult(res.serverId); this.serverIds.push(uploadResult.filename); this.tempVisits.push(uploadResult.tempVisit); } catch (err) { console.log('上报三方下载链接err:::', err); } resolve() }; if (type == 'onerror') { window.wx.getLocalImgData({ localId, // 图片的localID success: (LocalRes) => { this.localIds[index] = LocalRes.localData; _img.src = this.localIds[index]; _img.onerror = uploadHandel; _img.onload = uploadHandel; }, }); } else { uploadHandel(); } }, fail: (err) => { this.reject && this.reject(err); }, }); }; _img.onload = () => load('onload'); _img.onerror = () => load('onerror'); _img.src = localId; }) }
2021-04-26