完善提示

This commit is contained in:
kron
2025-08-06 11:37:24 +08:00
parent 5191f33fce
commit b286a236ee

View File

@@ -22,14 +22,22 @@ const handleScan = () => {
onlyFromCamera: true, onlyFromCamera: true,
scanType: ["qrCode"], scanType: ["qrCode"],
success: async (res) => { success: async (res) => {
const base64Decode = (str) => { try {
// 将 base64 转换为 utf8 字符串 const base64Decode = (str) => {
const bytes = wx.base64ToArrayBuffer(str); // 将 base64 转换为 utf8 字符串
return String.fromCharCode.apply(null, new Uint8Array(bytes)); const bytes = wx.base64ToArrayBuffer(str);
}; return String.fromCharCode.apply(null, new Uint8Array(bytes));
};
addDevice.value = JSON.parse(base64Decode(res.result)); addDevice.value = JSON.parse(base64Decode(res.result));
confirmBindTip.value = true; confirmBindTip.value = true;
} catch (err) {
uni.showToast({
title: "无效二维码",
icon: "none",
duration: 2000,
});
}
}, },
fail: (err) => { fail: (err) => {
console.error("扫码失败:", err); console.error("扫码失败:", err);