手机获取nfc-id数组中的数据

This commit is contained in:
WindowBird 2025-11-20 14:19:02 +08:00
parent b51f87790f
commit cb37e2355f

View File

@ -19,9 +19,7 @@
</view> </view>
<view v-if="nfcSupported" class="nfc-status"> <view v-if="nfcSupported" class="nfc-status">
<view class="nfc-status-header"> <view class="nfc-status-header">
<view <view :class="['status-dot', nfcEnabled ? 'online' : 'offline']" />
:class="['status-dot', nfcEnabled ? 'online' : 'offline']"
/>
<text class="nfc-status-title">{{ nfcStatusText }}</text> <text class="nfc-status-title">{{ nfcStatusText }}</text>
</view> </view>
<view v-if="nfcError" class="nfc-error-text"> <view v-if="nfcError" class="nfc-error-text">
@ -676,17 +674,18 @@ export default {
console.log("=== NFC 卡号提取详情 ==="); console.log("=== NFC 卡号提取详情 ===");
console.log("ArrayBuffer 字节长度:", res.id.byteLength); console.log("ArrayBuffer 字节长度:", res.id.byteLength);
console.log("ArrayBuffer 字节数组(十进制):", bytes); console.log("ArrayBuffer 字节数组(十进制):", bytes);
console.log("ArrayBuffer 字节数组(十六进制):", bytes.map(b => "0x" + b.toString(16).padStart(2, "0").toUpperCase())); console.log(
"ArrayBuffer 字节数组(十六进制):",
bytes.map(
(b) => "0x" + b.toString(16).padStart(2, "0").toUpperCase(),
),
);
// 0 // 0
// NFC // NFC
cardNo = bytes cardNo = bytes.join("").toUpperCase();
.join("")
.toUpperCase();
// [0, 0, 5, 32] "00000520" console.log("转换后的卡号(十进制字符串):", cardNo);
// [32, 5, 0, 0] "20050000"
console.log("转换后的卡号(十六进制字符串):", cardNo);
console.log("卡号长度:", cardNo.length, "字符"); console.log("卡号长度:", cardNo.length, "字符");
console.log("========================"); console.log("========================");
} else if (typeof res.id === "string") { } else if (typeof res.id === "string") {