uni.authorize({
scope: "scope.writePhotosAlbum",
success: (success) => {
// 保存图片到本地
this.saveImg()
},
fail: (fail) => {
uni.getSetting({
success: (setting) => {
// 不允许保存
if (setting.authSetting["scope.writePhotosAlbum"] == false) {
wx.showModal({
title: "温馨提示",
content: "请允许小程序保存相册或视频",
success: (res) => {
if (res.confirm) {
wx.openSetting();
}
},
});
} else {
// 保存图片到本地
this.saveImg();
}
},
});
}
})
// 保存图片方法
saveImg() {
console.log('this.codeImage', this.codeImage);
uni.saveImageToPhotosAlbum({
filePath: this.codeImage,
success: () => {
uni.showToast({
title: "图片保存成功",
icon: "success",
});
},
fail: (fail) => {
console.log('fail', fail);
uni.showToast({
title: "图片未保存",
icon: "none",
});
},
});
},
|