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

28 lines
781 B
JavaScript

function scanQRCode(wx) {
// 只允许从相机扫码
wx.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')) {
// let scene = searchParams[1].substring(searchParams[1].indexOf('='))
console.log("searchParams", searchParams)
wx.navigateTo({
url: "/pages/scan/entrance?" + searchParams[1]
})
return
}
}
wx.showToast({
title: "您扫描的不是门禁码",
icon: 'error',
duration: 2000
})
}
})
}
module.exports = scanQRCode;