图片上传

parent 34c97c57
...@@ -145,44 +145,44 @@ const convertSize = (sizeInKB) => { ...@@ -145,44 +145,44 @@ const convertSize = (sizeInKB) => {
// 下载图片 // 下载图片
const handleDownload = () => { const handleDownload = () => {
uni.downloadFile({ // uni.downloadFile({
url: previewImages.value[index.value], // url: previewImages.value[index.value],
success: (res) => { // success: (res) => {
if (res.statusCode === 200) { // if (res.statusCode === 200) {
// 保存图片到相册 // // 保存图片到相册
plus.gallery.save(res.tempFilePath, () => { // plus.gallery.save(res.tempFilePath, () => {
uni.showToast({ // uni.showToast({
title: '图片保存成功', // title: '图片保存成功',
icon: 'success' // icon: 'success'
}); // });
}, (err) => { // }, (err) => {
console.error('保存图片失败', err); // console.error('保存图片失败', err);
uni.showToast({ // uni.showToast({
title: '图片保存失败', // title: '图片保存失败',
icon: 'none' // icon: 'none'
}); // });
}); // });
} else { // } else {
console.error('图片下载失败'); // console.error('图片下载失败');
} // }
}, fail: (err) => { // }, fail: (err) => {
console.error('图片下载失败', err); // console.error('图片下载失败', err);
} // }
});
// xma.downloadFile({
// url: previewImages.value[index.value], // 替换为你要下载的图片URL
// success: (res) => {
// if (res.statusCode === 200) {
// // 下载成功后保存图片到相册
// saveImage(res.tempFilePath);
// } else {
// console.error('下载图片失败');
// }
// },
// fail: (err) => {
// console.error('下载图片失败', err);
// }
// }); // });
xma.downloadFile({
url: previewImages.value[index.value], // 替换为你要下载的图片URL
success: (res) => {
if (res.statusCode === 200) {
// 下载成功后保存图片到相册
saveImage(res.tempFilePath);
} else {
console.error('下载图片失败');
}
},
fail: (err) => {
console.error('下载图片失败', err);
}
});
} }
// function saveImage(filePath) { // function saveImage(filePath) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment