随笔 - 18  文章 - 0 评论 - 0 阅读 - 23328
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

// 保存图片至相册
			saveImg() {
				//获取文件管理器对象
				const fs = wx.getFileSystemManager()
				//文件保存路径
				const Imgpath = wx.env.USER_DATA_PATH + '/qrcodeImg' + '.png'
				//base64图片文件
				let imageSrc = this.src.replace(/^data:image\/\w+;base64,/, '')

				//写入本地文件
				fs.writeFile({
					filePath: Imgpath,
					data: imageSrc,
					encoding: 'base64',
					success(res) {
						console.log(res)

						//保存到手机相册
						wx.saveImageToPhotosAlbum({
							filePath: Imgpath,
							success(res) {
								console.log(res)
								wx.showToast({
									title: '保存成功',
									icon: 'success'
								})
							},
							fail: function(err) {
								console.log("失败了")
								console.log(err)
							}
						})
					}
				})
			}
posted on   无聊猿  阅读(289)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· Ollama——大语言模型本地部署的极速利器
· 使用C#创建一个MCP客户端
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· Windows编程----内核对象竟然如此简单?
· ollama系列1:轻松3步本地部署deepseek,普通电脑可用
点击右上角即可分享
微信分享提示