downloadImg:function(e){//触发函数console.log(e.currentTarget.dataset.url)wx.downloadFile({url:e.currentTarget.dataset.url,//需要下载的图片urlsuccess:function(res){//成功后的回调函数wx.saveImageToPhotosAlbum({//保存到本地filePath:res.tempFilePath,success(res){wx.showToast({title:'保存成功',icon:'success',duration:2000})},fail:function(err){if(err.errMsg==="saveImageToPhotosAlbum:failauthdeny"){wx.openSetting({success(settingdata){console.log(settingdata)if(settingdata.authSetting['scope.writePhotosAlbum']){console.log('获取权限成功,给出再次点击图片保存到相册的提示。')}else{console.log('获取权限失败,给出不给权限就无法正常使用的提示')}}})}}})}});},

TAG标签: 微信小程序小程序下载微信图片

http://www.xiaochengxub.com/read-107989.html