修改NFC读取
This commit is contained in:
52
src/uni_modules/read-nfc/readme.md
Normal file
52
src/uni_modules/read-nfc/readme.md
Normal file
@@ -0,0 +1,52 @@
|
||||
# read-nfc
|
||||
## 插件示例
|
||||
|
||||
1、通过插件市场“使用 HBuilderX 导入示例项目”下载插件示例项目
|
||||
|
||||
2、通过插件市场“试用”导入插件到示例项目中
|
||||
|
||||
3、打包并运行自定义基座
|
||||
|
||||
使用了NFC的Android原生库需要打包使用自定义基座
|
||||
|
||||
## 引入插件对象
|
||||
```
|
||||
import * as nfc from "@/uni_modules/read-nfc";
|
||||
```
|
||||
|
||||
## 调起NFC识别
|
||||
|
||||
```
|
||||
data() {
|
||||
return {
|
||||
title: '读取NFC监听',
|
||||
nfcCode:''
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
this.gotoNfcActivity();//调起NFC识别,并监听回调
|
||||
},
|
||||
methods: {
|
||||
gotoNfcActivity() {
|
||||
let that=this;
|
||||
nfc.gotoNfcActivity(function(result){
|
||||
that.nfcCode=result.message;
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: result.message,
|
||||
confirmText:'继续',
|
||||
success: function (res) {
|
||||
if (res.confirm) {
|
||||
that.gotoNfcActivity();//继续识别
|
||||
console.log('用户点击继续!');
|
||||
} else if (res.cancel) {
|
||||
console.log('用户点击取消!');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
console.log('NFC',result);
|
||||
});
|
||||
}
|
||||
}
|
||||
```
|
||||
Reference in New Issue
Block a user