@wx.saveImageToPhotosAlbum
微信小程序–保存图片到相册 失败:saveImageToPhotosAlbum:fail auth deny
是否授权了保存功能 wx.openSetting()
附上代码:
wx.saveImageToPhotosAlbum({
filePath: _this.data.posterImg,
success(res) {
wx.showModal({
title: '提示',
content: '保存成功,可以去相册查找',
showCancel: false,
})
},
fail() {
wx.showModal({
title: '提示',
content: '需要您授权保存相册',
showCancel: false,
success() {
wx.openSetting({
success(settingdata) {
if (settingdata.authSetting['scope.writePhotosAlbum']) {
wx.showModal({
title: '提示',
content: '获取权限成功,再次保存图片即可成功',
showCancel: false,
})
} else {
wx.showModal({
title: '提示',
content: '获取权限失败,无法保存到相册',
showCancel: false,
})
}
},
complete(comp) {
console.log("complete", finishData)
}
})
}
})
}
}) wx.saveImageToPhotosAlbum({
filePath: filePath,//图片地址
success(res) {
wx.showModal({
title: '提示',
content: '保存成功,可以去相册查找',
showCancel: false,
})
},
fail() {
wx.showModal({
title: '提示',
content: '需要您授权保存相册',
showCancel: false,
success() {
wx.openSetting({
success(settingdata) {
if (settingdata.authSetting['scope.writePhotosAlbum']) {//是否授权保存到相册
wx.showModal({
title: '提示',
content: '获取权限成功,再次保存图片即可成功',
showCancel: false,
})
} else {
wx.showModal({
title: '提示',
content: '获取权限失败,无法保存到相册',
showCancel: false,
})
}
},
complete(complet) {
console.log("complet", complet)
}
})
}
})
}
})