亲测有效,vue如果采用的是history路由,第一个页面(首次进入页面),就是授权验证成功的页面(可以简单理解为登录页)
ios14 wx.config报invalid signature?公众号网页,经测试只有ios14出现问题,直接从域名进去是正常可以调用接口的,域名后加上具体路径就会报错
2021-09-09 private getImgBase64(wxLocalIds: string[], index: number) { if (index >= wxLocalIds.length) { return; } const that = this; wx.getLocalImgData({ localId: wxLocalIds[index], success(res: any) { that.localIds.push(res.localData); const tmp = index + 1; that.getImgBase64(wxLocalIds, tmp); }, }); }
for循环上传多张图片,为何IOS系统只调用一次 wx.uploadImage?for (; index < 10; index++) { uploadImageSourceToWeChat(subjectExtend, index).then(function(res) {// do some work }) } function uploadImageSourceToWeChat(subjectExtend, orderNo) { console.log("这里会执行多次") return new Promise(function(resolve, reject) { console.log("这里也会执行多次") setTimeout(function() { wx.uploadImage({ localId: subjectExtend.content[orderNo], isShowProgressTips: 0, success: function success(res) { console.log("这里只执行一次") }, fail: function fail() { alert('上传微信图片失败!'); reject(); } }); }, 100); } ); }
2021-09-08一个递归就解决了 private getImgBase64(wxLocalIds: string[], index: number) { if (index >= wxLocalIds.length) { return; } const that = this; wx.getLocalImgData({ localId: wxLocalIds[index], success(res: any) { that.localIds.push(res.localData); const tmp = index + 1; that.getImgBase64(wxLocalIds, tmp); }, }); }
wx.getlocalimgdata 怎么循环转base64,单图片上传可以,多张图片就不可以?jweixin.chooseImage({ count: checkNumber, // 默认9 sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有 sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有 success: function(res) { let count = checkNumber <= res.localIds.length ? checkNumber : res.localIds.length for (let i = 0; i < count; i++) { jweixin.getLocalImgData({ localId: res.localIds[i], // 图片的localID success: function(res) { const localData = res.localData; let imageBase64 = ''; if (localData.indexOf('data:image') == 0) { //苹果的直接赋值,默认生成'data:image/jpeg;base64,'的头部拼接 imageBase64 = localData; } else { //此处是安卓中的唯一得坑!在拼接前需要对localData进行换行符的全局替换 //此时一个正常的base64图片路径就完美生成赋值到img的src中了 imageBase64 = 'data:image/jpeg;base64,' + localData.replace(/\n/g, ''); } var blobUrl = window.URL.createObjectURL(_this.dataURLtoBlob(imageBase64)); _this.$myUploadFile({ header: {}, filePath: blobUrl }).then(function(response) { _this.addProperties(response.imgs[0]) }) } }); } } });[图片][图片]
2021-09-08