clickCanvas() {
console.log("点击按钮保存");
let rpx = this.rpx;
let that = this;
// let width = 357 * rpx;
// let height = 579 * rpx;
let width = that.canvasWidth;
let height = that.canvasHeight;
Taro.canvasToTempFilePath({
x: 0,
y: 0,
width,
height,
destWidth: width,
destHeight: height,
quality: 1,
fileType: "jpg",
canvasId: "poster",
success: function(res) {
wx.saveImageToPhotosAlbum({
filePath: res.tempFilePath,
success: result => {
Taro.showToast({
title: "保存成功,从相册中分享到朋友圈吧!",
icon: "none"
});
},
fail: err => {
if (
err.errMsg ===
"saveImageToPhotosAlbum:fail:auth denied" ||
err.errMsg ===
"saveImageToPhotosAlbum:fail auth deny"
) {
Taro.showModal({
title: "提示",
content: "需要您授权保存相册",
showCancel: false,
success: modalSuccess => {
Taro.openSetting({
success(settingdata) {
if (
settingdata.authSetting[
"scope.writePhotosAlbum"
]
) {
Taro.showModal({
title: "提示",
content:
"获取权限成功,再次点击即可保存",
showCancel: false
});
} else {
Taro.showModal({
title: "提示",
content:
"获取权限失败,将无法保存到相册哦~",
showCancel: false
});
}
},
fail(failData) {},
complete(finishData) {}
});
}
});
}
}
});
}
});
},
相关文章:
- 微信小程序点击按钮将图片保存到手机 2021-11-08
- 微信小程序点击保存图片到本机 2021-04-18
- 小程序保存图片到手机相册 2022-12-23
- 微信小程序授权保存到相册功能 2021-12-15
- 微信小程序 webview 截图 保存相册 2021-07-13
- Taro -- 微信小程序长按图片保存到相册 2021-11-24
- 微信小程序canvas 生成海报保存到相册 2021-12-29