|
@@ -1,6 +1,7 @@
|
|
|
import 'dart:math';
|
|
|
import 'package:fis_jsonrpc/rpc.dart';
|
|
|
import 'package:get/get.dart';
|
|
|
+import 'package:idread/model/id_card_info_model.dart';
|
|
|
import 'package:vitalapp/architecture/utils/prompt_box.dart';
|
|
|
import 'package:idread/idread.dart';
|
|
|
|
|
@@ -15,7 +16,9 @@ class CardReaderController extends GetxController {
|
|
|
bool start = await Idread.startRead();
|
|
|
if (start) {
|
|
|
Idread.dataStreamListen((data) {
|
|
|
- print(data.toString());
|
|
|
+ if (data is IdCardInfoModel) {
|
|
|
+ onReadInfo(data);
|
|
|
+ }
|
|
|
});
|
|
|
}
|
|
|
}
|
|
@@ -29,7 +32,9 @@ class CardReaderController extends GetxController {
|
|
|
bool start = await Idread.startRead();
|
|
|
if (start) {
|
|
|
Idread.dataStreamListen((data) {
|
|
|
- print(data.toString());
|
|
|
+ if (data is IdCardInfoModel) {
|
|
|
+ onReadInfo(data);
|
|
|
+ }
|
|
|
});
|
|
|
}
|
|
|
} else {
|
|
@@ -41,16 +46,17 @@ class CardReaderController extends GetxController {
|
|
|
|
|
|
/// 读取到数据的回调
|
|
|
/// TODO addListener 监听读卡器读到数据
|
|
|
- void onReadInfo(String mockData) {
|
|
|
+ void onReadInfo(IdCardInfoModel data) {
|
|
|
+ print("读卡器读到数据:$data");
|
|
|
+ print("读卡器读到数据:${data.birthDay}");
|
|
|
final result = CardReaderResult(
|
|
|
success: true,
|
|
|
- cardNo: "123456789012345678",
|
|
|
- name: "张三",
|
|
|
- nation: "汉族",
|
|
|
- gender: GenderEnum.Female,
|
|
|
+ cardNo: data.idCard,
|
|
|
+ name: data.peopleName,
|
|
|
+ nation: data.people,
|
|
|
+ gender: data.sex == '男' ? GenderEnum.Male : GenderEnum.Female,
|
|
|
birthday: DateTime(1990, 1, 1),
|
|
|
- address: "北京市朝阳区",
|
|
|
- censusRegister: "北京市朝阳区",
|
|
|
+ address: data.address,
|
|
|
);
|
|
|
Get.back(
|
|
|
result: result,
|
|
@@ -97,19 +103,16 @@ class CardReaderResult {
|
|
|
/// 出生日期
|
|
|
DateTime birthday;
|
|
|
|
|
|
- /// 现住地址
|
|
|
+ /// 地址
|
|
|
String address;
|
|
|
|
|
|
- /// 户籍地址
|
|
|
- String censusRegister;
|
|
|
-
|
|
|
- CardReaderResult(
|
|
|
- {required this.success,
|
|
|
- required this.cardNo,
|
|
|
- required this.name,
|
|
|
- required this.gender,
|
|
|
- required this.nation,
|
|
|
- required this.birthday,
|
|
|
- required this.address,
|
|
|
- required this.censusRegister});
|
|
|
+ CardReaderResult({
|
|
|
+ required this.success,
|
|
|
+ required this.cardNo,
|
|
|
+ required this.name,
|
|
|
+ required this.gender,
|
|
|
+ required this.nation,
|
|
|
+ required this.birthday,
|
|
|
+ required this.address,
|
|
|
+ });
|
|
|
}
|