网络图片保存到本地 调用downloadfile后在真机临时文件路径有问题
所以给一个固定路径使用:filePath1
let fileName = new Date().valueOf();
let filePath1 = wx.env.USER_DATA_PATH + '/' + fileName + '.jpg'
uni.downloadFile({
url: this.host + filePath,
filePath: filePath1,
success: (res) => {
if (res.statusCode === 200) {
this.saveImage(filePath1)
// uni.saveImageToPhotosAlbum({
// filePath: res.tempFilePath,
// success: function() {
// uni.showToast({
// title: "保存成功",
// icon: "none"
// });
// },
// fail: function() {
// uni.showToast({
// title: "保存失败,请稍后重试",
// icon: "none"
// });
// }
// });
}
}
})