修改NFC读取
This commit is contained in:
4
src/uni_modules/ohyes-nfc/changelog.md
Normal file
4
src/uni_modules/ohyes-nfc/changelog.md
Normal file
@@ -0,0 +1,4 @@
|
||||
## 1.0.2(2025-08-29)
|
||||
api 变更注意查看最新文档
|
||||
## 1.0.0(2025-07-30)
|
||||
无
|
||||
BIN
src/uni_modules/ohyes-nfc/encrypt
Normal file
BIN
src/uni_modules/ohyes-nfc/encrypt
Normal file
Binary file not shown.
105
src/uni_modules/ohyes-nfc/package.json
Normal file
105
src/uni_modules/ohyes-nfc/package.json
Normal file
@@ -0,0 +1,105 @@
|
||||
{
|
||||
"id": "ohyes-nfc",
|
||||
"displayName": "android NFC ",
|
||||
"version": "1.0.2",
|
||||
"description": "ohyes-nfc",
|
||||
"keywords": [
|
||||
"android",
|
||||
"uts",
|
||||
"nfc"
|
||||
],
|
||||
"repository": "",
|
||||
"engines": {
|
||||
"HBuilderX": "^4.66",
|
||||
"uni-app": "^4.27",
|
||||
"uni-app-x": "^4.27"
|
||||
},
|
||||
"dcloudext": {
|
||||
"type": "uts",
|
||||
"sale": {
|
||||
"regular": {
|
||||
"price": "1.00"
|
||||
},
|
||||
"sourcecode": {
|
||||
"price": "3000.00"
|
||||
}
|
||||
},
|
||||
"contact": {
|
||||
"qq": "1209808782"
|
||||
},
|
||||
"declaration": {
|
||||
"ads": "无",
|
||||
"data": "无",
|
||||
"permissions": "android.permission.NFC\nandroid.permission.VIBRATE"
|
||||
},
|
||||
"npmurl": "",
|
||||
"darkmode": "x",
|
||||
"i18n": "x",
|
||||
"widescreen": "x"
|
||||
},
|
||||
"uni_modules": {
|
||||
"dependencies": [],
|
||||
"encrypt": [],
|
||||
"platforms": {
|
||||
"cloud": {
|
||||
"tcb": "√",
|
||||
"aliyun": "√",
|
||||
"alipay": "√"
|
||||
},
|
||||
"client": {
|
||||
"uni-app": {
|
||||
"vue": {
|
||||
"vue2": {
|
||||
"extVersion": "1.0.1",
|
||||
"minVersion": ""
|
||||
},
|
||||
"vue3": {
|
||||
"extVersion": "1.0.1",
|
||||
"minVersion": ""
|
||||
}
|
||||
},
|
||||
"web": {
|
||||
"safari": "-",
|
||||
"chrome": "-"
|
||||
},
|
||||
"app": {
|
||||
"vue": "-",
|
||||
"nvue": "-",
|
||||
"android": "-",
|
||||
"ios": "-",
|
||||
"harmony": "-"
|
||||
},
|
||||
"mp": {
|
||||
"weixin": "-",
|
||||
"alipay": "-",
|
||||
"toutiao": "-",
|
||||
"baidu": "-",
|
||||
"kuaishou": "-",
|
||||
"jd": "-",
|
||||
"harmony": "-",
|
||||
"qq": "-",
|
||||
"lark": "-"
|
||||
},
|
||||
"quickapp": {
|
||||
"huawei": "-",
|
||||
"union": "-"
|
||||
}
|
||||
},
|
||||
"uni-app-x": {
|
||||
"web": {
|
||||
"safari": "-",
|
||||
"chrome": "-"
|
||||
},
|
||||
"app": {
|
||||
"android": "-",
|
||||
"ios": "-",
|
||||
"harmony": "-"
|
||||
},
|
||||
"mp": {
|
||||
"weixin": "-"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
174
src/uni_modules/ohyes-nfc/readme.md
Normal file
174
src/uni_modules/ohyes-nfc/readme.md
Normal file
@@ -0,0 +1,174 @@
|
||||
*注意:iOS平台的NFC功能暂无支持计划,当前版本仅支持Android平台。*
|
||||
|
||||
# ohyes-nfc
|
||||
|
||||
一个用于uni-app的NFC读取插件,支持Android的NFC标签读取功能。
|
||||
|
||||
## 免责声明
|
||||
- 源码无后门代码。
|
||||
- 由第三方SDK而导致的任何损失,与作者无关。
|
||||
- 使用本插件而导致的任何损失,与作者无关。
|
||||
- 使用该插件即代表同意免责声明。
|
||||
|
||||
## 是否使用第三方SDK?
|
||||
- 无
|
||||
|
||||
## 我有需求怎么办?
|
||||
发送邮件到 helloword202507@163.com 感谢支持
|
||||
|
||||
## 功能特性
|
||||
|
||||
- 🔍 **NFC标签读取** - 支持多种NFC标签类型的读取
|
||||
- 🏷️ **多种标签格式** - 支持NDEF、Mifare Classic、Mifare Ultralight、ISO-DEP等
|
||||
- 📊 **详细信息获取** - 获取标签ID、技术列表、内容、内存使用情况等
|
||||
- 🔒 **安全验证** - 支持标签签名验证和密码保护检测
|
||||
|
||||
## 支持的标签类型
|
||||
|
||||
- **NDEF标签** - NFC Forum Type 1-5
|
||||
- **Mifare Classic** - 1K/4K标签
|
||||
- **Mifare Ultralight** - 轻量级标签
|
||||
- **ISO-DEP** - ISO14443-4标准标签
|
||||
- **NFC-A/B/F/V** - 各种NFC技术标准
|
||||
|
||||
## 安装
|
||||
|
||||
将插件导入到你的uni-app项目中:
|
||||
|
||||
1. 下载插件包
|
||||
2. 将插件放入项目的`uni_modules`目录
|
||||
3. 重新编译项目
|
||||
|
||||
## 权限配置
|
||||
|
||||
### Android权限
|
||||
|
||||
插件会自动添加以下权限到AndroidManifest.xml:
|
||||
|
||||
```xml
|
||||
<uses-feature android:name="android.hardware.nfc" android:required="true" />
|
||||
<uses-permission android:name="android.permission.NFC" />
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
```
|
||||
|
||||
## 使用方法
|
||||
|
||||
### 基本用法
|
||||
|
||||
参考示例工程
|
||||
|
||||
## API文档
|
||||
|
||||
### enableNFCRead()
|
||||
|
||||
启用NFC读取模式
|
||||
|
||||
### disableNFCRead()
|
||||
|
||||
停用NFC读取模式
|
||||
|
||||
### isNFCSupported()
|
||||
|
||||
检查当前设备是否支持NFC功能
|
||||
|
||||
**返回值:**
|
||||
- `boolean` - true表示设备支持NFC,false表示不支持
|
||||
|
||||
### isNFCEnabled()
|
||||
|
||||
检查当前设备NFC功能是否已打开
|
||||
|
||||
**返回值:**
|
||||
- `boolean` - true表示NFC已启用,false表示NFC未启用
|
||||
|
||||
### openNFCSettings()
|
||||
|
||||
跳转到系统NFC设置页面,用户可以手动打开NFC开关
|
||||
|
||||
### onNFCListener(callback:(res:NFCInfo)=>void)
|
||||
|
||||
监听NFC返回数据,全局唯一,重复调用会覆盖
|
||||
|
||||
## NFCInfo数据结构
|
||||
|
||||
读取成功后返回的NFC信息对象包含以下字段:
|
||||
|
||||
```typescript
|
||||
interface NFCInfo {
|
||||
id: string // 标签唯一ID
|
||||
techList: string[] // 支持的技术列表
|
||||
type: string // 标签类型
|
||||
size: number // 标签容量(字节)
|
||||
isWritable: boolean // 是否可写
|
||||
content: string // 标签内容
|
||||
atqa: string // ATQA值(NFC-A技术)
|
||||
sak: string // SAK值(NFC-A技术)
|
||||
signature: string // 签名状态
|
||||
passwordProtected: boolean // 是否密码保护
|
||||
dataFormat: string // 数据格式
|
||||
recordCount: number // NDEF记录数量
|
||||
usedBytes: number // 已使用字节数
|
||||
freeBytes: number // 剩余字节数
|
||||
}
|
||||
```
|
||||
|
||||
### 字段说明
|
||||
|
||||
- **id**: 标签的唯一标识符,通常为十六进制字符串
|
||||
- **techList**: 标签支持的NFC技术,如["NfcA", "Ndef", "MifareUltralight"]
|
||||
- **type**: 标签类型描述,如"Type 2 (Ultralight)"
|
||||
- **size**: 标签总容量,单位为字节
|
||||
- **isWritable**: 标签是否支持写入操作
|
||||
- **content**: 解析后的标签内容,包括文本、URL等
|
||||
- **atqa/sak**: NFC-A技术的技术参数
|
||||
- **signature**: 标签签名验证状态
|
||||
- **dataFormat**: 数据格式,如"NFC Forum Type 2"
|
||||
- **recordCount**: NDEF消息中的记录数量
|
||||
- **usedBytes/freeBytes**: 内存使用情况
|
||||
|
||||
## 支持的内容类型
|
||||
|
||||
插件能够解析以下类型的NFC内容:
|
||||
|
||||
### NDEF记录类型
|
||||
- **文本记录** - 纯文本内容,支持多语言
|
||||
- **URI记录** - 网址、电话、邮箱等链接
|
||||
- **MIME记录** - 多媒体内容
|
||||
- **外部类型** - 自定义格式
|
||||
|
||||
### 非NDEF标签
|
||||
- **Mifare Classic** - 读取扇区和块数据
|
||||
- **Mifare Ultralight** - 读取页面数据
|
||||
- **ISO-DEP** - 读取历史字节和高层响应
|
||||
|
||||
## 平台支持
|
||||
|
||||
| 平台 | 支持状态 | 说明 |
|
||||
|------|----------|------|
|
||||
| Android | ✅ 完全支持 | 支持所有NFC功能,包括多种标签类型 |
|
||||
|
||||
## 注意事项
|
||||
|
||||
1. **设备要求**: 设备必须支持NFC功能
|
||||
2. **权限**: Android需要NFC权限,iOS需要在设置中启用NFC
|
||||
3. **距离**: NFC读取需要设备与标签距离很近(通常<4cm)
|
||||
4. **性能**: 读取大容量标签时可能需要较长时间
|
||||
5. **兼容性**: 不同厂商的NFC标签可能有细微差异
|
||||
|
||||
## 错误处理
|
||||
|
||||
常见错误及处理方法:
|
||||
|
||||
- **"NFC不可用"** - 检查设备是否支持NFC并已启用
|
||||
- **"读取超时"** - 确保标签与设备距离足够近
|
||||
- **"标签格式不支持"** - 标签可能损坏或使用了不支持的格式
|
||||
- **"权限被拒绝"** - 检查应用是否有NFC权限
|
||||
|
||||
## 更新日志
|
||||
|
||||
### v1.0.0
|
||||
- 初始版本发布
|
||||
- 支持Android平台NFC读取
|
||||
- 支持多种标签类型和格式
|
||||
- 提供详细的标签信息
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"
|
||||
package="com.ohyes.nfc">
|
||||
<uses-feature android:name="android.hardware.nfc" android:required="true" />
|
||||
<uses-permission android:name="android.permission.NFC" />
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
</manifest>
|
||||
BIN
src/uni_modules/ohyes-nfc/utssdk/app-android/NFCUtil.kt
Normal file
BIN
src/uni_modules/ohyes-nfc/utssdk/app-android/NFCUtil.kt
Normal file
Binary file not shown.
3
src/uni_modules/ohyes-nfc/utssdk/app-android/config.json
Normal file
3
src/uni_modules/ohyes-nfc/utssdk/app-android/config.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"minSdkVersion": "21"
|
||||
}
|
||||
BIN
src/uni_modules/ohyes-nfc/utssdk/app-android/index.uts
Normal file
BIN
src/uni_modules/ohyes-nfc/utssdk/app-android/index.uts
Normal file
Binary file not shown.
3
src/uni_modules/ohyes-nfc/utssdk/app-ios/config.json
Normal file
3
src/uni_modules/ohyes-nfc/utssdk/app-ios/config.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"deploymentTarget": "12"
|
||||
}
|
||||
BIN
src/uni_modules/ohyes-nfc/utssdk/app-ios/index.uts
Normal file
BIN
src/uni_modules/ohyes-nfc/utssdk/app-ios/index.uts
Normal file
Binary file not shown.
29
src/uni_modules/ohyes-nfc/utssdk/interface.uts
Normal file
29
src/uni_modules/ohyes-nfc/utssdk/interface.uts
Normal file
@@ -0,0 +1,29 @@
|
||||
export type NFCEnableReadMode = () => void
|
||||
export type NFCDisableReadMode = () => void
|
||||
export type NFCIsSupported = () => boolean
|
||||
export type NFCIsEnabled = () => boolean
|
||||
export type NFCOpenSettings = () => void
|
||||
|
||||
export type NFCListener = (info : NFCInfo) => void
|
||||
|
||||
export type NFCReadOptions = {
|
||||
resolve : (res : NFCInfo) => void
|
||||
reject : (e : String) => void
|
||||
}
|
||||
|
||||
export type NFCInfo = {
|
||||
id : string,
|
||||
techList : Array<string>,
|
||||
type : string,
|
||||
size : number,
|
||||
isWritable : boolean,
|
||||
content : string,
|
||||
atqa : string,
|
||||
sak : string,
|
||||
signature : string,
|
||||
passwordProtected : boolean,
|
||||
dataFormat : string,
|
||||
recordCount : number,
|
||||
usedBytes : number,
|
||||
freeBytes : number
|
||||
}
|
||||
18
src/uni_modules/read-nfc/changelog.md
Normal file
18
src/uni_modules/read-nfc/changelog.md
Normal file
@@ -0,0 +1,18 @@
|
||||
## 1.0.8(2025-07-22)
|
||||
修复uniapp x打包报错,AndroidManifest.xml 需要显式声明 android:exported="true"
|
||||
## 1.0.7(2025-06-26)
|
||||
修改BUG
|
||||
## 1.0.6(2024-07-24)
|
||||
更新刷卡监听界面背景透明化,提高界面友好度
|
||||
## 1.0.5(2024-07-24)
|
||||
更新刷新提示窗体
|
||||
## 1.0.4(2024-05-14)
|
||||
修改BUG
|
||||
## 1.0.3(2024-05-11)
|
||||
优化
|
||||
## 1.0.2(2024-05-11)
|
||||
更换图标
|
||||
## 1.0.1(2024-04-12)
|
||||
增加设备支持与NFC启用判断
|
||||
## 1.0.0(2024-04-12)
|
||||
提交插件
|
||||
1
src/uni_modules/read-nfc/encrypt
Normal file
1
src/uni_modules/read-nfc/encrypt
Normal file
@@ -0,0 +1 @@
|
||||
<EFBFBD>,<2C>P<EFBFBD><50>=<3D>[&<26>۸<>6<EFBFBD><36>z<EFBFBD>s<EFBFBD>+<2B>g<02><>_<EFBFBD><5F>ϭ<EFBFBD><12><><EFBFBD>륀<EFBFBD><EBA580>e<EFBFBD>$<24>,<14><><EFBFBD><EFBFBD>s`<60>_<><5F><07>B<EFBFBD><42><EFBFBD><EFBFBD>Wa<57><61>8W<0C><><EFBFBD>t<EFBFBD>O<EFBFBD><4F>{_Hf<48><66>ڎ@<15>-u+UX<55><02>*<2A><><EFBFBD>zl0f<30>U8K^G<><47><EFBFBD>0<14><><17><><EFBFBD>hpj<70><6A><EFBFBD><EFBFBD><EFBFBD>]^?
|
||||
102
src/uni_modules/read-nfc/package.json
Normal file
102
src/uni_modules/read-nfc/package.json
Normal file
@@ -0,0 +1,102 @@
|
||||
{
|
||||
"id": "read-nfc",
|
||||
"displayName": "read-nfc",
|
||||
"version": "1.0.8",
|
||||
"description": "读取NFC卡号 read-nfc",
|
||||
"keywords": [
|
||||
"read-nfc"
|
||||
],
|
||||
"repository": "",
|
||||
"engines": {
|
||||
"uni-app": "^4.06",
|
||||
"uni-app-x": "^4.07"
|
||||
},
|
||||
"dcloudext": {
|
||||
"type": "uts",
|
||||
"sale": {
|
||||
"regular": {
|
||||
"price": "50.00"
|
||||
},
|
||||
"sourcecode": {
|
||||
"price": "200.00"
|
||||
}
|
||||
},
|
||||
"contact": {
|
||||
"qq": ""
|
||||
},
|
||||
"declaration": {
|
||||
"ads": "无",
|
||||
"data": "插件不采集任何数据",
|
||||
"permissions": "<uses-permission android:name=\"android.permission.NFC\" /> \r\n<uses-feature android:name=\"android.hardware.nfc\" android:required=\"true\" />"
|
||||
},
|
||||
"npmurl": "",
|
||||
"darkmode": "x",
|
||||
"i18n": "x",
|
||||
"widescreen": "x"
|
||||
},
|
||||
"uni_modules": {
|
||||
"dependencies": [],
|
||||
"encrypt": [],
|
||||
"platforms": {
|
||||
"cloud": {
|
||||
"tcb": "√",
|
||||
"aliyun": "√",
|
||||
"alipay": "√"
|
||||
},
|
||||
"client": {
|
||||
"uni-app": {
|
||||
"vue": {
|
||||
"vue2": "√",
|
||||
"vue3": "√"
|
||||
},
|
||||
"web": {
|
||||
"safari": "-",
|
||||
"chrome": "-"
|
||||
},
|
||||
"app": {
|
||||
"vue": "√",
|
||||
"nvue": "-",
|
||||
"android": {
|
||||
"extVersion": "1.0.0",
|
||||
"minVersion": "21"
|
||||
},
|
||||
"ios": "-",
|
||||
"harmony": "-"
|
||||
},
|
||||
"mp": {
|
||||
"weixin": "-",
|
||||
"alipay": "-",
|
||||
"toutiao": "-",
|
||||
"baidu": "-",
|
||||
"kuaishou": "-",
|
||||
"jd": "-",
|
||||
"harmony": "-",
|
||||
"qq": "-",
|
||||
"lark": "-"
|
||||
},
|
||||
"quickapp": {
|
||||
"huawei": "-",
|
||||
"union": "-"
|
||||
}
|
||||
},
|
||||
"uni-app-x": {
|
||||
"web": {
|
||||
"safari": "-",
|
||||
"chrome": "-"
|
||||
},
|
||||
"app": {
|
||||
"android": {
|
||||
"extVersion": "1.0.0",
|
||||
"minVersion": "21"
|
||||
},
|
||||
"ios": "-",
|
||||
"harmony": "-"
|
||||
},
|
||||
"mp": {
|
||||
"weixin": "-"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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);
|
||||
});
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"
|
||||
package="io.dcloud.uni_modules.read_nfc">
|
||||
<!--获取NFC权限-->
|
||||
<uses-permission android:name="android.permission.NFC" />
|
||||
<uses-feature android:name="android.hardware.nfc" android:required="true" />
|
||||
|
||||
<application>
|
||||
<activity android:name="uts.sdk.modules.readNfc.NfcActivity" android:exported="true" android:launchMode="singleTop" android:theme="@android:style/Theme.Translucent">
|
||||
<intent-filter>
|
||||
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<data android:mimeType="text/plain" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.nfc.action.TAG_DISCOVERED" />
|
||||
<data android:mimeType="text/plain" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
</manifest>
|
||||
3
src/uni_modules/read-nfc/utssdk/app-android/config.json
Normal file
3
src/uni_modules/read-nfc/utssdk/app-android/config.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"minSdkVersion": "21"
|
||||
}
|
||||
BIN
src/uni_modules/read-nfc/utssdk/app-android/index.uts
Normal file
BIN
src/uni_modules/read-nfc/utssdk/app-android/index.uts
Normal file
Binary file not shown.
BIN
src/uni_modules/read-nfc/utssdk/app-android/res/drawable/nfc.png
Normal file
BIN
src/uni_modules/read-nfc/utssdk/app-android/res/drawable/nfc.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.9 KiB |
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:orientation="vertical">
|
||||
<ImageView
|
||||
android:id="@+id/imageView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:contentDescription="请靠近NFC卡"
|
||||
android:gravity="center_horizontal"
|
||||
android:src="@drawable/nfc" />
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:gravity="center_horizontal"
|
||||
android:text="请靠近NFC卡"
|
||||
android:textColor="#000"
|
||||
android:textSize="20sp" />
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
||||
45
src/uni_modules/read-nfc/utssdk/interface.uts
Normal file
45
src/uni_modules/read-nfc/utssdk/interface.uts
Normal file
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* interface.uts
|
||||
* uts插件接口定义文件,按规范定义接口文件可以在HBuilderX中更好的做到语法提示
|
||||
*/
|
||||
|
||||
/**
|
||||
* myApi 异步函数的参数,在type里定义函数需要的参数以及api成功、失败的相关回调函数。
|
||||
*/
|
||||
export type MyApiOptions = {
|
||||
paramA : boolean
|
||||
success ?: (res : MyApiResult) => void
|
||||
fail ?: (res : MyApiFail) => void
|
||||
complete ?: (res : any) => void
|
||||
}
|
||||
|
||||
/**
|
||||
* 函数返回结果
|
||||
* 可以是void, 基本数据类型,自定义type, 或者其他类型。
|
||||
* [可选实现]
|
||||
*/
|
||||
export type MyApiResult = {
|
||||
fieldA : number,
|
||||
fieldB : boolean,
|
||||
fieldC : string
|
||||
}
|
||||
|
||||
/**
|
||||
* 错误码
|
||||
* 根据uni错误码规范要求,建议错误码以90开头,以下是错误码示例:
|
||||
* - 9010001 错误信息1
|
||||
* - 9010002 错误信息2
|
||||
*/
|
||||
export type MyApiErrorCode = 9010001 | 9010002;
|
||||
/**
|
||||
* myApi 的错误回调参数
|
||||
*/
|
||||
export interface MyApiFail extends IUniError {
|
||||
errCode : MyApiErrorCode
|
||||
};
|
||||
|
||||
/* 异步函数定义 */
|
||||
export type MyApi = (options : MyApiOptions) => void
|
||||
|
||||
/* 同步函数定义 */
|
||||
export type MyApiSync = (paramA : boolean) => MyApiResult
|
||||
BIN
src/uni_modules/read-nfc/utssdk/unierror.uts
Normal file
BIN
src/uni_modules/read-nfc/utssdk/unierror.uts
Normal file
Binary file not shown.
Reference in New Issue
Block a user