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