微信小程序下载图片功能代码demo

bindseaveimage:function(){

   wx.getImageInfo({

     src: this.data.imagecode,//这里放你要下载图片的数组(多张) 或 字符串(一张) 下面代码不用改动

     success: function (ret) {

       var path = ret.path;

       wx.saveImageToPhotosAlbum({

         filePath: path,

         success(result) {

           console.log("成功");

           wx.hideLoading();

           wx.showToast({

             title: '下载图片成功',

             duration: 2000,

             mask: true,

           });

         },

         fail(result) {

           console.log("失败,你取消了" + JSON.stringify(result))

           console.log(path);

           wx.openSetting({

             success: (res) => {

               console.log(res);

             }

           })

         }

       });

     }

   });

 }