|
|
|
|
@ -38,6 +38,42 @@ Component({
|
|
|
|
|
this.setData({
|
|
|
|
|
showModal: false
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
saveImage: function (e) {
|
|
|
|
|
console.log('saveImage', e.currentTarget.dataset.src);
|
|
|
|
|
const imageUrl = e.currentTarget.dataset.src;
|
|
|
|
|
// 给出确认弹窗
|
|
|
|
|
wx.downloadFile({
|
|
|
|
|
url: imageUrl,
|
|
|
|
|
success: res => {
|
|
|
|
|
if (res.statusCode === 200) {
|
|
|
|
|
wx.saveImageToPhotosAlbum({
|
|
|
|
|
filePath: res.tempFilePath,
|
|
|
|
|
success: () => {
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '保存成功',
|
|
|
|
|
icon: 'success'
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
fail: err => {
|
|
|
|
|
console.error('保存失败', err);
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '保存失败',
|
|
|
|
|
icon: 'none'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
fail: err => {
|
|
|
|
|
console.error('下载失败', err);
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '下载失败',
|
|
|
|
|
icon: 'none'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
})
|