如果微信原生的话,此处uni可以换成wx
this.canvas是上一篇文章生成的canvas画布
uni.canvasToTempFilePath({// res.tempFilePath临时路径
canvas: this.canvas,
success: (res) => {
uni.saveImageToPhotosAlbum({ // 保存本地
filePath: res.tempFilePath,
success: (response) => {
console.log(response, 'success');
},
fail: (response) => {
console.log(response, 'error');
uni.openSetting({ //打开权限
success: (response) => {
if(!response.authSetting['scope.writePhotosAlbum']) {
uni.showToast({
title: '获取权限成功, 再次点击即可保存',
icon: none
})
} else {
uni.showToast({
title: '获取权限失败, 无法保存',
icon: none
})
}
}
})
}
})
}
})