修改NFC读取
This commit is contained in:
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