//读取NFC标签
readNFC(){
let app = this;
wx.nfc = wx.getNFCAdapter();
wx.nfc.startDiscovery({
success: (res) => {
console.log('NFC发现成功', res);
wx.nfc.onDiscovered((res) => {
wx.showToast({
title: JSON.stringify(res),
icon: 'none'
});
app.$modal.alert('res',JSON.stringify(res))
app.$modal.alert('res.messages',JSON.stringify(res.techs))
app.$modal.alert('res.messages[0]',JSON.stringify(res.messages[0]))
const nfcData = res.messages[0].Text;
app.nfcData=nfcData;
let Ndef = wx.nfc.getNdef();
let NfcA = wx.nfc.getNfcA();
NfcA.connect({
success:(res)=>{
app.$modal.alert('nfca3',JSON.stringify(res))
NfcA.getAtqa({success:(res)=>{
app.$modal.alert('Atqa',JSON.stringify(res))
}})
NfcA.getSak({success:(res)=>{
app.$modal.alert('Sak',JSON.stringify(res))
}})
}
}
)
Ndef.connect({
success:(res)=>{
app.$modal.alert('onNdef3',JSON.stringify(res))
Ndef.onNdefMessage((res)=>{
app.$modal.alert('onNdef4',JSON.stringify(res))
})
}
}
)
}
);
},
fail: (err) => {
console.error('NFC发现失败', err);
wx.showToast({
title: 'NFC发现失败',
icon: 'none'
});
}
});
},
{"records":[{"tnf":2,"type": ,"id"@,"payload":{}]}
res.messages[0]