|
@@ -1,10 +1,49 @@
|
|
|
+import 'dart:convert';
|
|
|
+
|
|
|
+import 'package:fis_common/index.dart';
|
|
|
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';
|
|
|
+import 'package:vitalapp/js_platform/handlers/idcard_handler.dart';
|
|
|
import 'package:vitalapp/managers/interfaces/device.dart';
|
|
|
import 'package:vitalapp/managers/interfaces/models/device.dart';
|
|
|
+import 'package:vitalapp/rpc.dart';
|
|
|
+
|
|
|
+class IDInformation {
|
|
|
+ String? name;
|
|
|
+ String? sex;
|
|
|
+ String? id;
|
|
|
+ String? nation;
|
|
|
+ String? birthday;
|
|
|
+ String? address;
|
|
|
+
|
|
|
+ IDInformation(
|
|
|
+ {this.name, this.sex, this.id, this.nation, this.birthday, this.address});
|
|
|
+
|
|
|
+ factory IDInformation.fromJson(Map<String, dynamic> json) {
|
|
|
+ return IDInformation(
|
|
|
+ name: json['Name'],
|
|
|
+ sex: json['Sex'],
|
|
|
+ id: json['ID'],
|
|
|
+ nation: json['Nation'],
|
|
|
+ birthday: json['Birthday'],
|
|
|
+ address: json['Address'],
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, dynamic> toJson() {
|
|
|
+ final Map<String, dynamic> data = new Map<String, dynamic>();
|
|
|
+ data['Name'] = this.name;
|
|
|
+ data['Sex'] = this.sex;
|
|
|
+ data['ID'] = this.id;
|
|
|
+ data['Nation'] = this.nation;
|
|
|
+ data['Birthday'] = this.birthday;
|
|
|
+ data['Address'] = this.address;
|
|
|
+ return data;
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
class CardReaderController extends GetxController {
|
|
|
CardReaderController();
|
|
@@ -13,10 +52,29 @@ class CardReaderController extends GetxController {
|
|
|
bool isCardReaderBinding = false;
|
|
|
|
|
|
_initData() async {
|
|
|
+ if (FPlatform.isWindows) {
|
|
|
+ Idread.isShell = true;
|
|
|
+ Idread.shellRead = rpc.platform.startIDCardReader;
|
|
|
+ Idread.shellStopRead = rpc.platform.stopIDCardReader;
|
|
|
+ }
|
|
|
bool result = await Idread.init();
|
|
|
if (result) {
|
|
|
bool start = await Idread.startRead();
|
|
|
- if (start) {
|
|
|
+ if (FPlatform.isWindows) {
|
|
|
+ OpenIDCardPageHandler.onIDCardRead.addListener((sender, e) {
|
|
|
+ var jsonOBJ = jsonDecode(e);
|
|
|
+ var shellIDData = IDInformation.fromJson(jsonOBJ);
|
|
|
+ var data = IdCardInfoModel(
|
|
|
+ people: shellIDData.nation!,
|
|
|
+ peopleName: shellIDData.name!,
|
|
|
+ sex: shellIDData.sex!,
|
|
|
+ birthDay: shellIDData.birthday!,
|
|
|
+ address: shellIDData.address!,
|
|
|
+ idCard: shellIDData.id!,
|
|
|
+ );
|
|
|
+ onReadInfo(data);
|
|
|
+ });
|
|
|
+ } else {
|
|
|
Idread.dataStreamListen((data) {
|
|
|
if (data is IdCardInfoModel) {
|
|
|
onReadInfo(data);
|
|
@@ -40,6 +98,9 @@ class CardReaderController extends GetxController {
|
|
|
}
|
|
|
|
|
|
void checkReader() async {
|
|
|
+ if (FPlatform.isWindows) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
bool result = await Idread.init();
|
|
|
if (result) {
|
|
|
bool start = await Idread.startRead();
|
|
@@ -59,6 +120,7 @@ class CardReaderController extends GetxController {
|
|
|
|
|
|
|
|
|
void onReadInfo(IdCardInfoModel data) {
|
|
|
+ print(data.toJson().toString());
|
|
|
final result = CardReaderResult(
|
|
|
success: true,
|
|
|
cardNo: data.idCard,
|