和隔壁画布隐藏一起,卡了我几个小时…
保存相册失败后,再次授权
// 下载
btn() {
uni.canvasToTempFilePath({
// x: 100,
// y: 200,
// width: 50,
// height: 50,
// destWidth: 100,
// destHeight: 100,
fileType: 'jpg',
canvasId: 'myCanvas',
success: function(res) {
// 在H5平台下,tempFilePath 为 base64
console.log(res.tempFilePath)
uni.saveImageToPhotosAlbum({
filePath: res.tempFilePath,
success: () => {
console.log('save success');
uni.showToast({
title: '下载成功,请进入相册查看',
duration: 2000
});
},
fail: (err) => {
if (err.errMsg === 'saveImageToPhotosAlbum:fail auth deny') {
uni.showModal({
content: '检测到您没打开获取信息功能权限,是否去设置打开?',
confirmText: "确认",
cancelText: '取消',
success: (res) => {
if (res.confirm) {
uni.openSetting({
success: (res) => {
console.log(res);
uni.showToast({
icon: "none",
title: "请重新点击联单下载保存图片"
});
}
})
} else {
uni.showToast({
icon: "none",
title: "保存失败,请打开权限功能重试"
});
}
}
})
} else {
// console.log(res);
uni.showToast({
icon: 'none',
title: '下载失败:' + err.errMsg
});
}
}
});
画布要下载必须有这个dom,所有v-if和v-show都没用,宽高0也没用,用下面这css,可以让他在页面上又不显示
position: fixed;
left: 100%;