扫码
This commit is contained in:
@@ -20,7 +20,8 @@
|
|||||||
"Geolocation" : {},
|
"Geolocation" : {},
|
||||||
"Camera" : {},
|
"Camera" : {},
|
||||||
"Push" : {},
|
"Push" : {},
|
||||||
"Bluetooth": {}
|
"Bluetooth" : {},
|
||||||
|
"Barcode" : {}
|
||||||
},
|
},
|
||||||
"distribute" : {
|
"distribute" : {
|
||||||
"android" : {
|
"android" : {
|
||||||
|
|||||||
@@ -86,12 +86,29 @@ function handleClick() {
|
|||||||
function handleScan() {
|
function handleScan() {
|
||||||
uni.scanCode({
|
uni.scanCode({
|
||||||
scanType: ['barCode', 'qrCode', 'datamatrix', 'pdf417'],
|
scanType: ['barCode', 'qrCode', 'datamatrix', 'pdf417'],
|
||||||
success: function (res) {
|
autoZoom: true, // iOS 自动对焦优化
|
||||||
|
onlyFromCamera: false, // 允许从相册选取图片识别码
|
||||||
|
success: res => {
|
||||||
formData.value.deviceCode = res.result
|
formData.value.deviceCode = res.result
|
||||||
},
|
},
|
||||||
error: err => {
|
fail: err => {
|
||||||
|
// 判断相机权限被拒场景
|
||||||
|
if (err.errMsg.includes('permission') || err.errMsg.includes('camera')) {
|
||||||
|
uni.showModal({
|
||||||
|
title: '权限不足',
|
||||||
|
content: '需要相机权限才能扫码,请前往系统设置开启',
|
||||||
|
confirmText: '去设置',
|
||||||
|
success: modalRes => {
|
||||||
|
if (modalRes.confirm) {
|
||||||
|
// APP端跳转系统设置(iOS/安卓通用)
|
||||||
|
plus.runtime.openURL('app-settings://')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
icon: 'error',
|
icon: 'none',
|
||||||
title: '扫描异常'
|
title: '扫描异常'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user