- webview 跳页面调用 getLocation,报错"invalid signature"?
小程序webview内嵌H5,步骤如下: 在首次进入的a页面 "https://xxx.com/a",初始化JS-SDK,获取JS-SDK签名,并调用 "wx.config" 成功跳转下一个b页面"https://xxx.com/b"此时在b页面有两种情况: A. iOS:调用 "wx.getLocation"、"wx.chooseImage" 都能成功 B. Android:调用 "wx.getLocation" 提示 "getLocation:invalid signature",而调用 "wx.chooseImage" 却能成功 社区看了一圈的说法是iOS只需要在首个页面时签名,而Android需要在每个页面都重新签名,但为什么不同的API行为不一样?"wx.chooseImage"不需要重新签名,而 "wx.getLocation" 则需要?
2023-08-05 - 360手机 N6 Pro wx.uploadFile 失败
360手机 N6 Pro,iPhone 8 Plus(MQ8F2CH/A),使用wx.chooseImage拍照,wx.compressImage压缩图片后调用wx.uploadFile报错,在wx.uploadFile的success回调里拿到了上传报错信息,没有走fail回调。其他机型未发现问题。 图片路径获取正常: [图片] 代码片段: function wxChooseImageWeb(quality = default_quality, count = 1, sourceType = ['camera'], sizeType = ['compressed']) { return new Promise((resolve, reject) => { chooseImage(count, sourceType, sizeType).then(tempFiles => { compressImage(tempFiles[0].path, quality).then(compressImagePath => { upLoadImage(compressImagePath).then(res => { resolve(res.data); }).catch(res => { reject(res); }) }).catch(() => { upLoadImage(tempFiles[0].path).then(res => { resolve(res.data); }).catch(res => { reject(res); }) }); }).catch(res => { reject(res); }); }) } function chooseImage(count = 1, sourceType = ['camera'], sizeType = ['compressed']) { return new Promise((resolve, reject) => { wx.chooseImage({ count: count, sizeType: sizeType, sourceType: sourceType, success(res) { const tempFiles = res.tempFiles resolve(tempFiles); }, fail(res) { log.warn("调起选择照片组件错误(chooseImage)"); log.warn({res}); reject(res); } }) }) } function compressImage(filePath, quality = default_quality) { return new Promise((resolve, reject) => { wx.compressImage({ src: filePath, // 图片路径 quality: quality, // 压缩质量 success(res) { console.log('压缩图片路径:', res.tempFilePath) resolve(res.tempFilePath); }, fail(res) { log.warn("压缩图片错误(compressImage)"); log.warn({res}); log.warn(res.errMsg) reject(res); } }) }) } function upLoadImage(filePath) { console.log('upload image filePath', filePath) return new Promise((resolve, reject) => { wx.uploadFile({ url: config.imgUpload, filePath: filePath, header: { "Content-Type": "multipart/form-data; boundary=----pxt1Wc2xg7qmKkE6pyH" }, name: 'file', success: function (res) { // 在success里这里拿到了上传报错信息,没有走fail res.data = JSON.parse(res.data); console.log('res.data', res.data) util.resultUtil(res).then(() => { resolve(res.data); }).catch(() => { reject(res.data); }); }, fail: function(err) { console.log(err) } }) }
2022-02-17