1
0
Code Issues Pull Requests Packages Projects Releases Wiki Activity GitHub Gitee
epp/weixin-miniprogram/utils/scanQRCode.js

26 lines
635 B
JavaScript
Raw Normal View History

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;