wx.downloadFile({
url: im.imageUrl,
success: res=> {
if (res.statusCode === 200) {
wx.saveImageToPhotosAlbum({
filePath: res.tempFilePath,
success: res2 => {
wx.showToast({ title: ‘保存成功’, icon: ‘success’, duration: 2000 });
},
fail: res2 => {
if (res2.errMsg === ‘saveImageToPhotosAlbum:fail cancel’) {
wx.showToast({ title: ‘保存失败’, icon: ‘none’, duration: 2000 });
} else {
this.setData({ tipSaveImg: true });
}
}
})
} else {
wx.showToast({
title: ‘状态’,
})
}
},
fail:res=> {
wx.showToast({
title: ‘图片下载失败’,
})
console.log(res)
}
})
},
这个是代码