- 为什么NFC读写报参数错误13011参数错误?
writeNFC() { let app = this; // 获取NFC适配器实例 const nfc = wx.getNFCAdapter(); // 检查NFC是否可用 nfc.startDiscovery({ success: (res) => { console.log('NFC发现成功', res); // 监听NFC标签发现 nfc.onDiscovered((res) => { console.log('NFC标签发现', res); // 打印完整的发现结果 if (res.messages && res.messages.length > 0) { const nfcData = res.messages[0]; console.log('NFC数据', nfcData); // 打印具体的NFC数据 app.$modal.alert('NFC数据tnf1', JSON.stringify(nfcData)); // 准备要写入的NDEF数据 const ndefMessage = [{ tnf: 2, // URI类型 type: '', id: '', payload: 'https://www.example.com' }]; let Ndef = nfc.getNdef(); Ndef.connect({success:(res)=>{ wx.showToast({ title: 'nde连接成功', icon: 'success' }) // 写入NDEF数据 const apduCommand = new Uint8Array(); Ndef.writeNdefMessage({ texts: ['Hello World', '小程序NFC测试'], success: (res) => { console.log('写入成功', res); wx.showToast({ title: '写入成功', icon: 'success' }); }, fail: (err) => { console.error('写入失败', err); app.$modal.alert('写入失败', JSON.stringify(err)); wx.showToast({ title: '写入失败', icon: 'none' }); } }); Ndef.onNdefMessage((res) => { console.log('NFC标签发现', res); // 打印完整的发现结果 app.$modal.alert('NFC数据res', JSON.stringify(res)); if (res.messages && res.messages.length > 0) { const nfcData = res.messages[0]; console.log('NFC数据', nfcData); // 打印具体的NFC数据 if (nfcData.records && nfcData.records.length > 0) { nfcData.records.forEach(record => { if (record.tnf === 2) { // 处理URI类型 try { const uri = record.type + record.payload; console.log('解析的URI:', uri); app.$modal.alert('解析的URI', uri); } catch (e) { console.error('解析URI失败', e); } } else if (record.tnf === 1) { // 处理其他类型的NDEF记录 console.log('NDEF记录', record); app.$modal.alert('NFC数据tnf1', JSON.stringify(record)); } }); } else { console.error('NFC记录为空'); } } else { console.error('没有发现NFC标签'); } }); }}) } else { console.error('没有发现NFC标签'); } }); }, fail: (err) => { console.error('NFC发现失败', err); wx.showToast({ title: 'NFC不可用', icon: 'none' }); } }); },
05-08 - 写入NDEF数据数据失败,报错码13011?
// 写入NDEF数据 Ndef.writeNdefMessage({ texts: ['12312收到'], success: (res) => { console.log('写入成功', res); wx.showToast({ title: '写入成功', icon: 'success' }); }, fail: (err) => { console.error('写入失败', err); app.$modal.alert('写入失败', JSON.stringify(err)); wx.showToast({ title: '写入失败', icon: 'none' }); } });
05-06 - 读取NFC标签数据为空数据?
//读取NFC标签 readNFC(){ let app = this; wx.nfc = wx.getNFCAdapter(); wx.nfc.startDiscovery({ success: (res) => { console.log('NFC发现成功', res); wx.nfc.onDiscovered((res) => { app.$modal.alert('res',JSON.stringify(res)) app.$modal.alert('res.messages[0]',JSON.stringify(res)) const nfcData = res.messages[0]; app.nfcData=nfcData; } ); }, fail: (err) => { console.error('NFC发现失败', err); wx.showToast({ title: 'NFC发现失败', icon: 'none' }); } }); }, 打印的数据{"records":[{"tnf":2,"type":{},"id"{},"payload":{}}]}
05-06 - NFC标签读取数据为空?
//读取NFC标签 readNFC(){ let app = this; wx.nfc = wx.getNFCAdapter(); wx.nfc.startDiscovery({ success: (res) => { console.log('NFC发现成功', res); wx.nfc.onDiscovered((res) => { app.$modal.alert('res',JSON.stringify(res)) app.$modal.alert('res.messages[0]',JSON.stringify(res)) const nfcData = res.messages[0]; app.nfcData=nfcData; } ); }, fail: (err) => { console.error('NFC发现失败', err); wx.showToast({ title: 'NFC发现失败', icon: 'none' }); } }); }
05-06 - 真机调试控制台和请求没有数据?
[图片]
05-06 - NFC监听,信息获取,返回数据为空?
//读取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' }); } }); },
05-06 - 小程序云开发新用户首月免费配额,没有一直免费的配额吗?
小程序云开发新用户首月免费配额,没有一直免费的配额吗?
2023-03-24 - 支付成了,但并没有进入回调地址,用postman请求回调地址是可以的,回调的url规则也没有问?
支付成了,但并没有进入回调地址,用postman请求回调地址是可以的,回调的url规则也没有问
2022-03-30 - tabbar中list最多只能有五个超过五个怎么办?
app.json 文件中 tabbar中list最多只能有五个,超过五个怎么办?
2022-03-09 - 小程序发布收索不到?
wxc4a02c7d26509942
2020-12-14