uniapp保存网络图片到相册
//下载网络图片
saveHttpImg(url){
let _t = this;
uni.downloadFile({
url:url, //仅为示例,并非真实的资源
success: (res) => {
if (res.statusCode === 200) {
let file = res.tempFilePath;
_t.save(file)
}
}
});
},
//保存图片到本地
save(url){
let _this = this;
_this.$util._loading("保存中...");
uni.saveImageToPhotosAlbum({
filePath: url,
success: () => {
uni.hideLoading();
_this.$util._toast("图片已保存");
},
fail: () => {
uni.hideLoading();
_this.$util._toast("保存失败");
},
complete: () => {
}
});
},