1. saveImgToLocal: function(e) {
    2. let me = this;
    3. uni.showModal({
    4. title: '提示',
    5. content: '确定保存到相册吗',
    6. success: function(res) {
    7. if (res.confirm) {
    8. uni.downloadFile({
    9. url: me.kf.kf_img, //图片地址
    10. success: res => {
    11. if (res.statusCode === 200) {
    12. uni.saveImageToPhotosAlbum({
    13. filePath: res.tempFilePath,
    14. success: function() {
    15. uni.showToast({
    16. title: '保存成功',
    17. icon: 'none'
    18. });
    19. },
    20. fail: function() {
    21. uni.showToast({
    22. title: '保存失败',
    23. icon: 'none'
    24. });
    25. }
    26. });
    27. }
    28. }
    29. });
    30. } else if (res.cancel) {
    31. }
    32. }
    33. });
    34. }

    绑定长按事件

    1. @longtap="saveImgToLocal"