打开相册又出现扫码的bug
This commit is contained in:
parent
0c6ce09506
commit
f6ed231d12
|
|
@ -106,17 +106,40 @@ export default {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// 从相册选择图片并识别二维码
|
||||||
chooseFromAlbum() {
|
chooseFromAlbum() {
|
||||||
uni.chooseImage({
|
uni.chooseImage({
|
||||||
count: 1,
|
count: 1,
|
||||||
|
sourceType: ['album'], // 仅限相册
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
|
const filePath = res.tempFilePaths[0];
|
||||||
|
uni.showLoading({ title: '识别中...' });
|
||||||
|
|
||||||
|
// #ifdef APP-PLUS
|
||||||
|
// 调用 App 底层引擎,静默解析本地图片,绝不弹出原生扫码界面
|
||||||
|
plus.barcode.scan(
|
||||||
|
filePath,
|
||||||
|
(type, result) => {
|
||||||
|
uni.hideLoading();
|
||||||
|
// 成功识别到二维码,直接将内容丢给你的处理逻辑
|
||||||
|
this.handleCodeResult(result);
|
||||||
|
},
|
||||||
|
(error) => {
|
||||||
|
uni.hideLoading();
|
||||||
|
uni.showToast({ title: '未识别到有效二维码', icon: 'none' });
|
||||||
|
}
|
||||||
|
);
|
||||||
|
// #endif
|
||||||
|
|
||||||
|
// #ifndef APP-PLUS
|
||||||
|
// 非 App 环境(比如小程序兜底),才走普通的 scanCode
|
||||||
|
uni.hideLoading();
|
||||||
uni.scanCode({
|
uni.scanCode({
|
||||||
onlyFromCamera: false,
|
|
||||||
scanType: ['qrCode'],
|
|
||||||
success: (scanRes) => {
|
success: (scanRes) => {
|
||||||
this.handleCodeResult(scanRes.result);
|
this.handleCodeResult(scanRes.result);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
// #endif
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue