同步下载多个图片 downloadFile(url) { const that = this; return new Promise(function (resolve) { wx.downloadFile({ url, success: function (downRes) { if (downRes.statusCode === 200) { wx.getImageInfo({ src: downRes.tempFilePath, success: function (info) { resolve({ info, url: downRes.tempFilePath }); } }); } } }); }); }, downloadFileList(list) { const that = this; let pList = []; for (let i = 0; i < list.length; i++) { pList[i] = that.downloadFile(list[i]); } return Promise.all(pList); }, that.downloadFileList(imgList).then(urlList => { //...todo... });
drawImage,手机端预览,图片不显示图片地址是https [代码]context.setFontSize(20)[代码] [代码]context.fillText(name, width / 2 + 6, [代码][代码]"50"[代码][代码])[代码] [代码]context.drawImage([代码][代码]"https://dl1.loveq.cn/animated_favicon.gif"[代码][代码], width / 2 - 64, 12, 50, 50)[代码] [代码]wx.canvasToTempFilePath({[代码] [代码] [代码][代码]x: 0,[代码] [代码] [代码][代码]y: 0,[代码] [代码] [代码][代码]width: width,[代码] [代码] [代码][代码]height: height,[代码] [代码] [代码][代码]destWidth: width,[代码] [代码] [代码][代码]destHeight: height,[代码] [代码] [代码][代码]canvasId: [代码][代码]'1'[代码][代码],[代码] [代码] [代码][代码]success: [代码][代码]function[代码] [代码](res) {[代码] [代码] [代码][代码]console.log(res.tempFilePath)[代码] [代码] [代码][代码]wx.saveImageToPhotosAlbum({[代码] [代码] [代码][代码]filePath: res.tempFilePath,[代码] [代码] [代码][代码]success(res) {[代码] [代码] [代码][代码]console.log(res)[代码] [代码] [代码][代码]}[代码] [代码] [代码][代码]})[代码] [代码] [代码][代码]}[代码] [图片] [图片] 模拟器的界面正常,控制台都出现了地址,但是手机开发者版本预览,还是显示不了图片,是什么原因?
2018-05-17