洛阳学员端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

40 lines
955 B

export let downloadImg = function (imageUrl) {
uni.downloadFile({
url: imageUrl,
success(res) {
if (res.statusCode === 200) {
// 下载成功后,获取临时文件路径
const tempFilePath = res.tempFilePath;
// 保存图片到本地相册
uni.saveImageToPhotosAlbum({
filePath: tempFilePath,
success() {
uni.showToast({
title: '图片保存成功',
icon: 'success',
duration: 2000
});
},
fail(err) {
console.error('保存图片失败', err);
uni.showToast({
title: '图片保存失败',
icon: 'none',
duration: 2000
});
}
});
}
},
fail(err) {
console.error('下载图片失败', err);
uni.showToast({
title: '图片下载失败',
icon: 'none',
duration: 2000
});
}
});
}