代码如下
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