是啊,这几天客户反馈过来,确实有这个问题,赶紧修复修复
调用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-27