小程序NFC识别身份证为啥报发送数据失败,是我传的参数不对吗?那要传什么?
onShow: function () {
var that = this;
var adapter = wx.getNFCAdapter();//获取NFCAdapter实例对象
console.log(adapter);
//启动监听NFC标签
adapter.startDiscovery({
success: res => {
that.setData({
title:'success-->请将设备放入识别区NFC'
})
console.log('开始监听贴卡',res);
//初始化监听回调事件
adapter.onDiscovered(res => {
console.log('读到卡片了', res);
let arrbuf = that.strToArrayBuffer('GET DATA')//字符串转ArrayBuffer 发送IC卡adpu指令
if(res.techs.includes(adapter.tech.nfcB)){
console.log('发现'+adapter.tech.nfcB+'卡');
let nfcB = adapter.getNfcB();
app.nfcB = nfcB;
nfcB.connect({
success: function(res){
console.log('设备已连接', res)
nfcB.transceive({
// data:new ArrayBuffer(0),
data:arrbuf,
success: function(res){
console.log('发送数据成功, 接收数据如下:', res);
that.setData({
title:'发送数据成功, 接收数据...'
})
},
fail: function(err){
console.log('发送数据失败', err);
}
})
},
fail: function(err){
console.log('设备联接错误', err);
}
});
}
});
},
fail: error => {
that.setData({
title:'错误信息-->' + error.errMsg
})
console.log(error);
},
complete: res => {
console.log('complete');
console.log(res);
}
});
},
1 回复
你好,麻烦提供能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)
并且麻烦在手机微信那里上传下日志: 我->设置->帮助与反馈右上角有个上报日志的入口,麻烦提供一下微信号,时间点