26 lines
635 B
JavaScript
26 lines
635 B
JavaScript
|
function scanQRCode(Taro) {
|
||
|
// 只允许从相机扫码
|
||
|
Taro.scanCode({
|
||
|
onlyFromCamera: true,
|
||
|
success(res) {
|
||
|
console.log(res)
|
||
|
if (res.scanType == "WX_CODE" && res.path) {
|
||
|
let searchParams = res.path.split('?');
|
||
|
if (searchParams.length > 1 && searchParams[1].startsWith('scene=guard')) {
|
||
|
Taro.navigateTo({
|
||
|
url: "/pages/scan/entrance"
|
||
|
})
|
||
|
return
|
||
|
}
|
||
|
}
|
||
|
Taro.showToast({
|
||
|
title: "您扫描的不是门禁码",
|
||
|
icon: 'error',
|
||
|
duration: 2000
|
||
|
})
|
||
|
}
|
||
|
})
|
||
|
}
|
||
|
|
||
|
module.exports = scanQRCode;
|