2023-04-15 23:47:18 +08:00
|
|
|
function scanQRCode(wx) {
|
2023-03-17 04:55:02 +08:00
|
|
|
// 只允许从相机扫码
|
2023-04-15 23:47:18 +08:00
|
|
|
wx.scanCode({
|
2023-03-17 04:55:02 +08:00
|
|
|
onlyFromCamera: true,
|
|
|
|
success(res) {
|
|
|
|
console.log(res)
|
|
|
|
if (res.scanType == "WX_CODE" && res.path) {
|
2023-04-16 16:56:56 +08:00
|
|
|
// console.log("res.path", res.path)
|
|
|
|
// res.path pages/index/index?scene=guard;1758617522619420679
|
2023-03-17 04:55:02 +08:00
|
|
|
let searchParams = res.path.split('?');
|
2023-04-16 16:56:56 +08:00
|
|
|
let params = searchParams[1]
|
|
|
|
console.log("searchParams", searchParams, "params", params)
|
|
|
|
if (params && params.startsWith('scene=guard')) {
|
2023-04-15 23:47:18 +08:00
|
|
|
wx.navigateTo({
|
2023-04-16 16:56:56 +08:00
|
|
|
url: "/pages/scan/entrance?" + params
|
2023-03-17 04:55:02 +08:00
|
|
|
})
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
2023-04-15 23:47:18 +08:00
|
|
|
wx.showToast({
|
2023-03-17 04:55:02 +08:00
|
|
|
title: "您扫描的不是门禁码",
|
|
|
|
icon: 'error',
|
|
|
|
duration: 2000
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = scanQRCode;
|