首页 > 其他分享 >uniapp 拍照并转为base64格式

uniapp 拍照并转为base64格式

时间:2024-09-05 11:55:30浏览次数:6  
标签:uniapp 拍照 title res base64 rel uni data

代码如下

            doIdentify() {
				let ctx = uni.createCameraContext();
				ctx.takePhoto({
					quality: 'high',
					success: res => {
						this.shooting = false;
						this.tempImg = res.tempImagePath;
						uni.showLoading({
							title: '识别中'
						})
						uni.getFileSystemManager().readFile({
							filePath: res.tempImagePath,
							encoding: 'base64',
							success: imgInfo => {
								request.post('marketing/product/search', {
									picture: 'data:image/jpeg;base64,' + imgInfo.data
								}).then(rel => {
									uni.hideLoading();
									this.isBottle = rel.data.result;
									if (this.isBottle) return;
									uni.showToast({
										title: '没识别出来呢,再拍一次吧',
										duration: 1000
									})
									setTimeout(this.reShoot, 500)
								})
							},
						});
					}
				})
			},

标签:uniapp,拍照,title,res,base64,rel,uni,data
From: https://blog.csdn.net/CZDBGSY/article/details/141888941

相关文章