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 }); } }); }