调用图片downloadFile下载成功但是临时路径为空?
在模拟器上是可以实现的。但是在iphoneX上。statusCode:200 .TempFilePath:wxfile:// 就没有然后了。
wx.downloadFile({ url: 'https://www.parrotfamily.cn/static/image/2019/鉴定卡.jpg', success(res) { that.showToast(JSON.stringify(res),300000); console.log('res:' + JSON.stringify(res)); if (res.statusCode === 200) { //缓存图片 const fs = wx.getFileSystemManager() fs.saveFile({ tempFilePath: res.tempFilePath, // 传入一个临时文件路径 success(res) { that.showToast('保存成功',JSON.stringify(res), 30000); that.setData({ bgImage: res.savedFilePath, downImageState:true, }) wx.setStorageSync('image_cache', res.savedFilePath) }, fail(res){ that.showToast('保存失败', JSON.stringify(res), 30000); } }) } }, fail(res){ this.showToast('下载图片失败',2000); that.setData({ downImageState: false, }) } }); |
