From 389477c0e5cda2c4bfd22530b1ceed3089bc2032 Mon Sep 17 00:00:00 2001 From: Daisy <> Date: Sat, 18 May 2024 09:19:48 +0800 Subject: [PATCH 01/44] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=BC=BA=E5=A4=B1?= =?UTF-8?q?=E6=8E=88=E6=9D=83=E7=AE=A1=E7=90=86=E5=91=98=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- star_lock/images/lan/lan_en.json | 1 + star_lock/images/lan/lan_keys.json | 1 + star_lock/images/lan/lan_zh.json | 1 + .../authorizedAdministratorList_page.dart | 37 +++++++++++++++---- .../valueAddedServicesList_page.dart | 1 + .../lib/tools/showCupertinoAlertView.dart | 6 +-- 6 files changed, 37 insertions(+), 10 deletions(-) diff --git a/star_lock/images/lan/lan_en.json b/star_lock/images/lan/lan_en.json index 27e1c76e..76e14461 100644 --- a/star_lock/images/lan/lan_en.json +++ b/star_lock/images/lan/lan_en.json @@ -817,6 +817,7 @@ "身份证号":"ID number", "请输入真实姓名":"Please enter your real name", "请输入身份证号":"Please enter your ID number", + "请输入身份证号和真实姓名":"Please enter your ID number and real name", "点击返回设备配对":"Tap Back to device pairing", "无法连接?尝试升级":"Can't connect?Upgrade attempted", "固件升级提示":"Firmware upgrade prompt", diff --git a/star_lock/images/lan/lan_keys.json b/star_lock/images/lan/lan_keys.json index 3d671b57..ed1eaa51 100644 --- a/star_lock/images/lan/lan_keys.json +++ b/star_lock/images/lan/lan_keys.json @@ -844,6 +844,7 @@ "身份证号":"身份证号", "请输入真实姓名":"请输入真实姓名", "请输入身份证号":"请输入身份证号", + "请输入身份证号和真实姓名":"请输入身份证号和真实姓名", "点击返回设备配对":"点击返回设备配对", "无法连接?尝试升级":"无法连接?尝试升级", diff --git a/star_lock/images/lan/lan_zh.json b/star_lock/images/lan/lan_zh.json index 1bd2b742..7a31ca86 100644 --- a/star_lock/images/lan/lan_zh.json +++ b/star_lock/images/lan/lan_zh.json @@ -815,6 +815,7 @@ "身份证号": "身份证号", "请输入真实姓名": "请输入真实姓名", "请输入身份证号": "请输入身份证号", + "请输入身份证号和真实姓名":"请输入身份证号和真实姓名", "点击返回设备配对": "点击返回设备配对", "无法连接?尝试升级": "无法连接?尝试升级", "固件升级提示": "固件升级提示", diff --git a/star_lock/lib/mine/mineSet/authorizedAdministrator/authorizedAdministrator/authorizedAdministratorList_page.dart b/star_lock/lib/mine/mineSet/authorizedAdministrator/authorizedAdministrator/authorizedAdministratorList_page.dart index 6b94317e..c2922066 100644 --- a/star_lock/lib/mine/mineSet/authorizedAdministrator/authorizedAdministrator/authorizedAdministratorList_page.dart +++ b/star_lock/lib/mine/mineSet/authorizedAdministrator/authorizedAdministrator/authorizedAdministratorList_page.dart @@ -5,6 +5,7 @@ import 'package:get/get.dart'; import 'package:star_lock/mine/mineSet/authorizedAdministrator/authorizedAdministrator/authorizedAdminListEntity.dart'; import 'package:star_lock/tools/noData.dart'; import 'package:star_lock/tools/showCupertinoAlertView.dart'; +import 'package:star_lock/tools/submitBtn.dart'; import '../../../../../appRouters.dart'; import '../../../../../app_settings/app_colors.dart'; @@ -92,13 +93,35 @@ class _AuthorizedAdministratorListPageState } Widget _buildMainUI() { - return Obx(() => state.itemDataList.value.isEmpty - ? NoData( - noDataHeight: 1.sh - - ScreenUtil().statusBarHeight - - ScreenUtil().bottomBarHeight - - 190.h - - 64.h) + return Obx(() => state.itemDataList.isEmpty + ? Stack( + children: [ + NoData( + noDataHeight: 1.sh - + ScreenUtil().statusBarHeight - + ScreenUtil().bottomBarHeight - + 190.h - + 64.h), + Align( + alignment: const Alignment(0.0, 0.2), + child: SizedBox( + width: 360.w, + child: SubmitBtn( + btnName: '添加授权管理员', + onClick: () { + Navigator.pushNamed( + context, Routers.addAuthorizedAdministratorPage) + .then((value) { + setState(() { + logic.pageNo = 1; + getHttpData(); + }); + }); + }), + ), + ), + ], + ) : SlidableAutoCloseBehavior( child: ListView.separated( itemCount: state.itemDataList.value.length, diff --git a/star_lock/lib/mine/valueAddedServices/valueAddedServicesList/valueAddedServicesList_page.dart b/star_lock/lib/mine/valueAddedServices/valueAddedServicesList/valueAddedServicesList_page.dart index 25d7493f..33744dcf 100644 --- a/star_lock/lib/mine/valueAddedServices/valueAddedServicesList/valueAddedServicesList_page.dart +++ b/star_lock/lib/mine/valueAddedServices/valueAddedServicesList/valueAddedServicesList_page.dart @@ -3,6 +3,7 @@ import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/mine/valueAddedServices/valueAddedServicesList/valueAddedServicesList_logic.dart'; +import 'package:star_lock/tools/commonDataManage.dart'; import 'package:star_lock/tools/storage.dart'; import '../../../appRouters.dart'; diff --git a/star_lock/lib/tools/showCupertinoAlertView.dart b/star_lock/lib/tools/showCupertinoAlertView.dart index 09ee39a7..aef9105b 100644 --- a/star_lock/lib/tools/showCupertinoAlertView.dart +++ b/star_lock/lib/tools/showCupertinoAlertView.dart @@ -221,14 +221,14 @@ class ShowCupertinoAlertView { String name = ''; return CupertinoAlertDialog( - title: const Text('请输入身份证号和真实姓名'), + title: Text('请输入身份证号和真实姓名'.tr), content: Column( children: [ SizedBox( height: 10.h, ), CupertinoTextField( - placeholder: '请输入身份证号', + placeholder: '请输入身份证号'.tr, onChanged: (value) { idCard = value; }, @@ -237,7 +237,7 @@ class ShowCupertinoAlertView { height: 10.h, ), CupertinoTextField( - placeholder: '请输入真实姓名', + placeholder: '请输入真实姓名'.tr, onChanged: (value) { name = value; }, From 06b3b956b008fd000769bc11c3876d035dde73b9 Mon Sep 17 00:00:00 2001 From: anfe <448468458@qq.com> Date: Sat, 18 May 2024 10:11:34 +0800 Subject: [PATCH 02/44] =?UTF-8?q?feat:=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E9=A3=8E=E6=A0=BC=E6=A3=80=E6=B5=8B=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- analysis_options.yaml | 306 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 282 insertions(+), 24 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 61b6c4de..7a875bfc 100755 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1,29 +1,287 @@ -# This file configures the analyzer, which statically analyzes Dart code to -# check for errors, warnings, and lints. +# For a list of lints, see: http://dart-lang.github.io/linter/lints/ +# See the configuration guide for more +# https://github.com/dart-lang/sdk/tree/master/pkg/analyzer#configuring-the-analyzer # -# The issues identified by the analyzer are surfaced in the UI of Dart-enabled -# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be -# invoked from the command line by running `flutter analyze`. +# There are other similar analysis options files in the flutter repos, +# which should be kept in sync with this file: +# +# - analysis_options.yaml (this file) +# - packages/flutter/lib/analysis_options_user.yaml +# - https://github.com/flutter/plugins/blob/master/analysis_options.yaml +# - https://github.com/flutter/engine/blob/master/analysis_options.yaml +# +# This file contains the analysis options used by Flutter tools, such as IntelliJ, +# Android Studio, and the `flutter analyze` command. -# The following line activates a set of recommended lints for Flutter apps, -# packages, and plugins designed to encourage good coding practices. -include: package:flutter_lints/flutter.yaml +analyzer: + strong-mode: + implicit-casts: true + implicit-dynamic: true + errors: + # treat missing required parameters as a warning (not a hint) + missing_required_param: warning + # treat missing returns as a warning (not a hint) + missing_return: warning + # allow having TODOs in the code + todo: ignore + # allow self-reference to deprecated members (we do this because otherwise we have + # to annotate every member in every test, assert, etc, when we deprecate something) + # deprecated_member_use_from_same_package: ignore + # Ignore analyzer hints for updating pub specs when using Future or + # Stream and not importing dart:async + # Please see https://github.com/flutter/flutter/pull/24528 for details. + sdk_version_async_exported_from_core: ignore + exclude: + # - "**" + # the following two are relative to the stocks example and the flutter package respectively + # see https://github.com/dart-lang/sdk/issues/28463 + - "ios/*" + - "android/*" + - "analysis_options.yaml" linter: - # The lint rules applied to this project can be customized in the - # section below to disable rules from the `package:flutter_lints/flutter.yaml` - # included above or to enable additional rules. A list of all available lints - # and their documentation is published at - # https://dart-lang.github.io/linter/lints/index.html. - # - # Instead of disabling a lint rule for the entire project in the - # section below, it can also be suppressed for a single line of code - # or a specific dart file by using the `// ignore: name_of_lint` and - # `// ignore_for_file: name_of_lint` syntax on the line or in the file - # producing the lint. rules: - # avoid_print: false # Uncomment to disable the `avoid_print` rule - # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule - -# Additional information about this file can be found at -# https://dart.dev/guides/language/analysis-options + # these rules are documented on and in the same order as + # the Dart Lint rules page to make maintenance easier + # https://github.com/dart-lang/linter/blob/master/example/all.yaml + - always_declare_return_types + - avoid_bool_literals_in_conditional_expressions + - avoid_field_initializers_in_const_classes + - avoid_return_types_on_setters + - avoid_slow_async_io + - avoid_unused_constructor_parameters + - avoid_void_async + - cast_nullable_to_non_nullable + - flutter_style_todos + - iterable_contains_unrelated_type + - leading_newlines_in_multiline_strings + - library_prefixes + - no_adjacent_strings_in_list + - null_check_on_nullable_type_parameter + - package_api_docs + - package_prefixed_library_names + - prefer_final_in_for_each + - prefer_for_elements_to_map_fromIterable + - prefer_foreach + - prefer_generic_function_type_aliases + - prefer_if_elements_to_conditional_expressions + - prefer_iterable_whereType + - prefer_single_quotes + - prefer_spread_collections + - throw_in_finally + - tighten_type_of_initializing_formals + - type_init_formals + - unnecessary_nullable_for_final_variable_declarations + - use_is_even_rather_than_modulo + - use_late_for_private_fields_and_variables + - use_raw_strings + # ======================= 自定义规则 + # -------------------------命名 + # - 类型定义采用大写驼峰 + - camel_case_types + # - 函数拓展采用大写驼峰 + - camel_case_extensions + # - 库和文件名采用小写+下划线的方式命名 + - library_names + - file_names + # - 普通变量使用驼峰命名 + - non_constant_identifier_names + # - 静态变量推荐使用驼峰命名 + - constant_identifier_names + # -------------------------排 + # - 包引用排序: + # - dart开头的包排在最前面, + # - package开头的包排在相对引用包前面 + # - exports列在单独模块 + # - 每个模块内引用按字母顺序排序 + - directives_ordering + # -------------------------格式化 + # - 控制流中尽量使用大括号 + - curly_braces_in_flow_control_structures + # -------------------------评论 + # - 评论使用三斜杠标识 + - slash_for_doc_comments + # - 评论中使用可引用范围内的变量 + - comment_references + # -------------------------库使用 + # - 避免引用包内的具体实现文件 + - implementation_imports + # - 避免对lib/目录下的文件采用相对引用 + - avoid_relative_lib_imports + #-------------------------NULL + # - 避免初始化变量为null + - avoid_init_to_null + # -------------------------字符串 + # - 避免不需要的大括号 + - unnecessary_brace_in_string_interps + # - 使用相邻字符串的方式连接字符串 + - prefer_adjacent_string_concatenation + # -------------------------集合 + # - 尽量使用显式类型的方式初始化集合 + - prefer_collection_literals + # - 使用isEmpty和isNotE叩ty来判断是否为空,而不是通过length是否为0的方式 + - prefer_is_empty + - prefer_is_not_empty + # -------------------------函数 + # - 去除不必要的lambdas表达式 + - unnecessary_lambdas + # - 函数默认值尽量使用=来赋值 + - prefer_equal_for_default_values + # - 使用函数声明的方式将函数和变量做绑定 + - prefer_function_declarations_over_variables + # -------------------------成员变量 + # - 如无特殊作用,不用专门定义设置和获取方法 + - unnecessary_getters_setters + # - 避免使用this方式调用变量 + - unnecessary_this + # - 私有变量推荐定义成final + - prefer_final_fields + # - 可以考虑使用..这样方式,而不是返回this指针的方式来实现流式调用 + - avoid_returning_this + # - 避免返回null + - avoid_returning_null + # -------------------------构造函数 + # - 避免构造函数使用{}做空实现可以直接使用; + - empty_constructor_bodies + # - 推荐在构造函数中直接对成员变量进行赋值 + - prefer_initializing_formals + # - 去掉new关键字 + - unnecessary_new + # - 在const环境中,避免使用const关键字 + - unnecessary_const + # -------------------------异常处理 + # - 对捕获异常不处理的情况话,建议使用rethrow方式重新抛出而不是直接throw + - use_rethrow_when_possible + #-------------------------Mixin + # - 建议尽可能使用mixin机制 + - prefer_mixin + # -------------------------类型 + # - 未初始化变量,尽量提供类型 + - prefer_typing_uninitialized_variables + # - 尽可能显式声明变量类型 + - always_specify_types + # -------------------------参数 + # - 避免使用True或者 false作为参数。应该换成更有语义的表达 + - avoid_positional_boolean_parameters + # -------------------------质量 + # - 如果重写了==同时也需要重写hashcode + - hash_and_equals + # - 非immutable1e类不要重写hashCode和=否则在集合中会出现bug + - avoid_equals_and_hash_code_on_mutable_classes + # - 在自定义==时,不要做null检查 + - avoid_null_checks_in_equality_operators + # -------------------------Core集合融合部分 + # - 避免空的else语句 + - avoid_empty_else + # - 避免使用隐形类型传递 + - avoid_shadowing_type_parameters + # - 避免类型做参数 + - avoid_types_as_parameter_names + # - 避免await非future对象 + - await_only_futures + # - 避免catch空实现 + - empty_catches + # - 集合的 remove需要传递符合集合的类型的参数 + - list_remove_unrelated_type + # - case中避免重复 + - no_duplicate_case_values + # - deprecated函数或者变量需要注明相关信息 + - provide_deprecation_message + # - 去掉不需要的重写注解 + - unnecessary_overrides + # - 两个变量比较时,避免类型不一致 + - unrelated_type_equality_checks + # - 避免赋值给void类型变量 + - void_checks + # - 正则表达式合法性校验 + - valid_regexps + # -------------------------Recommended 集合融合部分 + # - 非空变量使用 require 关键字 + - always_require_non_null_named_parameters + # - 对重写的方法和变量加 override注解 + - annotate_overrides + # - 重写方法的参数不要改变参数名称 + - avoid_renaming_method_parameters + # - 不要在void函数中返回null + - avoid_returning_null_for_void + # - 避免在单个函数调用中使用传递调用语法 + - avoid_single_cascade_in_expression_statements + # - 避免在finally语句块中使用控制流语句 + - control_flow_in_finally + # - 避免空语句 + - empty_statements + # - 避免传递null给闭包参数 + - null_closures + # - 避免重写类的field + - overridden_fields + # - 建议判空逻辑中建议使用??=语法 + - prefer_conditional_assignment + # - 判断集合或者字符串的包含的逻辑使用contains而不是indexOf + - prefer_contains + # - 空判断尽量使用??操作符 + - prefer_if_null_operators + # - 允许情况下,1ist使用内联的方式声明 + - prefer_inlined_adds + # - 推荐使用is!操作符 + - prefer_is_not_operator + # - 推荐使用?.操作符 + - prefer_null_aware_operators + # - 类型定义尽可能使用void而不是null + - prefer_void_to_null + # - 避免递归调用 getter + - recursive_getters + # - 避免在空判断中使用null + - unnecessary_null_in_if_null_operators + # - 去掉不必要的反斜线 + - unnecessary_string_escapes + # - 避免不必要的字符串引用逻辑 + - unnecessary_string_interpolations + # -------------------------Flutter 集合融合部分 + # - 避免生产环境使用print + - avoid_print + # - 去掉无用的container节点 + - avoid_unnecessary_containers + # - 避免在flutter代码中引入web相关的库 + - avoid_web_libraries_in_flutter + # - 在state create函数中不加入额外逻辑 + - no_logic_in_create_state + # - 优先使用 const构造函数 + - prefer_const_constructors + # - 在immutable类定义中使用 const构造函数 + - prefer_const_constructors_in_immutables + # - 尽可能定义成const变量 + - prefer_const_declarations + # - 在immutable类创建中尽量使用 const变量 + - prefer_const_literals_to_create_immutables + # - 优先使用SizedBox而不是 Container + - sized_box_for_whitespace + # - 使用8位16进制整数标识颜色值 + - use_full_hex_values_for_flutter_colors + # - 在构造函数中加入key参数 + - use_key_in_widget_constructors + # -------------------------其他规则融合部分 + # - 无用代码清理 + - unnecessary_statements + # - 控制流语句分散到不同层 + - always_put_control_body_on_new_line + # - required修饰变量排到变量列表前面 + - always_put_required_named_parameters_first + #dart.async.StreamSubscription需要在恰当时机调用 cancel方法 + - cancel_subscriptions + # - 倾向在初始化列表中增加 assert + - prefer_asserts_in_initializer_lists + # - 符合标准情况下加上final关键字 + - prefer_final_locals + # - 构造函数排在变量之前 + - sort_constructors_first + - sort_unnamed_constructors_first + # - 在比较之前先测试类型是否符合要求 + - test_types_in_equals + # - 避免不必要的null判断 + - unnecessary_null_aware_assignments + # - 去掉不必要的圆括号 + - unnecessary_parenthesis + # - 避免不安全HTML的API + - unsafe_html + # - 避免魔鬼数值 + - avoid_hard_coded_literals From 17908feb36977e21d96f850dc7106a72bef10fe4 Mon Sep 17 00:00:00 2001 From: Daisy <> Date: Sat, 18 May 2024 13:44:09 +0800 Subject: [PATCH 03/44] =?UTF-8?q?=E5=A6=82=E6=9E=9C=E6=97=A0=E9=94=81?= =?UTF-8?q?=E4=B8=8D=E8=83=BD=E8=BF=9B=E5=85=A5=E9=AB=98=E7=BA=A7=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/mine/mine/starLockMine_page.dart | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/mine/mine/starLockMine_page.dart b/lib/mine/mine/starLockMine_page.dart index 54f8d203..d59c3225 100755 --- a/lib/mine/mine/starLockMine_page.dart +++ b/lib/mine/mine/starLockMine_page.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/flavors.dart'; +import 'package:star_lock/tools/commonDataManage.dart'; import '../../appRouters.dart'; import '../../app_settings/app_colors.dart'; @@ -91,8 +92,12 @@ class StarLockMinePageState extends State with BaseWidget { Obx(() => GestureDetector( onTap: () { if (state.isVip.value == null || !state.isVip.value) { - Get.toNamed(Routers.advancedFeaturesWebPage, - arguments: {'isShop': true}); + if (CommonDataManage().currentKeyInfo == null) { + logic.showToast('请先添加设备'); + } else { + Get.toNamed(Routers.advancedFeaturesWebPage, + arguments: {'isShop': true}); + } } else { Get.toNamed( Routers.valueAddedServicesHighFunctionPage); From a80297615667d3e7d70323517f88c6afcce9fa72 Mon Sep 17 00:00:00 2001 From: anfe <448468458@qq.com> Date: Sat, 18 May 2024 14:32:59 +0800 Subject: [PATCH 04/44] =?UTF-8?q?fix:=E8=A7=A3=E5=86=B3=20ios=20=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E7=BC=96=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ios/Podfile.lock | 2 +- ios/Runner/Info.plist | 52 +++++++++++++++++++++---------- lib/mine/mall/lockMall_logic.dart | 4 +-- pubspec.yaml | 7 +++++ 4 files changed, 45 insertions(+), 20 deletions(-) diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 1f76cd62..0aeb6030 100755 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -323,7 +323,7 @@ SPEC CHECKSUMS: flutter_pcm_sound: de0572ca4f99091cc2abfcc31601b8a4ddd33c0e flutter_voice_processor: 2b89b93d69b02227ae3fd58589ee0bcfa3ca2a82 fluttertoast: 9f2f8e81bb5ce18facb9748d7855bf5a756fe3db - fluwx: daa284756ce53442b3d0417ceeda66e981906811 + fluwx: c18fd6c16b03a2187cd07d6e48e32a7801962849 google_maps_flutter_ios: f135b968a67c05679e0a53538e900b5c174b0d99 GoogleMaps: 20d7b12be49a14287f797e88e0e31bc4156aaeb4 image_gallery_saver: cb43cc43141711190510e92c460eb1655cd343cb diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist index 4d5787d5..9cfa745c 100755 --- a/ios/Runner/Info.plist +++ b/ios/Runner/Info.plist @@ -22,14 +22,49 @@ $(FLUTTER_BUILD_NAME) CFBundleSignature ???? + CFBundleURLTypes + + + CFBundleTypeRole + None + CFBundleURLIconFile + + CFBundleURLName + com.sky.skysmartlock + CFBundleURLSchemes + + skysmartlock + + + + + + CFBundleTypeRole + Editor + CFBundleURLName + weixin + CFBundleURLSchemes + + 123456 + + + CFBundleVersion $(FLUTTER_BUILD_NUMBER) + LSApplicationQueriesSchemes + + weixin + weixinULAPI + weixinURLParamsAPI + LSRequiresIPhoneOS NSAppTransportSecurity NSAllowsArbitraryLoads + NSAllowsArbitraryLoadsInWebContent + NSExceptionDomains jpush.cn @@ -86,23 +121,6 @@ UIViewControllerBasedStatusBarAppearance - CFBundleURLTypes - - - CFBundleURLName - com.sky.skysmartlock - CFBundleURLSchemes - - skysmartlock - - - - CFBundleURLIconFile - - CFBundleTypeRole - None - - io.flutter.embedded_views_preview diff --git a/lib/mine/mall/lockMall_logic.dart b/lib/mine/mall/lockMall_logic.dart index 9ff79012..e9daa4e9 100755 --- a/lib/mine/mall/lockMall_logic.dart +++ b/lib/mine/mall/lockMall_logic.dart @@ -66,8 +66,8 @@ class LockMallLogic extends BaseGetXController { //监听webview的调用 Future flutterBridge(JavaScriptMessage message) async { - final dynamic obj = jsonDecode(message.message); - AppLog.log(obj); + final dynamic obj = json.decode(message.message); + AppLog.log(obj.toString()); if (obj is! Map && obj['action'] is String) { return; } diff --git a/pubspec.yaml b/pubspec.yaml index a4928970..3f11c43b 100755 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -55,6 +55,13 @@ version: 1.0.41+2024051705 environment: sdk: '>=2.12.0 <3.0.0' +fluwx: + app_id: 'wxbe340095d2b8fd51' + debug_logging: true + android: + ios: + universal_link: https://lock.skychip.top/apple-app-site-association.json + # Dependencies specify other packages that your package needs in order to work. # To automatically upgrade your package dependencies to the latest versions # consider running `flutter pub upgrade --major-versions`. Alternatively, From a35e184b6070cc770dd379e9a4cb91adae589228 Mon Sep 17 00:00:00 2001 From: Daisy <> Date: Sat, 18 May 2024 14:54:44 +0800 Subject: [PATCH 05/44] =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E6=9D=83=E9=99=90=E4=BB=A5=E5=8F=8A=E6=98=AF=E5=90=A6=E6=8B=A5?= =?UTF-8?q?=E6=9C=89=E9=94=81=E6=9D=A5=E6=98=BE=E7=A4=BA=E9=AB=98=E7=BA=A7?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E7=9B=B8=E5=85=B3=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/mine/mine/starLockMine_page.dart | 7 ++++--- .../valueAddedServicesList_page.dart | 8 ++++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/mine/mine/starLockMine_page.dart b/lib/mine/mine/starLockMine_page.dart index d59c3225..74d0fb59 100755 --- a/lib/mine/mine/starLockMine_page.dart +++ b/lib/mine/mine/starLockMine_page.dart @@ -91,9 +91,10 @@ class StarLockMinePageState extends State with BaseWidget { ), Obx(() => GestureDetector( onTap: () { - if (state.isVip.value == null || !state.isVip.value) { - if (CommonDataManage().currentKeyInfo == null) { - logic.showToast('请先添加设备'); + if (!state.isVip.value) { + if (CommonDataManage().currentKeyInfo.isLockOwner != + 1) { + logic.showToast('请先添加锁'); } else { Get.toNamed(Routers.advancedFeaturesWebPage, arguments: {'isShop': true}); diff --git a/lib/mine/valueAddedServices/valueAddedServicesList/valueAddedServicesList_page.dart b/lib/mine/valueAddedServices/valueAddedServicesList/valueAddedServicesList_page.dart index 33744dcf..6b599b24 100755 --- a/lib/mine/valueAddedServices/valueAddedServicesList/valueAddedServicesList_page.dart +++ b/lib/mine/valueAddedServices/valueAddedServicesList/valueAddedServicesList_page.dart @@ -66,8 +66,12 @@ class _ValueAddedServicesPageListState TranslationLoader.lanKeys!.advancedFunction!.tr, () async { var isVip = await Storage.getBool(saveIsVip); if (isVip == null || !isVip) { - Get.toNamed(Routers.advancedFeaturesWebPage, - arguments: {'isShop': true}); + if (CommonDataManage().currentKeyInfo.isLockOwner != 1) { + logic.showToast('请先添加锁'); + } else { + Get.toNamed(Routers.advancedFeaturesWebPage, + arguments: {'isShop': true}); + } } else { Get.toNamed(Routers.valueAddedServicesHighFunctionPage); } From 8988c59800792b4786ce80a92c753360fd979296 Mon Sep 17 00:00:00 2001 From: anfe <448468458@qq.com> Date: Sat, 18 May 2024 14:57:02 +0800 Subject: [PATCH 06/44] =?UTF-8?q?feat:=E6=B7=BB=E5=8A=A0=20flutter=20?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E7=9B=91=E6=8E=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ios/Runner/Info.plist | 10 +++ lib/app_settings/app_settings.dart | 85 +++++++++++++----------- lib/main.dart | 32 ++++++--- lib/mine/about/debug/debug_console.dart | 4 +- lib/translations/translation_loader.dart | 20 +++--- 5 files changed, 91 insertions(+), 60 deletions(-) diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist index 9cfa745c..9266fd0f 100755 --- a/ios/Runner/Info.plist +++ b/ios/Runner/Info.plist @@ -48,6 +48,16 @@ 123456 + + CFBundleTypeRole + Editor + CFBundleURLName + weixin + CFBundleURLSchemes + + wxbe340095d2b8fd51 + + CFBundleVersion $(FLUTTER_BUILD_NUMBER) diff --git a/lib/app_settings/app_settings.dart b/lib/app_settings/app_settings.dart index 7998bf68..04bbe53d 100755 --- a/lib/app_settings/app_settings.dart +++ b/lib/app_settings/app_settings.dart @@ -4,38 +4,41 @@ import 'dart:io'; import 'package:star_lock/mine/about/debug/debug_console.dart'; - class AppLog { static bool _printLog = false; static bool _onlyError = false; - static showLog({required bool printLog, bool? onlyError}){ + static void showLog({required bool printLog, bool? onlyError}) { _printLog = printLog; _onlyError = onlyError ?? false; } - static log(String msg,{bool? error}){ + + static void log(String msg, {StackTrace? stackTrace, bool? error}) { msg = '${DateTime.now().toIso8601String()} : $msg'; - DebugConsole.info(msg); - if(!kDebugMode)return; + DebugConsole.info(msg, stackTrace: stackTrace, isErr: error ?? false); + if (!kDebugMode) { + return; + } error = error ?? false; // if(!_printLog)return; // if(_onlyError && !error) return; - if(error){ - msg = '----->>> $msg'; + if (error) { + msg = '----->>> $msg $stackTrace'; } Get.log(msg); } } class AppPlatform { - static bool isIOS = Platform.isIOS; - static bool isAndroid = Platform.isAndroid; - static String platformString(){ + static bool isIOS = Platform.isIOS; + static bool isAndroid = Platform.isAndroid; + + static String platformString() { String name = 'unknown'; - if(isIOS){ + if (isIOS) { name = 'iOS'; } - if(isAndroid){ + if (isAndroid) { name = 'Android'; } return name; @@ -44,50 +47,59 @@ class AppPlatform { static String _brand = 'unknown'; static int _sdkInt = 23; - static void setBrandString(String brand){ + static void setBrandString(String brand) { _brand = brand; } - static String getBrandString()=>_brand; - static void setSDKInt(int sdkInt){ + + static String getBrandString() => _brand; + + static void setSDKInt(int sdkInt) { _sdkInt = sdkInt; } - static bool isSamsung()=>_brand.toLowerCase().contains('samsung'); - static int getSdkIntValue()=>_sdkInt; - static bool onlyCanNetUpgrade()=>isSamsung() && (getSdkIntValue() >= 29); + static bool isSamsung() => _brand.toLowerCase().contains('samsung'); + + static int getSdkIntValue() => _sdkInt; + + static bool onlyCanNetUpgrade() => isSamsung() && (getSdkIntValue() >= 29); } class AppMowerCodes { - static int idCodeLength(){ + static int idCodeLength() { int len = 19; return len; } + static int fenceNameLength = 8; static int registerCodeLength = 4; } class AppDate { static String dateString() { - return '${year()}-${month().toString().padLeft(2,'0')}-${day().toString() - .padLeft(2,'0')}'; + return '${year()}-${month().toString().padLeft(2, '0')}-${day().toString().padLeft(2, '0')}'; } static String calendarString() { - String temp = '${year()}${month().toString().padLeft(2,'0')}${day().toString() - .padLeft(2,'0')}${hour().toString().padLeft(2,'0')}${second() - .toString().padLeft(2,'0')}'; + String temp = + '${year()}${month().toString().padLeft(2, '0')}${day().toString().padLeft(2, '0')}${hour().toString().padLeft(2, '0')}${second().toString().padLeft(2, '0')}'; return temp; } - static int year()=>DateTime.now().year; - static int month()=>DateTime.now().month; - static int day()=>DateTime.now().day; - static int hour()=>DateTime.now().hour; - static int minute()=>DateTime.now().minute; - static int second()=>DateTime.now().second; - static int weekDay()=>DateTime.now().weekday; - static int timeZeroOffset()=>DateTime.now().timeZoneOffset.inHours; + static int year() => DateTime.now().year; + static int month() => DateTime.now().month; + + static int day() => DateTime.now().day; + + static int hour() => DateTime.now().hour; + + static int minute() => DateTime.now().minute; + + static int second() => DateTime.now().second; + + static int weekDay() => DateTime.now().weekday; + + static int timeZeroOffset() => DateTime.now().timeZoneOffset.inHours; } //TODO:错误类型 @@ -99,9 +111,9 @@ enum ErrorType { } class AppErrorCode { - static int errorCode(ErrorType type){ + static int errorCode(ErrorType type) { int code = 0; - switch(type){ + switch (type) { case ErrorType.modeNotMatch: code = 1; break; @@ -118,8 +130,3 @@ class AppErrorCode { return code; } } - - - - - diff --git a/lib/main.dart b/lib/main.dart index 2d09e1a8..8b2c3710 100755 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,14 +1,16 @@ import 'dart:async'; + import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:get/get.dart'; import 'package:star_lock/flavors.dart'; -import 'package:star_lock/translations/trans_lib.dart'; -import 'app.dart'; import 'package:star_lock/tools/device_info_service.dart'; import 'package:star_lock/tools/platform_info_services.dart'; +import 'package:star_lock/translations/trans_lib.dart'; + +import 'app.dart'; import 'app_settings/app_settings.dart'; import 'tools/store_service.dart'; -import 'package:get/get.dart'; // 该文件不可作为编译入口,请查看 flavorizr.yaml 中的说明 FutureOr main() async { @@ -19,20 +21,32 @@ FutureOr main() async { // 设置国际化信息 await _initTranslation(); - runApp(const MyApp()); + //错误日志监控 + FlutterError.onError = (FlutterErrorDetails details) async { + AppLog.log('error:${details.exception.toString()}', + stackTrace: details.stack, error: true); + Zone.current.handleUncaughtError(details.exception, details.stack!); + }; + + //错误日志监控 + runZonedGuarded>(() async { + runApp(const MyApp()); + }, (Object error, StackTrace stackTrace) async { + AppLog.log('error:$error', stackTrace: stackTrace, error: true); + }); if (AppPlatform.isAndroid) { - SystemUiOverlayStyle systemUiOverlayStyle = - const SystemUiOverlayStyle(statusBarColor: Colors.transparent); + const SystemUiOverlayStyle systemUiOverlayStyle = + SystemUiOverlayStyle(statusBarColor: Colors.transparent); SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle); } } // 设置国际化信息 Future _initTranslation() async => TranslationLoader.loadTranslation( - zhSource: "images/lan/lan_zh.json", - enSource: "images/lan/lan_en.json", - keySource: "images/lan/lan_keys.json", + zhSource: 'images/lan/lan_zh.json', + enSource: 'images/lan/lan_en.json', + keySource: 'images/lan/lan_keys.json', ); // 设置包名服务设备信息 diff --git a/lib/mine/about/debug/debug_console.dart b/lib/mine/about/debug/debug_console.dart index b7a96d22..ebb3406a 100755 --- a/lib/mine/about/debug/debug_console.dart +++ b/lib/mine/about/debug/debug_console.dart @@ -8,7 +8,6 @@ import 'package:star_lock/mine/about/debug/controller.dart'; import 'package:star_lock/mine/about/debug/log.dart'; import 'package:star_lock/mine/about/debug/tile.dart'; - /// # Debug Console /// /// A console for debugging Flutter apps, and displaying console messages on the widget. @@ -104,10 +103,11 @@ class DebugConsole extends StatefulWidget { Object? message, { DateTime? timestamp, StackTrace? stackTrace, + bool isErr = false, }) => log( message, - level: DebugConsoleLevel.info, + level: isErr ? DebugConsoleLevel.error : DebugConsoleLevel.info, timestamp: timestamp, stackTrace: stackTrace, ); diff --git a/lib/translations/translation_loader.dart b/lib/translations/translation_loader.dart index afdc737f..a8dd33ed 100755 --- a/lib/translations/translation_loader.dart +++ b/lib/translations/translation_loader.dart @@ -6,9 +6,9 @@ class TranslationLoader { static bool get isEn => Get.locale?.languageCode.toLowerCase() == 'en'; static Map - _zhMap = {}, - _enMap = {}, - _keyMap = {}; + _zhMap = {}, + _enMap = {}, + _keyMap = {}; static Map get zhDic => _zhMap; static Map get enDic => _enMap; @@ -16,7 +16,7 @@ class TranslationLoader { static LanKeyEntity? _lanKeyEntity; static LanKeyEntity? get lanKeys => _lanKeyEntity; - static Future loadTranslation({ + static Future loadTranslation({ String? zhSource, String? enSource, String? keySource,}) async { @@ -26,15 +26,15 @@ class TranslationLoader { _lanKeyEntity = LanKeyEntity.fromJson(_keyMap); } - static Future> _loadJsonFile(String filePath) async => rootBundle.loadString(filePath).then((jsonString){ - Map enJson = jsonDecode(jsonString); - Map map = {}; - enJson.forEach((key, value) { + static Future> _loadJsonFile(String filePath) async => rootBundle.loadString(filePath).then((String jsonString){ + final Map enJson = jsonDecode(jsonString); + final Map map = {}; + enJson.forEach((String key,dynamic value) { map[key] = value.toString(); }); return map; - }).onError((error, stackTrace){ - return Future.value({}); + }).onError((Object? error, StackTrace stackTrace){ + return Future>.value({}); }); } From f60613a549c3630e76f0fe847497c36c72f5e602 Mon Sep 17 00:00:00 2001 From: anfe <448468458@qq.com> Date: Sat, 18 May 2024 15:21:32 +0800 Subject: [PATCH 07/44] =?UTF-8?q?feat:=E6=89=93=E5=8C=85=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .DS_Store | Bin 6148 -> 6148 bytes pubspec.yaml | 3 ++- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.DS_Store b/.DS_Store index e5bcb7e3dd236e05c1702c467c8668c6b8f01e90..ab459319e6a778b2a3dea34e5b8e7b01e88e0ec3 100755 GIT binary patch delta 51 zcmZoMXfc@J&&azmU^g=(?`9sB=S744Di$3@K&7MR_^-dFc!c42%;K|88dI H_{$Ffc+C$I delta 28 kcmZoMXfc@J&&abeU^g=(&t@K$=S&+@MHn};bNuB80D*=G#sB~S diff --git a/pubspec.yaml b/pubspec.yaml index 3f11c43b..e9487b95 100755 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -49,8 +49,9 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # 1.0.39+2024051703:打包给欧阳回归测试 # 1.0.40+2024051704:打包给欧阳回归测试 # 1.0.41+2024051705:打包给公司测试 +# 1.0.42+2024051801:打包给欧阳回归测试 -version: 1.0.41+2024051705 +version: 1.0.42+2024051801 environment: sdk: '>=2.12.0 <3.0.0' From 0df385cba2330bf0e5616a1dcb0f42a04e67f045 Mon Sep 17 00:00:00 2001 From: anfe <448468458@qq.com> Date: Sat, 18 May 2024 15:58:50 +0800 Subject: [PATCH 08/44] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=91=98=E5=B7=A5=E5=AF=86=E7=A0=81=E5=90=8E=E5=9B=9B=E4=BD=8D?= =?UTF-8?q?=E6=B2=A1=E6=9C=89****=E5=8F=B7=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/app.dart | 19 +- .../checkingInAddStaff_page.dart | 269 +++++++++++------- 2 files changed, 174 insertions(+), 114 deletions(-) diff --git a/lib/app.dart b/lib/app.dart index a88fa173..f674b529 100755 --- a/lib/app.dart +++ b/lib/app.dart @@ -11,7 +11,6 @@ import 'package:star_lock/main/lockMian/lockMain/lockMain_logic.dart'; import 'package:star_lock/tools/app_manager.dart'; import 'package:star_lock/tools/bindings/app_binding.dart'; import 'package:star_lock/tools/storage.dart'; -import 'package:star_lock/tools/xs_jPhush.dart'; import 'package:star_lock/translations/app_dept.dart'; import 'package:star_lock/translations/trans_lib.dart'; @@ -19,7 +18,6 @@ import 'package:star_lock/translations/trans_lib.dart'; import 'appRouters.dart'; import 'baseWidget.dart'; import 'tools/appRouteObserver.dart'; -import 'dart:io'; import 'tools/store_service.dart'; @@ -38,24 +36,25 @@ class _MyAppState extends State with WidgetsBindingObserver, BaseWidget { Widget build(BuildContext context) { return ScreenUtilInit( designSize: const Size(585, 1265), - builder: (w, a) => _initMaterialApp()); + builder: (BuildContext w, Widget? a) => _initMaterialApp()); } GetMaterialApp _initMaterialApp() => GetMaterialApp( // enableLog: false, title: F.navTitle, - navigatorObservers: [AppRouteObserver().routeObserver], + navigatorObservers: [AppRouteObserver().routeObserver], translations: TranslationMessage(), supportedLocales: appDept.deptSupportedLocales, - localizationsDelegates: const [ + localizationsDelegates: const >[ GlobalMaterialLocalizations.delegate, GlobalCupertinoLocalizations.delegate, GlobalWidgetsLocalizations.delegate, ], - localeResolutionCallback: (locale, supportedLocales) { + localeResolutionCallback: + (Locale? locale, Iterable supportedLocales) { if (!supportedLocales.contains(locale)) { - int idx = appSupportedLocales.indexWhere( - (element) => element.languageCode == locale!.languageCode); + final int idx = appSupportedLocales.indexWhere( + (Locale element) => element.languageCode == locale!.languageCode); if (idx != -1) { locale = appSupportedLocales[idx]; } else { @@ -68,7 +67,7 @@ class _MyAppState extends State with WidgetsBindingObserver, BaseWidget { }, locale: StoreService.to.getLanguageCode()!.isNotEmpty ? appDept.deptSupportedLocales - .where((element) => + .where((Locale element) => element.languageCode == StoreService.to.getLanguageCode()) .first : Get.deviceLocale, @@ -148,7 +147,7 @@ class _MyAppState extends State with WidgetsBindingObserver, BaseWidget { } Future getLoginStatus() async { - final data = await Storage.getString(saveUserLoginData); + final String? data = await Storage.getString(saveUserLoginData); if (data != null && data.isNotEmpty) { return true; } diff --git a/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_page.dart b/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_page.dart index 4f600d95..9a03705f 100755 --- a/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_page.dart +++ b/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_page.dart @@ -2,6 +2,8 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; +import 'package:star_lock/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaffSelectKey_entity.dart'; +import 'package:star_lock/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_state.dart'; import '../../../../../appRouters.dart'; import '../../../../../app_settings/app_colors.dart'; @@ -20,8 +22,9 @@ class CheckingInAddStaffPage extends StatefulWidget { } class _CheckingInAddStaffPageState extends State { - final logic = Get.put(CheckingInAddStaffLogic()); - final state = Get.find().state; + final CheckingInAddStaffLogic logic = Get.put(CheckingInAddStaffLogic()); + final CheckingInAddStaffState state = + Get.find().state; @override Widget build(BuildContext context) { @@ -33,11 +36,11 @@ class _CheckingInAddStaffPageState extends State { haveBack: true, backgroundColor: AppColors.mainColor), body: Column( - children: [ + children: [ // 姓名 CommonItem( leftTitel: TranslationLoader.lanKeys!.name!.tr, - rightTitle: "", + rightTitle: '', isHaveLine: true, isHaveRightWidget: true, rightWidget: getTFWidget( @@ -50,35 +53,42 @@ class _CheckingInAddStaffPageState extends State { isHaveLine: false, isHaveDirection: true, action: () { - var list = ["APP", "密码".tr, "卡".tr, "指纹".tr]; - if(state.getKeyInfosData.value.lockName!.contains("T9A")){ - list.add("人脸".tr); + final List list = [ + 'APP', + '密码'.tr, + '卡'.tr, + '指纹'.tr + ]; + if (state.getKeyInfosData.value.lockName!.contains('T9A')) { + list.add('人脸'.tr); } - _showSelectClockInType(list, list, "1", "选择钥匙".tr); + _showSelectClockInType(list, list, '1', '选择钥匙'.tr); })), SizedBox(height: 10.h), //员工是否有App、卡、钥匙、指纹必须显示 Obx(() => CommonItem( leftTitel: addStaffGetIfHaveKey(), - rightTitle: "", + rightTitle: '', isHaveLine: true, isHaveRightWidget: true, rightWidget: Row( - children: [ - whetherTheEmployeeHasAKeyWidget("无".tr, state.appUnHaveAccount.value, () { + children: [ + whetherTheEmployeeHasAKeyWidget( + '无'.tr, state.appUnHaveAccount.value, () { setState(() { state.appUnHaveAccount.value = true; - state.attendanceWayNumber.value = ""; + state.attendanceWayNumber.value = ''; logic.isCanClickAction(); }); }), SizedBox( width: 30.w, ), - whetherTheEmployeeHasAKeyWidget("有".tr, !state.appUnHaveAccount.value, () { + whetherTheEmployeeHasAKeyWidget( + '有'.tr, !state.appUnHaveAccount.value, () { setState(() { state.appUnHaveAccount.value = false; - state.attendanceWayNumber.value = ""; + state.attendanceWayNumber.value = ''; logic.isCanClickAction(); }); }), @@ -86,12 +96,15 @@ class _CheckingInAddStaffPageState extends State { ))), // 当选择App时且没有钥匙的时候 显示输入账号输入框和选择国家 其他隐藏 Obx(() => Visibility( - visible: (state.appUnHaveAccount.value && state.selectPrintingMethodType.value == "1") ? true : false, + visible: (state.appUnHaveAccount.value && + state.selectPrintingMethodType.value == '1') + ? true + : false, child: Column( - children: [ + children: [ CommonItem( leftTitel: TranslationLoader.lanKeys!.accountNumber!.tr, - rightTitle: "", + rightTitle: '', isHaveLine: true, isHaveRightWidget: true, rightWidget: getTFWidget( @@ -100,7 +113,7 @@ class _CheckingInAddStaffPageState extends State { CommonItem( leftTitel: TranslationLoader.lanKeys!.countryAndRegion!.tr, - rightTitle: "", + rightTitle: '', isHaveLine: true, isHaveRightWidget: true, isHaveDirection: true, @@ -112,7 +125,7 @@ class _CheckingInAddStaffPageState extends State { color: AppColors.darkGrayTextColor), ), action: () async { - var result = await Navigator.pushNamed( + final Object? result = await Navigator.pushNamed( context, Routers.selectCountryRegionPage); if (result != null) { result as Map; @@ -127,103 +140,128 @@ class _CheckingInAddStaffPageState extends State { )), // 当选择密码、卡、指纹时显示 Obx(() => Visibility( - visible: (state.selectPrintingMethodType.value != "1" && state.appUnHaveAccount.value) ? true : false, + visible: state.selectPrintingMethodType.value != '1' && + state.appUnHaveAccount.value, child: CommonItem( leftTitel: addStaffGetKeyType(), isHaveLine: false, isHaveRightWidget: true, rightWidget: Row( - children: [ - Obx(() => Text(state.attendanceWayNumber.value, style: TextStyle(fontSize: 24.sp))), + children: [ + Obx(() => Text(state.attendanceWayNumber.value, + style: TextStyle(fontSize: 24.sp))), SizedBox(width: 30.w), GestureDetector( onTap: () async { - switch (int.parse(state.selectPrintingMethodType.value)) { + switch (int.parse( + state.selectPrintingMethodType.value)) { case 2: - // 获取密码 + // 获取密码 logic.getKeyboardPwdRequest(); break; case 3: - // 卡 + // 卡 if (state.staffNameController.text.isEmpty) { - logic.showToast("请输入姓名".tr); + logic.showToast('请输入姓名'.tr); return; } - var data = await Get.toNamed( + final data = await Get.toNamed( Routers.addCardPage, - arguments: { - "lockId": state.getKeyInfosData.value.lockId, - "fromType": 2, // 1从添加钥匙列表进入 2从考勤添加员工入口进入 - "fromTypeTwoStaffName": state.staffNameController.text + arguments: { + 'lockId': + state.getKeyInfosData.value.lockId, + 'fromType': 2, // 1从添加钥匙列表进入 2从考勤添加员工入口进入 + 'fromTypeTwoStaffName': + state.staffNameController.text }); - if (data != null) { - - } + if (data != null) {} break; case 4: - // 指纹 + // 指纹 if (state.staffNameController.text.isEmpty) { - logic.showToast("请输入姓名".tr); + logic.showToast('请输入姓名'.tr); return; } - var data = await Get.toNamed( + final data = await Get.toNamed( Routers.addFingerprintTypePage, - arguments: { - "lockId": state.getKeyInfosData.value.lockId, - "fromType": 2, // 1从添加钥匙列表进入 2从考勤添加员工入口进入 - "fromTypeTwoStaffName": state.staffNameController.text + arguments: { + 'lockId': + state.getKeyInfosData.value.lockId, + 'fromType': 2, // 1从添加钥匙列表进入 2从考勤添加员工入口进入 + 'fromTypeTwoStaffName': + state.staffNameController.text }); - if (data != null) { - - } + if (data != null) {} break; case 5: - Get.toNamed(Routers.addFaceTypePage, arguments: { - "lockId": state.getKeyInfosData.value.lockId, - "fromType": 2, // 1从添加钥匙列表进入 2从考勤添加员工入口进入 - "fromTypeTwoStaffName": state.staffNameController.text - }); + Get.toNamed(Routers.addFaceTypePage, + arguments: { + 'lockId': + state.getKeyInfosData.value.lockId, + 'fromType': 2, // 1从添加钥匙列表进入 2从考勤添加员工入口进入 + 'fromTypeTwoStaffName': + state.staffNameController.text + }); break; } }, child: Container( height: 40.h, - padding: EdgeInsets.only(left: 25.w, right: 25.w, top: 2.h), + padding: EdgeInsets.only( + left: 25.w, right: 25.w, top: 2.h), decoration: BoxDecoration( color: AppColors.mainColor, borderRadius: BorderRadius.circular(20.h), ), - child: Text(addStaffSelectKeyType(), textAlign: TextAlign.center, - style: TextStyle(color: Colors.white, fontSize: 22.sp) - ), + child: Text(addStaffSelectKeyType(), + textAlign: TextAlign.center, + style: TextStyle( + color: Colors.white, fontSize: 22.sp)), ), ), ], )), )), // 当选择钥匙类型为有时 必显示 - Obx(() => Visibility( - visible: !state.appUnHaveAccount.value, - child: CommonItem( - leftTitel: addStaffGetKeyType(), - rightTitle: state.attendanceWayNumber.value, - isHaveLine: false, - isHaveDirection: true, - action: () { - logic.addStaffSelectKey((v) { - var showList = []; - List numberList = []; - for (var element in v) { - showList.add("${element.staffName}-${element.attendanceWay}"); - numberList.add(element.attendanceWay); + Obx(() { + final bool isPass = state.selectPrintingMethodType.value == '2'; + String rightTitle = state.attendanceWayNumber.value; + if (isPass) { + rightTitle = showPass(rightTitle); + } + return Visibility( + visible: !state.appUnHaveAccount.value, + child: CommonItem( + leftTitel: addStaffGetKeyType(), + rightTitle: rightTitle, + isHaveLine: false, + isHaveDirection: true, + action: () { + logic.addStaffSelectKey( + (List v) { + final List showList = []; + final List numberList = []; + for (final CheckingInAddStaffKeyEntity element in v) { + final bool isPass = + state.selectPrintingMethodType.value == '2'; + String attendanceWay = element.attendanceWay ?? ''; + if (isPass) { + attendanceWay = showPass(attendanceWay); } - _showSelectClockInType(showList, numberList, "2", addStaffSelectKeySelectClockInType()); - }); - }), - )), + final String text = + '${element.staffName}-$attendanceWay'; + showList.add(text); + numberList.add(element.attendanceWay ?? ''); + } + _showSelectClockInType(showList, numberList, '2', + addStaffSelectKeySelectClockInType()); + }); + }), + ); + }), SizedBox(height: 50.w), Obx(() => SubmitBtn( btnName: TranslationLoader.lanKeys!.sure!.tr, @@ -231,25 +269,38 @@ class _CheckingInAddStaffPageState extends State { margin: EdgeInsets.only(left: 30.w, right: 30.w, top: 30.w), padding: EdgeInsets.only(top: 25.w, bottom: 25.w), isDisabled: state.isCanClick.value, - onClick: state.isCanClick.value ? (){ - if (state.isAdd.value == "2") { - logic.editStaffLoadData(); - } else { - logic.addStaffLoadData(); - } - }: null)) + onClick: state.isCanClick.value + ? () { + if (state.isAdd.value == '2') { + logic.editStaffLoadData(); + } else { + logic.addStaffLoadData(); + } + } + : null)) ], ), ); } + //显示密码 + String showPass(String text) { + final int length = text.length; + if (length > 4) { + return text.substring(0, length - 4) + '****'; + } else if (length > 00) { + return '****'; + } + return ''; + } + Widget getTFWidget(String tfStr, TextEditingController tf) { return SizedBox( // height: 50.h, width: 300.w, // color: Colors.red, child: Row( - children: [ + children: [ Expanded( child: TextField( //输入框一行 @@ -258,11 +309,12 @@ class _CheckingInAddStaffPageState extends State { FilteringTextInputFormatter.deny('\n'), // LengthLimitingTextInputFormatter(30), ], - style: TextStyle(fontSize: 22.sp, color: AppColors.darkGrayTextColor), + style: TextStyle( + fontSize: 22.sp, color: AppColors.darkGrayTextColor), controller: tf, autofocus: false, textAlign: TextAlign.end, - onChanged: (v) { + onChanged: (String v) { logic.changeInput(tf); }, decoration: InputDecoration( @@ -270,10 +322,18 @@ class _CheckingInAddStaffPageState extends State { // contentPadding: const EdgeInsets.only(top: 12.0, bottom: 8.0), hintText: tfStr, hintStyle: TextStyle(fontSize: 22.sp), - focusedBorder: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)), - disabledBorder: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)), - enabledBorder: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)), - border: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)), + focusedBorder: const OutlineInputBorder( + borderSide: + BorderSide(width: 0, color: Colors.transparent)), + disabledBorder: const OutlineInputBorder( + borderSide: + BorderSide(width: 0, color: Colors.transparent)), + enabledBorder: const OutlineInputBorder( + borderSide: + BorderSide(width: 0, color: Colors.transparent)), + border: const OutlineInputBorder( + borderSide: + BorderSide(width: 0, color: Colors.transparent)), contentPadding: const EdgeInsets.symmetric(vertical: 0), ), ), @@ -284,7 +344,8 @@ class _CheckingInAddStaffPageState extends State { } // type 1 打卡方式 2选择钥匙 - void _showSelectClockInType(List showList, List numberList, String showBottomSheetToolType, String title) { + void _showSelectClockInType(List showList, List numberList, + String showBottomSheetToolType, String title) { ShowBottomSheetTool().showSingleRowPicker( //上下文 context, @@ -298,12 +359,12 @@ class _CheckingInAddStaffPageState extends State { //adapter: PickerAdapter(), data: showList, //选择事件的回调 - clickCallBack: (int index, var str) { + clickCallBack: (int index, Object str) { setState(() { - if (showBottomSheetToolType == "1") { + if (showBottomSheetToolType == '1') { state.selectPrintingMethodType.value = (index + 1).toString(); state.selectPrintingMethodStr.value = str.toString(); - state.attendanceWayNumber.value = ""; + state.attendanceWayNumber.value = ''; } else { state.attendanceWayNumber.value = numberList[index].toString(); } @@ -312,16 +373,17 @@ class _CheckingInAddStaffPageState extends State { }); } - Widget whetherTheEmployeeHasAKeyWidget(String title, bool appUnHaveAccount, Function() action) { + Widget whetherTheEmployeeHasAKeyWidget( + String title, bool appUnHaveAccount, Function() action) { return GestureDetector( onTap: action, child: Container( // width: 80.w, height: 65.w, - padding: EdgeInsets.only(left:10.w, right: 10.w), + padding: EdgeInsets.only(left: 10.w, right: 10.w), // color: Colors.red, child: Row( - children: [ + children: [ Image.asset( appUnHaveAccount ? 'images/icon_round_select.png' @@ -345,7 +407,7 @@ class _CheckingInAddStaffPageState extends State { } String addStaffGetIfHaveKey() { - String title = ""; + String title = ''; switch (int.parse(state.selectPrintingMethodType.value)) { case 1: title = TranslationLoader.lanKeys!.whetherTheEmployeeHasAKey!.tr; @@ -360,14 +422,14 @@ class _CheckingInAddStaffPageState extends State { title = TranslationLoader.lanKeys!.whetherTheEmployeeHasFingerprint!.tr; break; case 4: - title = "员工是否有人脸".tr; + title = '员工是否有人脸'.tr; break; } return title; } String addStaffGetKeyType() { - String title = ""; + String title = ''; switch (int.parse(state.selectPrintingMethodType.value)) { case 1: title = TranslationLoader.lanKeys!.accountNumber!.tr; @@ -389,7 +451,7 @@ class _CheckingInAddStaffPageState extends State { } String addStaffSelectKeyType() { - String title = ""; + String title = ''; switch (int.parse(state.selectPrintingMethodType.value)) { case 1: title = TranslationLoader.lanKeys!.getKey!.tr; @@ -404,32 +466,31 @@ class _CheckingInAddStaffPageState extends State { title = TranslationLoader.lanKeys!.getFingerprint!.tr; break; case 5: - title = "获取人脸".tr; + title = '获取人脸'.tr; break; } return title; } String addStaffSelectKeySelectClockInType() { - String title = ""; + String title = ''; switch (int.parse(state.selectPrintingMethodType.value)) { case 1: - title = "选择钥匙".tr; + title = '选择钥匙'.tr; break; case 2: - title = "选择密码".tr; + title = '选择密码'.tr; break; case 3: - title = "选择卡".tr; + title = '选择卡'.tr; break; case 4: - title = "选择指纹".tr; + title = '选择指纹'.tr; break; case 5: - title = "选择人脸".tr; + title = '选择人脸'.tr; break; } return title; } - } From af04296143c7ec2e4ffe144290f23e3a7a56a3ca Mon Sep 17 00:00:00 2001 From: anfe <448468458@qq.com> Date: Sat, 18 May 2024 16:38:50 +0800 Subject: [PATCH 09/44] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E7=94=B5=E5=AD=90?= =?UTF-8?q?=E9=92=A5=E5=8C=99=E9=87=8C=E7=9A=84=E6=8E=88=E6=9D=83=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=91=98=E8=AF=A6=E6=83=85=E5=A4=9A=E4=BA=86=E5=8F=96?= =?UTF-8?q?=E6=B6=88=E6=8E=88=E6=9D=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../electronicKeyDetail_logic.dart | 194 ++++++++++-------- .../electronicKeyList_page.dart | 43 ++-- 2 files changed, 126 insertions(+), 111 deletions(-) diff --git a/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_logic.dart b/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_logic.dart index ba70139e..708938d8 100755 --- a/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_logic.dart +++ b/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_logic.dart @@ -25,17 +25,17 @@ class ElectronicKeyDetailLogic extends BaseGetXController { //修改钥匙名称请求 Future modifyKeyNameRequest() async { if (state.changeNameController.text.isEmpty) { - showToast("请输入钥匙名称".tr); + showToast('请输入钥匙名称'.tr); return; } - KeyOperationRecordEntity entity = await ApiRepository.to + final KeyOperationRecordEntity entity = await ApiRepository.to .modifyKeyNameForAdmin(state.itemData.value.keyId.toString(), state.changeNameController.text, ''); if (entity.errorCode!.codeIsSuccessful) { state.itemData.value.keyName = state.changeNameController.text; state.keyName.value = state.itemData.value.keyName!; Get.back(); - showToast("修改成功".tr, something: () { + showToast('修改成功'.tr, something: () { eventBus.fire(ElectronicKeyListRefreshUI()); eventBus.fire(AuthorizedAdminPageRefreshUI()); }); @@ -44,19 +44,21 @@ class ElectronicKeyDetailLogic extends BaseGetXController { //编辑电子钥匙有效期请求 updateType 1:仅管理自己创建的用户 2:远程开锁 Future updateKeyDateRequest(int updateType) async { - KeyOperationRecordEntity entity = await ApiRepository.to.updateKeyDate( - keyId: state.itemData.value.keyId.toString(), - lockId: state.itemData.value.lockId.toString(), - endDate: state.endDate.value.toString(), - startDate: state.starDate.value.toString(), - weekDays: state.itemData.value.weekDays!, - keyType: state.itemData.value.keyType!, - startTime: int.parse(state.starTime.value), - endTime: int.parse(state.endTime.value), - isOnlyManageSelf: state.onlyManageYouCreatesUser.value == true ? 1 : 0, - remoteEnable: state.isRemoteUnlock.value == true ? 1 : 2); + final KeyOperationRecordEntity entity = await ApiRepository.to + .updateKeyDate( + keyId: state.itemData.value.keyId.toString(), + lockId: state.itemData.value.lockId.toString(), + endDate: state.endDate.value.toString(), + startDate: state.starDate.value.toString(), + weekDays: state.itemData.value.weekDays!, + keyType: state.itemData.value.keyType!, + startTime: int.parse(state.starTime.value), + endTime: int.parse(state.endTime.value), + isOnlyManageSelf: + state.onlyManageYouCreatesUser.value == true ? 1 : 0, + remoteEnable: state.isRemoteUnlock.value == true ? 1 : 2); if (entity.errorCode!.codeIsSuccessful) { - showToast("修改成功".tr, something: () { + showToast('修改成功'.tr, something: () { eventBus.fire(ElectronicKeyListRefreshUI()); eventBus.fire(AuthorizedAdminPageRefreshUI()); }); @@ -65,11 +67,12 @@ class ElectronicKeyDetailLogic extends BaseGetXController { //删除电子钥匙名称请求 Future deleteKeyRequest(int includeUnderlings) async { - ElectronicKeyListEntity entity = await ApiRepository.to.deleteElectronicKey( - keyId: state.itemData.value.keyId.toString(), - includeUnderlings: includeUnderlings); + final ElectronicKeyListEntity entity = await ApiRepository.to + .deleteElectronicKey( + keyId: state.itemData.value.keyId.toString(), + includeUnderlings: includeUnderlings); if (entity.errorCode!.codeIsSuccessful) { - showToast("删除成功".tr, something: () { + showToast('删除成功'.tr, something: () { eventBus.fire(ElectronicKeyListRefreshUI()); eventBus.fire(AuthorizedAdminPageRefreshUI()); Get.back(); @@ -79,11 +82,12 @@ class ElectronicKeyDetailLogic extends BaseGetXController { //设置授权管理员 Future setAdministrator() async { - ElectronicKeyListEntity entity = await ApiRepository.to.setAdministrator( + final ElectronicKeyListEntity entity = + await ApiRepository.to.setAdministrator( keyId: state.itemData.value.keyId.toString(), ); if (entity.errorCode!.codeIsSuccessful) { - showToast("设置成功".tr, something: () { + showToast('设置成功'.tr, something: () { eventBus.fire(ElectronicKeyListRefreshUI()); eventBus.fire(AuthorizedAdminPageRefreshUI()); Get.back(); @@ -93,11 +97,12 @@ class ElectronicKeyDetailLogic extends BaseGetXController { //取消授权管理员 Future cancelAdministrator() async { - ElectronicKeyListEntity entity = await ApiRepository.to.cancelAdministrator( + final ElectronicKeyListEntity entity = + await ApiRepository.to.cancelAdministrator( keyId: state.itemData.value.keyId.toString(), ); if (entity.errorCode!.codeIsSuccessful) { - showToast("设置成功".tr, something: () { + showToast('设置成功'.tr, something: () { eventBus.fire(ElectronicKeyListRefreshUI()); eventBus.fire(AuthorizedAdminPageRefreshUI()); Get.back(); @@ -107,11 +112,11 @@ class ElectronicKeyDetailLogic extends BaseGetXController { //冻结 Future freezeKey(int includeUnderlings) async { - ElectronicKeyListEntity entity = await ApiRepository.to.freezeKey( + final ElectronicKeyListEntity entity = await ApiRepository.to.freezeKey( keyId: state.itemData.value.keyId.toString(), includeUnderlings: includeUnderlings); if (entity.errorCode!.codeIsSuccessful) { - showToast("设置成功".tr, something: () { + showToast('设置成功'.tr, something: () { eventBus.fire(ElectronicKeyListRefreshUI()); eventBus.fire(AuthorizedAdminPageRefreshUI()); Get.back(); @@ -121,11 +126,11 @@ class ElectronicKeyDetailLogic extends BaseGetXController { //取消冻结 Future cancelFreeze(int includeUnderlings) async { - ElectronicKeyListEntity entity = await ApiRepository.to.cancelFreeze( + final ElectronicKeyListEntity entity = await ApiRepository.to.cancelFreeze( keyId: state.itemData.value.keyId.toString(), includeUnderlings: includeUnderlings); if (entity.errorCode!.codeIsSuccessful) { - showToast("设置成功".tr, something: () { + showToast('设置成功'.tr, something: () { eventBus.fire(ElectronicKeyListRefreshUI()); eventBus.fire(AuthorizedAdminPageRefreshUI()); Get.back(); @@ -137,14 +142,15 @@ class ElectronicKeyDetailLogic extends BaseGetXController { Future checkRealNameStatus(int realNameAuthStatus) async { //打开实名认证 必须输入身份证号和真实姓名 if (realNameAuthStatus == 1) { - AdvancedFunctionRecordEntity entity = await ApiRepository.to.keyCheckFace( + final AdvancedFunctionRecordEntity entity = + await ApiRepository.to.keyCheckFace( lockId: CommonDataManage().currentKeyInfo.lockId ?? 0, ); if (entity.errorCode!.codeIsSuccessful) { if (state.getRealName.value.isEmpty || state.getIDCardNumber.value.isEmpty) { - ShowCupertinoAlertView() - .showOpenAuthWithIDCardInfoAlert((idCard, realName) { + ShowCupertinoAlertView().showOpenAuthWithIDCardInfoAlert( + (String? idCard, String? realName) { state.getIDCardNumber.value = idCard ?? ''; state.getRealName.value = realName ?? ''; updateRealNameInfoWithAuthStatus(realNameAuthStatus); @@ -158,7 +164,7 @@ class ElectronicKeyDetailLogic extends BaseGetXController { titleStr: '实名认证为付费功能,请购买后再使用'.tr, sureClick: () { Get.toNamed(Routers.advancedFeaturesWebPage, - arguments: {'isShop': false}); + arguments: {'isShop': false}); }); } else if (entity.errorCode == 433) { //需联系管理员购买 @@ -171,16 +177,17 @@ class ElectronicKeyDetailLogic extends BaseGetXController { //更新钥匙实名认证信息--实名认证状态 Future updateRealNameInfoWithAuthStatus(int realNameAuthStatus) async { - KeyOperationRecordEntity entity = await ApiRepository.to.updateRealNameInfo( - lockId: state.itemData.value.lockId ?? 0, - keyId: state.itemData.value.keyId ?? 0, - uid: state.itemData.value.uid ?? 0, - faceAuthentication: realNameAuthStatus, - realName: state.getRealName.value, - idCardNumber: state.getIDCardNumber.value); + final KeyOperationRecordEntity entity = await ApiRepository.to + .updateRealNameInfo( + lockId: state.itemData.value.lockId ?? 0, + keyId: state.itemData.value.keyId ?? 0, + uid: state.itemData.value.uid ?? 0, + faceAuthentication: realNameAuthStatus, + realName: state.getRealName.value, + idCardNumber: state.getIDCardNumber.value); if (entity.errorCode!.codeIsSuccessful) { state.isRealNameAuth.value = !state.isRealNameAuth.value; - showToast("修改成功".tr, something: () { + showToast('修改成功'.tr, something: () { eventBus.fire(ElectronicKeyListRefreshUI()); eventBus.fire(AuthorizedAdminPageRefreshUI()); }); @@ -192,25 +199,26 @@ class ElectronicKeyDetailLogic extends BaseGetXController { switch (alertEnum) { case ShowAlertEnum.realName: if (state.changeRealNameController.text.isEmpty) { - showToast("请输入真实姓名".tr); + showToast('请输入真实姓名'.tr); return; } break; case ShowAlertEnum.idCardNumber: if (state.changeIDCardController.text.isEmpty) { - showToast("请输入身份证号".tr); + showToast('请输入身份证号'.tr); return; } break; default: } - KeyOperationRecordEntity entity = await ApiRepository.to.updateRealNameInfo( - lockId: state.itemData.value.lockId ?? 0, - keyId: state.itemData.value.keyId ?? 0, - uid: state.itemData.value.uid ?? 0, - faceAuthentication: state.isRealNameAuth.value ? 1 : 2, - realName: state.changeRealNameController.text, - idCardNumber: state.changeIDCardController.text); + final KeyOperationRecordEntity entity = await ApiRepository.to + .updateRealNameInfo( + lockId: state.itemData.value.lockId ?? 0, + keyId: state.itemData.value.keyId ?? 0, + uid: state.itemData.value.uid ?? 0, + faceAuthentication: state.isRealNameAuth.value ? 1 : 2, + realName: state.changeRealNameController.text, + idCardNumber: state.changeIDCardController.text); if (entity.errorCode!.codeIsSuccessful) { if (alertEnum == ShowAlertEnum.realName) { state.itemData.value.userIdCard!.realName = @@ -222,7 +230,7 @@ class ElectronicKeyDetailLogic extends BaseGetXController { state.getIDCardNumber.value = state.itemData.value.userIdCard!.idCardNumber!; } - showToast("修改成功".tr, something: () { + showToast('修改成功'.tr, something: () { eventBus.fire(ElectronicKeyListRefreshUI()); eventBus.fire(AuthorizedAdminPageRefreshUI()); }); @@ -232,44 +240,54 @@ class ElectronicKeyDetailLogic extends BaseGetXController { String getKeyTypeShowDateTime() { String useDateStr = ''; if (state.keyType.value == 1) { - useDateStr = "永久".tr; + useDateStr = '永久'.tr; } else if (state.keyType.value == 2) { useDateStr = - "${DateTool().dateToYMDHNString(state.starDate.value)}\n${DateTool().dateToYMDHNString(state.endDate.value)}"; + '${DateTool().dateToYMDHNString(state.starDate.value)}\n${DateTool().dateToYMDHNString(state.endDate.value)}'; } else if (state.keyType.value == 3) { - useDateStr = "单次".tr; + useDateStr = '单次'.tr; } else if (state.keyType.value == 4) { useDateStr = - "${DateTool().dateToYMDString(state.starDate.value)}\n${DateTool().dateToYMDString(state.endDate.value)}"; + '${DateTool().dateToYMDString(state.starDate.value)}\n${DateTool().dateToYMDString(state.endDate.value)}'; } return useDateStr; } - Future openModalBottomSheet(BuildContext context) async { - var textList = []; + Future openModalBottomSheet(BuildContext context) async { + List textList = []; if (state.itemData.value.keyRight == 1) { // 授权管理员 - textList = [ - state.itemData.value.keyStatus == XSConstantMacro.keyStatusFrozen ? '取消冻结'.tr : "冻结".tr, - "取消授权".tr + textList = [ + if (state.itemData.value.keyStatus == XSConstantMacro.keyStatusFrozen) + '取消冻结'.tr + else + '冻结'.tr, + // '取消授权'.tr ]; } else if (CommonDataManage().currentKeyInfo.isLockOwner == 1) { // 锁拥有者 if (state.keyType.value == 1 || state.keyType.value == 2) { - textList = [ - state.itemData.value.keyStatus == XSConstantMacro.keyStatusFrozen ? '取消冻结'.tr : "冻结".tr, - state.itemData.value.keyRight == 1 ? '取消授权'.tr : '授权'.tr + textList = [ + if (state.itemData.value.keyStatus == XSConstantMacro.keyStatusFrozen) + '取消冻结'.tr + else + '冻结'.tr, + if (state.itemData.value.keyRight == 1) '取消授权'.tr else '授权'.tr ]; } else if (state.keyType.value == 4) { - textList = [ - state.itemData.value.keyStatus == XSConstantMacro.keyStatusFrozen - ? '取消冻结'.tr - : "冻结".tr + textList = [ + if (state.itemData.value.keyStatus == XSConstantMacro.keyStatusFrozen) + '取消冻结'.tr + else + '冻结'.tr ]; } - }else{ - textList = [ - state.itemData.value.keyStatus == XSConstantMacro.keyStatusFrozen ? '取消冻结'.tr : "冻结".tr, + } else { + textList = [ + if (state.itemData.value.keyStatus == XSConstantMacro.keyStatusFrozen) + '取消冻结'.tr + else + '冻结'.tr, ]; } showModalBottomSheet( @@ -280,20 +298,21 @@ class ElectronicKeyDetailLogic extends BaseGetXController { return AlertBottomWidget( topTitle: '', items: textList, - chooseCallback: (value) { - int index = value; + chooseCallback: (int value) { + final int index = value; if (index == 0) { - if (state.itemData.value.keyStatus == XSConstantMacro.keyStatusFrozen) { + if (state.itemData.value.keyStatus == + XSConstantMacro.keyStatusFrozen) { // 取消冻结 if (state.itemData.value.keyRight == 1) { // 管理员 ShowTipView().showDeleteAdministratorIsHaveAllDataDialog( - '同时解冻其发送的钥匙'.tr, (isAllData) { + '同时解冻其发送的钥匙'.tr, (bool isAllData) { cancelFreeze(isAllData ? 1 : 0); }); } else { ShowTipView() - .showIosTipWithContentDialog("取消冻结会在用户APP连网后生效".tr, () { + .showIosTipWithContentDialog('取消冻结会在用户APP连网后生效'.tr, () { cancelFreeze(0); }); } @@ -301,12 +320,12 @@ class ElectronicKeyDetailLogic extends BaseGetXController { if (state.itemData.value.keyRight == 1) { // 管理员 ShowTipView().showDeleteAdministratorIsHaveAllDataDialog( - '同时冻结其发送的钥匙'.tr, (isAllData) { + '同时冻结其发送的钥匙'.tr, (bool isAllData) { freezeKey(isAllData ? 1 : 0); }); } else { ShowTipView() - .showIosTipWithContentDialog("冻结会在用户APP连网后生效".tr, () { + .showIosTipWithContentDialog('冻结会在用户APP连网后生效'.tr, () { freezeKey(0); }); } @@ -315,15 +334,11 @@ class ElectronicKeyDetailLogic extends BaseGetXController { // 取消/授权管理员 if (state.itemData.value.keyRight == 1) { // 管理员 - ShowTipView() - .showIosTipWithContentDialog("取消授权会在用户APP连网后生效".tr, () { - cancelAdministrator(); - }); + ShowTipView().showIosTipWithContentDialog( + '取消授权会在用户APP连网后生效'.tr, cancelAdministrator); } else { ShowTipView().showIosTipWithContentDialog( - "授权用户拥有管理员的大部分权限,比如发送钥匙、发送密码".tr, () { - setAdministrator(); - }); + '授权用户拥有管理员的大部分权限,比如发送钥匙、发送密码'.tr, setAdministrator); } } }, @@ -331,16 +346,16 @@ class ElectronicKeyDetailLogic extends BaseGetXController { }); } - deletKeyLogic() { + void deletKeyLogic() { if (state.itemData.value.keyRight == 1) { // 授权管理员 ShowTipView().showDeleteAdministratorIsHaveAllDataDialog( - '同时删除其发送的所有钥匙,钥匙删除后不能恢复'.tr, (isAllData) { + '同时删除其发送的所有钥匙,钥匙删除后不能恢复'.tr, (bool isAllData) { deleteKeyRequest(isAllData ? 1 : 0); }); } else { // 普通用户 - ShowTipView().showIosTipWithContentDialog("删除钥匙会在用户APP连网后生效".tr, () { + ShowTipView().showIosTipWithContentDialog('删除钥匙会在用户APP连网后生效'.tr, () { deleteKeyRequest(0); }); } @@ -363,16 +378,17 @@ class ElectronicKeyDetailLogic extends BaseGetXController { return currentController; } - noModificationAllowedDuringFreeze() { + void noModificationAllowedDuringFreeze() { if (state.itemData.value.keyStatus == XSConstantMacro.keyStatusFrozen) { - showToast("冻结状态下不允许修改钥匙权限".tr); + showToast('冻结状态下不允许修改钥匙权限'.tr); return; } } //检测实名认证是否支持开启 Future keyCheckFace() async { - AdvancedFunctionRecordEntity entity = await ApiRepository.to.keyCheckFace( + final AdvancedFunctionRecordEntity entity = + await ApiRepository.to.keyCheckFace( lockId: CommonDataManage().currentKeyInfo.lockId ?? 0, ); if (entity.errorCode!.codeIsSuccessful) { @@ -385,7 +401,7 @@ class ElectronicKeyDetailLogic extends BaseGetXController { titleStr: '实名认证为付费功能,请购买后再使用'.tr, sureClick: () { Get.toNamed(Routers.advancedFeaturesWebPage, - arguments: {'isShop': false}); + arguments: {'isShop': false}); }); } else if (entity.errorCode == 433) { //需联系管理员购买 diff --git a/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_page.dart b/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_page.dart index 91550e95..504bef2a 100755 --- a/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_page.dart +++ b/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_page.dart @@ -5,6 +5,7 @@ import 'package:flutter_slidable/flutter_slidable.dart'; import 'package:get/get.dart'; import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart'; import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_logic.dart'; +import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_state.dart'; import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart'; import 'package:star_lock/tools/noData.dart'; import 'package:star_lock/tools/storage.dart'; @@ -26,8 +27,8 @@ class ElectronicKeyListPage extends StatefulWidget { } class _ElectronicKeyListPageState extends State { - final logic = Get.put(ElectronicKeyListLogic()); - final state = Get.find().state; + final ElectronicKeyListLogic logic = Get.put(ElectronicKeyListLogic()); + final ElectronicKeyListState state = Get.find().state; @override void initState() { @@ -38,7 +39,7 @@ class _ElectronicKeyListPageState extends State { Future mockRequest() async { // 获取是否是演示模式 演示模式不获取接口 - var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); + bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); if (isDemoMode == false) { logic.mockNetworkDataRequest().then((ElectronicKeyListEntity value) { setState(() {}); @@ -54,7 +55,7 @@ class _ElectronicKeyListPageState extends State { barTitle: TranslationLoader.lanKeys!.electronicKey!.tr, haveBack: true, backgroundColor: AppColors.mainColor, - actionsList: [ + actionsList: [ TextButton( child: Text( TranslationLoader.lanKeys!.reset!.tr, @@ -62,13 +63,11 @@ class _ElectronicKeyListPageState extends State { ), onPressed: () async { // 获取是否是演示模式 演示模式不获取接口 - var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); + final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); if (isDemoMode == false) { - ShowTipView().showIosTipWithContentDialog("该锁的电子钥匙都将被删除".tr, (){ - logic.resetElectronicKeyListRequest(); - }); + ShowTipView().showIosTipWithContentDialog('该锁的电子钥匙都将被删除'.tr, logic.resetElectronicKeyListRequest); } else { - logic.showToast("演示模式".tr); + logic.showToast('演示模式'.tr); } }, ), @@ -83,7 +82,7 @@ class _ElectronicKeyListPageState extends State { mockRequest(); }, child: Column( - children: [ + children: [ // _searchWidget(), KeySearchWidget( editingController: state.searchController, @@ -102,7 +101,7 @@ class _ElectronicKeyListPageState extends State { AddBottomWhiteBtn( btnName: TranslationLoader.lanKeys!.sendKey!.tr, onClick: () { - Navigator.pushNamed(context, Routers.sendElectronicKeyPage).then((val) { + Navigator.pushNamed(context, Routers.sendElectronicKeyPage).then((Object? val) { if (val != null) { logic.pageNo = 1; mockRequest(); @@ -130,7 +129,7 @@ class _ElectronicKeyListPageState extends State { child: ListView.separated( shrinkWrap: true, itemCount: state.itemDataList.value.length, - itemBuilder: (c, index) { + itemBuilder: (BuildContext c, int index) { ElectronicKeyListItem indexEntity = state.itemDataList.value[index]; String useDateStr = ''; //使用期限 String keyStatus = ''; //钥匙状态 @@ -154,7 +153,7 @@ class _ElectronicKeyListPageState extends State { endActionPane: ActionPane( extentRatio: 0.2, motion: const ScrollMotion(), - children: [ + children: [ SlidableAction( onPressed: (BuildContext context) { logic.deletKeyLogic(indexEntity); @@ -175,9 +174,9 @@ class _ElectronicKeyListPageState extends State { indexEntity.remoteEnable == 1 ? true : false, () { Navigator.pushNamed( context, Routers.electronicKeyDetailPage, - arguments: { - "itemData": indexEntity, - }).then((val) { + arguments: { + 'itemData': indexEntity, + }).then((Object? val) { if (val != null) { logic.mockNetworkDataRequest(); setState(() {}); @@ -214,7 +213,7 @@ class _ElectronicKeyListPageState extends State { useDateStr = '${sendDateStr.toLocal().toString().substring(0, 16)} ${"永久".tr}'; } else if (indexEntity.keyType == XSConstantMacro.keyTypeOnce) { //单次 - useDateStr = "单次".tr; + useDateStr = '单次'.tr; useDateStr = '${sendDateStr.toLocal().toString().substring(0, 16)} ${"单次".tr}'; } else if (indexEntity.keyType == XSConstantMacro.keyTypeLoop) { //循环 @@ -232,7 +231,7 @@ class _ElectronicKeyListPageState extends State { color: Colors.white, height: 90.h, child: Row( - children: [ + children: [ SizedBox(width: 30.w), Image.asset( avatarURL, @@ -243,14 +242,14 @@ class _ElectronicKeyListPageState extends State { Expanded( child: Column( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ Row( // mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ + children: [ SizedBox( width: 1.sw - 110.w - 34.w - 60.w, child: Row( - children: [ + children: [ Flexible( child: Text(receiveUser, maxLines: 1, @@ -290,7 +289,7 @@ class _ElectronicKeyListPageState extends State { SizedBox(height: 10.h), Row( mainAxisAlignment: MainAxisAlignment.start, - children: [ + children: [ Text( useDate, style: TextStyle( From f5b28cf6bb0aaad570d018c7fc312304840908a2 Mon Sep 17 00:00:00 2001 From: anfe <448468458@qq.com> Date: Sat, 18 May 2024 18:25:39 +0800 Subject: [PATCH 10/44] =?UTF-8?q?feat:=E6=B7=BB=E5=8A=A0=20bugly=20?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E6=97=A5=E5=BF=97=E7=9B=91=E6=8E=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- android/app/src/main/AndroidManifest.xml | 3 +- ios/Podfile.lock | 10 +++++ lib/app_settings/app_settings.dart | 3 +- lib/flavors.dart | 19 ++++++++- lib/main.dart | 16 +++----- lib/tools/bugly/bugly_tool.dart | 51 ++++++++++++++++++++++++ pubspec.yaml | 2 + 7 files changed, 89 insertions(+), 15 deletions(-) create mode 100644 lib/tools/bugly/bugly_tool.dart diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index afb5fd51..24086c3f 100755 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -22,7 +22,8 @@ - + + diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 0aeb6030..3ffb1e4d 100755 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -36,6 +36,7 @@ PODS: - Flutter - auto_orientation (0.0.1): - Flutter + - Bugly (2.6.1) - camera_avfoundation (0.0.1): - Flutter - connectivity_plus (0.0.1): @@ -81,6 +82,9 @@ PODS: - Flutter (1.0.0) - flutter_blue_plus (0.0.1): - Flutter + - flutter_bugly_plugin (0.0.1): + - Bugly + - Flutter - flutter_local_notifications (0.0.1): - Flutter - flutter_native_contact_picker (0.0.1): @@ -170,6 +174,7 @@ DEPENDENCIES: - file_picker (from `.symlinks/plugins/file_picker/ios`) - Flutter (from `Flutter`) - flutter_blue_plus (from `.symlinks/plugins/flutter_blue_plus/ios`) + - flutter_bugly_plugin (from `.symlinks/plugins/flutter_bugly_plugin/ios`) - flutter_local_notifications (from `.symlinks/plugins/flutter_local_notifications/ios`) - flutter_native_contact_picker (from `.symlinks/plugins/flutter_native_contact_picker/ios`) - flutter_pcm_sound (from `.symlinks/plugins/flutter_pcm_sound/ios`) @@ -205,6 +210,7 @@ SPEC REPOS: - AMap3DMap - AMapFoundation - AMapLocation + - Bugly - DKImagePickerController - DKPhotoGallery - GoogleMaps @@ -248,6 +254,8 @@ EXTERNAL SOURCES: :path: Flutter flutter_blue_plus: :path: ".symlinks/plugins/flutter_blue_plus/ios" + flutter_bugly_plugin: + :path: ".symlinks/plugins/flutter_bugly_plugin/ios" flutter_local_notifications: :path: ".symlinks/plugins/flutter_local_notifications/ios" flutter_native_contact_picker: @@ -309,6 +317,7 @@ SPEC CHECKSUMS: audio_session: 088d2483ebd1dc43f51d253d4a1c517d9a2e7207 audioplayers_darwin: 877d9a4d06331c5c374595e46e16453ac7eafa40 auto_orientation: 102ed811a5938d52c86520ddd7ecd3a126b5d39d + Bugly: 217ac2ce5f0f2626d43dbaa4f70764c953a26a31 camera_avfoundation: 759172d1a77ae7be0de08fc104cfb79738b8a59e connectivity_plus: bf0076dd84a130856aa636df1c71ccaff908fa1d device_info_plus: e5c5da33f982a436e103237c0c85f9031142abed @@ -318,6 +327,7 @@ SPEC CHECKSUMS: file_picker: ce3938a0df3cc1ef404671531facef740d03f920 Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7 flutter_blue_plus: 4837da7d00cf5d441fdd6635b3a57f936778ea96 + flutter_bugly_plugin: d2db6d6641938269fa538575126e8ff530ee02c7 flutter_local_notifications: 4cde75091f6327eb8517fa068a0a5950212d2086 flutter_native_contact_picker: bd430ba0fbf82768bb50c2c52a69a65759a8f907 flutter_pcm_sound: de0572ca4f99091cc2abfcc31601b8a4ddd33c0e diff --git a/lib/app_settings/app_settings.dart b/lib/app_settings/app_settings.dart index 04bbe53d..f03b8cf1 100755 --- a/lib/app_settings/app_settings.dart +++ b/lib/app_settings/app_settings.dart @@ -23,7 +23,8 @@ class AppLog { // if(!_printLog)return; // if(_onlyError && !error) return; if (error) { - msg = '----->>> $msg $stackTrace'; + final bool stackTraceIsNull = stackTrace != null; + msg = '----->>> $msg ${stackTraceIsNull ? '\n$stackTrace' : ''}'; } Get.log(msg); } diff --git a/lib/flavors.dart b/lib/flavors.dart index 9d350755..2eb513d9 100755 --- a/lib/flavors.dart +++ b/lib/flavors.dart @@ -86,7 +86,7 @@ class F { switch (appFlavor) { case Flavor.local: return 'https://ge.lock.star-lock.cn'; // 葛工 - // return 'http://192.168.1.15:8022'; // 谢工 + // return 'http://192.168.1.15:8022'; // 谢工 case Flavor.dev: return 'https://dev.lock.star-lock.cn'; case Flavor.pre: @@ -95,7 +95,7 @@ class F { return 'https://lock.skychip.top'; case Flavor.xhj: return 'https://lock.xhjcn.ltd'; - // return 'https://pre.lock.star-lock.cn'; + // return 'https://pre.lock.star-lock.cn'; default: throw Exception('flavor[$name] apiPrefix not found'); } @@ -125,4 +125,19 @@ class F { throw Exception('flavor[$name] aMapKey not found'); } } + + // 是否是生产环境 + static bool get isProductionEnv { + switch (appFlavor) { + case Flavor.local: + case Flavor.dev: + case Flavor.pre: + return false; + case Flavor.sky: + case Flavor.xhj: + return true; + default: + return false; + } + } } diff --git a/lib/main.dart b/lib/main.dart index 8b2c3710..b0647eda 100755 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,9 +1,12 @@ import 'dart:async'; +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:flutter_bugly_plugin/flutter_bugly_plugin.dart'; import 'package:get/get.dart'; import 'package:star_lock/flavors.dart'; +import 'package:star_lock/tools/bugly/bugly_tool.dart'; import 'package:star_lock/tools/device_info_service.dart'; import 'package:star_lock/tools/platform_info_services.dart'; import 'package:star_lock/translations/trans_lib.dart'; @@ -21,18 +24,9 @@ FutureOr main() async { // 设置国际化信息 await _initTranslation(); - //错误日志监控 - FlutterError.onError = (FlutterErrorDetails details) async { - AppLog.log('error:${details.exception.toString()}', - stackTrace: details.stack, error: true); - Zone.current.handleUncaughtError(details.exception, details.stack!); - }; - - //错误日志监控 - runZonedGuarded>(() async { + // bugly错误日志监控 + BuglyTool.init(() { runApp(const MyApp()); - }, (Object error, StackTrace stackTrace) async { - AppLog.log('error:$error', stackTrace: stackTrace, error: true); }); if (AppPlatform.isAndroid) { diff --git a/lib/tools/bugly/bugly_tool.dart b/lib/tools/bugly/bugly_tool.dart new file mode 100644 index 00000000..3864b1d2 --- /dev/null +++ b/lib/tools/bugly/bugly_tool.dart @@ -0,0 +1,51 @@ +import 'dart:async'; + +import 'package:flutter/cupertino.dart'; +import 'package:flutter/foundation.dart'; +import 'package:flutter_bugly_plugin/flutter_bugly_plugin.dart'; +import 'package:star_lock/app_settings/app_settings.dart'; +import 'package:star_lock/flavors.dart'; + +/// +/// 错误日志监控 +/// +/// +class BuglyTool { + static Future init(Function on) async { + if (F.isProductionEnv) { + //生产 + await FlutterBuglyPlugin.init( + appIdAndroid: '73c99cca00', + appIdiOS: 'b25632a54f', + ); + } else { + //测试 + await FlutterBuglyPlugin.init( + appIdAndroid: '02fb541c1c', + appIdiOS: '618ab9feeb', + ); + } + + //错误日志监控 + FlutterError.onError = (FlutterErrorDetails details) async { + AppLog.log('error:${details.exception.toString()}', + stackTrace: details.stack, error: true); + Zone.current.handleUncaughtError( + details.exception, details.stack ?? StackTrace.empty); + }; + + //错误日志监控 + PlatformDispatcher.instance.onError = (Object error, StackTrace stack) { + FlutterBuglyPlugin.reportException( + exceptionName: error.toString(), reason: stack.toString()); + AppLog.log('error:$error', stackTrace: stack, error: true); + return true; + }; + + //错误日志监控 + runZonedGuarded>(() async => on(), + (Object error, StackTrace stackTrace) async { + AppLog.log('error:$error', stackTrace: stackTrace, error: true); + }); + } +} diff --git a/pubspec.yaml b/pubspec.yaml index e9487b95..00210fe1 100755 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -191,6 +191,8 @@ dependencies: expandable: ^5.0.1 colorfilter_generator: ^0.0.8 file_picker: ^5.3.1 + # 错误日志监控 + flutter_bugly_plugin: ^0.0.9 dependency_overrides: From c978444330b13dbf6a8645bf137a3e4b10fb8a5a Mon Sep 17 00:00:00 2001 From: anfe <448468458@qq.com> Date: Mon, 20 May 2024 09:45:50 +0800 Subject: [PATCH 11/44] =?UTF-8?q?feat:=E6=B7=BB=E5=8A=A0bugly=20userId=20?= =?UTF-8?q?=E5=85=B3=E8=81=94=EF=BC=8C=E4=BF=AE=E5=A4=8D=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/login/login/starLock_login_logic.dart | 34 ++++++----------------- lib/main.dart | 6 ++-- lib/tools/bugly/bugly_tool.dart | 23 ++++++++++----- 3 files changed, 28 insertions(+), 35 deletions(-) diff --git a/lib/login/login/starLock_login_logic.dart b/lib/login/login/starLock_login_logic.dart index 8142990f..508c1f15 100755 --- a/lib/login/login/starLock_login_logic.dart +++ b/lib/login/login/starLock_login_logic.dart @@ -1,8 +1,11 @@ import 'dart:io'; import 'package:flutter/material.dart'; +import 'package:flutter_bugly_plugin/flutter_bugly_plugin.dart'; import 'package:get/get.dart'; import 'package:star_lock/appRouters.dart'; +import 'package:star_lock/login/login/entity/LoginEntity.dart'; +import 'package:star_lock/mine/mine/starLockMine_state.dart'; import 'package:star_lock/tools/baseGetXController.dart'; import 'package:star_lock/tools/xs_jPhush.dart'; @@ -14,34 +17,15 @@ import 'starLock_login_state.dart'; class StarLockLoginLogic extends BaseGetXController { final StarLockLoginState state = StarLockLoginState(); - final stateMyLogic = Get.put(StarLockMineLogic()).state; + final StarLockMineState stateMyLogic = Get.put(StarLockMineLogic()).state; int indexFocusNode = noneFocusNode; static int noneFocusNode = 0; static int emailOrPhoneFocusNode = 1; static int pwdFocusNode = 2; - @override - void onInit() { - super.onInit(); - // state.emailOrPhoneFocusNode.addListener(() { - // if (state.emailOrPhoneFocusNode.hasFocus) { - // indexFocusNode = emailOrPhoneFocusNode; - // } else { - // changeInputFocusNode(); - // } - // }); - // state.pwdFocusNode.addListener(() { - // if (state.pwdFocusNode.hasFocus) { - // indexFocusNode = pwdFocusNode; - // } else { - // changeInputFocusNode(); - // } - // }); - } - //检查焦点状态 void changeInputFocusNode() { - Future.delayed(Duration(milliseconds: 100), () { + Future.delayed(const Duration(milliseconds: 100), () { if (indexFocusNode == noneFocusNode) { return; } @@ -53,9 +37,9 @@ class StarLockLoginLogic extends BaseGetXController { }); } - void login() async { - var entity = await ApiRepository.to.login( - loginType: "1", + Future login() async { + final LoginEntity entity = await ApiRepository.to.login( + loginType: '1', password: state.pwd.value, countryCode: state.countryCode.value, username: state.emailOrPhone.value); @@ -67,7 +51,7 @@ class StarLockLoginLogic extends BaseGetXController { // Get.toNamed(Routers.starLockMain); XSJPushProvider().initJPushService(); XSJPushProvider().initLocalNotification(false); - Get.offNamedUntil(Routers.starLockMain, (route) => false); + Get.offNamedUntil(Routers.starLockMain, (Route route) => false); } } diff --git a/lib/main.dart b/lib/main.dart index b0647eda..65a67850 100755 --- a/lib/main.dart +++ b/lib/main.dart @@ -25,9 +25,9 @@ FutureOr main() async { await _initTranslation(); // bugly错误日志监控 - BuglyTool.init(() { - runApp(const MyApp()); - }); + await BuglyTool.init(); + + runApp(const MyApp()); if (AppPlatform.isAndroid) { const SystemUiOverlayStyle systemUiOverlayStyle = diff --git a/lib/tools/bugly/bugly_tool.dart b/lib/tools/bugly/bugly_tool.dart index 3864b1d2..fb50076c 100644 --- a/lib/tools/bugly/bugly_tool.dart +++ b/lib/tools/bugly/bugly_tool.dart @@ -5,13 +5,15 @@ import 'package:flutter/foundation.dart'; import 'package:flutter_bugly_plugin/flutter_bugly_plugin.dart'; import 'package:star_lock/app_settings/app_settings.dart'; import 'package:star_lock/flavors.dart'; +import 'package:star_lock/login/login/entity/LoginData.dart'; +import 'package:star_lock/tools/storage.dart'; /// /// 错误日志监控 /// /// class BuglyTool { - static Future init(Function on) async { + static Future init() async { if (F.isProductionEnv) { //生产 await FlutterBuglyPlugin.init( @@ -26,26 +28,33 @@ class BuglyTool { ); } + //关联用户 id + final LoginData? loginData = await Storage.getLoginData(); + setUserId(loginData?.userid); + //错误日志监控 FlutterError.onError = (FlutterErrorDetails details) async { AppLog.log('error:${details.exception.toString()}', stackTrace: details.stack, error: true); + FlutterBuglyPlugin.reportException( + exceptionName: details.exception.toString(), + reason: details.stack.toString()); Zone.current.handleUncaughtError( details.exception, details.stack ?? StackTrace.empty); }; //错误日志监控 PlatformDispatcher.instance.onError = (Object error, StackTrace stack) { + AppLog.log('error:$error', stackTrace: stack, error: true); FlutterBuglyPlugin.reportException( exceptionName: error.toString(), reason: stack.toString()); - AppLog.log('error:$error', stackTrace: stack, error: true); return true; }; + } - //错误日志监控 - runZonedGuarded>(() async => on(), - (Object error, StackTrace stackTrace) async { - AppLog.log('error:$error', stackTrace: stackTrace, error: true); - }); + //关联 userid + static void setUserId(int? userId) { + FlutterBuglyPlugin.setUserIdentifier( + userIdentifier: (userId ?? 0).toString()); } } From b3d0c04ddca62dc89d38d40014b790c91bc25bea Mon Sep 17 00:00:00 2001 From: anfe <448468458@qq.com> Date: Mon, 20 May 2024 11:04:15 +0800 Subject: [PATCH 12/44] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=20=E7=AC=AC4?= =?UTF-8?q?=E6=A0=8F=E5=BA=94=E9=83=BD=E8=A6=81=E6=98=BE=E7=A4=BA=EF=BC=8C?= =?UTF-8?q?=E6=98=9F=E9=94=81=E5=8F=AA=E6=98=BE=E7=A4=BA=E5=90=8E=E9=83=A8?= =?UTF-8?q?=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .DS_Store | Bin 6148 -> 6148 bytes .../checkingInAddStaff_logic.dart | 50 ++++++++++-------- .../checkingInAddStaff_page.dart | 34 +++++++----- .../checkingInAddStaff_state.dart | 47 ++++++++-------- .../checkingInStaffList_page.dart | 41 +++++++------- 5 files changed, 93 insertions(+), 79 deletions(-) diff --git a/.DS_Store b/.DS_Store index ab459319e6a778b2a3dea34e5b8e7b01e88e0ec3..fce4fcc3b0432e5f39e9c8a2564ff8e890f2dd76 100755 GIT binary patch delta 45 zcmZoMXfc@J&&aniU^g=(-)0_`PfU{^ur_cQS(xZ37+V-j&S0~j{F%*ZGdss$egH+I B4m|(> delta 31 ncmZoMXfc@J&&azmU^g=(?`9sBPfU|9u$xaTxU`v_<1aq|s7nhR diff --git a/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_logic.dart b/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_logic.dart index ab08598e..6f21bf4e 100755 --- a/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_logic.dart +++ b/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_logic.dart @@ -4,6 +4,8 @@ import 'dart:ffi'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:star_lock/app_settings/app_settings.dart'; +import 'package:star_lock/login/login/entity/LoginEntity.dart'; +import 'package:star_lock/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyEntity.dart'; import 'package:star_lock/tools/baseGetXController.dart'; import '../../../../../network/api_repository.dart'; import '../../../../../tools/eventBusEventManage.dart'; @@ -23,30 +25,30 @@ class CheckingInAddStaffLogic extends BaseGetXController { // 蓝牙协议通知传输跟蓝牙之外的数据传输类不一样 eventBus _getNumberEvent = eventBus .on() - .listen((event) { + .listen((ChickInAddStaffCardAndFingerprintBlockNumberEvent event) { state.attendanceWayNumber.value = event.number; isCanClickAction(); }); } // 添加员工 - void addStaffLoadData() async { - var usernameType = "1"; - if (state.appUnHaveAccount.value && state.staffAccount.contains("@")) { - usernameType = "2"; + Future addStaffLoadData() async { + String usernameType = '1'; + if (state.appUnHaveAccount.value && state.staffAccount.contains('@')) { + usernameType = '2'; } // 当是app且没有钥匙时,直接把账号赋值给attendanceWayNumber if (state.appUnHaveAccount.value && - state.selectPrintingMethodType.value == "1") { + state.selectPrintingMethodType.value == '1') { state.attendanceWayNumber.value = state.staffAccountController.text; } - var entity = await ApiRepository.to.addStaffData( + final LoginEntity entity = await ApiRepository.to.addStaffData( attendanceType: state.selectPrintingMethodType.value, attendanceWay: state.attendanceWayNumber.value, companyId: state.companyId.value, - have: state.appUnHaveAccount.value ? "2" : "1", + have: state.appUnHaveAccount.value ? '2' : '1', staffName: state.staffNameController.text, countryCode: state.countryCode.value, usernameType: usernameType, @@ -54,7 +56,7 @@ class CheckingInAddStaffLogic extends BaseGetXController { if (entity.errorCode!.codeIsSuccessful) { eventBus.fire(RefreshCheckInSetDataEvent()); eventBus.fire(RefreshCheckInListEvent()); - Get.back(result: "addScuess"); + Get.back(result: 'addScuess'); } else if (entity.errorCode! == 425) { showToast(entity.errorMsg!); } @@ -62,8 +64,9 @@ class CheckingInAddStaffLogic extends BaseGetXController { // 考勤设置添加员工-选择钥匙 1为APP,2为密码,3为卡,4为指纹,返回数据中, // attendanceWay分别为用户名、密码、卡号、指纹号 - void addStaffSelectKey(KeyClickCallback kyClickCallback) async { - var entity = await ApiRepository.to.addStaffSelectKeyData( + Future addStaffSelectKey(KeyClickCallback kyClickCallback) async { + final CheckingInAddStaffSelectKeyEntity entity = + await ApiRepository.to.addStaffSelectKeyData( companyId: state.companyId.value, type: state.selectPrintingMethodType.value, ); @@ -74,18 +77,17 @@ class CheckingInAddStaffLogic extends BaseGetXController { } // 编辑员工 - void editStaffLoadData() async { - var usernameType = "1"; - if (state.appUnHaveAccount.value && state.staffAccount.contains("@")) { - usernameType = "2"; + Future editStaffLoadData() async { + String usernameType = '1'; + if (state.appUnHaveAccount.value && state.staffAccount.contains('@')) { + usernameType = '2'; } - - var entity = await ApiRepository.to.editStaffData( + final LoginEntity entity = await ApiRepository.to.editStaffData( attendanceType: state.selectPrintingMethodType.value, attendanceWay: state.attendanceWayNumber.value, staffId: state.staffListItemData.value.staffId.toString(), - have: state.appUnHaveAccount.value ? "2" : "1", + have: state.appUnHaveAccount.value ? '2' : '1', staffName: state.staffNameController.text, countryCode: state.countryCode.value, usernameType: usernameType, @@ -99,13 +101,13 @@ class CheckingInAddStaffLogic extends BaseGetXController { } //获取密码请求 - void getKeyboardPwdRequest() async { + Future getKeyboardPwdRequest() async { if (state.staffNameController.text.isEmpty) { - showToast("请输入姓名"); + showToast('请输入姓名'); return; } - var entity = await ApiRepository.to.getPasswordKey( - endDate: "0", + final PasswordKeyEntity entity = await ApiRepository.to.getPasswordKey( + endDate: '0', keyboardPwdName: state.staffNameController.text, keyboardPwdType: 2.toString(), lockId: state.getKeyInfosData.value.lockId.toString(), @@ -136,7 +138,7 @@ class CheckingInAddStaffLogic extends BaseGetXController { // 是否能点击 void isCanClickAction() { - if (state.selectPrintingMethodType.value == "1" && + if (state.selectPrintingMethodType.value == '1' && state.appUnHaveAccount.value) { // 没有账号的时候直接判断姓名和账号是否为空 state.isCanClick.value = @@ -154,6 +156,8 @@ class CheckingInAddStaffLogic extends BaseGetXController { _initLoadDataAction(); changeInput(state.staffNameController); + + } @override diff --git a/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_page.dart b/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_page.dart index 9a03705f..0376b3a1 100755 --- a/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_page.dart +++ b/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_page.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaffSelectKey_entity.dart'; @@ -62,7 +63,7 @@ class _CheckingInAddStaffPageState extends State { if (state.getKeyInfosData.value.lockName!.contains('T9A')) { list.add('人脸'.tr); } - _showSelectClockInType(list, list, '1', '选择钥匙'.tr); + _showSelectClockInType(list, list, list, '1', '选择钥匙'.tr); })), SizedBox(height: 10.h), //员工是否有App、卡、钥匙、指纹必须显示 @@ -96,10 +97,8 @@ class _CheckingInAddStaffPageState extends State { ))), // 当选择App时且没有钥匙的时候 显示输入账号输入框和选择国家 其他隐藏 Obx(() => Visibility( - visible: (state.appUnHaveAccount.value && - state.selectPrintingMethodType.value == '1') - ? true - : false, + visible: state.appUnHaveAccount.value && + state.selectPrintingMethodType.value == '1', child: Column( children: [ CommonItem( @@ -166,7 +165,7 @@ class _CheckingInAddStaffPageState extends State { return; } - final data = await Get.toNamed( + final dynamic data = await Get.toNamed( Routers.addCardPage, arguments: { 'lockId': @@ -228,9 +227,14 @@ class _CheckingInAddStaffPageState extends State { // 当选择钥匙类型为有时 必显示 Obx(() { final bool isPass = state.selectPrintingMethodType.value == '2'; - String rightTitle = state.attendanceWayNumber.value; + String attendanceWayNumber = state.attendanceWayNumber.value; + final String attendanceWayName = state.attendanceWayName.value; if (isPass) { - rightTitle = showPass(rightTitle); + attendanceWayNumber = showPass(attendanceWayNumber); + } + String rightTitle = attendanceWayNumber; + if (attendanceWayName.trim() != '') { + rightTitle = '$attendanceWayName - ' + rightTitle; } return Visibility( visible: !state.appUnHaveAccount.value, @@ -243,6 +247,7 @@ class _CheckingInAddStaffPageState extends State { logic.addStaffSelectKey( (List v) { final List showList = []; + final List nameList = []; final List numberList = []; for (final CheckingInAddStaffKeyEntity element in v) { final bool isPass = @@ -252,12 +257,13 @@ class _CheckingInAddStaffPageState extends State { attendanceWay = showPass(attendanceWay); } final String text = - '${element.staffName}-$attendanceWay'; + '${element.staffName} - $attendanceWay'; showList.add(text); numberList.add(element.attendanceWay ?? ''); + nameList.add(element.staffName ?? ''); } - _showSelectClockInType(showList, numberList, '2', - addStaffSelectKeySelectClockInType()); + _showSelectClockInType(showList, numberList, nameList, + '2', addStaffSelectKeySelectClockInType()); }); }), ); @@ -344,8 +350,8 @@ class _CheckingInAddStaffPageState extends State { } // type 1 打卡方式 2选择钥匙 - void _showSelectClockInType(List showList, List numberList, - String showBottomSheetToolType, String title) { + void _showSelectClockInType(List showList, List numberList, + List nameList, String showBottomSheetToolType, String title) { ShowBottomSheetTool().showSingleRowPicker( //上下文 context, @@ -364,8 +370,10 @@ class _CheckingInAddStaffPageState extends State { if (showBottomSheetToolType == '1') { state.selectPrintingMethodType.value = (index + 1).toString(); state.selectPrintingMethodStr.value = str.toString(); + state.attendanceWayName.value = ''; state.attendanceWayNumber.value = ''; } else { + state.attendanceWayName.value = nameList[index].toString(); state.attendanceWayNumber.value = numberList[index].toString(); } logic.isCanClickAction(); diff --git a/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_state.dart b/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_state.dart index 10f58706..dd23cda8 100755 --- a/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_state.dart +++ b/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_state.dart @@ -6,27 +6,28 @@ import '../checkingInSetStaffList/checkingInStaffList_entity.dart'; import 'checkingInAddStaffSelectKey_entity.dart'; class CheckingInAddStaffState { - final getKeyInfosData = LockListInfoItemEntity().obs; - final companyId = "".obs; - final staffListItemData = CheckingInAddStaffListItemEntity().obs; + final Rx getKeyInfosData = LockListInfoItemEntity().obs; + final RxString companyId = ''.obs; + final Rx staffListItemData = CheckingInAddStaffListItemEntity().obs; final TextEditingController staffNameController = TextEditingController(); final TextEditingController staffAccountController = TextEditingController(); - final selectPrintingMethodType = "1".obs; // 选择打卡类型 1APP 2密码 3卡 4指纹 5人脸 - final selectPrintingMethodStr = "APP".obs; // 选择打卡类型字符串 + final RxString selectPrintingMethodType = '1'.obs; // 选择打卡类型 1APP 2密码 3卡 4指纹 5人脸 + final RxString selectPrintingMethodStr = 'APP'.obs; // 选择打卡类型字符串 - final countryName = "中国".tr.obs; - final countryCode = "86".obs; + final RxString countryName = '中国'.tr.obs; + final RxString countryCode = '86'.obs; - final appUnHaveAccount = true.obs; // 默认没有账号 - final keyEntity = [].obs; // 选择钥匙数据 + final RxBool appUnHaveAccount = true.obs; // 默认没有账号 + final RxList keyEntity = [].obs; // 选择钥匙数据 - final isAdd = "1".obs; // 1添加 2编辑 - final attendanceWayNumber = "".obs; - final isCanClick = false.obs; - var staffName = ''.obs; - var staffAccount = ''.obs; + final RxString isAdd = '1'.obs; // 1添加 2编辑 + final RxString attendanceWayName = ''.obs; + final RxString attendanceWayNumber = ''.obs; + final RxBool isCanClick = false.obs; + RxString staffName = ''.obs; + RxString staffAccount = ''.obs; bool get staffNameIsNotEmpty => staffName.value.isNotEmpty; @@ -37,28 +38,28 @@ class CheckingInAddStaffState { CheckingInAddStaffState() { Map map = Get.arguments; - getKeyInfosData.value = map["getKeyInfosData"]; - companyId.value = map["companyId"]; + getKeyInfosData.value = map['getKeyInfosData']; + companyId.value = map['companyId']; - isAdd.value = map["isAdd"]; - if (isAdd.value == "2") { - staffListItemData.value = map["staffListItem"]; + isAdd.value = map['isAdd']; + if (isAdd.value == '2') { + staffListItemData.value = map['staffListItem']; staffNameController.text = staffListItemData.value.staffName!; selectPrintingMethodType.value = staffListItemData.value.attendanceType.toString(); switch (staffListItemData.value.attendanceType) { case 1: - selectPrintingMethodStr.value = "APP"; + selectPrintingMethodStr.value = 'APP'; break; case 2: - selectPrintingMethodStr.value = "密码".tr; + selectPrintingMethodStr.value = '密码'.tr; break; case 3: - selectPrintingMethodStr.value = "卡".tr; + selectPrintingMethodStr.value = '卡'.tr; break; case 4: - selectPrintingMethodStr.value = "指纹".tr; + selectPrintingMethodStr.value = '指纹'.tr; break; } diff --git a/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_page.dart b/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_page.dart index c3d189b7..a1ae4a07 100755 --- a/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_page.dart +++ b/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_page.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_slidable/flutter_slidable.dart'; import 'package:get/get.dart'; +import 'package:star_lock/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_state.dart'; import 'package:star_lock/tools/showTipView.dart'; import '../../../../../appRouters.dart'; @@ -23,8 +24,8 @@ class CheckingInStaffListPage extends StatefulWidget { } class _CheckingInStaffListPageState extends State { - final logic = Get.put(CheckingInStaffManageLogic()); - final state = Get.find().state; + final CheckingInStaffManageLogic logic = Get.put(CheckingInStaffManageLogic()); + final CheckingInStaffManageState state = Get.find().state; @override Widget build(BuildContext context) { @@ -34,13 +35,13 @@ class _CheckingInStaffListPageState extends State { barTitle: TranslationLoader.lanKeys!.staff!.tr, haveBack: true, backgroundColor: AppColors.mainColor, - actionsList: [ + actionsList: [ GestureDetector( onTap: () async { - var data = await Get.toNamed(Routers.checkingInAddStaffPage, arguments: { - "getKeyInfosData": state.getKeyInfosData.value, - "companyId": state.companyId.value, - "isAdd": "1", + final dynamic data = await Get.toNamed(Routers.checkingInAddStaffPage, arguments: { + 'getKeyInfosData': state.getKeyInfosData.value, + 'companyId': state.companyId.value, + 'isAdd': '1', }); if(data != null) { logic.getStaffList(); @@ -62,23 +63,23 @@ class _CheckingInStaffListPageState extends State { SlidableAutoCloseBehavior( child: ListView.separated( itemCount: state.staffListData.value.length, - itemBuilder: (c, index) { - CheckingInAddStaffListItemEntity staffListItem = state.staffListData[index]; + itemBuilder: (BuildContext c, int index) { + final CheckingInAddStaffListItemEntity staffListItem = state.staffListData[index]; return Slidable( key:ValueKey(staffListItem.staffId), endActionPane: ActionPane( extentRatio: 0.2, motion: const ScrollMotion(), - children: [ + children: [ SlidableAction( onPressed: (BuildContext context){ // 1APP 2密码 3卡 4指纹 5人脸 if(staffListItem.attendanceType == 1){ - ShowTipView().showDeleteAdministratorIsHaveAllDataDialog('同时删除员工钥匙'.tr, (isAllData) { + ShowTipView().showDeleteAdministratorIsHaveAllDataDialog('同时删除员工钥匙'.tr, (bool isAllData) { logic.deletStaff(staffListItem.staffId!, (isAllData ? 1 : 0)); }); }else{ - ShowTipView().showIosTipWithContentDialog("确定要删除员工吗?".tr, () { + ShowTipView().showIosTipWithContentDialog('确定要删除员工吗?'.tr, () { logic.deletStaff(staffListItem.staffId!, 0); }); // showIosTipViewDialog(staffListItem.staffId!, context); @@ -92,10 +93,10 @@ class _CheckingInStaffListPageState extends State { ], ), child: _checkingInStaffManageItem(staffListItem, () { - Get.toNamed(Routers.checkingInStaffDetailPage, arguments: { - "staffListItem": staffListItem, - "getKeyInfosData": state.getKeyInfosData.value, - "companyId": state.companyId.value, + Get.toNamed(Routers.checkingInStaffDetailPage, arguments: { + 'staffListItem': staffListItem, + 'getKeyInfosData': state.getKeyInfosData.value, + 'companyId': state.companyId.value, }); }), ); @@ -108,7 +109,7 @@ class _CheckingInStaffListPageState extends State { // }); // }); }, - separatorBuilder: (context, index) { + separatorBuilder: (BuildContext context, int index) { return Divider(height: 1.h, indent: 20.w, color: AppColors.greyLineColor); }, ), @@ -125,14 +126,14 @@ class _CheckingInStaffListPageState extends State { color: Colors.white, margin: EdgeInsets.only(right: 10.w, top: 10.h, bottom: 10.h), child: Row( - children: [ + children: [ SizedBox(width: 20.w,), // CustomNetworkImage(url: staffListItem.headurl!, width: 40.w , height: 40.w), Image.asset(getTypeIcon(staffListItem.attendanceType!), width: 60.w, height: 60.w), SizedBox(width: 20.w,), Column( crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ SizedBox( width: 1.sw - 20.w - 60.w - 20.w - 30.w, child: Text(staffListItem.staffName!, @@ -153,7 +154,7 @@ class _CheckingInStaffListPageState extends State { borderRadius: BorderRadius.circular(5.w), color: AppColors.openPassageModeColor, ), - child: Text("打卡方式无效".tr, style: TextStyle(fontSize: 18.sp, color: AppColors.appBarIconColor)), + child: Text('打卡方式无效'.tr, style: TextStyle(fontSize: 18.sp, color: AppColors.appBarIconColor)), ), ), ], From a394c339a23f1c02b0a966b835c4a84ccb27c479 Mon Sep 17 00:00:00 2001 From: anfe <448468458@qq.com> Date: Mon, 20 May 2024 11:59:34 +0800 Subject: [PATCH 13/44] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=20=E5=BC=80?= =?UTF-8?q?=E9=94=81=E9=A1=B5-=E8=80=83=E5=8B=A4-=E8=AE=BE=E7=BD=AE=20?= =?UTF-8?q?=E5=85=AC=E5=8F=B8=E5=90=8D=E7=A7=B0=20=E9=95=BF=E4=BD=8D?= =?UTF-8?q?=E7=9A=84=E6=98=BE=E7=A4=BA=E4=B8=8D=E5=85=A8=EF=BC=8C=E9=80=9A?= =?UTF-8?q?=E9=80=9A=E9=94=81=E6=98=BE=E7=A4=BA2=E6=A0=8F=E3=80=82?= =?UTF-8?q?=E5=8F=A6=E4=BF=AE=E6=94=B9=E6=9C=AA=E5=81=9A=E9=95=BF=E5=BA=A6?= =?UTF-8?q?=E9=99=90=E5=88=B6=EF=BC=8C=E5=BA=94=E9=99=90=E5=88=B66-30?= =?UTF-8?q?=E4=BD=8D=EF=BC=8C=E5=92=8C=E5=88=9B=E5=BB=BA=E4=B8=80=E6=A0=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- images/lan/lan_en.json | 3 +- images/lan/lan_keys.json | 3 +- images/lan/lan_zh.json | 23 +-- .../checkingInSet/checkingInSet_page.dart | 78 +++++---- .../checkingInSet/checkingInSet_state.dart | 32 ++-- .../checkingInAddStaff_page.dart | 8 +- .../checkingInAddStaff_state.dart | 67 ++++---- lib/tools/commonItem.dart | 162 ++++++++---------- lib/tools/showTFView.dart | 1 + 9 files changed, 195 insertions(+), 182 deletions(-) diff --git a/images/lan/lan_en.json b/images/lan/lan_en.json index 2898b9b3..f0754730 100755 --- a/images/lan/lan_en.json +++ b/images/lan/lan_en.json @@ -855,5 +855,6 @@ "门铃事件":"Doorbell event", "视频事件":"Video event", "请开启蓝牙":"Please turn on Bluetooth", - "请选择有效日":"Please select the effective day" + "请选择有效日":"Please select the effective day", + "公司名字长度不能小于 6 ": "The length of the company name cannot be less than 6" } diff --git a/images/lan/lan_keys.json b/images/lan/lan_keys.json index 3f091d55..9e5a1a1d 100755 --- a/images/lan/lan_keys.json +++ b/images/lan/lan_keys.json @@ -884,5 +884,6 @@ "门铃事件":"门铃事件", "视频事件":"视频事件", "请开启蓝牙":"请开启蓝牙", - "请选择有效日":"请选择有效日" + "请选择有效日":"请选择有效日", + "公司名字长度不能小于 6 ": "公司名字长度不能小于 6 " } diff --git a/images/lan/lan_zh.json b/images/lan/lan_zh.json index c47e1cc2..83529ac4 100755 --- a/images/lan/lan_zh.json +++ b/images/lan/lan_zh.json @@ -815,7 +815,7 @@ "身份证号": "身份证号", "请输入真实姓名": "请输入真实姓名", "请输入身份证号": "请输入身份证号", - "请输入身份证号和真实姓名":"请输入身份证号和真实姓名", + "请输入身份证号和真实姓名": "请输入身份证号和真实姓名", "点击返回设备配对": "点击返回设备配对", "无法连接?尝试升级": "无法连接?尝试升级", "固件升级提示": "固件升级提示", @@ -845,14 +845,15 @@ "操作失败,请确认锁是否在附近,或重启手机蓝牙后再试。": "操作失败,请确认锁是否在附近,或重启手机蓝牙后再试。", "如果是全自动锁,请使屏幕变亮": "如果是全自动锁,请使屏幕变亮", "正在尝试闭锁……": "正在尝试闭锁……", - "清空记录":"清空记录", - "是否要删除操作记录?":"是否要删除操作记录?", - "被删除的记录不能恢复":"被删除的记录不能恢复", - "全部事件":"全部事件", - "开锁事件":"开锁事件", - "异常事件":"异常事件", - "门铃事件":"门铃事件", - "视频事件":"视频事件", - "请开启蓝牙":"请开启蓝牙", - "请选择有效日":"请选择有效日" + "清空记录": "清空记录", + "是否要删除操作记录?": "是否要删除操作记录?", + "被删除的记录不能恢复": "被删除的记录不能恢复", + "全部事件": "全部事件", + "开锁事件": "开锁事件", + "异常事件": "异常事件", + "门铃事件": "门铃事件", + "视频事件": "视频事件", + "请开启蓝牙": "请开启蓝牙", + "请选择有效日": "请选择有效日", + "公司名字长度不能小于 6 ": "公司名字长度不能小于 6 " } diff --git a/lib/main/lockDetail/checkingIn/checkingInSet/checkingInSet_page.dart b/lib/main/lockDetail/checkingIn/checkingInSet/checkingInSet_page.dart index 0cf124c0..da4c5f2c 100755 --- a/lib/main/lockDetail/checkingIn/checkingInSet/checkingInSet_page.dart +++ b/lib/main/lockDetail/checkingIn/checkingInSet/checkingInSet_page.dart @@ -4,6 +4,7 @@ import 'package:flutter/services.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/app_settings/app_colors.dart'; +import 'package:star_lock/main/lockDetail/checkingIn/checkingInSet/checkingInSet_state.dart'; import '../../../../appRouters.dart'; import '../../../../tools/commonItem.dart'; @@ -22,8 +23,8 @@ class CheckingInSetPage extends StatefulWidget { } class _CheckingInSetPageState extends State { - final logic = Get.put(CheckingInSetLogic()); - final state = Get.find().state; + final CheckingInSetLogic logic = Get.put(CheckingInSetLogic()); + final CheckingInSetState state = Get.find().state; @override Widget build(BuildContext context) { @@ -31,17 +32,17 @@ class _CheckingInSetPageState extends State { backgroundColor: AppColors.mainBackgroundColor, appBar: TitleAppBar( barTitle: - "${TranslationLoader.lanKeys!.checkingIn!.tr}${TranslationLoader.lanKeys!.set!.tr}", + '${TranslationLoader.lanKeys!.checkingIn!.tr}${TranslationLoader.lanKeys!.set!.tr}', haveBack: true, backgroundColor: AppColors.mainColor), body: Column( - children: [ + children: [ Obx(() => CommonItem( leftTitel: - "公司名称".tr, - // rightTitle: state.companyName.value ?? "", - isHaveRightWidget: true, - rightWidget: getTFWidget(), + '公司名称'.tr, + rightTitle: state.companyName.value ?? '', + // isHaveRightWidget: true, + // rightWidget: getTFWidget(), isHaveLine: true, isHaveDirection: true, action: () { @@ -53,23 +54,23 @@ class _CheckingInSetPageState extends State { isHaveLine: true, isHaveDirection: true, action: () { - Get.toNamed(Routers.checkingInStaffManagePage, arguments: { - "getKeyInfosData": state.getKeyInfosData.value, - "companyId": state.companyId.value + Get.toNamed(Routers.checkingInStaffManagePage, arguments: { + 'getKeyInfosData': state.getKeyInfosData.value, + 'companyId': state.companyId.value }); })), Obx(() => CommonItem( leftTitel: "${TranslationLoader.lanKeys!.work!.tr}${TranslationLoader.lanKeys!.time!.tr}", - rightTitle: (state.beginTime.value.isNotEmpty) ? "${state.beginTime.value} - ${state.endTime.value}" : "", + rightTitle: (state.beginTime.value.isNotEmpty) ? '${state.beginTime.value} - ${state.endTime.value}' : '', isHaveLine: true, isHaveDirection: true, action: () async { - var data = await Get.toNamed(Routers.checkingInSetWorkTimePage, arguments: { + var data = await Get.toNamed(Routers.checkingInSetWorkTimePage, arguments: { // "getKeyInfosData": state.getKeyInfosData.value, - "companyId": state.companyId.value, - "pushType": "2", - "checkingInSetInfo": state.checkingInSetInfo.value, + 'companyId': state.companyId.value, + 'pushType': '2', + 'checkingInSetInfo': state.checkingInSetInfo.value, }); if(data != null) { setState(() { @@ -84,30 +85,30 @@ class _CheckingInSetPageState extends State { Obx(() => CommonItem( leftTitel: "${TranslationLoader.lanKeys!.workday!.tr}${TranslationLoader.lanKeys!.set!.tr}", - rightTitle: state.isCustom.value == true ? state.weekDaysStr.value : (state.weekDaysStr.value.length == 5 ? "单休" : "双休"), + rightTitle: state.isCustom.value == true ? state.weekDaysStr.value : (state.weekDaysStr.value.length == 5 ? '单休' : '双休'), isHaveLine: true, isHaveDirection: true, action: () async { - var data = await Get.toNamed(Routers.checkingInSetWorkdaySet, arguments: { - "getKeyInfosData": state.getKeyInfosData.value, - "companyId": state.companyId.value, - "pushType": "2", - "checkingInSetInfo": state.checkingInSetInfo.value, + var data = await Get.toNamed(Routers.checkingInSetWorkdaySet, arguments: { + 'getKeyInfosData': state.getKeyInfosData.value, + 'companyId': state.companyId.value, + 'pushType': '2', + 'checkingInSetInfo': state.checkingInSetInfo.value, }); if(data != null) { - state.isCustom.value = data["attendanceType"]; - state.weekDays.value = data["weekDays"]; - state.weekDaysStr.value = state.weekDays.value.join(","); + state.isCustom.value = data['attendanceType']; + state.weekDays.value = data['weekDays']; + state.weekDaysStr.value = state.weekDays.value.join(','); } })), CommonItem( leftTitel: TranslationLoader.lanKeys!.holidays!.tr, - rightTitle: "", + rightTitle: '', isHaveLine: false, isHaveDirection: true, action: () { - Get.toNamed(Routers.checkingInSetHolidaysPage, arguments: { - "companyId": state.companyId.value + Get.toNamed(Routers.checkingInSetHolidaysPage, arguments: { + 'companyId': state.companyId.value }); }), SizedBox( @@ -117,14 +118,14 @@ class _CheckingInSetPageState extends State { visible: state.getKeyInfosData.value.isLockOwner == 1, child: SubmitBtn( btnName: - "${TranslationLoader.lanKeys!.delete!.tr} ${TranslationLoader.lanKeys!.company!.tr}", + '${TranslationLoader.lanKeys!.delete!.tr} ${TranslationLoader.lanKeys!.company!.tr}', borderRadius: 20.w, fontSize: 32.sp, isDelete: true, margin: EdgeInsets.only(left: 30.w, right: 30.w, top: 20.w), padding: EdgeInsets.only(top: 20.w, bottom: 20.w), onClick: () { - ShowTipView().showIosTipWithContentDialog("是否删除?".tr, () { + ShowTipView().showIosTipWithContentDialog('是否删除?'.tr, () { logic.deletCompanyData(); }); // showDeletCompanyAlertDialog(context); @@ -140,12 +141,19 @@ class _CheckingInSetPageState extends State { context: context, builder: (BuildContext context) { return ShowTFView( - title: "修改公司名字".tr, - tipTitle: "", + title: '修改公司名字'.tr, + tipTitle: '', controller: state.changeNameController, + inputFormatters: [ + LengthLimitingTextInputFormatter(30), + ], sureClick: () { if(state.changeNameController.text.isEmpty){ - logic.showToast("请输入公司名字".tr); + logic.showToast('请输入公司名字'.tr); + return; + } + if(state.changeNameController.text.length <6){ + logic.showToast('公司名字长度不能小于 6 '.tr); return; } Get.back(); @@ -159,7 +167,7 @@ class _CheckingInSetPageState extends State { // 接受者信息输入框 Widget getTFWidget() { - state.nameController.text = state.companyName.value ?? ""; + state.nameController.text = state.companyName.value ?? ''; return Container( // color: Colors.red, height: 65.h, @@ -168,7 +176,7 @@ class _CheckingInSetPageState extends State { child: Row( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ Expanded( child: TextField( //输入框一行 diff --git a/lib/main/lockDetail/checkingIn/checkingInSet/checkingInSet_state.dart b/lib/main/lockDetail/checkingIn/checkingInSet/checkingInSet_state.dart index 476e3c51..89b334f6 100755 --- a/lib/main/lockDetail/checkingIn/checkingInSet/checkingInSet_state.dart +++ b/lib/main/lockDetail/checkingIn/checkingInSet/checkingInSet_state.dart @@ -6,28 +6,28 @@ import '../../../lockMian/entity/lockListInfo_entity.dart'; import 'checkingInSet_entity.dart'; class CheckingInSetState{ - final getKeyInfosData = LockListInfoItemEntity().obs; - final companyId = "".obs; + CheckingInSetState() { + Map map = Get.arguments; + getKeyInfosData.value = map['getKeyInfosData']; + } + final Rx getKeyInfosData = LockListInfoItemEntity().obs; + final RxString companyId = ''.obs; - var isCustom = false.obs; + RxBool isCustom = false.obs; - var weekDays = [].obs;// 工作天数 - var weekDaysStr = "".obs;// 拼接显示的字符串天数 + RxList weekDays = [].obs;// 工作天数 + RxString weekDaysStr = ''.obs;// 拼接显示的字符串天数 - var beginTime = "".obs;// 开始时间 - var endTime = "".obs;// 结束时间 - var beginTimeTimestamp = "".obs;// 开始时间时间戳 - var endTimeTimestamp = "".obs;// 结束时间时间戳 + RxString beginTime = ''.obs;// 开始时间 + RxString endTime = ''.obs;// 结束时间 + RxString beginTimeTimestamp = ''.obs;// 开始时间时间戳 + RxString endTimeTimestamp = ''.obs;// 结束时间时间戳 - var staffNumber = "".obs;// 员工数量 - var companyName = "".obs;// 公司名称 + RxString staffNumber = ''.obs;// 员工数量 + RxString companyName = ''.obs;// 公司名称 final TextEditingController changeNameController = TextEditingController(); final TextEditingController nameController = TextEditingController(); - final checkingInSetInfo = CheckingInSetInfo().obs; - CheckingInSetState() { - Map map = Get.arguments; - getKeyInfosData.value = map["getKeyInfosData"]; - } + final Rx checkingInSetInfo = CheckingInSetInfo().obs; } \ No newline at end of file diff --git a/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_page.dart b/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_page.dart index 0376b3a1..e8aee62b 100755 --- a/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_page.dart +++ b/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_page.dart @@ -5,6 +5,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaffSelectKey_entity.dart'; import 'package:star_lock/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_state.dart'; +import 'package:star_lock/tools/commonDataManage.dart'; import '../../../../../appRouters.dart'; import '../../../../../app_settings/app_colors.dart'; @@ -45,7 +46,7 @@ class _CheckingInAddStaffPageState extends State { isHaveLine: true, isHaveRightWidget: true, rightWidget: getTFWidget( - "${TranslationLoader.lanKeys!.pleaseEnter!.tr}${TranslationLoader.lanKeys!.name!.tr}", + '${TranslationLoader.lanKeys!.pleaseEnter!.tr}${TranslationLoader.lanKeys!.name!.tr}', state.staffNameController)), // 选择打卡方式 Obx(() => CommonItem( @@ -60,7 +61,10 @@ class _CheckingInAddStaffPageState extends State { '卡'.tr, '指纹'.tr ]; - if (state.getKeyInfosData.value.lockName!.contains('T9A')) { + + // if (state.getKeyInfosData.value.lockName!.contains('T9A')) { + if (CommonDataManage().currentKeyInfo.lockFeature?.d3Face == + 1) { list.add('人脸'.tr); } _showSelectClockInType(list, list, list, '1', '选择钥匙'.tr); diff --git a/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_state.dart b/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_state.dart index dd23cda8..1a939a7a 100755 --- a/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_state.dart +++ b/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_state.dart @@ -6,38 +6,9 @@ import '../checkingInSetStaffList/checkingInStaffList_entity.dart'; import 'checkingInAddStaffSelectKey_entity.dart'; class CheckingInAddStaffState { - final Rx getKeyInfosData = LockListInfoItemEntity().obs; - final RxString companyId = ''.obs; - final Rx staffListItemData = CheckingInAddStaffListItemEntity().obs; - - final TextEditingController staffNameController = TextEditingController(); - final TextEditingController staffAccountController = TextEditingController(); - - final RxString selectPrintingMethodType = '1'.obs; // 选择打卡类型 1APP 2密码 3卡 4指纹 5人脸 - final RxString selectPrintingMethodStr = 'APP'.obs; // 选择打卡类型字符串 - - final RxString countryName = '中国'.tr.obs; - final RxString countryCode = '86'.obs; - - final RxBool appUnHaveAccount = true.obs; // 默认没有账号 - final RxList keyEntity = [].obs; // 选择钥匙数据 - - final RxString isAdd = '1'.obs; // 1添加 2编辑 - final RxString attendanceWayName = ''.obs; - final RxString attendanceWayNumber = ''.obs; - final RxBool isCanClick = false.obs; - RxString staffName = ''.obs; - RxString staffAccount = ''.obs; - - bool get staffNameIsNotEmpty => staffName.value.isNotEmpty; - - bool get staffAccountIsNotEmpty => staffAccount.value.isNotEmpty; - - bool get attendanceWayNumberIsNotEmpty => - attendanceWayNumber.value.isNotEmpty; CheckingInAddStaffState() { - Map map = Get.arguments; + final Map map = Get.arguments; getKeyInfosData.value = map['getKeyInfosData']; companyId.value = map['companyId']; @@ -61,6 +32,9 @@ class CheckingInAddStaffState { case 4: selectPrintingMethodStr.value = '指纹'.tr; break; + case 5: + selectPrintingMethodStr.value = '人脸'.tr; + break; } if (staffListItemData.value.attendanceWay!.isNotEmpty) { @@ -71,4 +45,37 @@ class CheckingInAddStaffState { } } } + final Rx getKeyInfosData = + LockListInfoItemEntity().obs; + final RxString companyId = ''.obs; + final Rx staffListItemData = + CheckingInAddStaffListItemEntity().obs; + + final TextEditingController staffNameController = TextEditingController(); + final TextEditingController staffAccountController = TextEditingController(); + + final RxString selectPrintingMethodType = + '1'.obs; // 选择打卡类型 1APP 2密码 3卡 4指纹 5人脸 + final RxString selectPrintingMethodStr = 'APP'.obs; // 选择打卡类型字符串 + + final RxString countryName = '中国'.tr.obs; + final RxString countryCode = '86'.obs; + + final RxBool appUnHaveAccount = true.obs; // 默认没有账号 + final RxList keyEntity = + [].obs; // 选择钥匙数据 + + final RxString isAdd = '1'.obs; // 1添加 2编辑 + final RxString attendanceWayName = ''.obs; + final RxString attendanceWayNumber = ''.obs; + final RxBool isCanClick = false.obs; + RxString staffName = ''.obs; + RxString staffAccount = ''.obs; + + bool get staffNameIsNotEmpty => staffName.value.isNotEmpty; + + bool get staffAccountIsNotEmpty => staffAccount.value.isNotEmpty; + + bool get attendanceWayNumberIsNotEmpty => + attendanceWayNumber.value.isNotEmpty; } diff --git a/lib/tools/commonItem.dart b/lib/tools/commonItem.dart index 3cf2bf79..f1e20fee 100755 --- a/lib/tools/commonItem.dart +++ b/lib/tools/commonItem.dart @@ -3,6 +3,20 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:star_lock/app_settings/app_colors.dart'; class CommonItem extends StatelessWidget { + CommonItem( + {required this.leftTitel, + Key? key, + this.rightTitle, + this.allHeight, + this.isHaveDirection = false, + this.isHaveLine = false, + this.isHaveRightWidget = false, + this.isPadding = true, + this.rightWidget, + this.isTipsImg, + this.action, + this.tipsImgAction}) + : super(key: key); String? leftTitel; String? rightTitle; bool? isHaveDirection; @@ -15,97 +29,73 @@ class CommonItem extends StatelessWidget { bool? isTipsImg; bool? isPadding; - CommonItem( - {Key? key, - required this.leftTitel, - this.rightTitle, - this.allHeight, - this.isHaveDirection = false, - this.isHaveLine = false, - this.isHaveRightWidget = false, - this.isPadding = true, - this.rightWidget, - this.isTipsImg, - this.action, - this.tipsImgAction}) - : super(key: key); - @override Widget build(BuildContext context) { return GestureDetector( onTap: action, - child: Column( - // mainAxisAlignment: MainAxisAlignment.center, - children: [ - Container( - height: allHeight ?? 65.h, - color: Colors.white, - padding: isPadding == true ? EdgeInsets.only(left: 20.w, right: 10.w) : EdgeInsets.zero, // , top: 20.w, bottom: 20.w - child: Row( - children: [ - // SizedBox(width: 20.w), - SizedBox( - // width: isHaveRightWidget! ? 100.w : 300.w, - child: Text(leftTitel!, style: TextStyle(fontSize: 22.sp))), - SizedBox(width: 6.w), - isTipsImg == true - ? GestureDetector( - onTap: tipsImgAction, - child: Container( - width: 50.h, - height: 50.h, - padding: EdgeInsets.only(right:10.h, top: 15.h, bottom: 10.h), - child: Image.asset( - 'images/icon_tips_Q.png', - width: 20.w, - height: 20.w, - ), - ), - ) - : Container(), - Expanded(child: SizedBox(width: 10.w)), - Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - isHaveRightWidget! - ? rightWidget! - : SizedBox( - // width: rightTitle!.isNotEmpty ? 260.w : 0.1.w, - child: Text( - rightTitle ?? "", - textAlign: TextAlign.right, - overflow: TextOverflow.ellipsis, - maxLines: 2, - style: TextStyle( - fontSize: 22.sp, - color: AppColors.darkGrayTextColor), - ), - ), - ], - ), - isHaveDirection! ? SizedBox(width: 15.w) : Container(), - isHaveDirection! - ? Image.asset( - 'images/icon_right_grey.png', - width: 12.w, - height: 21.w, - ) - : SizedBox(width: 10.w), - isHaveDirection! ? SizedBox(width: 5.w) : Container(), - ], - ), - ), - // isHaveLine!?Container(height: 0.5.h, color: Colors.grey,):Container() - //by DaisyWu - isHaveLine! - ? Divider( - color: AppColors.greyLineColor, - indent: isPadding == true ? 20.w : 0, - endIndent: isPadding == true ? 20.w : 0, - height: 1, + child: Container( + height: allHeight ?? 65.h, + padding: isPadding == true + ? EdgeInsets.only(left: 20.w, right: 10.w) + : EdgeInsets.zero, + decoration: BoxDecoration( + color: Colors.white, + border: isHaveLine! + ? Border( + bottom: BorderSide( + color: AppColors.greyLineColor, // 设置边框颜色 + width: 2.0.h, // 设置边框宽度 + ), ) - : Container() - ], + : null, + ), + child: Row( + children: [ + Text(leftTitel!, style: TextStyle(fontSize: 22.sp)), + SizedBox(width: 6.w), + if (isTipsImg == true) + GestureDetector( + onTap: tipsImgAction, + child: Container( + width: 50.h, + height: 50.h, + padding: + EdgeInsets.only(right: 10.h, top: 15.h, bottom: 10.h), + child: Image.asset( + 'images/icon_tips_Q.png', + width: 20.w, + height: 20.w, + ), + ), + ) + else + Container(), + if (isHaveRightWidget!) ...[ + const Spacer(), + rightWidget! + ] else + Expanded( + child: Text( + rightTitle ?? '', + textAlign: TextAlign.right, + overflow: TextOverflow.ellipsis, + maxLines: 2, + style: TextStyle( + fontSize: 22.sp, color: AppColors.darkGrayTextColor), + ), + ), + if (isHaveDirection!) SizedBox(width: 15.w) else Container(), + if (isHaveDirection!) + Image.asset( + 'images/icon_right_grey.png', + width: 12.w, + height: 21.w, + ) + else + SizedBox(width: 10.w), + if (isHaveDirection!) SizedBox(width: 5.w) else Container(), + ], + ), ), ); } diff --git a/lib/tools/showTFView.dart b/lib/tools/showTFView.dart index a21637c0..a3b05179 100755 --- a/lib/tools/showTFView.dart +++ b/lib/tools/showTFView.dart @@ -65,6 +65,7 @@ class ShowTFView extends StatelessWidget { //不需要输入框下划线 border: InputBorder.none, ), + ), ) ], From faf006c6775e1b83c65d6f1519f3eb69ac736e86 Mon Sep 17 00:00:00 2001 From: anfe <448468458@qq.com> Date: Mon, 20 May 2024 14:55:36 +0800 Subject: [PATCH 14/44] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=20=E5=BC=80?= =?UTF-8?q?=E9=94=81=E9=A1=B5-=E8=80=83=E5=8B=A4-=E8=AE=BE=E7=BD=AE-?= =?UTF-8?q?=E8=8A=82=E5=81=87=E6=97=A5-=E5=A7=93=E5=90=8D=20=E8=BE=93?= =?UTF-8?q?=E9=95=BF=E4=BD=8D=E7=9A=84=E6=98=BE=E7=A4=BA=E5=8D=8A=E6=88=AA?= =?UTF-8?q?=EF=BC=8C=E5=8F=A6=E8=BE=93=E5=AE=8C=E5=90=8E=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E4=B8=8D=E5=85=A8=EF=BC=8C=E5=BA=94=E9=99=90=E5=88=B630?= =?UTF-8?q?=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../checkingInAddHolidays_page.dart | 90 +++++---- .../checkingInSetHolidays_page.dart | 176 +++++++++--------- lib/tools/commonItem.dart | 8 +- 3 files changed, 138 insertions(+), 136 deletions(-) diff --git a/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInAddHolidays/checkingInAddHolidays_page.dart b/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInAddHolidays/checkingInAddHolidays_page.dart index cecd68b0..4cad5ecd 100755 --- a/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInAddHolidays/checkingInAddHolidays_page.dart +++ b/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInAddHolidays/checkingInAddHolidays_page.dart @@ -1,7 +1,9 @@ import 'package:date_format/date_format.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; +import 'package:star_lock/main/lockDetail/checkingIn/checkingInHolidays/checkingInAddHolidays/checkingInAddHolidays_state.dart'; import '../../../../../app_settings/app_colors.dart'; import '../../../../../tools/commonItem.dart'; @@ -20,8 +22,10 @@ class CheckingInAddHolidaysPage extends StatefulWidget { } class _CheckingInAddHolidaysPageState extends State { - final logic = Get.put(CheckingInAddHolidaysLogic()); - final state = Get.find().state; + final CheckingInAddHolidaysLogic logic = + Get.put(CheckingInAddHolidaysLogic()); + final CheckingInAddHolidaysState state = + Get.find().state; @override Widget build(BuildContext context) { @@ -32,27 +36,31 @@ class _CheckingInAddHolidaysPageState extends State { haveBack: true, backgroundColor: AppColors.mainColor), body: Column( - children: [ + children: [ CommonItem( leftTitel: TranslationLoader.lanKeys!.name!.tr, - rightTitle: "", + rightTitle: '', isHaveLine: true, isHaveRightWidget: true, + setHeight: false, rightWidget: getTFWidget( - "(${TranslationLoader.lanKeys!.mustFillIn!.tr})")), + '(${TranslationLoader.lanKeys!.mustFillIn!.tr})')), Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.startDate!.tr, - rightTitle: state.beginDate.value.isEmpty ? "(${TranslationLoader.lanKeys!.mustFillIn!.tr})" : state.beginDate.value, + rightTitle: state.beginDate.value.isEmpty + ? '(${TranslationLoader.lanKeys!.mustFillIn!.tr})' + : state.beginDate.value, isHaveLine: true, isHaveDirection: false, action: () async { await showDialog( context: context, - builder: (context) { + builder: (BuildContext context) { return ShowCalendar( datePickerMode: DatePickerMode.day, - selectAction: (dateTime) { - String beginDate = formatDate(dateTime, [yyyy,'-',mm,'-',dd]); + selectAction: (DateTime dateTime) { + final String beginDate = formatDate( + dateTime, [yyyy, '-', mm, '-', dd]); state.beginDate.value = beginDate; Get.back(); // Navigator.of(context).pop(true); @@ -61,17 +69,20 @@ class _CheckingInAddHolidaysPageState extends State { })), Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.endDate!.tr, - rightTitle: state.endDate.value.isEmpty ? "(${TranslationLoader.lanKeys!.mustFillIn!.tr})" : state.endDate.value, + rightTitle: state.endDate.value.isEmpty + ? '(${TranslationLoader.lanKeys!.mustFillIn!.tr})' + : state.endDate.value, isHaveLine: true, isHaveDirection: false, action: () async { await showDialog( context: context, - builder: (context) { + builder: (BuildContext context) { return ShowCalendar( datePickerMode: DatePickerMode.day, - selectAction: (dateTime) { - String endDate = formatDate(dateTime, [yyyy,'-',mm,'-',dd]); + selectAction: (DateTime dateTime) { + final String endDate = formatDate( + dateTime, [yyyy, '-', mm, '-', dd]); state.endDate.value = endDate; Get.back(); }); @@ -85,11 +96,12 @@ class _CheckingInAddHolidaysPageState extends State { action: () async { await showDialog( context: context, - builder: (context) { + builder: (BuildContext context) { return ShowCalendar( datePickerMode: DatePickerMode.day, - selectAction: (dateTime) { - String makeUpWorkDate = formatDate(dateTime, [yyyy,'-',mm,'-',dd]); + selectAction: (DateTime dateTime) { + final String makeUpWorkDate = formatDate( + dateTime, [yyyy, '-', mm, '-', dd]); state.makeUpWorkDate.value = makeUpWorkDate; Get.back(); }); @@ -112,30 +124,26 @@ class _CheckingInAddHolidaysPageState extends State { } Widget getTFWidget(String tfStr) { - return Container( - height: 50.h, - width: 300.w, - // color: Colors.red, - child: Row( - children: [ - Expanded( - child: TextField( - //输入框一行 - maxLines: 1, - controller: state.staffNameController, - autofocus: false, - textAlign: TextAlign.end, - decoration: InputDecoration( - //输入里面输入文字内边距设置 - contentPadding: const EdgeInsets.only(top: 12.0, bottom: 8.0), - hintText: tfStr, - hintStyle: TextStyle( - fontSize: 22.sp, color: AppColors.darkGrayTextColor), - //不需要输入框下划线 - border: InputBorder.none, - ), - ), - ), + return Expanded( + child: TextField( + //输入框一行 + maxLines: 2, + minLines: 1, + controller: state.staffNameController, + autofocus: false, + textAlign: TextAlign.end, + decoration: InputDecoration( + //输入里面输入文字内边距设置 + contentPadding: const EdgeInsets.only(bottom: 3), + hintText: tfStr, + hintStyle: TextStyle( + fontSize: 22.sp, color: AppColors.darkGrayTextColor, height: 1), + //不需要输入框下划线 + border: InputBorder.none, + isCollapsed: true, + ), + inputFormatters: [ + LengthLimitingTextInputFormatter(30), ], ), ); @@ -145,7 +153,7 @@ class _CheckingInAddHolidaysPageState extends State { return GestureDetector( onTap: () {}, child: Row( - children: [ + children: [ Image.asset( 'images/icon_round_unSelect.png', width: 40.w, diff --git a/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInSetHolidays/checkingInSetHolidays_page.dart b/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInSetHolidays/checkingInSetHolidays_page.dart index 76480bc8..eece3717 100755 --- a/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInSetHolidays/checkingInSetHolidays_page.dart +++ b/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInSetHolidays/checkingInSetHolidays_page.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; +import 'package:star_lock/main/lockDetail/checkingIn/checkingInHolidays/checkingInSetHolidays/checkingInSetHolidays_state.dart'; import 'package:star_lock/tools/noData.dart'; import 'package:star_lock/tools/pickers/pickers.dart'; import 'package:star_lock/tools/pickers/style/picker_style.dart'; @@ -25,8 +26,10 @@ class CheckingInSetHolidaysPage extends StatefulWidget { } class _CheckingInSetHolidaysPageState extends State { - final logic = Get.put(CheckingInSetHolidaysLogic()); - final state = Get.find().state; + final CheckingInSetHolidaysLogic logic = + Get.put(CheckingInSetHolidaysLogic()); + final CheckingInSetHolidaysState state = + Get.find().state; @override Widget build(BuildContext context) { @@ -37,12 +40,14 @@ class _CheckingInSetHolidaysPageState extends State { titleWidget: titleWidget(), haveBack: true, backgroundColor: AppColors.mainColor, - actionsList: [ + actionsList: [ GestureDetector( onTap: () async { - var data = await Get.toNamed( + final dynamic data = await Get.toNamed( Routers.checkingInAddHolidaysPage, - arguments: {"companyId": state.companyId.value}); + arguments: { + 'companyId': state.companyId.value + }); if (data != null) { logic.editStaffLoadData(); } @@ -58,12 +63,12 @@ class _CheckingInSetHolidaysPageState extends State { ], ), body: Obx(() { - return state.holidaysListData.value!.isNotEmpty + return state.holidaysListData.isNotEmpty ? ListView.builder( - itemCount: state.holidaysListData.value!.length, - itemBuilder: (c, index) { - HolidaysMonthListData holidaysMonthListData = - state.holidaysListData.value![index]; + itemCount: state.holidaysListData.length, + itemBuilder: (BuildContext c, int index) { + final HolidaysMonthListData holidaysMonthListData = + state.holidaysListData[index]; return _checkingInListMouthItem(holidaysMonthListData); }) : NoData(); @@ -71,34 +76,44 @@ class _CheckingInSetHolidaysPageState extends State { } Widget _checkingInListMouthItem(HolidaysMonthListData holidaysMonthListData) { + final double width = Get.width - 20.w * 2; + final double l = width * 0.2; + final double r = width * 0.8; return GestureDetector( child: Container( - height: 140.h * holidaysMonthListData.listItem!.length + 20.w, - padding: EdgeInsets.only(left: 20.w, right: 20.w, top: 20.w), + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [ + colorWithMonth(int.parse( + holidaysMonthListData.listItem![0].month.toString())), + Colors.white + ], + stops: const [0.2, 0.2], + ), + ), + margin: EdgeInsets.only(left: 20.w, right: 20.w, top: 20.w), child: Row( - children: [ + children: [ Container( color: colorWithMonth(int.parse( holidaysMonthListData.listItem![0].month.toString())), - width: 100.w, - height: 140.h * holidaysMonthListData.listItem!.length, + width: l, child: Center( child: Text( - "${holidaysMonthListData.listItem![0].month}\n${TranslationLoader.lanKeys!.month!.tr}", + '${holidaysMonthListData.listItem![0].month}\n${TranslationLoader.lanKeys!.month!.tr}', textAlign: TextAlign.center, style: TextStyle(fontSize: 28.sp, color: Colors.white), ))), SizedBox( - height: 140.h * holidaysMonthListData.listItem!.length, - width: 1.sw - 100.w - 20.w * 2, + width: r, child: ListView.builder( shrinkWrap: true, physics: const NeverScrollableScrollPhysics(), itemCount: holidaysMonthListData.listItem!.length, - itemBuilder: (c, index) { - ListItem listItem = holidaysMonthListData.listItem![index]; + itemBuilder: (BuildContext c, int index) { + final ListItem listItem = + holidaysMonthListData.listItem![index]; return _checkingInListItem( - index, listItem.vacationName, DateTool().dateToYMDString( listItem.vacationStartDate.toString()), @@ -107,10 +122,10 @@ class _CheckingInSetHolidaysPageState extends State { listItem.fillClassDate!.isNotEmpty ? DateTool().dateToYMDString( listItem.fillClassDate.toString()) - : "", () async { - var data = await Get.toNamed( + : '', () async { + final dynamic data = await Get.toNamed( Routers.checkingInDeletHolidaysPage, - arguments: {"listItem": listItem}); + arguments: {'listItem': listItem}); if (data != null) { logic.editStaffLoadData(); } @@ -123,83 +138,66 @@ class _CheckingInSetHolidaysPageState extends State { ); } - Widget _checkingInListItem( - int index, - String? lockTypeTitle, - String? vacationStartDate, - String? vacationEndDate, - String? makeUpClass, - Function() action) { + Widget _checkingInListItem(String? lockTypeTitle, String? vacationStartDate, + String? vacationEndDate, String? makeUpClass, Function() action) { return GestureDetector( onTap: action, - child: Column( - children: [ - Container( - color: Colors.white, - height: 140.h, - padding: EdgeInsets.only(left: 20.w, right: 20.w, top: 10.h), - child: Row( - children: [ - Expanded( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - lockTypeTitle!, - style: TextStyle(fontSize: 24.sp), - ), - ], - ), - SizedBox(height: 10.h), - Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Text( - "${TranslationLoader.lanKeys!.libertyDay!.tr}:$vacationStartDate - $vacationEndDate", - style: TextStyle(fontSize: 20.sp), - ), - ], - ), - SizedBox(height: 5.h), - Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Text( - "${TranslationLoader.lanKeys!.coverDate!.tr}:$makeUpClass", - style: TextStyle(fontSize: 20.sp), - ), - ], - ), - ], - ), - ), - SizedBox(width: 20.h), - ], + child: Container( + padding: + EdgeInsets.only(left: 20.w, right: 20.w, top: 10.h, bottom: 10.h), + decoration: BoxDecoration( + border: Border( + bottom: BorderSide( + color: AppColors.mainBackgroundColor, width: 1.h, // 设置边框宽度 ), ), - Container(color: AppColors.mainBackgroundColor, height: 1.h) - ], + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + Characters(lockTypeTitle!).join('\u{200B}'), + style: TextStyle(fontSize: 24.sp), + ), + SizedBox(height: 10.h), + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Text( + '${TranslationLoader.lanKeys!.libertyDay!.tr}:$vacationStartDate - $vacationEndDate', + style: TextStyle(fontSize: 20.sp), + ), + ], + ), + SizedBox(height: 5.h), + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Text( + '${TranslationLoader.lanKeys!.coverDate!.tr}:$makeUpClass', + style: TextStyle(fontSize: 20.sp), + ), + ], + ), + ], + ), ), ); } Widget titleWidget() { return GestureDetector( - onTap: () { - showListType(); - }, + onTap: showListType, child: Obx(() => Container( width: 300.w, height: 50.h, color: AppColors.mainColor, child: Row( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ Text( - "${state.selectYear.value}${TranslationLoader.lanKeys!.year!.tr}", + '${state.selectYear.value}${TranslationLoader.lanKeys!.year!.tr}', style: TextStyle(color: Colors.white, fontSize: 26.sp), ), SizedBox( @@ -226,9 +224,7 @@ class _CheckingInSetHolidaysPageState extends State { // 样式 详见下方样式 pickerStyle: PickerStyle( cancelButton: GestureDetector( - onTap: () { - Get.back(); - }, + onTap: Get.back, child: Container( alignment: Alignment.center, padding: const EdgeInsets.only(left: 22, right: 12), @@ -237,9 +233,7 @@ class _CheckingInSetHolidaysPageState extends State { ), ), commitButton: GestureDetector( - onTap: () { - Get.back(); - }, + onTap: Get.back, child: Container( alignment: Alignment.center, padding: const EdgeInsets.only(left: 22, right: 12), @@ -252,7 +246,7 @@ class _CheckingInSetHolidaysPageState extends State { selectDate: PDuration(year: 2023), minDate: PDuration(year: 1900), maxDate: PDuration(year: 2100), - onConfirm: (p) { + onConfirm: (PDuration p) { state.selectYear.value = p.year!; logic.editStaffLoadData(); }, diff --git a/lib/tools/commonItem.dart b/lib/tools/commonItem.dart index f1e20fee..d6776391 100755 --- a/lib/tools/commonItem.dart +++ b/lib/tools/commonItem.dart @@ -12,6 +12,7 @@ class CommonItem extends StatelessWidget { this.isHaveLine = false, this.isHaveRightWidget = false, this.isPadding = true, + this.setHeight = true, this.rightWidget, this.isTipsImg, this.action, @@ -26,6 +27,7 @@ class CommonItem extends StatelessWidget { Function()? action; Function()? tipsImgAction; double? allHeight; + bool? setHeight; bool? isTipsImg; bool? isPadding; @@ -34,7 +36,7 @@ class CommonItem extends StatelessWidget { return GestureDetector( onTap: action, child: Container( - height: allHeight ?? 65.h, + height: setHeight == true ? allHeight ?? 65.h : null, padding: isPadding == true ? EdgeInsets.only(left: 20.w, right: 10.w) : EdgeInsets.zero, @@ -67,9 +69,7 @@ class CommonItem extends StatelessWidget { height: 20.w, ), ), - ) - else - Container(), + ), if (isHaveRightWidget!) ...[ const Spacer(), rightWidget! From 04d2dde5ebb5c47316e263e26498bd39ebfd254b Mon Sep 17 00:00:00 2001 From: anfe <448468458@qq.com> Date: Mon, 20 May 2024 15:04:13 +0800 Subject: [PATCH 15/44] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=20=E5=BC=80?= =?UTF-8?q?=E9=94=81=E9=A1=B5-=E8=80=83=E5=8B=A4-=E6=97=A5=E6=A6=9C?= =?UTF-8?q?=E5=92=8C=E6=9C=88=E6=A6=9C=E5=88=97=E8=A1=A8=E9=87=8C=E5=A7=93?= =?UTF-8?q?=E5=90=8D=E5=89=8D=E7=9A=84=E5=9B=BE=E5=83=8F=E9=83=BD=E4=B8=80?= =?UTF-8?q?=E6=A0=B7=EF=BC=8C=E5=BA=94=E5=92=8C=E5=91=98=E5=B7=A5=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E9=87=8C=E4=B8=80=E6=A0=B7=E5=8C=BA=E5=88=86=EF=BC=8C?= =?UTF-8?q?=E5=8F=A6APP=E5=A6=82=E6=9C=89=E5=A4=B4=E5=83=8F=E5=BA=94?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E5=A4=B4=E5=83=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../checkingInList/checkingInList_page.dart | 530 +++++++++++------- .../checkingInStaffList_page.dart | 214 +++---- 2 files changed, 450 insertions(+), 294 deletions(-) diff --git a/lib/main/lockDetail/checkingIn/checkingInList/checkingInList_page.dart b/lib/main/lockDetail/checkingIn/checkingInList/checkingInList_page.dart index 20344f94..608da425 100755 --- a/lib/main/lockDetail/checkingIn/checkingInList/checkingInList_page.dart +++ b/lib/main/lockDetail/checkingIn/checkingInList/checkingInList_page.dart @@ -3,6 +3,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/main/lockDetail/checkingIn/checkingInList/checkingInListMonth_entity.dart'; +import 'package:star_lock/main/lockDetail/checkingIn/checkingInList/checkingInList_state.dart'; +import 'package:star_lock/main/lockMian/entity/lockListInfo_entity.dart'; import '../../../../appRouters.dart'; import '../../../../app_settings/app_colors.dart'; @@ -23,8 +25,8 @@ class CheckingInListPage extends StatefulWidget { } class _CheckingInListPageState extends State { - final logic = Get.put(CheckingInListLogic()); - final state = Get.find().state; + final CheckingInListLogic logic = Get.put(CheckingInListLogic()); + final CheckingInListState state = Get.find().state; @override Widget build(BuildContext context) { @@ -35,26 +37,33 @@ class _CheckingInListPageState extends State { titleWidget: titleWidget(), haveBack: true, backgroundColor: AppColors.mainColor, - actionsList: [ - (state.getKeyInfosData.value.keyRight == 1) ? - GestureDetector( - onTap: () async { - var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); - if(isDemoMode == false){ - Get.toNamed(Routers.checkingInSetPage, arguments: { - "getKeyInfosData": state.getKeyInfosData.value, - }); - }else{ - // Get.toNamed(Routers.selectLockTypePage); - logic.showToast("演示模式"); - } - }, - child: Image.asset('images/main/icon_lockDetail_checkIn_set.png', width: 36.w, height: 36.w,)) : Container(), + actionsList: [ + (state.getKeyInfosData.value.keyRight == 1) + ? GestureDetector( + onTap: () async { + final bool? isDemoMode = + await Storage.getBool(ifIsDemoModeOrNot); + if (isDemoMode == false) { + Get.toNamed(Routers.checkingInSetPage, + arguments: { + 'getKeyInfosData': state.getKeyInfosData.value, + }); + } else { + // Get.toNamed(Routers.selectLockTypePage); + logic.showToast('演示模式'); + } + }, + child: Image.asset( + 'images/main/icon_lockDetail_checkIn_set.png', + width: 36.w, + height: 36.w, + )) + : Container(), SizedBox(width: 30.w), ], ), body: Column( - children: [ + children: [ topInfo(), SizedBox(height: 10.h), middleDayInfo(), @@ -70,7 +79,7 @@ class _CheckingInListPageState extends State { // height: 280.h, color: Colors.white, child: Column( - children: [ + children: [ SizedBox(height: 30.h), Obx(() => Container( width: 110.w, @@ -80,32 +89,38 @@ class _CheckingInListPageState extends State { color: AppColors.mainColor, borderRadius: BorderRadius.circular(60.w), ), - child: Image.asset(getTopImg(), width: 120.w, height: 120.w) - )), + child: Image.asset(getTopImg(), width: 120.w, height: 120.w))), SizedBox(height: 10.h), - Obx(() => Text(getTopTitle(), style: TextStyle(color: Colors.black, fontSize: 24.sp))), + Obx(() => Text(getTopTitle(), + style: TextStyle(color: Colors.black, fontSize: 24.sp))), SizedBox(height: 30.h), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ + children: [ // SizedBox(width: 30.w,), Row( - children: [ - SizedBox(width: 20.w,), + children: [ + SizedBox( + width: 20.w, + ), GestureDetector( onTap: () async { - var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); - if(isDemoMode == false){ + final bool? isDemoMode = + await Storage.getBool(ifIsDemoModeOrNot); + if (isDemoMode == false) { setState(() { state.isDay.value = true; - DateTime dateTime = DateTime.fromMillisecondsSinceEpoch(state.checkListDateTimestamp.value); - String beginDate = formatDate(dateTime, [mm,'-',dd]); + final DateTime dateTime = + DateTime.fromMillisecondsSinceEpoch( + state.checkListDateTimestamp.value); + final String beginDate = + formatDate(dateTime, [mm, '-', dd]); state.checkListDate.value = beginDate; logic.loadDataByType(); }); - }else{ + } else { // Get.toNamed(Routers.selectLockTypePage); - logic.showToast("演示模式"); + logic.showToast('演示模式'); } }, child: Container( @@ -113,37 +128,47 @@ class _CheckingInListPageState extends State { // height: 100.h, color: Colors.white, child: Obx(() => Column( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - Text(TranslationLoader.lanKeys!.dailyCharts!.tr, style: TextStyle(color: state.isDay.value ? AppColors.mainColor : Colors.black, fontSize: 22.sp)), - SizedBox(height: 10.h), - Visibility( - visible: state.isDay.value, - child: Container( - width: 20.w, - height: 2.h, - color: state.isDay.value ? AppColors.mainColor : Colors.black - ), - ) - ], - )), + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + Text(TranslationLoader.lanKeys!.dailyCharts!.tr, + style: TextStyle( + color: state.isDay.value + ? AppColors.mainColor + : Colors.black, + fontSize: 22.sp)), + SizedBox(height: 10.h), + Visibility( + visible: state.isDay.value, + child: Container( + width: 20.w, + height: 2.h, + color: state.isDay.value + ? AppColors.mainColor + : Colors.black), + ) + ], + )), ), ), // SizedBox(width: 20.w,), GestureDetector( onTap: () async { - var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); - if(isDemoMode == false){ + final bool? isDemoMode = + await Storage.getBool(ifIsDemoModeOrNot); + if (isDemoMode == false) { setState(() { state.isDay.value = false; - DateTime dateTime = DateTime.fromMillisecondsSinceEpoch(state.checkListDateTimestamp.value); - String beginDate = formatDate(dateTime, [mm]); + final DateTime dateTime = + DateTime.fromMillisecondsSinceEpoch( + state.checkListDateTimestamp.value); + final String beginDate = + formatDate(dateTime, [mm]); state.checkListDate.value = beginDate; logic.loadDataByType(); }); - }else{ + } else { // Get.toNamed(Routers.selectLockTypePage); - logic.showToast("演示模式"); + logic.showToast('演示模式'); } }, child: Container( @@ -151,49 +176,76 @@ class _CheckingInListPageState extends State { // height: 100.h, color: Colors.white, child: Obx(() => Column( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - Text(TranslationLoader.lanKeys!.monthlyLeaderboard!.tr, style: TextStyle(color: !state.isDay.value ? AppColors.mainColor : Colors.black, fontSize: 22.sp)), - SizedBox(height: 10.h), - Visibility( - visible: !state.isDay.value, - child: Container(width: 20.w, height: 2.h, color: !state.isDay.value ? AppColors.mainColor : Colors.black)) - ], - )), + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + Text( + TranslationLoader + .lanKeys!.monthlyLeaderboard!.tr, + style: TextStyle( + color: !state.isDay.value + ? AppColors.mainColor + : Colors.black, + fontSize: 22.sp)), + SizedBox(height: 10.h), + Visibility( + visible: !state.isDay.value, + child: Container( + width: 20.w, + height: 2.h, + color: !state.isDay.value + ? AppColors.mainColor + : Colors.black)) + ], + )), ), ), ], ), GestureDetector( onTap: () async { - var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); - if(isDemoMode == false){ + final bool? isDemoMode = + await Storage.getBool(ifIsDemoModeOrNot); + if (isDemoMode == false) { await showDialog( context: Get.context!, - builder: (context) { + builder: (BuildContext context) { return ShowCalendar( datePickerMode: DatePickerMode.day, - selectAction: (dateTime) { + selectAction: (DateTime dateTime) { setState(() { - state.checkListDateTimestamp.value = dateTime.millisecondsSinceEpoch; - String beginDate = formatDate(dateTime, state.isDay.value ? [mm,'-',dd] : [mm]); + state.checkListDateTimestamp.value = + dateTime.millisecondsSinceEpoch; + final String beginDate = formatDate( + dateTime, + state.isDay.value + ? [mm, '-', dd] + : [mm]); state.checkListDate.value = beginDate; logic.loadDataByType(); Get.back(); }); }); }); - }else{ + } else { // Get.toNamed(Routers.selectLockTypePage); - logic.showToast("演示模式"); + logic.showToast('演示模式'); } }, child: Row( mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text(state.checkListDate.value, style: TextStyle(color: Colors.black, fontSize: 22.sp),), - Image.asset('images/icon_grayPullDown.png', width: 50.w, height: 30.w,), - SizedBox(width: 10.w,), + children: [ + Text( + state.checkListDate.value, + style: TextStyle(color: Colors.black, fontSize: 22.sp), + ), + Image.asset( + 'images/icon_grayPullDown.png', + width: 50.w, + height: 30.w, + ), + SizedBox( + width: 10.w, + ), ], ), ) @@ -207,110 +259,151 @@ class _CheckingInListPageState extends State { Widget middleDayInfo() { return Obx(() => Visibility( - visible: state.isDay.value, - child: Container( - height: 80.h, - color: Colors.white, - margin: EdgeInsets.only(left: 15.h, right: 15.h, bottom: 10.h), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - Column( + visible: state.isDay.value, + child: Container( + height: 80.h, + color: Colors.white, + margin: EdgeInsets.only(left: 15.h, right: 15.h, bottom: 10.h), + child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - SizedBox(height: 5.h), - Text(state.lateTimes.value, style: TextStyle(color: Colors.black, fontSize: 20.sp)), - Text(TranslationLoader.lanKeys!.beLate!.tr, style: TextStyle(color: Colors.black, fontSize: 22.sp)), - SizedBox(height: 5.h), + children: [ + Column( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + SizedBox(height: 5.h), + Text(state.lateTimes.value, + style: TextStyle(color: Colors.black, fontSize: 20.sp)), + Text(TranslationLoader.lanKeys!.beLate!.tr, + style: TextStyle(color: Colors.black, fontSize: 22.sp)), + SizedBox(height: 5.h), + ], + ), + Column( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + SizedBox(height: 5.h), + Text(state.earlyTimes.value, + style: TextStyle(color: Colors.black, fontSize: 20.sp)), + Text(TranslationLoader.lanKeys!.leaveEarly!.tr, + style: TextStyle(color: Colors.black, fontSize: 22.sp)), + SizedBox(height: 5.h), + ], + ), + Column( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + SizedBox(height: 5.h), + Text(state.noPunchTimes.value, + style: TextStyle(color: Colors.black, fontSize: 20.sp)), + Text(TranslationLoader.lanKeys!.noCardPunched!.tr, + style: TextStyle(color: Colors.black, fontSize: 22.sp)), + SizedBox(height: 5.h), + ], + ), ], ), - Column( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - SizedBox(height: 5.h), - Text(state.earlyTimes.value, style: TextStyle(color: Colors.black, fontSize: 20.sp)), - Text(TranslationLoader.lanKeys!.leaveEarly!.tr, style: TextStyle(color: Colors.black, fontSize: 22.sp)), - SizedBox(height: 5.h), - ], - ), - Column( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - SizedBox(height: 5.h), - Text(state.noPunchTimes.value, style: TextStyle(color: Colors.black, fontSize: 20.sp)), - Text(TranslationLoader.lanKeys!.noCardPunched!.tr, style: TextStyle(color: Colors.black, fontSize: 22.sp)), - SizedBox(height: 5.h), - ], - ), - ], - ), - ), - )); + ), + )); } - Widget getBottomList(){ - if((state.isDay.value == true && (state.listType.value == "1")) || (state.isDay.value == true && (state.listType.value == "2"))){ + Widget getBottomList() { + if ((state.isDay.value == true && (state.listType.value == '1')) || + (state.isDay.value == true && (state.listType.value == '2'))) { return bottomDayList(); - }else{ + } else { return bottomMonthList(); } } Widget bottomDayList() { - return Obx(() => state.checkingInDayListData.value.isNotEmpty ? ListView.separated( - itemCount: state.checkingInDayListData.value.length, - itemBuilder: (c, index) { - AttendanceRecordDayList attendanceRecordList= state.checkingInDayListData.value[index]; - return _checkingInListItem(index, attendanceRecordList.headurl, attendanceRecordList.staffName, () { - Get.toNamed(Routers.checkingInDetailPage, arguments: { - // "getKeyInfosData": state.getKeyInfosData.value, - "companyId": state.companyId.value, - "staffId": attendanceRecordList.staffId, - "staffName": attendanceRecordList.staffName, + return Obx(() => state.checkingInDayListData.isNotEmpty + ? ListView.separated( + itemCount: state.checkingInDayListData.length, + itemBuilder: (BuildContext c, int index) { + final AttendanceRecordDayList attendanceRecordList = + state.checkingInDayListData[index]; + return _checkingInListItem( + index, + attendanceRecordList.headurl, + attendanceRecordList.staffName, + attendanceRecordList.attendanceType, () { + Get.toNamed(Routers.checkingInDetailPage, + arguments: { + // "getKeyInfosData": state.getKeyInfosData.value, + 'companyId': state.companyId.value, + 'staffId': attendanceRecordList.staffId, + 'staffName': attendanceRecordList.staffName, + }); }); - }); - }, - separatorBuilder: (context, index) { - return const Divider(height: 1, color: AppColors.greyLineColor); - }, - ) : NoData(noDataHeight: 1.sh - ScreenUtil().statusBarHeight*2 - 64.h - 280.h - 90.h,)); + }, + separatorBuilder: (BuildContext context, int index) { + return const Divider(height: 1, color: AppColors.greyLineColor); + }, + ) + : NoData( + noDataHeight: + 1.sh - ScreenUtil().statusBarHeight * 2 - 64.h - 280.h - 90.h, + )); } Widget bottomMonthList() { - return Obx(() => state.checkingInMonthListData.value.isNotEmpty ? ListView.separated( - itemCount: state.checkingInMonthListData.value.length, - itemBuilder: (c, index) { - AttendanceRecordMonthList attendanceRecordList= state.checkingInMonthListData.value[index]; - return _checkingInListItem(index, attendanceRecordList.headurl, attendanceRecordList.staffName, () { - Get.toNamed(Routers.checkingInDetailPage, arguments: { - "companyId": state.companyId.value, - "staffId": attendanceRecordList.staffId, - "staffName": attendanceRecordList.staffName, - }); - }); - }, - separatorBuilder: (context, index) { - return const Divider(height: 1, color: AppColors.greyLineColor); - }, - ) : NoData(noDataHeight: 1.sh - - ScreenUtil().statusBarHeight - 280.h - 90.h,)); + return Obx(() => state.checkingInMonthListData.isNotEmpty + ? ListView.separated( + itemCount: state.checkingInMonthListData.length, + itemBuilder: (BuildContext c, int index) { + final AttendanceRecordMonthList attendanceRecordList = + state.checkingInMonthListData[index]; + return _checkingInListItem( + index, + attendanceRecordList.headurl, + attendanceRecordList.staffName, + attendanceRecordList.attendanceType, () { + Get.toNamed(Routers.checkingInDetailPage, + arguments: { + 'companyId': state.companyId.value, + 'staffId': attendanceRecordList.staffId, + 'staffName': attendanceRecordList.staffName, + }); + }); + }, + separatorBuilder: (BuildContext context, int index) { + return const Divider(height: 1, color: AppColors.greyLineColor); + }, + ) + : NoData( + noDataHeight: 1.sh - -ScreenUtil().statusBarHeight - 280.h - 90.h, + )); } - Widget _checkingInListItem(int index, String? headUrl, String? name, Function() action) { + Widget _checkingInListItem( + int index, String? headUrl, String? name, int? type, Function() action) { return GestureDetector( onTap: action, child: Container( // height: 80.h, - padding: EdgeInsets.only(left: 20.w, right: 20.w, top: 10.h, bottom: 10.h), + padding: + EdgeInsets.only(left: 20.w, right: 20.w, top: 10.h, bottom: 10.h), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(10.w), ), child: Row( - children: [ - SizedBox(width: 20.w,), - Text("${index+1}", style: TextStyle(fontSize: 20.sp),), - SizedBox(width: 20.w,), - Image.asset('images/controls_user.png', width: 60.w, height: 60.w,), + children: [ + SizedBox( + width: 20.w, + ), + Text( + '${index + 1}', + style: TextStyle(fontSize: 20.sp), + ), + SizedBox( + width: 20.w, + ), + Image.asset( + getTypeIcon(type ?? 0), + width: 60.w, + height: 60.w, + ), // Container( // width: 60.h, // height: 60.h, @@ -328,10 +421,17 @@ class _CheckingInListPageState extends State { // )), SizedBox(width: 20.w), Expanded( - child: Text(name!, style: TextStyle(fontSize: 24.sp),), + child: Text( + name!, + style: TextStyle(fontSize: 24.sp), + ), ), SizedBox(width: 20.h), - Image.asset("images/icon_right_grey.png", width: 21.w, height: 21.w,), + Image.asset( + 'images/icon_right_grey.png', + width: 21.w, + height: 21.w, + ), SizedBox(width: 20.h), ], ), @@ -339,35 +439,71 @@ class _CheckingInListPageState extends State { ); } + // 1APP 2密码 3卡 4指纹 + String getTypeIcon(int type) { + String title = 'images/controls_user.png'; + switch (type) { + case 1: + // 蓝牙开锁 + title = 'images/controls_user.png'; + break; + case 2: + // 密码开锁 + title = 'images/icon_password.png'; + break; + case 3: + // ic卡 + title = 'images/icon_card.png'; + break; + case 4: + // 指纹开锁 + title = 'images/icon_fingerprint.png'; + break; + default: + break; + } + return title; + } + Widget titleWidget() { return GestureDetector( onTap: () async { - var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); - if(isDemoMode == false){ + final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); + if (isDemoMode == false) { showListType(); - }else{ + } else { // Get.toNamed(Routers.selectLockTypePage); - logic.showToast("演示模式"); + logic.showToast('演示模式'); } }, child: Obx(() => Container( - // width: 200.w, - // height: 60.h, - color: AppColors.mainColor, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text(state.listTypeStr.value, style: TextStyle(color: Colors.white, fontSize: 26.sp),), - SizedBox(width: 5.w,), - Image.asset('images/main/icon_lockDetail_checkIn_topTitle.png', width: 22.w, height: 16.w, fit: BoxFit.fill,) - ], - ), - )), + // width: 200.w, + // height: 60.h, + color: AppColors.mainColor, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + state.listTypeStr.value, + style: TextStyle(color: Colors.white, fontSize: 26.sp), + ), + SizedBox( + width: 5.w, + ), + Image.asset( + 'images/main/icon_lockDetail_checkIn_topTitle.png', + width: 22.w, + height: 16.w, + fit: BoxFit.fill, + ) + ], + ), + )), ); } void showListType() { - var list = [ + final List list = [ TranslationLoader.lanKeys!.earlyArrivalList!.tr, TranslationLoader.lanKeys!.lateList!.tr, TranslationLoader.lanKeys!.hardWorkingList!.tr @@ -385,39 +521,39 @@ class _CheckingInListPageState extends State { //adapter: PickerAdapter(), data: list, //选择事件的回调 - clickCallBack: (int index, var str) { - setState(() { - state.listTypeStr.value = str.toString(); - state.isDay.value = true; - if(index == 0){ - state.listType.value = "1"; - }else if(index == 1){ - state.listType.value = "2"; - }else if(index == 2){ - state.listType.value = "3"; - } - logic.loadDataByType(); - }); - }); + clickCallBack: (int index, Object str) { + setState(() { + state.listTypeStr.value = str.toString(); + state.isDay.value = true; + if (index == 0) { + state.listType.value = '1'; + } else if (index == 1) { + state.listType.value = '2'; + } else if (index == 2) { + state.listType.value = '3'; + } + logic.loadDataByType(); + }); + }); } - String getTopImg(){ - if(state.listType.value == "1"){ - return "images/main/icon_lockDetail_checkInRanking_zd.png"; - }else if(state.listType.value == "2"){ - return "images/main/icon_lockDetail_checkInRanking_cd.png"; - }else{ - return "images/main/icon_lockDetail_checkInRanking_qf.png"; + String getTopImg() { + if (state.listType.value == '1') { + return 'images/main/icon_lockDetail_checkInRanking_zd.png'; + } else if (state.listType.value == '2') { + return 'images/main/icon_lockDetail_checkInRanking_cd.png'; + } else { + return 'images/main/icon_lockDetail_checkInRanking_qf.png'; } } - String getTopTitle(){ - if(state.listType.value == "1"){ - return "无考勤记录"; - }else if(state.listType.value == "2"){ - return "大家干劲十足"; - }else{ - return "工作时长未出炉"; + String getTopTitle() { + if (state.listType.value == '1') { + return '无考勤记录'; + } else if (state.listType.value == '2') { + return '大家干劲十足'; + } else { + return '工作时长未出炉'; } } } diff --git a/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_page.dart b/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_page.dart index a1ae4a07..2b0e1afe 100755 --- a/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_page.dart +++ b/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_page.dart @@ -24,8 +24,10 @@ class CheckingInStaffListPage extends StatefulWidget { } class _CheckingInStaffListPageState extends State { - final CheckingInStaffManageLogic logic = Get.put(CheckingInStaffManageLogic()); - final CheckingInStaffManageState state = Get.find().state; + final CheckingInStaffManageLogic logic = + Get.put(CheckingInStaffManageLogic()); + final CheckingInStaffManageState state = + Get.find().state; @override Widget build(BuildContext context) { @@ -38,12 +40,14 @@ class _CheckingInStaffListPageState extends State { actionsList: [ GestureDetector( onTap: () async { - final dynamic data = await Get.toNamed(Routers.checkingInAddStaffPage, arguments: { - 'getKeyInfosData': state.getKeyInfosData.value, - 'companyId': state.companyId.value, - 'isAdd': '1', - }); - if(data != null) { + final dynamic data = await Get.toNamed( + Routers.checkingInAddStaffPage, + arguments: { + 'getKeyInfosData': state.getKeyInfosData.value, + 'companyId': state.companyId.value, + 'isAdd': '1', + }); + if (data != null) { logic.getStaffList(); } }, @@ -59,65 +63,76 @@ class _CheckingInStaffListPageState extends State { ), body: Container( color: Colors.white, - child: Obx(() => state.staffListData.value.isNotEmpty ? - SlidableAutoCloseBehavior( - child: ListView.separated( - itemCount: state.staffListData.value.length, - itemBuilder: (BuildContext c, int index) { - final CheckingInAddStaffListItemEntity staffListItem = state.staffListData[index]; - return Slidable( - key:ValueKey(staffListItem.staffId), - endActionPane: ActionPane( - extentRatio: 0.2, - motion: const ScrollMotion(), - children: [ - SlidableAction( - onPressed: (BuildContext context){ - // 1APP 2密码 3卡 4指纹 5人脸 - if(staffListItem.attendanceType == 1){ - ShowTipView().showDeleteAdministratorIsHaveAllDataDialog('同时删除员工钥匙'.tr, (bool isAllData) { - logic.deletStaff(staffListItem.staffId!, (isAllData ? 1 : 0)); - }); - }else{ - ShowTipView().showIosTipWithContentDialog('确定要删除员工吗?'.tr, () { - logic.deletStaff(staffListItem.staffId!, 0); - }); - // showIosTipViewDialog(staffListItem.staffId!, context); - } - }, - backgroundColor: Colors.red, - foregroundColor: Colors.white, - label: '删除'.tr, - padding: EdgeInsets.only(left: 5.w, right: 5.w), - ), - ], + child: Obx(() => state.staffListData.isNotEmpty + ? SlidableAutoCloseBehavior( + child: ListView.separated( + itemCount: state.staffListData.length, + itemBuilder: (BuildContext c, int index) { + final CheckingInAddStaffListItemEntity staffListItem = + state.staffListData[index]; + return Slidable( + key: ValueKey(staffListItem.staffId), + endActionPane: ActionPane( + extentRatio: 0.2, + motion: const ScrollMotion(), + children: [ + SlidableAction( + onPressed: (BuildContext context) { + // 1APP 2密码 3卡 4指纹 5人脸 + if (staffListItem.attendanceType == 1) { + ShowTipView() + .showDeleteAdministratorIsHaveAllDataDialog( + '同时删除员工钥匙'.tr, (bool isAllData) { + logic.deletStaff(staffListItem.staffId!, + (isAllData ? 1 : 0)); + }); + } else { + ShowTipView().showIosTipWithContentDialog( + '确定要删除员工吗?'.tr, () { + logic.deletStaff(staffListItem.staffId!, 0); + }); + // showIosTipViewDialog(staffListItem.staffId!, context); + } + }, + backgroundColor: Colors.red, + foregroundColor: Colors.white, + label: '删除'.tr, + padding: EdgeInsets.only(left: 5.w, right: 5.w), + ), + ], + ), + child: _checkingInStaffManageItem(staffListItem, () { + Get.toNamed(Routers.checkingInStaffDetailPage, + arguments: { + 'staffListItem': staffListItem, + 'getKeyInfosData': state.getKeyInfosData.value, + 'companyId': state.companyId.value, + }); + }), + ); + + // return _checkingInStaffManageItem(staffListItem, () { + // Get.toNamed(Routers.checkingInStaffDetailPage, arguments: { + // "staffListItem": staffListItem, + // "getKeyInfosData": state.getKeyInfosData.value, + // "companyId": state.companyId.value, + // }); + // }); + }, + separatorBuilder: (BuildContext context, int index) { + return Divider( + height: 1.h, + indent: 20.w, + color: AppColors.greyLineColor); + }, ), - child: _checkingInStaffManageItem(staffListItem, () { - Get.toNamed(Routers.checkingInStaffDetailPage, arguments: { - 'staffListItem': staffListItem, - 'getKeyInfosData': state.getKeyInfosData.value, - 'companyId': state.companyId.value, - }); - }), - ); - - // return _checkingInStaffManageItem(staffListItem, () { - // Get.toNamed(Routers.checkingInStaffDetailPage, arguments: { - // "staffListItem": staffListItem, - // "getKeyInfosData": state.getKeyInfosData.value, - // "companyId": state.companyId.value, - // }); - // }); - }, - separatorBuilder: (BuildContext context, int index) { - return Divider(height: 1.h, indent: 20.w, color: AppColors.greyLineColor); - }, - ), - ) : NoData()), + ) + : NoData()), )); } - Widget _checkingInStaffManageItem(CheckingInAddStaffListItemEntity staffListItem, Function() action) { + Widget _checkingInStaffManageItem( + CheckingInAddStaffListItemEntity staffListItem, Function() action) { return GestureDetector( onTap: action, child: Container( @@ -127,10 +142,15 @@ class _CheckingInStaffListPageState extends State { margin: EdgeInsets.only(right: 10.w, top: 10.h, bottom: 10.h), child: Row( children: [ - SizedBox(width: 20.w,), + SizedBox( + width: 20.w, + ), // CustomNetworkImage(url: staffListItem.headurl!, width: 40.w , height: 40.w), - Image.asset(getTypeIcon(staffListItem.attendanceType!), width: 60.w, height: 60.w), - SizedBox(width: 20.w,), + Image.asset(getTypeIcon(staffListItem.attendanceType!), + width: 60.w, height: 60.w), + SizedBox( + width: 20.w, + ), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -139,22 +159,23 @@ class _CheckingInStaffListPageState extends State { child: Text(staffListItem.staffName!, // maxLines: 1, // overflow: TextOverflow.ellipsis, - style: TextStyle(fontSize: 24.sp) - ) - ), + style: TextStyle(fontSize: 24.sp))), Visibility( - visible: staffListItem.cardStatus == 1 ? true : false, - child: SizedBox(height: 5.h,) - ), + visible: staffListItem.cardStatus == 1, + child: SizedBox( + height: 5.h, + )), Visibility( - visible: staffListItem.cardStatus == 1 ? true : false, + visible: staffListItem.cardStatus == 1, child: Container( padding: EdgeInsets.only(right: 5.w, left: 5.w), decoration: BoxDecoration( borderRadius: BorderRadius.circular(5.w), color: AppColors.openPassageModeColor, ), - child: Text('打卡方式无效'.tr, style: TextStyle(fontSize: 18.sp, color: AppColors.appBarIconColor)), + child: Text('打卡方式无效'.tr, + style: TextStyle( + fontSize: 18.sp, color: AppColors.appBarIconColor)), ), ), ], @@ -170,19 +191,19 @@ class _CheckingInStaffListPageState extends State { String title = 'images/controls_user.png'; switch (type) { case 1: - // 蓝牙开锁 + // 蓝牙开锁 title = 'images/controls_user.png'; break; case 2: - // 密码开锁 + // 密码开锁 title = 'images/icon_password.png'; break; case 3: - // ic卡 + // ic卡 title = 'images/icon_card.png'; break; case 4: - // 指纹开锁 + // 指纹开锁 title = 'images/icon_fingerprint.png'; break; default: @@ -191,23 +212,22 @@ class _CheckingInStaffListPageState extends State { return title; } - // void showIosTipViewDialog(int staffId, BuildContext context) { - // showDialog( - // context: context, - // builder: (BuildContext context) { - // return ShowIosTipView( - // title: "提示", - // tipTitle: "确定要删除员工吗?", - // sureClick: () async { - // Get.back(); - // logic.deletStaff(staffId, 0); - // }, - // cancelClick: () { - // Get.back(); - // }, - // ); - // }, - // ); - // } - +// void showIosTipViewDialog(int staffId, BuildContext context) { +// showDialog( +// context: context, +// builder: (BuildContext context) { +// return ShowIosTipView( +// title: "提示", +// tipTitle: "确定要删除员工吗?", +// sureClick: () async { +// Get.back(); +// logic.deletStaff(staffId, 0); +// }, +// cancelClick: () { +// Get.back(); +// }, +// ); +// }, +// ); +// } } From 11c90ca414011335b492bc7bd522adb4bb75a96a Mon Sep 17 00:00:00 2001 From: anfe <448468458@qq.com> Date: Mon, 20 May 2024 15:09:09 +0800 Subject: [PATCH 16/44] =?UTF-8?q?faet:=E4=BB=A3=E7=A0=81=E8=A1=A5=E5=85=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../checkingInList/checkingInList_page.dart | 78 +++++++++---------- 1 file changed, 37 insertions(+), 41 deletions(-) diff --git a/lib/main/lockDetail/checkingIn/checkingInList/checkingInList_page.dart b/lib/main/lockDetail/checkingIn/checkingInList/checkingInList_page.dart index 608da425..17e73087 100755 --- a/lib/main/lockDetail/checkingIn/checkingInList/checkingInList_page.dart +++ b/lib/main/lockDetail/checkingIn/checkingInList/checkingInList_page.dart @@ -38,27 +38,28 @@ class _CheckingInListPageState extends State { haveBack: true, backgroundColor: AppColors.mainColor, actionsList: [ - (state.getKeyInfosData.value.keyRight == 1) - ? GestureDetector( - onTap: () async { - final bool? isDemoMode = - await Storage.getBool(ifIsDemoModeOrNot); - if (isDemoMode == false) { - Get.toNamed(Routers.checkingInSetPage, - arguments: { - 'getKeyInfosData': state.getKeyInfosData.value, - }); - } else { - // Get.toNamed(Routers.selectLockTypePage); - logic.showToast('演示模式'); - } - }, - child: Image.asset( - 'images/main/icon_lockDetail_checkIn_set.png', - width: 36.w, - height: 36.w, - )) - : Container(), + if (state.getKeyInfosData.value.keyRight == 1) + GestureDetector( + onTap: () async { + final bool? isDemoMode = + await Storage.getBool(ifIsDemoModeOrNot); + if (isDemoMode == false) { + Get.toNamed(Routers.checkingInSetPage, + arguments: { + 'getKeyInfosData': state.getKeyInfosData.value, + }); + } else { + // Get.toNamed(Routers.selectLockTypePage); + logic.showToast('演示模式'); + } + }, + child: Image.asset( + 'images/main/icon_lockDetail_checkIn_set.png', + width: 36.w, + height: 36.w, + )) + else + Container(), SizedBox(width: 30.w), ], ), @@ -399,26 +400,21 @@ class _CheckingInListPageState extends State { SizedBox( width: 20.w, ), - Image.asset( - getTypeIcon(type ?? 0), - width: 60.w, - height: 60.w, - ), - // Container( - // width: 60.h, - // height: 60.h, - // decoration: BoxDecoration( - // color: AppColors.mainColor, - // border: Border.all(width: 1, color: AppColors.mainColor), - // borderRadius: BorderRadius.circular(30.h), - // ), - // padding: EdgeInsets.all(10.w), - // child: Image.asset( - // 'images/controls_user.png', - // width: 30.w, - // height: 30.w, - // color: Colors.white, - // )), + if (headUrl == null || headUrl == '') + Image.asset( + getTypeIcon(type ?? 0), + width: 60.w, + height: 60.w, + ) + else + ClipRRect( + borderRadius: BorderRadius.circular(100.w), + child: Image.network( + headUrl, + width: 60.w, + height: 60.w, + ), + ), SizedBox(width: 20.w), Expanded( child: Text( From 3da93adfb5e124fb43b5f4e7fe8f1baac0460207 Mon Sep 17 00:00:00 2001 From: anfe <448468458@qq.com> Date: Mon, 20 May 2024 16:28:11 +0800 Subject: [PATCH 17/44] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=20event?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lockDetail/lockDetail_logic.dart | 144 ++++--- .../lockDetail/lockDetail_page.dart | 398 +++++++++--------- .../lockMian/lockMain/lockMain_logic.dart | 3 +- lib/main/lockMian/lockMain/lockMain_page.dart | 9 +- lib/network/api_provider.dart | 6 +- lib/network/api_provider_base.dart | 1 - lib/network/api_repository.dart | 4 +- lib/tools/eventBusEventManage.dart | 4 +- 8 files changed, 292 insertions(+), 277 deletions(-) diff --git a/lib/main/lockDetail/lockDetail/lockDetail_logic.dart b/lib/main/lockDetail/lockDetail/lockDetail_logic.dart index 0ecca01f..33a21cd5 100755 --- a/lib/main/lockDetail/lockDetail/lockDetail_logic.dart +++ b/lib/main/lockDetail/lockDetail/lockDetail_logic.dart @@ -1,4 +1,3 @@ - import 'dart:async'; import 'package:flutter/scheduler.dart'; @@ -7,6 +6,8 @@ import 'package:get/get.dart'; import 'package:intl/intl.dart'; import 'package:permission_handler/permission_handler.dart'; import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart'; +import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart'; +import 'package:star_lock/main/lockDetail/lockSet/lockTime/getServerDatetime_entity.dart'; import 'package:star_lock/widget/permission/permission_dialog.dart'; @@ -35,7 +36,7 @@ class LockDetailLogic extends BaseGetXController { // 监听设备返回的数据 void initReplySubscription() { state.replySubscription = - EventBusManager().eventBus!.on().listen((reply) async { + EventBusManager().eventBus!.on().listen((Reply reply) async { // 开门 if (reply is OpenDoorReply && state.ifCurrentScreen.value == true) { _replyOpenLock(reply); @@ -51,7 +52,7 @@ class LockDetailLogic extends BaseGetXController { // 开门数据解析 Future _replyOpenLock(Reply reply) async { - int status = reply.data[6]; + final int status = reply.data[6]; switch (status) { case 0x00: @@ -62,19 +63,20 @@ class LockDetailLogic extends BaseGetXController { state.iSClosedUnlockSuccessfulPopup.value = true; state.closedUnlockSuccessfulTimer?.cancel(); // 如果没有点击关闭弹窗,3秒后自动关闭 - state.closedUnlockSuccessfulTimer = Timer.periodic(3.seconds, (timer) { + state.closedUnlockSuccessfulTimer = + Timer.periodic(3.seconds, (Timer timer) { state.iSClosedUnlockSuccessfulPopup.value = false; timer.cancel(); eventBus.fire(RefreshLockDetailInfoDataEvent()); }); // 电量 - int power = reply.data[7]; + final int power = reply.data[7]; state.electricQuantity.value = power; // 备用电量 if (state.keyInfos.value.lockFeature!.isSupportBackupBattery == 1) { - int powerStandby = reply.data[9]; + final int powerStandby = reply.data[9]; state.electricQuantityStandby.value = powerStandby; } // 更新电量 @@ -85,14 +87,17 @@ class LockDetailLogic extends BaseGetXController { break; case 0x06: //无权限 - var privateKey = await Storage.getStringList(saveBluePrivateKey); - List getPrivateKeyList = changeStringListToIntList(privateKey!); + final List? privateKey = + await Storage.getStringList(saveBluePrivateKey); + final List getPrivateKeyList = + changeStringListToIntList(privateKey!); - var signKey = await Storage.getStringList(saveBlueSignKey); - List signKeyDataList = changeStringListToIntList(signKey!); + final List? signKey = + await Storage.getStringList(saveBlueSignKey); + final List signKeyDataList = changeStringListToIntList(signKey!); - var tokenData = reply.data.sublist(2, 6); - var saveStrList = changeIntListToStringList(tokenData); + final List tokenData = reply.data.sublist(2, 6); + final List saveStrList = changeIntListToStringList(tokenData); Storage.setStringList(saveBlueToken, saveStrList); IoSenderManage.senderOpenLock( @@ -110,7 +115,7 @@ class LockDetailLogic extends BaseGetXController { case 0x16: // 正在开锁中... resetOpenDoorState(); - showToast("正在开锁中...".tr, something: () { + showToast('正在开锁中...'.tr, something: () { cancelBlueConnetctToastTimer(); }); break; @@ -132,7 +137,7 @@ class LockDetailLogic extends BaseGetXController { break; case 0x0a: // 钥匙不存在 - showToast("钥匙不存在"); + showToast('钥匙不存在'); resetOpenDoorState(); cancelBlueConnetctToastTimer(); @@ -140,7 +145,7 @@ class LockDetailLogic extends BaseGetXController { break; case 0x0c: // 钥匙数量已到上限 - showToast("钥匙数量已到上限"); + showToast('钥匙数量已到上限'); resetOpenDoorState(); cancelBlueConnetctToastTimer(); @@ -148,7 +153,7 @@ class LockDetailLogic extends BaseGetXController { break; case 0x0e: // 钥匙已存在 - showToast("钥匙已存在"); + showToast('钥匙已存在'); resetOpenDoorState(); cancelBlueConnetctToastTimer(); @@ -156,7 +161,7 @@ class LockDetailLogic extends BaseGetXController { break; case 0x0f: // 用户已存在 - showToast("用户已存在"); + showToast('用户已存在'); resetOpenDoorState(); cancelBlueConnetctToastTimer(); @@ -164,7 +169,7 @@ class LockDetailLogic extends BaseGetXController { break; default: //失败 - AppLog.log("开锁失败"); + AppLog.log('开锁失败'); // state.animationController!.stop(); resetOpenDoorState(); cancelBlueConnetctToastTimer(); @@ -183,11 +188,11 @@ class LockDetailLogic extends BaseGetXController { // 根据时间查解析数据 Future _replyReferEventRecordTime(Reply reply) async { - int status = reply.data[2]; + final int status = reply.data[2]; switch (status) { case 0x00: //成功 - int dataLength = (reply.data[5] << 8) + reply.data[6]; + final int dataLength = (reply.data[5] << 8) + reply.data[6]; // AppLog.log("dataLength:$dataLength"); if (dataLength > 0) { reply.data.removeRange(0, 7); @@ -195,32 +200,32 @@ class LockDetailLogic extends BaseGetXController { if (reply.data.length < 17) { return; } - var getList = splitList(reply.data, 17); + final List> getList = splitList(reply.data, 17); // AppLog.log("getList:$getList"); - var uploadList = []; + final List uploadList = []; for (int i = 0; i < getList.length; i++) { - var indexList = getList[i]; + final List indexList = getList[i]; // AppLog.log("indexList:$indexList"); - var indexMap = {}; - indexMap["type"] = indexList[0].toString(); + final Map indexMap = {}; + indexMap['type'] = indexList[0].toString(); int operateDate = 0; if (indexList[0] == 2) { - var passwordData = reply.data.sublist(7, 17); - var password = utf8String(passwordData); - indexMap["user"] = password.toString(); + final List passwordData = reply.data.sublist(7, 17); + final String password = utf8String(passwordData); + indexMap['user'] = password.toString(); } else { - int userNo = (indexList[1] * 256) + indexList[2]; - indexMap["user"] = userNo.toString(); + final int userNo = (indexList[1] * 256) + indexList[2]; + indexMap['user'] = userNo.toString(); } - indexMap["success"] = "1"; + indexMap['success'] = '1'; - int time = ((0xff & indexList[(3)]) << 24 | + final int time = ((0xff & indexList[(3)]) << 24 | (0xff & indexList[4]) << 16 | (0xff & indexList[5]) << 8 | (0xFF & indexList[6])); operateDate = time * 1000; - indexMap["date"] = "$operateDate"; + indexMap['date'] = '$operateDate'; uploadList.add(indexMap); if (i == getList.length - 1) { @@ -256,14 +261,15 @@ class LockDetailLogic extends BaseGetXController { // BlueManage().stopScan(); BlueManage().disconnect(); }); - var privateKey = await Storage.getStringList(saveBluePrivateKey); - List getPrivateKeyList = changeStringListToIntList(privateKey!); + final List? privateKey = + await Storage.getStringList(saveBluePrivateKey); + final List getPrivateKeyList = changeStringListToIntList(privateKey!); - var signKey = await Storage.getStringList(saveBlueSignKey); - List signKeyDataList = changeStringListToIntList(signKey!); + final List? signKey = await Storage.getStringList(saveBlueSignKey); + final List signKeyDataList = changeStringListToIntList(signKey!); - var token = await Storage.getStringList(saveBlueToken); - List getTokenList = changeStringListToIntList(token!); + final List? token = await Storage.getStringList(saveBlueToken); + final List getTokenList = changeStringListToIntList(token!); BlueManage() .bludSendData(state.keyInfos.value.bluetooth!.bluetoothDeviceName!, @@ -303,14 +309,18 @@ class LockDetailLogic extends BaseGetXController { BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async { if (connectionState == BluetoothConnectionState.connected) { - var privateKey = await Storage.getStringList(saveBluePrivateKey); - List getPrivateKeyList = changeStringListToIntList(privateKey!); + final List? privateKey = + await Storage.getStringList(saveBluePrivateKey); + final List getPrivateKeyList = + changeStringListToIntList(privateKey!); - var token = await Storage.getStringList(saveBlueToken); - List getTokenList = changeStringListToIntList(token!); + final List? token = await Storage.getStringList(saveBlueToken); + final List getTokenList = changeStringListToIntList(token!); - var publicKey = await Storage.getStringList(saveBluePublicKey); - List getPublicKeyList = changeStringListToIntList(publicKey!); + final List? publicKey = + await Storage.getStringList(saveBluePublicKey); + final List getPublicKeyList = + changeStringListToIntList(publicKey!); IoSenderManage.senderReferEventRecordTimeCommand( keyID: BlueManage().connectDeviceName, @@ -329,7 +339,8 @@ class LockDetailLogic extends BaseGetXController { // 从服务器获取锁的时间 开锁时传入 void getServerDatetime() async { - var entity = await ApiRepository.to.getServerDatetimeData(); + final GetServerDatetimeEntity entity = + await ApiRepository.to.getServerDatetimeData(); if (entity.errorCode!.codeIsSuccessful) { state.differentialTime = entity.data!.date! ~/ 1000 - DateTime.now().millisecondsSinceEpoch ~/ 1000; @@ -344,17 +355,17 @@ class LockDetailLogic extends BaseGetXController { // 获取手机联网token,根据锁设置里面获取的开锁时是否联网来判断是否调用这个接口 void getLockNetToken() async { - LockNetTokenEntity entity = await ApiRepository.to + final LockNetTokenEntity entity = await ApiRepository.to .getLockNetToken(lockId: state.keyInfos.value.lockId.toString()); if (entity.errorCode!.codeIsSuccessful) { state.lockNetToken = entity.data!.token!.toString(); - AppLog.log("从服务器获取联网token:${state.lockNetToken}"); + AppLog.log('从服务器获取联网token:${state.lockNetToken}'); openDoorAction(); } else { - showToast("网络访问失败,请检查网络是否正常".tr, something: () { + showToast('网络访问失败,请检查网络是否正常'.tr, something: () { resetOpenDoorState(); cancelBlueConnetctToastTimer(); - state.lockNetToken = "0"; + state.lockNetToken = '0'; openDoorAction(); }); } @@ -362,7 +373,7 @@ class LockDetailLogic extends BaseGetXController { //电量更新请求 Future uploadElectricQuantityRequest() async { - KeyOperationRecordEntity entity = await ApiRepository.to + final KeyOperationRecordEntity entity = await ApiRepository.to .uploadElectricQuantity( electricQuantity: state.electricQuantity.value.toString(), electricQuantityStandby: @@ -371,15 +382,15 @@ class LockDetailLogic extends BaseGetXController { isUnShowLoading: true); if (entity.errorCode!.codeIsSuccessful) { SchedulerBinding.instance.addPostFrameCallback((_) { - eventBus.fire(RefreshLockListInfoDataEvent()); + eventBus.fire(RefreshLockListInfoDataEvent(isUnShowLoading: true)); }); } } // 查询锁记录最后时间 void getLockRecordLastUploadDataTime() async { - LockOperatingRecordGetLastRecordTimeEntity entity = await ApiRepository.to - .getLockRecordLastUploadDataTime( + final LockOperatingRecordGetLastRecordTimeEntity entity = + await ApiRepository.to.getLockRecordLastUploadDataTime( lockId: state.keyInfos.value.lockId.toString()); if (entity.errorCode!.codeIsSuccessful) { state.operateDate = entity.data!.operateDate! ~/ 1000; @@ -388,14 +399,14 @@ class LockDetailLogic extends BaseGetXController { } // 操作记录上传 - void lockRecordUploadData(List list) async { - KeyOperationRecordEntity entity = await ApiRepository.to + Future lockRecordUploadData(List list) async { + final KeyOperationRecordEntity entity = await ApiRepository.to .lockRecordUploadData( lockId: state.keyInfos.value.lockId.toString(), records: list); if (entity.errorCode!.codeIsSuccessful) { // mockNetworkDataRequest(); AppLog.log( - "state.keyInfos.value.keyType:${state.keyInfos.value.keyType}"); + 'state.keyInfos.value.keyType:${state.keyInfos.value.keyType}'); if (state.keyInfos.value.keyType == XSConstantMacro.keyTypeOnce) { // 单次删除 deletKeyData(); @@ -405,10 +416,11 @@ class LockDetailLogic extends BaseGetXController { // 普通用户或者授权管理员删除钥匙 void deletKeyData() async { - var entity = await ApiRepository.to.deleteElectronicKey( - keyId: state.keyInfos.value.keyId.toString(), includeUnderlings: 0); + final ElectronicKeyListEntity entity = await ApiRepository.to + .deleteElectronicKey( + keyId: state.keyInfos.value.keyId.toString(), includeUnderlings: 0); if (entity.errorCode!.codeIsSuccessful) { - BlueManage().connectDeviceMacAddress = ""; + BlueManage().connectDeviceMacAddress = ''; SchedulerBinding.instance.addPostFrameCallback((_) { eventBus.fire(RefreshLockListInfoDataEvent()); }); @@ -422,7 +434,7 @@ class LockDetailLogic extends BaseGetXController { state.lockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceEvent = eventBus .on() - .listen((event) { + .listen((LockSetChangeSetRefreshLockDetailWithType event) { if (event.type == 0) { // 0考勤 state.isAttendance.value = int.parse(event.setResult); @@ -433,7 +445,7 @@ class LockDetailLogic extends BaseGetXController { state.isOpenLockNeedOnline.value = int.parse(event.setResult); state.keyInfos.value.lockSetting!.appUnlockOnline = int.parse(event.setResult); - state.lockNetToken = ""; // 改变开锁时是否联网状态的时候清空token + state.lockNetToken = ''; // 改变开锁时是否联网状态的时候清空token } else if (event.type == 2) { // 2 常开模式 state.isOpenPassageMode.value = int.parse(event.setResult); @@ -458,7 +470,7 @@ class LockDetailLogic extends BaseGetXController { } String getKeyStatusTextAndShow() { - String text = ""; + String text = ''; if (state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusWaitIneffective || state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusFrozen || @@ -469,7 +481,7 @@ class LockDetailLogic extends BaseGetXController { "${"你的钥匙".tr}${XSConstantMacro.getKeyStatusStr(state.keyInfos.value.keyStatus!)}"; } else { text = state.isOpenPassageMode.value == 1 - ? "常开模式启动!长按闭锁".tr + ? '常开模式启动!长按闭锁'.tr : TranslationLoader.lanKeys!.clickUnlockAndHoldDownClose!.tr; } return text; @@ -477,9 +489,9 @@ class LockDetailLogic extends BaseGetXController { String getCurrentFormattedTime() { // 获取当前时间 - DateTime now = DateTime.now(); + final DateTime now = DateTime.now(); // 格式化日期和时间 - String formattedTime = DateFormat('MM/dd HH:mm').format(now); + final String formattedTime = DateFormat('MM/dd HH:mm').format(now); return formattedTime; } diff --git a/lib/main/lockDetail/lockDetail/lockDetail_page.dart b/lib/main/lockDetail/lockDetail/lockDetail_page.dart index 451f629f..f179465c 100755 --- a/lib/main/lockDetail/lockDetail/lockDetail_page.dart +++ b/lib/main/lockDetail/lockDetail/lockDetail_page.dart @@ -8,6 +8,7 @@ import 'package:intl/intl.dart'; import 'package:star_lock/app_settings/app_colors.dart'; import 'package:star_lock/flavors.dart'; import 'package:star_lock/main/lockDetail/lockDetail/lockDetail_list_page.dart'; +import 'package:star_lock/main/lockDetail/lockDetail/lockDetail_state.dart'; import 'package:star_lock/tools/aliyunRealNameAuth/aliyunRealNameAuthHandle.dart'; import 'package:star_lock/tools/showCupertinoAlertView.dart'; import 'package:star_lock/tools/showTipView.dart'; @@ -44,8 +45,8 @@ class LockDetailPage extends StatefulWidget { class _LockDetailPageState extends State with TickerProviderStateMixin, RouteAware { // with RouteAware - final logic = Get.put(LockDetailLogic()); - final state = Get.find().state; + final LockDetailLogic logic = Get.put(LockDetailLogic()); + final LockDetailState state = Get.find().state; @override void initState() { @@ -75,8 +76,9 @@ class _LockDetailPageState extends State void _initRefreshLockDetailInfoDataEventAction() { // 蓝牙协议通知传输跟蓝牙之外的数据传输类不一样 eventBus - _lockRefreshLockDetailInfoDataEvent = - eventBus.on().listen((event) { + _lockRefreshLockDetailInfoDataEvent = eventBus + .on() + .listen((RefreshLockDetailInfoDataEvent event) { setState(() {}); }); } @@ -114,26 +116,28 @@ class _LockDetailPageState extends State BlueManage().connectDeviceName = state.keyInfos.value.bluetooth!.bluetoothDeviceName!; - List publicKeyData = + final List publicKeyData = state.keyInfos.value.bluetooth!.publicKey!.cast(); - var saveStrList = changeIntListToStringList(publicKeyData); + final List saveStrList = changeIntListToStringList(publicKeyData); Storage.setStringList(saveBluePublicKey, saveStrList); // 私钥 - List privateKeyData = + final List privateKeyData = state.keyInfos.value.bluetooth!.privateKey!.cast(); - var savePrivateKeyList = changeIntListToStringList(privateKeyData); + final List savePrivateKeyList = + changeIntListToStringList(privateKeyData); Storage.setStringList(saveBluePrivateKey, savePrivateKeyList); // signKey - List signKeyData = + final List signKeyData = state.keyInfos.value.bluetooth!.signKey!.cast(); - var saveSignKeyList = changeIntListToStringList(signKeyData); + final List saveSignKeyList = changeIntListToStringList(signKeyData); Storage.setStringList(saveBlueSignKey, saveSignKeyList); - bool ifHaveKey = await Storage.ifHaveKey(saveBlueToken); + final bool ifHaveKey = await Storage.ifHaveKey(saveBlueToken); if (!ifHaveKey) { - var saveTokenList = changeIntListToStringList([0, 0, 0, 0]); + final List saveTokenList = + changeIntListToStringList([0, 0, 0, 0]); Storage.setStringList(saveBlueToken, saveTokenList); } } @@ -141,7 +145,7 @@ class _LockDetailPageState extends State @override Widget build(BuildContext context) { loadData(); - return F.sw(defaultCall: () => skWidget(), xhjCall: () => xhjWidget()); + return F.sw(defaultCall: skWidget, xhjCall: xhjWidget); } //鑫泓佳布局 @@ -150,9 +154,9 @@ class _LockDetailPageState extends State backgroundColor: Colors.white, body: Obx(() { return Stack( - children: [ + children: [ Column( - children: [ + children: [ SizedBox( height: 35.h, ), @@ -193,7 +197,7 @@ class _LockDetailPageState extends State decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(16.r), - boxShadow: [ + boxShadow: [ BoxShadow( color: Colors.black.withOpacity(0.15), offset: const Offset(0, 0), @@ -202,7 +206,7 @@ class _LockDetailPageState extends State ), ]), child: Row( - children: [ + children: [ Image.asset( img, width: 32.r, @@ -236,7 +240,7 @@ class _LockDetailPageState extends State fit: BoxFit.cover, ), borderRadius: BorderRadius.circular(20.r), - boxShadow: [ + boxShadow: [ BoxShadow( color: Colors.black.withOpacity(0.15), offset: const Offset(0, 0), @@ -247,19 +251,15 @@ class _LockDetailPageState extends State ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ const Spacer(), GestureDetector( onTap: state.openDoorBtnisUneable.value == true - ? () { - isNeedRealNameAuthThenOpenLock(); - } + ? isNeedRealNameAuthThenOpenLock : null, onLongPressStart: state.openDoorBtnisUneable.value == true - ? (details) { - setState(() { - startUnLock(); - }); + ? (LongPressStartDetails details) { + setState(startUnLock); } : null, child: Container( @@ -268,7 +268,7 @@ class _LockDetailPageState extends State decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(100.w), - boxShadow: [ + boxShadow: [ BoxShadow( color: Colors.black.withOpacity(0.3), offset: const Offset(0, 0), @@ -279,42 +279,44 @@ class _LockDetailPageState extends State margin: EdgeInsets.only(left: 35.w, bottom: 15.h), child: Stack( alignment: AlignmentDirectional.center, - children: [ - state.openDoorBtnisUneable.value == false - ? Icon( - Icons.bluetooth_searching, - size: 48.r, - color: AppColors.mainColor, - ) - : Image.asset( - state.isOpenPassageMode.value == 1 - ? 'images/icon_lock_err.png' - : 'images/icon_lock_fill.png', - width: 38.r, - height: 38.r, - color: AppColors.mainColor, - ), - state.openDoorBtnisUneable.value == false - ? Positioned( - child: Icon( - Icons.bluetooth_searching, - size: 96.r, - ), - ) - : state.openLockBtnState.value == 1 - ? xhjBuildRotationTransition( - width: 88.r, - height: 88.r, - ) - : Positioned( - child: Image.asset( - 'images/icon_circle_dotted.png', - width: 88.r, - height: 88.r, - color: state.isOpenPassageMode.value == 1 - ? Colors.red - : AppColors.mainColor, - )), + children: [ + if (state.openDoorBtnisUneable.value == false) + Icon( + Icons.bluetooth_searching, + size: 48.r, + color: AppColors.mainColor, + ) + else + Image.asset( + state.isOpenPassageMode.value == 1 + ? 'images/icon_lock_err.png' + : 'images/icon_lock_fill.png', + width: 38.r, + height: 38.r, + color: AppColors.mainColor, + ), + if (state.openDoorBtnisUneable.value == false) + Positioned( + child: Icon( + Icons.bluetooth_searching, + size: 96.r, + ), + ) + else + state.openLockBtnState.value == 1 + ? xhjBuildRotationTransition( + width: 88.r, + height: 88.r, + ) + : Positioned( + child: Image.asset( + 'images/icon_circle_dotted.png', + width: 88.r, + height: 88.r, + color: state.isOpenPassageMode.value == 1 + ? Colors.red + : AppColors.mainColor, + )), ], ), ), @@ -323,10 +325,10 @@ class _LockDetailPageState extends State padding: EdgeInsets.only(left: 15.w, right: 00.w, bottom: 15.h), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ + children: [ Column( crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ Text( TranslationLoader .lanKeys!.clickUnlockAndHoldDownClose!.tr, @@ -341,16 +343,16 @@ class _LockDetailPageState extends State Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ Row( mainAxisAlignment: MainAxisAlignment.end, - children: [ + children: [ Image.asset( showElectricIcon(state.electricQuantity.value), width: 30.w, height: 24.w), SizedBox(width: 2.w), - Text("${state.electricQuantity.value}%", + Text('${state.electricQuantity.value}%', style: TextStyle( fontSize: 18.sp, color: AppColors.darkGrayTextColor)), @@ -368,13 +370,13 @@ class _LockDetailPageState extends State ), Row( mainAxisAlignment: MainAxisAlignment.end, - children: [ + children: [ Image.asset( showElectricIcon(state.electricQuantity.value), width: 30.w, height: 24.w), SizedBox(width: 2.w), - Text("--%", + Text('--%', style: TextStyle( fontSize: 18.sp, color: AppColors.darkGrayTextColor)), @@ -400,32 +402,30 @@ class _LockDetailPageState extends State //斯凯布局 Widget skWidget() { return ListView( - children: [ + children: [ Visibility( visible: - ((state.keyInfos.value.keyType == XSConstantMacro.keyTypeTime || - state.keyInfos.value.keyType == - XSConstantMacro.keyTypeLoop) && // 限时、循环 - (DateTool().compareTimeGetDaysFromNow( - state.keyInfos.value.endDate!) <= - 15 && - DateTool().compareTimeGetDaysFromNow( - state.keyInfos.value.endDate!) >= - 0) && // 0到30天 - (state.keyInfos.value.keyStatus == - XSConstantMacro.keyStatusNormalUse || - state.keyInfos.value.keyStatus == - XSConstantMacro.keyStatusWaitReceive) // 正常使用、待接收 - ) - ? true - : false, + (state.keyInfos.value.keyType == XSConstantMacro.keyTypeTime || + state.keyInfos.value.keyType == + XSConstantMacro.keyTypeLoop) && // 限时、循环 + (DateTool().compareTimeGetDaysFromNow( + state.keyInfos.value.endDate!) <= + 15 && + DateTool().compareTimeGetDaysFromNow( + state.keyInfos.value.endDate!) >= + 0) && // 0到30天 + (state.keyInfos.value.keyStatus == + XSConstantMacro.keyStatusNormalUse || + state.keyInfos.value.keyStatus == + XSConstantMacro.keyStatusWaitReceive) // 正常使用、待接收 + , child: Container( // height: 30.h, color: const Color(0xFFFBEFD4), padding: EdgeInsets.only(top: 8.h, bottom: 8.h), child: Row( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ Text( "${"钥匙将在".tr}${DateTool().compareTimeGetDaysFromNow(state.keyInfos.value.endDate!)}${"天后失效".tr}", style: TextStyle( @@ -434,26 +434,26 @@ class _LockDetailPageState extends State ), ), ), - Stack(children: [ + Stack(children: [ Container( width: 1.sw, height: 1.sh - ScreenUtil().statusBarHeight, color: Colors.white, child: Column( - children: [ + children: [ topWidget(), SizedBox( height: 10.h, ), - Obx(() => buildPageIndicator()), + Obx(buildPageIndicator), Expanded( child: Container( margin: EdgeInsets.only(left: 10.w, right: 10.w, top: 30.h), child: PageView( scrollDirection: Axis.horizontal, controller: state.pageController, - children: [ - Obx(() => bottomWidget()), + children: [ + Obx(bottomWidget), attachmentWidget(), ], ), @@ -476,7 +476,7 @@ class _LockDetailPageState extends State Widget topWidget() { return Column( - children: [ + children: [ F.sw( defaultCall: () => SizedBox(height: 50.h), xhjCall: () => Padding( @@ -490,7 +490,7 @@ class _LockDetailPageState extends State ), ), Stack( - children: [ + children: [ Center( child: Text( state.lockAlias.value, @@ -504,7 +504,7 @@ class _LockDetailPageState extends State Positioned( child: Column( mainAxisSize: MainAxisSize.min, - children: [ + children: [ GestureDetector( onTap: () { ShowTipView().showSureAlertDialog( @@ -512,7 +512,7 @@ class _LockDetailPageState extends State }, child: Row( mainAxisAlignment: MainAxisAlignment.end, - children: [ + children: [ FlavorsImg( child: Image.asset( showElectricIcon(state.electricQuantity.value), @@ -520,7 +520,7 @@ class _LockDetailPageState extends State height: 24.w), ), SizedBox(width: 2.w), - Text("${state.electricQuantity.value}%", + Text('${state.electricQuantity.value}%', style: TextStyle( fontSize: 18.sp, color: AppColors.darkGrayTextColor)), @@ -542,7 +542,7 @@ class _LockDetailPageState extends State 1, child: Row( mainAxisAlignment: MainAxisAlignment.end, - children: [ + children: [ FlavorsImg( child: Image.asset( showElectricIcon( @@ -551,7 +551,7 @@ class _LockDetailPageState extends State height: 24.w), ), SizedBox(width: 2.w), - Text("${state.electricQuantityStandby.value}%", + Text('${state.electricQuantityStandby.value}%', style: TextStyle( fontSize: 18.sp, color: AppColors.darkGrayTextColor)), @@ -580,23 +580,19 @@ class _LockDetailPageState extends State color: Colors.white, height: 330.w, child: Stack( - children: [ + children: [ Center( child: GestureDetector( onTap: state.openDoorBtnisUneable.value == true - ? () { - isNeedRealNameAuthThenOpenLock(); - } + ? isNeedRealNameAuthThenOpenLock : null, onLongPressStart: state.openDoorBtnisUneable.value == true - ? (details) { - setState(() { - startUnLock(); - }); + ? (LongPressStartDetails details) { + setState(startUnLock); } : null, child: Stack( - children: [ + children: [ FlavorsImg( child: Image.asset( state.openDoorBtnisUneable.value == false @@ -609,31 +605,32 @@ class _LockDetailPageState extends State // color: AppColors.primaryTopColor, ), ), - state.openDoorBtnisUneable.value == false - ? Positioned( - child: FlavorsImg( + if (state.openDoorBtnisUneable.value == false) + Positioned( + child: FlavorsImg( + child: Image.asset( + 'images/main/icon_main_openLockBtn_grey.png', + width: 330.w, + height: 330.w, + ), + ), + ) + else + state.openLockBtnState.value == 1 + ? buildRotationTransition( + width: 330.w, + height: 330.w, + ) + : Positioned( + child: FlavorsImg( child: Image.asset( - 'images/main/icon_main_openLockBtn_grey.png', + state.isOpenPassageMode.value == 1 + ? 'images/main/icon_main_normallyOpenMode_circle.png' + : 'images/main/icon_main_openLockBtn_circle.png', width: 330.w, height: 330.w, ), - ), - ) - : state.openLockBtnState.value == 1 - ? buildRotationTransition( - width: 330.w, - height: 330.w, - ) - : Positioned( - child: FlavorsImg( - child: Image.asset( - state.isOpenPassageMode.value == 1 - ? 'images/main/icon_main_normallyOpenMode_circle.png' - : 'images/main/icon_main_openLockBtn_circle.png', - width: 330.w, - height: 330.w, - ), - )), + )), ], ), )), @@ -641,9 +638,8 @@ class _LockDetailPageState extends State right: 90.w, bottom: 1, child: Obx(() => Visibility( - visible: state.keyInfos.value.lockSetting!.remoteUnlock == 1 - ? true - : false, + visible: + state.keyInfos.value.lockSetting!.remoteUnlock == 1, child: GestureDetector( onTap: () { ShowCupertinoAlertView().isToRemoteUnLockAlert( @@ -672,7 +668,7 @@ class _LockDetailPageState extends State ), Row( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ Text( logic.getKeyStatusTextAndShow(), style: TextStyle( @@ -685,9 +681,7 @@ class _LockDetailPageState extends State SizedBox( height: 30.h, ), - F.sw( - defaultCall: () => adminInfoView(), - xhjCall: () => const SizedBox()), + F.sw(defaultCall: adminInfoView, xhjCall: () => const SizedBox()), SizedBox( height: 20.h, ), @@ -707,7 +701,7 @@ class _LockDetailPageState extends State mainAxisAlignment: center ? MainAxisAlignment.center : MainAxisAlignment.start, mainAxisSize: max ? MainAxisSize.max : MainAxisSize.min, - children: [ + children: [ Image.asset( 'images/icon_electronicKey_admin.png', width: 24.w, @@ -742,7 +736,7 @@ class _LockDetailPageState extends State ? AppColors.mainColor : AppColors.btnDisableColor), ), - if (add) ...[ + if (add) ...[ const Spacer(), GestureDetector( onTap: () { @@ -752,7 +746,7 @@ class _LockDetailPageState extends State padding: const EdgeInsets.all(8.0), child: Row( mainAxisSize: MainAxisSize.min, - children: [ + children: [ FlavorsImg( child: Image.asset( 'images/mine/icon_mine_main_addLock.png', @@ -823,7 +817,7 @@ class _LockDetailPageState extends State Widget buildPageIndicator() { return Row( mainAxisAlignment: MainAxisAlignment.center, - children: List.generate(2, (index) { + children: List.generate(2, (int index) { return Container( width: 10.0.w, height: 10.0.w, @@ -855,7 +849,7 @@ class _LockDetailPageState extends State // 配件配置 List getAttachmentWidget() { - var showWidgetArr = []; + final List showWidgetArr = []; // 无线键盘 // if (state.isAttendance.value == 1) { // showWidgetArr.add(bottomItem( @@ -911,7 +905,7 @@ class _LockDetailPageState extends State // 普通用户 List getNormalWidget() { - List showWidgetArr = []; + final List showWidgetArr = []; // 考勤 if (state.isAttendance.value == 1) { showWidgetArr.add(bottomItem( @@ -928,15 +922,17 @@ class _LockDetailPageState extends State TranslationLoader.lanKeys!.operatingRecord!.tr, state.bottomBtnisEable.value, () { Get.toNamed(Routers.doorLockLogPage, - arguments: {"keyInfo": state.keyInfos.value}); + arguments: { + 'keyInfo': state.keyInfos.value + }); })); // 设置 showWidgetArr.add(bottomItem('images/main/icon_main_set.png', TranslationLoader.lanKeys!.set!.tr, true, () { - Get.toNamed(Routers.lockSetPage, arguments: { - "lockId": state.keyInfos.value.lockId, - "isOnlyOneData": state.isOnlyOneData + Get.toNamed(Routers.lockSetPage, arguments: { + 'lockId': state.keyInfos.value.lockId, + 'isOnlyOneData': state.isOnlyOneData }); })); @@ -945,7 +941,7 @@ class _LockDetailPageState extends State // 授权管理员、超级管理员字段 List getAllWidget() { - var showWidgetArr = []; + final List showWidgetArr = []; // 考勤 if (state.isAttendance.value == 1) { showWidgetArr.add(bottomItem( @@ -971,7 +967,9 @@ class _LockDetailPageState extends State TranslationLoader.lanKeys!.password!.tr, state.bottomBtnisEable.value, () { Get.toNamed(Routers.passwordKeyListPage, - arguments: {"keyInfo": state.keyInfos.value}); + arguments: { + 'keyInfo': state.keyInfos.value + }); })); // ic卡 @@ -980,8 +978,8 @@ class _LockDetailPageState extends State 'images/main/icon_main_icCard.png', TranslationLoader.lanKeys!.card!.tr, state.bottomBtnisEable.value, () { - Get.toNamed(Routers.cardListPage, arguments: { - "lockId": state.keyInfos.value.lockId, + Get.toNamed(Routers.cardListPage, arguments: { + 'lockId': state.keyInfos.value.lockId, }); })); } @@ -992,8 +990,8 @@ class _LockDetailPageState extends State 'images/main/icon_main_fingerprint.png', TranslationLoader.lanKeys!.fingerprint!.tr, state.bottomBtnisEable.value, () { - Get.toNamed(Routers.fingerprintListPage, arguments: { - "lockId": state.keyInfos.value.lockId, + Get.toNamed(Routers.fingerprintListPage, arguments: { + 'lockId': state.keyInfos.value.lockId, }); })); } @@ -1015,8 +1013,8 @@ class _LockDetailPageState extends State 'images/main/icon_face.png', TranslationLoader.lanKeys!.humanFace!.tr, state.bottomBtnisEable.value, () { - Get.toNamed(Routers.faceListPage, arguments: { - "lockId": state.keyInfos.value.lockId, + Get.toNamed(Routers.faceListPage, arguments: { + 'lockId': state.keyInfos.value.lockId, }); }), ); @@ -1027,8 +1025,8 @@ class _LockDetailPageState extends State bottomItem( 'images/main/icon_iris.png', '虹膜'.tr, state.bottomBtnisEable.value, () { - Get.toNamed(Routers.irisListPage, arguments: { - "lockId": state.keyInfos.value.lockId, + Get.toNamed(Routers.irisListPage, arguments: { + 'lockId': state.keyInfos.value.lockId, }); }), ); @@ -1039,8 +1037,8 @@ class _LockDetailPageState extends State bottomItem( 'images/main/icon_palm.png', '手掌'.tr, state.bottomBtnisEable.value, () { - Get.toNamed(Routers.palmListPage, arguments: { - "lockId": state.keyInfos.value.lockId, + Get.toNamed(Routers.palmListPage, arguments: { + 'lockId': state.keyInfos.value.lockId, }); }), ); @@ -1053,9 +1051,9 @@ class _LockDetailPageState extends State 'images/main/icon_catEyes.png', TranslationLoader.lanKeys!.monitoring!.tr, state.bottomBtnisEable.value, () { - Get.toNamed(Routers.realTimePicturePage, arguments: { - "lockName": state.keyInfos.value.lockName, - "isMonitoring": true + Get.toNamed(Routers.realTimePicturePage, arguments: { + 'lockName': state.keyInfos.value.lockName, + 'isMonitoring': true }); }), ); @@ -1068,11 +1066,13 @@ class _LockDetailPageState extends State TranslationLoader.lanKeys!.authorizedAdmin!.tr, state.bottomBtnisEable.value, () { Get.toNamed(Routers.authorizedAdminListPage, - arguments: {"keyInfo": state.keyInfos.value}); + arguments: { + 'keyInfo': state.keyInfos.value + }); })); } - var endWiddget = []; + final List endWiddget = []; endWiddget.add( // 操作记录 bottomItem( @@ -1082,7 +1082,9 @@ class _LockDetailPageState extends State // Get.toNamed(Routers.lockOperatingRecordPage, // arguments: {"keyInfo": state.keyInfos.value}); Get.toNamed(Routers.doorLockLogPage, - arguments: {"keyInfo": state.keyInfos.value}); + arguments: { + 'keyInfo': state.keyInfos.value + }); }), ); @@ -1092,8 +1094,8 @@ class _LockDetailPageState extends State 'images/main/icon_lockDetail_videoLog.png', TranslationLoader.lanKeys!.videoLog!.tr, state.bottomBtnisEable.value, () { - Get.toNamed(Routers.videoLogPage, arguments: { - "lockId": state.keyInfos.value.lockId, + Get.toNamed(Routers.videoLogPage, arguments: { + 'lockId': state.keyInfos.value.lockId, }); })); } @@ -1103,8 +1105,8 @@ class _LockDetailPageState extends State 'images/main/icon_lockDetail_messageReminding.png', TranslationLoader.lanKeys!.messageReminding!.tr, state.bottomBtnisEable.value, () { - Get.toNamed(Routers.msgNotificationPage, arguments: { - "lockId": state.keyInfos.value.lockId, + Get.toNamed(Routers.msgNotificationPage, arguments: { + 'lockId': state.keyInfos.value.lockId, }); }), ); @@ -1114,9 +1116,9 @@ class _LockDetailPageState extends State bottomItem('images/main/icon_main_set.png', TranslationLoader.lanKeys!.set!.tr, true, () { // logic.clickItemBtnAction(10); - Get.toNamed(Routers.lockSetPage, arguments: { - "lockId": state.keyInfos.value.lockId, - "isOnlyOneData": state.isOnlyOneData, + Get.toNamed(Routers.lockSetPage, arguments: { + 'lockId': state.keyInfos.value.lockId, + 'isOnlyOneData': state.isOnlyOneData, }); }), ); @@ -1126,12 +1128,12 @@ class _LockDetailPageState extends State Widget bottomItem( String iconUrl, String name, bool bottomBtnisEable, Function() onClick) { - Widget child = F.sw( + final Widget child = F.sw( defaultCall: () => Container( color: Colors.white, child: Column( crossAxisAlignment: CrossAxisAlignment.center, - children: [ + children: [ SizedBox( width: 42.w, height: 42.h, @@ -1164,7 +1166,7 @@ class _LockDetailPageState extends State padding: EdgeInsets.symmetric(vertical: 15.h, horizontal: 15.w), child: Row( crossAxisAlignment: CrossAxisAlignment.center, - children: [ + children: [ SizedBox( width: 42.w, height: 42.h, @@ -1195,19 +1197,19 @@ class _LockDetailPageState extends State onTap: bottomBtnisEable ? onClick : () { - logic.showToast("请在锁旁边完成第一次开锁".tr); + logic.showToast('请在锁旁边完成第一次开锁'.tr); }, child: child, ); } - listeningAnimations() async { - await Future.delayed(Duration.zero, () { + Future listeningAnimations() async { + await Future.delayed(Duration.zero, () { state.animationController = AnimationController( duration: const Duration(seconds: 1), vsync: this); state.animationController!.repeat(); //动画开始、结束、向前移动或向后移动时会调用StatusListener - state.animationController!.addStatusListener((status) { + state.animationController!.addStatusListener((AnimationStatus status) { if (status == AnimationStatus.completed) { state.animationController!.reset(); state.animationController!.forward(); @@ -1237,7 +1239,7 @@ class _LockDetailPageState extends State Widget _unlockSuccessWidget() { return Center( child: Stack( - children: [ + children: [ Image.asset( state.iSOpenLock.value == true ? 'images/main/unlocked_bg.png' @@ -1250,7 +1252,7 @@ class _LockDetailPageState extends State left: 55.w, child: Column( mainAxisSize: MainAxisSize.min, - children: [ + children: [ Text( state.keyInfos.value.lockAlias!, style: TextStyle( @@ -1289,9 +1291,9 @@ class _LockDetailPageState extends State String getCurrentFormattedTime() { // 获取当前时间 - DateTime now = DateTime.now(); + final DateTime now = DateTime.now(); // 格式化日期和时间 - String formattedTime = DateFormat('MM/dd HH:mm').format(now); + final String formattedTime = DateFormat('MM/dd HH:mm').format(now); return formattedTime; } @@ -1303,24 +1305,20 @@ class _LockDetailPageState extends State DateTool().compareTimeIsOvertime(state.nextAuthTime.value) == true) { AliyunRealNameAuthProvider( getLockInfo: state.keyInfos.value, - onCertifyResultWithTime: ((bool isSuccess, int getNextAuthTime) { + onCertifyResultWithTime: (bool isSuccess, int getNextAuthTime) { state.nextAuthTime.value = getNextAuthTime; if (isSuccess) { // 认证成功,去开锁 - setState(() { - startOpenLock(); - }); + setState(startOpenLock); } - })).initAliyunRealNameAuth(); + }).initAliyunRealNameAuth(); } else { //无需认证,直接开锁 - setState(() { - startOpenLock(); - }); + setState(startOpenLock); } } - startOpenLock() { + void startOpenLock() { if (state.openLockBtnState.value == 1) { return; } @@ -1329,21 +1327,21 @@ class _LockDetailPageState extends State state.openLockBtnState.value = 1; state.animationController!.forward(); - AppLog.log("点击开锁"); + AppLog.log('点击开锁'); if (state.isOpenLockNeedOnline.value == 0) { // 不需要联网 state.openDoorModel = 0; - AppLog.log("点击开锁 state.openDoorModel = 0 不需要联网"); + AppLog.log('点击开锁 state.openDoorModel = 0 不需要联网'); logic.openDoorAction(); } else { // 需要联网 state.openDoorModel = 2; - AppLog.log("点击开锁 state.openDoorModel = 2 需要联网"); + AppLog.log('点击开锁 state.openDoorModel = 2 需要联网'); logic.getLockNetToken(); } } - startUnLock() { + void startUnLock() { if (state.openLockBtnState.value == 1) { return; } @@ -1352,16 +1350,16 @@ class _LockDetailPageState extends State state.openLockBtnState.value = 1; state.animationController!.forward(); - EasyLoading.showToast("正在尝试闭锁……".tr, duration: 2000.milliseconds); - AppLog.log("长按闭锁"); + EasyLoading.showToast('正在尝试闭锁……'.tr, duration: 2000.milliseconds); + AppLog.log('长按闭锁'); if (state.isOpenLockNeedOnline.value == 0) { // 不需要联网 - AppLog.log("长按闭锁 state.openDoorModel = 32 不需要联网"); + AppLog.log('长按闭锁 state.openDoorModel = 32 不需要联网'); state.openDoorModel = 32; logic.openDoorAction(); } else { // 需要联网 - AppLog.log("长按闭锁 state.openDoorModel = 34 需要联网"); + AppLog.log('长按闭锁 state.openDoorModel = 34 需要联网'); state.openDoorModel = 34; logic.getLockNetToken(); } diff --git a/lib/main/lockMian/lockMain/lockMain_logic.dart b/lib/main/lockMian/lockMain/lockMain_logic.dart index f86bd6fc..af2032bf 100755 --- a/lib/main/lockMian/lockMain/lockMain_logic.dart +++ b/lib/main/lockMian/lockMain/lockMain_logic.dart @@ -15,10 +15,11 @@ import 'lockMain_state.dart'; class LockMainLogic extends BaseGetXController { final LockMainState state = LockMainState(); - Future getStarLockInfo() async { + Future getStarLockInfo({bool isUnShowLoading = false}) async { LockListInfoEntity entity = await ApiRepository.to.getStarLockListInfo( pageNo: pageNo, pageSize: 50, + isUnShowLoading: isUnShowLoading, ); if (entity.errorCode!.codeIsSuccessful) { loadMainDataLogic(entity.data!); diff --git a/lib/main/lockMian/lockMain/lockMain_page.dart b/lib/main/lockMian/lockMain/lockMain_page.dart index 034df4a8..d8d7b3cb 100755 --- a/lib/main/lockMian/lockMain/lockMain_page.dart +++ b/lib/main/lockMian/lockMain/lockMain_page.dart @@ -37,14 +37,15 @@ class _StarLockMainPageState extends State with BaseWidget { final logic = Get.put(LockMainLogic()); final state = Get.find().state; - Future getHttpData({bool clearScanDevices = false}) async { + Future getHttpData( + {bool clearScanDevices = false, bool isUnShowLoading = false}) async { LockListInfoGroupEntity? lockListInfoGroupEntity = await Storage.getLockMainListData(); if (lockListInfoGroupEntity != null) { var localLockListInfoGroupEntity = lockListInfoGroupEntity; await logic.loadMainDataLogic(localLockListInfoGroupEntity); } - await logic.getStarLockInfo(); + await logic.getStarLockInfo(isUnShowLoading: isUnShowLoading); await Future.delayed(const Duration(milliseconds: 200)); if (clearScanDevices) { BlueManage().scanDevices.clear(); @@ -237,7 +238,9 @@ class _StarLockMainPageState extends State with BaseWidget { void _initLoadDataAction() { _teamEvent = eventBus.on().listen((event) { logic.pageNo = 1; - getHttpData(clearScanDevices: event.clearScanDevices); + getHttpData( + clearScanDevices: event.clearScanDevices, + isUnShowLoading: event.isUnShowLoading); }); } diff --git a/lib/network/api_provider.dart b/lib/network/api_provider.dart index c2182fa6..bfcbb04f 100755 --- a/lib/network/api_provider.dart +++ b/lib/network/api_provider.dart @@ -171,7 +171,7 @@ class ApiProvider extends BaseProvider { 'idCardNumber': idCardNumber })); - Future uploadElectricQuantity( + Future> uploadElectricQuantity( String electricQuantity, String electricQuantityStandby, String lockId, @@ -374,12 +374,12 @@ class ApiProvider extends BaseProvider { })); // 获取锁信息列表 - Future getStarLockListInfo(int pageNo, int pageSize) => post( + Future getStarLockListInfo(int pageNo, int pageSize,{bool isUnShowLoading = true}) => post( getStarLockInfoURL.toUrl, jsonEncode({ "pageNo": pageNo, 'pageSize': pageSize, - })); + }),isUnShowLoading: isUnShowLoading); // 获取所有锁设置信息 Future getLockSettingInfoData(String lockId) => post( diff --git a/lib/network/api_provider_base.dart b/lib/network/api_provider_base.dart index aebb0e7a..5698314a 100755 --- a/lib/network/api_provider_base.dart +++ b/lib/network/api_provider_base.dart @@ -37,7 +37,6 @@ class BaseProvider extends GetConnect with Api { }) async { AppLog.log("post: url:$url body:$body"); if (isUnShowLoading == false){ - // AppLog.log("post: url:$url show loading"); EasyLoading.show(); } if (isUserBaseUrl == false) { diff --git a/lib/network/api_repository.dart b/lib/network/api_repository.dart index 9288b3c8..bcaba46b 100755 --- a/lib/network/api_repository.dart +++ b/lib/network/api_repository.dart @@ -421,8 +421,8 @@ class ApiRepository { // 获取锁信息列表 Future getStarLockListInfo( - {required int pageNo, required int pageSize}) async { - final res = await apiProvider.getStarLockListInfo(pageNo, pageSize); + {required int pageNo, required int pageSize,required bool isUnShowLoading}) async { + final res = await apiProvider.getStarLockListInfo(pageNo, pageSize,isUnShowLoading:isUnShowLoading); return LockListInfoEntity.fromJson(res.body); } diff --git a/lib/tools/eventBusEventManage.dart b/lib/tools/eventBusEventManage.dart index 99ed2e1a..f6fca01a 100755 --- a/lib/tools/eventBusEventManage.dart +++ b/lib/tools/eventBusEventManage.dart @@ -9,8 +9,10 @@ EventBus eventBus = EventBus(); class RefreshLockListInfoDataEvent { //是否清除蓝牙设备列表缓存 bool clearScanDevices; + bool isUnShowLoading; - RefreshLockListInfoDataEvent({this.clearScanDevices = false}); + RefreshLockListInfoDataEvent( + {this.clearScanDevices = false, this.isUnShowLoading = false}); } /// 蓝牙添加用户成功 From 23f0a19fb87dc2c3f4d87164ed9eb610051fbcce Mon Sep 17 00:00:00 2001 From: anfe <448468458@qq.com> Date: Mon, 20 May 2024 16:37:49 +0800 Subject: [PATCH 18/44] =?UTF-8?q?feat:=E6=B7=BB=E5=8A=A0=E8=93=9D=E7=89=99?= =?UTF-8?q?=20debug=20=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/blue/blue_manage.dart | 160 +++++++++++++++++++------------------- 1 file changed, 82 insertions(+), 78 deletions(-) diff --git a/lib/blue/blue_manage.dart b/lib/blue/blue_manage.dart index 223fe584..73a9bdab 100755 --- a/lib/blue/blue_manage.dart +++ b/lib/blue/blue_manage.dart @@ -1,13 +1,9 @@ import 'dart:async'; import 'dart:io'; -import 'package:app_settings/app_settings.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:get/get.dart'; import 'package:star_lock/app_settings/app_settings.dart'; -import 'package:star_lock/tools/showTipView.dart'; -import 'package:star_lock/widget/permission/permission_dialog.dart'; -import 'package:url_launcher/url_launcher.dart'; import 'io_tool/io_model.dart'; import 'io_tool/io_tool.dart'; @@ -21,19 +17,19 @@ typedef ConnectStateCallBack = Function( typedef ScanDevicesCallBack = Function(List); class BlueManage { - final List scanDevices = []; + final List scanDevices = []; // 用来写入的服务id - final Guid _serviceIdConnect = Guid("fff0"); + final Guid _serviceIdConnect = Guid('fff0'); // 用来写入的服务id final Guid _serviceIdWrite = Guid('0000FFF0-0000-1000-8000-00805F9B34FB'); // 用来订阅的特征id - final Guid _characteristicIdSubscription = Guid("fff1"); + final Guid _characteristicIdSubscription = Guid('fff1'); // 用来写入的特征id - final Guid _characteristicIdWrite = Guid("fff2"); + final Guid _characteristicIdWrite = Guid('fff2'); // 监听发送事件 StreamSubscription? _sendStreamSubscription; @@ -50,10 +46,10 @@ class BlueManage { int? _mtuSize = 20; // 当前连接设备的名字 - String connectDeviceName = ""; + String connectDeviceName = ''; // 当前连接设备的mac地址 - String connectDeviceMacAddress = ""; + String connectDeviceMacAddress = ''; // 当前连接的设备 BluetoothDevice? bluetoothConnectDevice; @@ -93,7 +89,7 @@ class BlueManage { } void _initGetMtuSubscription() { - _mtuSubscription ??= bluetoothConnectDevice!.mtu.listen((value) { + _mtuSubscription ??= bluetoothConnectDevice!.mtu.listen((int value) { _mtuSize = value - 3; AppLog.log('_mtuSizeValue:$value mtuSize:$_mtuSize'); }); @@ -101,7 +97,7 @@ class BlueManage { void _initAdapterStateStateSubscription() { _adapterStateStateSubscription ??= - FlutterBluePlus.adapterState.listen((state) { + FlutterBluePlus.adapterState.listen((BluetoothAdapterState state) { _adapterState = state; }); } @@ -149,8 +145,8 @@ class BlueManage { _connectionStateSubscription?.cancel(); _connectionStateSubscription = null; - _connectionStateSubscription = - bluetoothConnectDevice!.connectionState.listen((state) async { + _connectionStateSubscription = bluetoothConnectDevice!.connectionState + .listen((BluetoothConnectionState state) async { bluetoothConnectionState = state; // AppLog.log("蓝牙连接状态:$state"); }); @@ -162,18 +158,18 @@ class BlueManage { .on() .listen((EventSendModel model) { if (model.sendChannel == DataChannel.ble) { - FlutterBluePlus.isSupported.then((isAvailable) async { + FlutterBluePlus.isSupported.then((bool isAvailable) async { if (isAvailable) { if (_adapterState == BluetoothAdapterState.on) { // 蓝牙已开启,可以进行蓝牙操作 writeCharacteristicWithResponse(model.data); } else { try {} catch (e) { - AppLog.log("蓝牙打开失败"); + AppLog.log('蓝牙打开失败'); } } } else { - AppLog.log("写入数据 蓝牙不可用,不能进行蓝牙操作"); + AppLog.log('写入数据 蓝牙不可用,不能进行蓝牙操作'); } }); } @@ -183,31 +179,33 @@ class BlueManage { /// 开始指定设备名称的扫描蓝牙设备 Future startScanSingle(String deviceName, int timeout, ScanDevicesCallBack scanDevicesCallBack) async { - FlutterBluePlus.isSupported.then((isAvailable) async { + FlutterBluePlus.isSupported.then((bool isAvailable) async { if (isAvailable) { if (_adapterState == BluetoothAdapterState.on) { try { FlutterBluePlus.startScan(timeout: Duration(seconds: timeout)); - Completer completer = Completer(); - var subscription = FlutterBluePlus.scanResults.listen((results) { - // AppLog.log("startScanSingle扫描到的设备:$results"); - bool isExit = results.any((element) => + final Completer completer = Completer(); + final StreamSubscription> subscription = + FlutterBluePlus.scanResults.listen((List results) { + final bool isExit = results.any((ScanResult element) => (element.device.platformName == deviceName) || (element.advertisementData.advName == deviceName)); + AppLog.log('扫描到的设备数:${results.length} 是否查找到 $isExit'); if (isExit) { - for (var scanResult in results) { + for (final ScanResult scanResult in results) { if (((scanResult.advertisementData.serviceUuids.isNotEmpty ? scanResult.advertisementData.serviceUuids[0] - : "") + : '') .toString() - .contains("758824")) && + .contains('758824')) && (scanResult.rssi >= -100)) { // 查询id相同的元素 - final knownDeviceIndex = scanDevices.indexWhere((d) => - (d.device.platformName == - scanResult.device.platformName) || - (d.advertisementData.advName == - scanResult.advertisementData.advName)); + final int knownDeviceIndex = scanDevices.indexWhere( + (ScanResult d) => + (d.device.platformName == + scanResult.device.platformName) || + (d.advertisementData.advName == + scanResult.advertisementData.advName)); // 不存在的时候返回-1 if (knownDeviceIndex >= 0) { scanDevices[knownDeviceIndex] = scanResult; @@ -220,7 +218,7 @@ class BlueManage { } }, onError: (e) { AppLog.log( - "扫描失败:$e", + '扫描失败:$e', ); }); FlutterBluePlus.cancelWhenScanComplete(subscription); @@ -228,7 +226,7 @@ class BlueManage { scanDevicesCallBack(scanDevices); subscription.cancel(); } catch (e) { - AppLog.log("扫描失败"); + AppLog.log('扫描失败'); } } else { try { @@ -236,11 +234,11 @@ class BlueManage { await FlutterBluePlus.turnOn(); } } catch (e) { - AppLog.log("蓝牙打开失败"); + AppLog.log('蓝牙打开失败'); } } } else { - AppLog.log("开始扫描 蓝牙不可用,不能进行蓝牙操作"); + AppLog.log('开始扫描 蓝牙不可用,不能进行蓝牙操作'); } }); } @@ -248,15 +246,16 @@ class BlueManage { /// 开始扫描蓝牙设备 Future startScan(int timeout, ScanDevicesCallBack scanDevicesCallBack, {List? idList}) async { - FlutterBluePlus.isSupported.then((isAvailable) async { + FlutterBluePlus.isSupported.then((bool isAvailable) async { if (isAvailable) { if (_adapterState == BluetoothAdapterState.on) { try { FlutterBluePlus.startScan(timeout: Duration(seconds: timeout)); - var subscription = FlutterBluePlus.scanResults.listen((results) { + final StreamSubscription> subscription = + FlutterBluePlus.scanResults.listen((List results) { scanDevices.clear(); - for (var scanResult in results) { + for (final ScanResult scanResult in results) { // 判断名字为空的直接剔除 // if (scanResult.device.advName.isEmpty) { // return; @@ -266,16 +265,17 @@ class BlueManage { // " rssi:${scanResult.rssi}"); if (((scanResult.advertisementData.serviceUuids.isNotEmpty ? scanResult.advertisementData.serviceUuids[0] - : "") + : '') .toString() - .contains("758824")) && + .contains('758824')) && (scanResult.rssi >= -100)) { // 查询id相同的元素 - final knownDeviceIndex = scanDevices.indexWhere((d) => - (d.device.platformName == - scanResult.device.platformName) || - (d.advertisementData.advName == - scanResult.advertisementData.advName)); + final int knownDeviceIndex = scanDevices.indexWhere( + (ScanResult d) => + (d.device.platformName == + scanResult.device.platformName) || + (d.advertisementData.advName == + scanResult.advertisementData.advName)); // 不存在的时候返回-1 if (knownDeviceIndex >= 0) { scanDevices[knownDeviceIndex] = scanResult; @@ -303,13 +303,13 @@ class BlueManage { // FlutterBluePlus.stopScan(); }, onError: (e) { AppLog.log( - "扫描失败:$e", + '扫描失败:$e', ); }); FlutterBluePlus.cancelWhenScanComplete(subscription); } catch (e) { - AppLog.log("扫描失败"); + AppLog.log('扫描失败'); } } else { try { @@ -317,11 +317,11 @@ class BlueManage { await FlutterBluePlus.turnOn(); } } catch (e) { - AppLog.log("蓝牙打开失败"); + AppLog.log('蓝牙打开失败'); } } } else { - AppLog.log("开始扫描 蓝牙不可用,不能进行蓝牙操作"); + AppLog.log('开始扫描 蓝牙不可用,不能进行蓝牙操作'); } }); } @@ -330,12 +330,13 @@ class BlueManage { Future bludSendData( String deviceName, ConnectStateCallBack stateCallBack, {bool isAddEquipment = false}) async { - FlutterBluePlus.isSupported.then((isAvailable) async { + FlutterBluePlus.isSupported.then((bool isAvailable) async { if (isAvailable) { + AppLog.log('蓝牙状态 系统蓝牙状态:$_adapterState 蓝牙连接状态:$bluetoothConnectionState'); if (_adapterState == BluetoothAdapterState.on) { // 蓝牙已开启,可以进行蓝牙操作 if (bluetoothConnectionState != BluetoothConnectionState.connected) { - _connect(deviceName, (state) { + _connect(deviceName, (BluetoothConnectionState state) { stateCallBack(bluetoothConnectionState!); }, isAddEquipment: isAddEquipment); } else { @@ -346,11 +347,11 @@ class BlueManage { stateCallBack(BluetoothConnectionState.disconnected); openBlue(); } catch (e) { - AppLog.log("蓝牙打开失败"); + AppLog.log('蓝牙打开失败'); } } } else { - AppLog.log("开始扫描 蓝牙不可用,不能进行蓝牙操作"); + AppLog.log('开始扫描 蓝牙不可用,不能进行蓝牙操作'); } }); } @@ -360,9 +361,9 @@ class BlueManage { String deviceName, ConnectStateCallBack connectStateCallBack, {bool isAddEquipment = false}) async { connectDeviceName = deviceName; - List devicesList = scanDevices; + final List devicesList = scanDevices; - bool isExistDevice = scanDevices.any((element) => + final bool isExistDevice = scanDevices.any((ScanResult element) => element.device.platformName == connectDeviceName || element.advertisementData.advName == connectDeviceName); @@ -383,7 +384,7 @@ class BlueManage { {bool isAddEquipment = false}) async { // 判断数组列表里面是否有这个设备 // AppLog.log("devicesList:$devicesList"); - final knownDeviceIndex = devicesList.indexWhere((d) => + final int knownDeviceIndex = devicesList.indexWhere((ScanResult d) => (d.device.platformName == deviceName) || (d.advertisementData.advName == deviceName)); @@ -412,15 +413,15 @@ class BlueManage { // AppLog.log("调用了停止扫描的方法"); await stopScan(); - if ((scanResult.advertisementData.serviceUuids[0].toString()[31] == "0") && + if ((scanResult.advertisementData.serviceUuids[0].toString()[31] == '0') && isAddEquipment == false) { connectStateCallBack(BluetoothConnectionState.disconnected); - EasyLoading.showToast("该锁已被重置".tr, duration: 2000.milliseconds); + EasyLoading.showToast('该锁已被重置'.tr, duration: 2000.milliseconds); return; } // 重连三次 - int maxAttempts = 3; + final int maxAttempts = 3; int attempt = 0; while (attempt < maxAttempts) { try { @@ -443,14 +444,16 @@ class BlueManage { // await bluetoothConnectDevice!.connect(); if (bluetoothConnectionState == BluetoothConnectionState.connected) { try { - bluetoothConnectDevice!.discoverServices().then((services) { - for (BluetoothService service in services) { + bluetoothConnectDevice! + .discoverServices() + .then((List services) { + for (final BluetoothService service in services) { // AppLog.log("11111service.remoteId:${service.remoteId}" // " service.uuid:${service.uuid}" // " service.characteristics:${service.characteristics}" // " service.includedServices:${service.includedServices}"); if (service.uuid == _serviceIdConnect) { - for (BluetoothCharacteristic characteristic + for (final BluetoothCharacteristic characteristic in service.characteristics) { // Get.log("22222characteristic.remoteId:${characteristic.remoteId}" // " characteristic.uuid:${characteristic.uuid}" @@ -478,14 +481,15 @@ class BlueManage { } // 听上报来的数据,参数来自前面扫描到的结果 - var allData = []; + List allData = []; // 保存上一次的数据,用来判断是否收到重复的数据 - var lastTimeData = []; + List lastTimeData = []; int? dataLen; _subScribeToCharacteristic(BluetoothCharacteristic characteristic) async { - final subscription = characteristic.onValueReceived.listen((data) { + final StreamSubscription> subscription = + characteristic.onValueReceived.listen((List data) { // AppLog.log("订阅获取的数据:$data"); if (data == lastTimeData || data.isEmpty) { return; @@ -580,15 +584,15 @@ class BlueManage { // 写入 Future writeCharacteristicWithResponse(List value) async { - List services = + final List services = await bluetoothConnectDevice!.discoverServices(); - for (BluetoothService service in services) { + for (final BluetoothService service in services) { // AppLog.log("33333 service.remoteId:${service.remoteId}" // " service.uuid:${service.uuid}\n\n" // " service.characteristics:${service.characteristics}\n\n" // " service.includedServices:${service.includedServices}"); if (service.uuid == _serviceIdConnect) { - for (BluetoothCharacteristic characteristic + for (final BluetoothCharacteristic characteristic in service.characteristics) { // AppLog.log("44444 characteristic.remoteId:${characteristic.remoteId}" // " characteristic.uuid:${characteristic.uuid}\n\n" @@ -598,8 +602,8 @@ class BlueManage { // .characteristicUuid}"); if (characteristic.characteristicUuid == _characteristicIdWrite) { try { - List valueList = value; - List subData = splitList(valueList, _mtuSize!); + final List valueList = value; + final List subData = splitList(valueList, _mtuSize!); // AppLog.log('writeCharacteristicWithResponse _mtuSize:$_mtuSize 得到的分割数据:$subData'); for (int i = 0; i < subData.length; i++) { if (characteristic.properties.writeWithoutResponse) { @@ -660,15 +664,15 @@ class BlueManage { // 写入 Future writeNull() async { - List services = + final List services = await bluetoothConnectDevice!.discoverServices(); - for (BluetoothService service in services) { + for (final BluetoothService service in services) { if (service.uuid == _serviceIdConnect) { - for (BluetoothCharacteristic characteristic + for (final BluetoothCharacteristic characteristic in service.characteristics) { if (characteristic.characteristicUuid == _characteristicIdWrite) { try { - List valueList = [1]; + final List valueList = [1]; AppLog.log('APP写入 writeNull '); await characteristic.write(valueList); } on Exception catch (e, s) { @@ -713,7 +717,7 @@ class BlueManage { try { await FlutterBluePlus.stopScan(); } catch (e) { - AppLog.log("停止扫描失败"); + AppLog.log('停止扫描失败'); } } @@ -721,17 +725,17 @@ class BlueManage { Future disconnect() async { try { // if(bluetoothConnectDevice != null && bluetoothConnectDevice!.connectionState == BluetoothConnectionState.connected){ - connectDeviceMacAddress = ""; + connectDeviceMacAddress = ''; if (bluetoothConnectionState == BluetoothConnectionState.connected) { // await writeNull(); // await Future.delayed(const Duration(milliseconds: 1000)); //加快蓝牙断连 await bluetoothConnectDevice!.disconnect(timeout: 2); - AppLog.log("断开连接成功"); + AppLog.log('断开连接成功'); } // } } on Exception catch (e, _) { - AppLog.log("断开连接失败: $e"); + AppLog.log('断开连接失败: $e'); } finally { bluetoothConnectionState = BluetoothConnectionState.disconnected; } @@ -742,7 +746,7 @@ class BlueManage { await FlutterBluePlus.turnOn(); } if (Platform.isIOS) { - EasyLoading.showToast("请开启蓝牙".tr, duration: 2000.milliseconds); + EasyLoading.showToast('请开启蓝牙'.tr, duration: 2000.milliseconds); } } From 0f8d27c600e9a1fdf68d9a02b9178dfa06fc6342 Mon Sep 17 00:00:00 2001 From: anfe <448468458@qq.com> Date: Mon, 20 May 2024 16:38:55 +0800 Subject: [PATCH 19/44] =?UTF-8?q?feat:=E6=B7=BB=E5=8A=A0=E6=89=93=E5=8C=85?= =?UTF-8?q?=E7=89=88=E6=9C=AC=20=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pubspec.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index 00210fe1..ed45adbe 100755 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -50,8 +50,9 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # 1.0.40+2024051704:打包给欧阳回归测试 # 1.0.41+2024051705:打包给公司测试 # 1.0.42+2024051801:打包给欧阳回归测试 +# 1.0.43+2024052001:打包给公司测试 -version: 1.0.42+2024051801 +version: 1.0.43+2024052001 environment: sdk: '>=2.12.0 <3.0.0' From 63e963b3e0529113deb73bf956ea46c0a2aeb57f Mon Sep 17 00:00:00 2001 From: Daisy <> Date: Mon, 20 May 2024 17:12:34 +0800 Subject: [PATCH 20/44] =?UTF-8?q?1=EF=BC=8C=E6=96=B0=E5=A2=9E=E5=85=AC?= =?UTF-8?q?=E7=94=A8=E6=AD=A3=E5=88=99=E5=88=A4=E6=96=AD=E6=96=87=E4=BB=B6?= =?UTF-8?q?=202=EF=BC=8C=E8=AE=BE=E7=BD=AE/=E6=9B=B4=E6=96=B0=E6=8E=88?= =?UTF-8?q?=E6=9D=83=E7=AE=A1=E7=90=86=E5=91=98=E6=8E=A5=E5=8F=A3=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E5=8F=8A=E5=AF=B9=E6=8E=A5=203=EF=BC=8C=E5=8F=91?= =?UTF-8?q?=E9=80=81=E6=8E=88=E6=9D=83=E7=AE=A1=E7=90=86=E5=91=98/?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E6=96=B0=E5=A2=9E=E4=BB=85=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E8=87=AA=E5=B7=B1=E5=88=9B=E5=BB=BA=E7=9A=84=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=8F=8A=E7=9B=B8=E5=85=B3=E9=80=BB=E8=BE=91=E5=A4=84=E7=90=86?= =?UTF-8?q?=204=EF=BC=8C=E6=89=B9=E9=87=8F=E6=8E=88=E6=9D=83=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=91=98=E6=A8=A1=E5=9D=97=E4=BB=A3=E7=A0=81=E9=87=8D?= =?UTF-8?q?=E6=9E=84=205=EF=BC=8C=E9=83=A8=E5=88=86=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E9=A3=8E=E6=A0=BC=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- images/lan/lan_zh.json | 2 +- .../volumeAuthorizationLock_logic.dart | 46 ++- .../volumeAuthorizationLock_page.dart | 301 ++++++++---------- .../volumeAuthorizationLock_state.dart | 29 +- .../massSendElectronicKey_page.dart | 9 +- .../view/sendElectronicKeyView_logic.dart | 21 +- .../notificationMode_page.dart | 87 ++--- lib/mine/mine/starLockMine_logic.dart | 11 +- lib/mine/mine/starLockMine_page.dart | 76 ++--- .../addAuthorizedAdministrator_logic.dart | 43 +-- .../addAuthorizedAdministrator_page.dart | 177 ++++++---- .../addAuthorizedAdministrator_state.dart | 32 +- .../adminDetailChangeDate_page.dart | 22 +- .../administratorDetailEntity.dart | 4 + .../administratorDetails_logic.dart | 131 ++++---- .../administratorDetails_page.dart | 217 +++++++------ .../administratorDetails_state.dart | 26 +- .../authorizedAdminListEntity.dart | 54 ++-- .../authorizedAdministratorList_logic.dart | 32 +- .../authorizedAdministratorList_page.dart | 43 +-- lib/network/api_provider.dart | 10 +- lib/network/api_repository.dart | 18 +- lib/tools/regularExpression.dart | 14 + 23 files changed, 762 insertions(+), 643 deletions(-) create mode 100644 lib/tools/regularExpression.dart diff --git a/images/lan/lan_zh.json b/images/lan/lan_zh.json index c47e1cc2..2ffd2bb7 100755 --- a/images/lan/lan_zh.json +++ b/images/lan/lan_zh.json @@ -753,7 +753,7 @@ "当被胁迫要求强行开锁时,使用胁迫指纹会触发报警,报警消息会推送给管理员,该功能需要锁联网": "当被胁迫要求强行开锁时,使用胁迫指纹会触发报警,报警消息会推送给管理员,该功能需要锁联网", "胁迫指纹": "胁迫指纹", "指纹列表": "指纹列表", - "经过以上设定的时间,锁没有被开启,系统会给指定对象发送提醒消息,该功能需要锁联网": "经过以上设定的时间,锁没有被开启,系统会给指定对象发送提醒消息,该功能需要锁联网", + "经过以上设定的时间,锁没有被开启,系统会给指定对象发送提醒消息,该功能需要锁联网": "经过以上设定的时间,锁没有被开启,系统会给指定对象发送提醒消息,该功能需要锁联网。", "打开提醒后,当锁电量低于20%、10%和5%,系统会给指定对象发送提醒消息。电量读取方式:网关读取或APP读取。": "打开提醒后,当锁电量低于20%、10%和5%,系统会给指定对象发送提醒消息。电量读取方式:网关读取或APP读取。", "门未开时间": "门未开时间", "添加和使用面容开锁时:": "添加和使用面容开锁时:", diff --git a/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_logic.dart b/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_logic.dart index dffadaf6..99472fb2 100755 --- a/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_logic.dart +++ b/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_logic.dart @@ -1,5 +1,8 @@ +import 'dart:ffi'; - +import 'package:flutter_easyloading/flutter_easyloading.dart'; +import 'package:get/get.dart'; +import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/tools/baseGetXController.dart'; import 'volumeAuthorizationLock_state.dart'; @@ -7,4 +10,43 @@ import 'volumeAuthorizationLock_state.dart'; class VolumeAuthorizationLockLogic extends BaseGetXController { final state = VolumeAuthorizationLockState(); -} \ No newline at end of file + //发送批量授权管理员 + Future addAuthorizedAdminRequest() async { + String getFailureDateTime = '0'; + String getEffectiveDateTime = '0'; + if (state.selectWidgetType == '1') { + getFailureDateTime = + state.failureDateTime.value.millisecondsSinceEpoch.toString(); + getEffectiveDateTime = + state.effectiveDateTime.value.millisecondsSinceEpoch.toString(); + } + + if (state.lockIdList.isEmpty) { + showToast('请选择锁'.tr); + return; + } + var entity = await ApiRepository.to.addAuthorizedAdmin( + createUser: state.isCreateUser.value ? '1' : '0', + endDate: getFailureDateTime, + isRemoteUnlock: '0', + keyGroupIdList: [], + lockIdList: state.lockIdList.value, + name: state.keyNameController.text, + startDate: getEffectiveDateTime, + userid: state.emailOrPhoneController.text, + countryCode: state.countryCode.value, + usernameType: '1', + isOnlyManageSelf: state.onlyManageYouCreatesUser.value == true ? 1 : 2, + ); + if (entity.errorCode!.codeIsSuccessful) { + state.isSendSuccess.value = true; + } else { + EasyLoading.showToast('${entity.errorMsg}', duration: 2000.milliseconds); + if (entity.errorCode == 425) { + //用户未注册 + state.isCreateUser.value = true; + addAuthorizedAdminRequest(); + } + } + } +} diff --git a/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_page.dart b/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_page.dart index ca2ee4e9..2aa60e45 100755 --- a/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_page.dart +++ b/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_page.dart @@ -1,19 +1,16 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_native_contact_picker/flutter_native_contact_picker.dart'; -// import 'package:flutter_pickers/pickers.dart'; -// import 'package:flutter_pickers/time_picker/model/date_mode.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/app_settings/app_colors.dart'; -import 'package:star_lock/network/api_repository.dart'; -import 'package:star_lock/tools/baseGetXController.dart'; +import 'package:star_lock/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_state.dart'; import 'package:star_lock/tools/pickers/pickers.dart'; import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart'; import 'package:star_lock/tools/pickers/time_picker/model/pduration.dart'; +import 'package:star_lock/tools/showTipView.dart'; import '../../../../appRouters.dart'; import '../../../../tools/commonItem.dart'; @@ -22,10 +19,9 @@ import '../../../../translations/trans_lib.dart'; import 'volumeAuthorizationLock_logic.dart'; class VolumeAuthorizationLockPage extends StatefulWidget { - final String type; - - const VolumeAuthorizationLockPage({Key? key, required this.type}) + const VolumeAuthorizationLockPage({required this.type, Key? key}) : super(key: key); + final String type; @override State createState() => @@ -33,53 +29,23 @@ class VolumeAuthorizationLockPage extends StatefulWidget { } //批量授权锁页面 -class _VolumeAuthorizationLockPageState extends State { - final logic = Get.put(VolumeAuthorizationLockLogic()); - final state = Get.find().state; - - final FlutterContactPicker _contactPicker = FlutterContactPicker(); - final TextEditingController _emailOrPhoneController = - TextEditingController(); //邮箱/手机号输入框 - final TextEditingController _keyNameController = - TextEditingController(); //钥匙名输入框 - late Contact _contact; - late List _lockIdList; - late bool _isSendSuccess; - late bool _isCreateUser; //是否需要创建用户 - late bool _isRemoteUnlock; //是否远程开锁 - var _selectEffectiveDate = ''; //生效时间 - var _selectFailureDate = ''; //失效时间 - late DateTime _effectiveDateTime; - late DateTime _failureDateTime; - String countryName = '中国'; - String countryCode = '86'; +class _VolumeAuthorizationLockPageState + extends State { + final VolumeAuthorizationLockLogic logic = + Get.put(VolumeAuthorizationLockLogic()); + final VolumeAuthorizationLockState state = + Get.find().state; @override Widget build(BuildContext context) { + state.selectWidgetType.value = widget.type; return SingleChildScrollView( - child: indexChangeWidget(), + child: Obx(indexChangeWidget), ); } - @override - void initState() { - super.initState(); - - _lockIdList = []; - _isRemoteUnlock = false; - _isSendSuccess = false; - _isCreateUser = false; - DateTime dateTime = DateTime.now(); - _effectiveDateTime = dateTime; - _failureDateTime = dateTime; - _selectEffectiveDate = - '${dateTime.year}-${dateTime.month}-${dateTime.day} ${dateTime.hour}:${dateTime.minute}'; //默认为当前时间 - _selectFailureDate = - '${dateTime.year}-${dateTime.month}-${dateTime.day} ${dateTime.hour}:${dateTime.minute}'; //默认为当前时间 - } - Widget indexChangeWidget() { - if (_isSendSuccess) { + if (state.isSendSuccess.value) { return sendElectronicKeySucceed(); } else { switch (int.parse(widget.type)) { @@ -87,7 +53,7 @@ class _VolumeAuthorizationLockPageState extends State[ keyInfoWidget(), remoteUnlockingWidget(), SizedBox( @@ -100,7 +66,7 @@ class _VolumeAuthorizationLockPageState extends State[ keyInfoWidget(), keyTimeWidget(), remoteUnlockingWidget(), @@ -117,47 +83,47 @@ class _VolumeAuthorizationLockPageState extends State[ CommonItem( leftTitel: TranslationLoader.lanKeys!.accountNumber!.tr, - rightTitle: "", + rightTitle: '', isHaveLine: true, isHaveRightWidget: true, rightWidget: getTFWidget( true, TranslationLoader.lanKeys!.pleaseEnterNumberOrEmail!.tr, - _emailOrPhoneController)), + state.emailOrPhoneController)), CommonItem( leftTitel: TranslationLoader.lanKeys!.countryAndRegion!.tr, - rightTitle: "", + rightTitle: '', isHaveLine: true, isHaveRightWidget: true, isHaveDirection: true, rightWidget: Text( - '$countryName +$countryCode', + '${state.countryName.value} +${state.countryCode.value}', textAlign: TextAlign.end, style: TextStyle(fontSize: 22.sp, color: AppColors.darkGrayTextColor), ), action: () async { - var result = await Navigator.pushNamed( + final Object? result = await Navigator.pushNamed( context, Routers.selectCountryRegionPage); if (result != null) { result as Map; - countryCode = result['code']; - countryName = result['countryName']; - setState(() {}); + state.countryCode.value = result['code']; + state.countryName.value = result['countryName']; + // setState(() {}); } }, ), CommonItem( leftTitel: TranslationLoader.lanKeys!.name!.tr, - rightTitle: "", + rightTitle: '', isHaveRightWidget: true, rightWidget: getTFWidget( false, TranslationLoader.lanKeys!.pleaseEnter!.tr, - _keyNameController)), + state.keyNameController)), Container(height: 10.h), ], ); @@ -166,36 +132,42 @@ class _VolumeAuthorizationLockPageState extends State[ CommonItem( leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr, - rightTitle: _selectEffectiveDate, + rightTitle: state.selectEffectiveDate.value, isHaveLine: true, isHaveDirection: true, action: () { - PDuration selectDate = PDuration.parse(_effectiveDateTime); + final PDuration selectDate = + PDuration.parse(state.effectiveDateTime.value); Pickers.showDatePicker(context, - selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) { - setState(() { - _selectEffectiveDate = - '${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}'; - _effectiveDateTime = DateTime.parse(_selectEffectiveDate); - }); + selectDate: selectDate, + mode: DateMode.YMDHM, onConfirm: (PDuration p) { + // setState(() { + state.selectEffectiveDate.value = + '${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}'; + state.effectiveDateTime.value = + DateTime.parse(state.selectEffectiveDate.value); + // }); }); }), CommonItem( leftTitel: TranslationLoader.lanKeys!.failureTime!.tr, - rightTitle: _selectFailureDate, + rightTitle: state.selectFailureDate.value, isHaveDirection: true, action: () { - PDuration selectDate = PDuration.parse(_failureDateTime); + final PDuration selectDate = + PDuration.parse(state.failureDateTime.value); Pickers.showDatePicker(context, - selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) { - setState(() { - _selectFailureDate = - '${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}'; - _failureDateTime = DateTime.parse(_selectFailureDate); - }); + selectDate: selectDate, + mode: DateMode.YMDHM, onConfirm: (PDuration p) { + // setState(() { + state.selectFailureDate.value = + '${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}'; + state.failureDateTime.value = + DateTime.parse(state.selectFailureDate.value); + // }); }); }), Container(height: 10.h), @@ -206,33 +178,46 @@ class _VolumeAuthorizationLockPageState extends State[ CommonItem( leftTitel: TranslationLoader.lanKeys!.lock!.tr, - rightTitle: _lockIdList.isEmpty + rightTitle: state.lockIdList.value.isEmpty ? TranslationLoader.lanKeys!.pleaseSelect!.tr - : _lockIdList.length.toString(), + : state.lockIdList.length.toString(), isHaveDirection: true, action: () { - Navigator.pushNamed(context, Routers.massSendLockGroupListPage, arguments: { - "keyLimits":"1" - }).then((value) { + Navigator.pushNamed(context, Routers.massSendLockGroupListPage, + arguments: {'keyLimits': '1'}) + .then((Object? value) { //得到选中的锁ID列表 if (value != null) { value as Map; - _lockIdList = value['selectLockIdList']; + state.lockIdList.value = value['selectLockIdList']; - setState(() {}); + // setState(() {}); } }); }), Container(height: 10.h), CommonItem( - leftTitel: TranslationLoader.lanKeys!.remoteUnlockingAllowed!.tr, - rightTitle: "", + leftTitel: '仅管理自己创建的用户', + rightTitle: '', isHaveRightWidget: true, - rightWidget: SizedBox(width: 60.w, height: 50.h, child: _switch()), - action: () {}), + isTipsImg: true, + tipsImgAction: () { + ShowTipView().showSureAlertDialog('授权管理员只能查看和管理自己下发的钥匙、密码等权限'); + }, + rightWidget: SizedBox( + width: 60.w, + height: 50.h, + child: _onlyManageYouCreatesUserSwitch())), + + // CommonItem( + // leftTitel: TranslationLoader.lanKeys!.remoteUnlockingAllowed!.tr, + // rightTitle: '', + // isHaveRightWidget: true, + // rightWidget: SizedBox(width: 60.w, height: 50.h, child: _switch()), + // action: () {}), Container(height: 10.h), ], ); @@ -240,14 +225,14 @@ class _VolumeAuthorizationLockPageState extends State[ SubmitBtn( btnName: TranslationLoader.lanKeys!.sure!.tr, borderRadius: 20.w, margin: EdgeInsets.only(left: 30.w, right: 30.w, top: 30.w), padding: EdgeInsets.only(top: 25.w, bottom: 25.w), onClick: () { - addAuthorizedAdminRequest(); + logic.addAuthorizedAdminRequest(); }), ], ); @@ -260,7 +245,7 @@ class _VolumeAuthorizationLockPageState extends State[ Expanded( child: TextField( controller: editController, @@ -294,89 +279,51 @@ class _VolumeAuthorizationLockPageState extends State addAuthorizedAdminRequest() async { - String getFailureDateTime = '0'; - String getEffectiveDateTime = '0'; - if (widget.type == '1') { - getFailureDateTime = _failureDateTime.millisecondsSinceEpoch.toString(); - getEffectiveDateTime = - _effectiveDateTime.millisecondsSinceEpoch.toString(); - } - - if (_lockIdList.isEmpty) { - logic.showToast("请选择锁".tr); - return; - } - var entity = await ApiRepository.to.addAuthorizedAdmin( - createUser: _isCreateUser ? "1" : "0", - endDate: getFailureDateTime, - isRemoteUnlock: _isRemoteUnlock == true ? '1' : '2', - keyGroupIdList: [], - lockIdList: _lockIdList, - name: _keyNameController.text, - startDate: getEffectiveDateTime, - userid: _emailOrPhoneController.text, - countryCode: countryCode, - usernameType: '1', - ); - if (entity.errorCode!.codeIsSuccessful) { - _isSendSuccess = true; - setState(() {}); - } else { - EasyLoading.showToast('${entity.errorMsg}', duration: 2000.milliseconds); - if (entity.errorCode == 425) { - //用户未注册 - _isCreateUser = true; - addAuthorizedAdminRequest(); - } - } - } - // 发送电子钥匙成功 Widget sendElectronicKeySucceed() { return Column( - children: [ + children: [ Container( height: 250.h, width: 1.sw, color: Colors.white, child: Column( - children: [ + children: [ SizedBox( height: 30.h, ), @@ -390,9 +337,9 @@ class _VolumeAuthorizationLockPageState extends State[ Text( - "发送成功", + '发送成功', style: TextStyle( fontSize: 26.sp, color: Colors.black, @@ -409,7 +356,7 @@ class _VolumeAuthorizationLockPageState extends State lockIdList = [].obs; + RxBool isSendSuccess = false.obs; + RxBool isCreateUser = false.obs; //是否需要创建用户 + RxBool sRemoteUnlock = false.obs; //是否远程开锁 + RxBool onlyManageYouCreatesUser = false.obs; //只能管理您创建的用户 + RxString selectEffectiveDate = + '${DateTime.now().year}-${DateTime.now().month}-${DateTime.now().day} ${DateTime.now().hour}:${DateTime.now().minute}' + .obs; //生效时间 + RxString selectFailureDate = ''.obs; //失效时间 + Rx effectiveDateTime = DateTime.now().obs; + Rx failureDateTime = DateTime.now().obs; + RxString countryName = '中国'.obs; + RxString countryCode = '86'.obs; + RxString selectWidgetType = '0'.obs; +} diff --git a/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendElectronicKey/massSendElectronicKey_page.dart b/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendElectronicKey/massSendElectronicKey_page.dart index c91a7c72..2711fe97 100755 --- a/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendElectronicKey/massSendElectronicKey_page.dart +++ b/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendElectronicKey/massSendElectronicKey_page.dart @@ -125,7 +125,7 @@ class _MassSendElectronicKeyPageState extends State { mainAxisAlignment: MainAxisAlignment.center, children: [ Text( - "发送成功".tr, + '发送成功'.tr, style: TextStyle( fontSize: 26.sp, color: Colors.black, @@ -201,9 +201,10 @@ class _MassSendElectronicKeyPageState extends State { : state.lockIdList.length.toString(), isHaveDirection: true, action: () { - Navigator.pushNamed(context, Routers.massSendLockGroupListPage, arguments:{ - "keyLimits":"2", - }).then((value) { + Navigator.pushNamed(context, Routers.massSendLockGroupListPage, + arguments: { + 'keyLimits': '2', + }).then((Object? value) { //得到选中的锁ID列表 if (value != null) { value as Map; diff --git a/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_logic.dart b/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_logic.dart index a5460d17..c4c35673 100755 --- a/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_logic.dart +++ b/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_logic.dart @@ -6,6 +6,7 @@ import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart'; import 'package:star_lock/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_state.dart'; import 'package:star_lock/mine/valueAddedServices/advancedFunctionRecord/advancedFunctionRecord_entity.dart'; import 'package:star_lock/network/api_repository.dart'; +import 'package:star_lock/tools/regularExpression.dart'; import 'package:star_lock/tools/showCupertinoAlertView.dart'; import 'package:star_lock/tools/baseGetXController.dart'; import 'package:star_lock/tools/commonDataManage.dart'; @@ -139,7 +140,9 @@ class SendElectronicKeyViewLogic extends BaseGetXController { var entity = await ApiRepository.to.sendElectronicKey( createUser: state.isCreateUser == true ? "1" : "0", countryCode: state.countryCode, - usernameType: isPhoneNumber(state.emailOrPhoneController.text) == true + usernameType: RegularExpression() + .isPhoneNumber(state.emailOrPhoneController.text) == + true ? '1' : '2', endDate: int.parse(endDate), @@ -184,7 +187,8 @@ class SendElectronicKeyViewLogic extends BaseGetXController { //检测实名认证是否支持开启 Future keyCheckFace() async { - AdvancedFunctionRecordEntity entity = await ApiRepository.to.keyCheckFace( + final AdvancedFunctionRecordEntity entity = + await ApiRepository.to.keyCheckFace( lockId: CommonDataManage().currentKeyInfo.lockId ?? 0, ); if (entity.errorCode!.codeIsSuccessful) { @@ -205,19 +209,6 @@ class SendElectronicKeyViewLogic extends BaseGetXController { } } - bool isPhoneNumber(String input) { - // 手机号正则表达式,这里简化为11位数字 - final RegExp phoneRegExp = RegExp(r'^\d{11}$'); - return phoneRegExp.hasMatch(input); - } - - bool isEmail(String input) { - // 邮箱正则表达式,这里简化为常见格式 - final RegExp emailRegExp = - RegExp(r'^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$'); - return emailRegExp.hasMatch(input); - } - TextEditingController getCurrentController(int lineIndex) { TextEditingController currentController = TextEditingController(); switch (lineIndex) { diff --git a/lib/main/lockDetail/messageWarn/notificationMode/notificationMode_page.dart b/lib/main/lockDetail/messageWarn/notificationMode/notificationMode_page.dart index 3b9745a6..2570952a 100755 --- a/lib/main/lockDetail/messageWarn/notificationMode/notificationMode_page.dart +++ b/lib/main/lockDetail/messageWarn/notificationMode/notificationMode_page.dart @@ -5,7 +5,9 @@ import 'package:get/get.dart'; import 'package:star_lock/appRouters.dart'; import 'package:star_lock/main/lockDetail/messageWarn/notificationMode/notificationMode_data.dart'; import 'package:star_lock/main/lockDetail/messageWarn/notificationMode/notificationMode_logic.dart'; +import 'package:star_lock/main/lockDetail/messageWarn/notificationMode/notificationMode_state.dart'; import 'package:star_lock/tools/commonItem.dart'; +import 'package:star_lock/tools/regularExpression.dart'; import 'package:star_lock/tools/submitBtn.dart'; import 'package:star_lock/translations/trans_lib.dart'; @@ -20,8 +22,8 @@ class NotificationModePage extends StatefulWidget { } class _NotificationModePageState extends State { - final logic = Get.put(NotificationModeLogic()); - final state = Get.find().state; + final NotificationModeLogic logic = Get.put(NotificationModeLogic()); + final NotificationModeState state = Get.find().state; @override void initState() { @@ -43,7 +45,7 @@ class _NotificationModePageState extends State { Widget _buildMainView() { return Column( - children: [ + children: [ CommonItem( leftTitel: 'APP推送'.tr, rightTitle: '管理员'.tr, @@ -66,7 +68,7 @@ class _NotificationModePageState extends State { SubmitBtn( btnName: '确定'.tr, onClick: () { - Get.back(result: { + Get.back(result: { 'emailReceiverList': state.emailReceiverList.value, 'phoneReceiverList': state.phoneReceiverList.value }); @@ -135,9 +137,9 @@ class _NotificationModePageState extends State { height: 62.h, color: Colors.white, child: Row( - children: [ + children: [ GestureDetector( - onTap: (() { + onTap: () { if (isEmail) { state.emailReceiverList.value.removeAt(index); state.emailReceiverList.refresh(); @@ -145,7 +147,7 @@ class _NotificationModePageState extends State { state.phoneReceiverList.value.removeAt(index); state.phoneReceiverList.refresh(); } - }), + }, child: Container( color: Colors.white, child: Image.asset( @@ -163,39 +165,40 @@ class _NotificationModePageState extends State { style: TextStyle(fontSize: 22.sp), ), Expanded(child: SizedBox(width: 10.w)), - !isEmail - ? GestureDetector( - child: Container( - width: 90.w, - color: Colors.white, - child: Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - Obx(() => Text( - '+${state.countryCode}', - style: TextStyle( - color: AppColors.darkGrayTextColor, - fontSize: 20.sp), - )), - Image.asset( - 'images/icon_grayPullDown.png', - width: 20.w, - height: 20.w, - ), - ], + if (!isEmail) + GestureDetector( + child: Container( + width: 90.w, + color: Colors.white, + child: Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Obx(() => Text( + '+${state.countryCode}', + style: TextStyle( + color: AppColors.darkGrayTextColor, + fontSize: 20.sp), + )), + Image.asset( + 'images/icon_grayPullDown.png', + width: 20.w, + height: 20.w, ), - ), - onTap: () async { - var result = - await Get.toNamed(Routers.selectCountryRegionPage); - if (result != null) { - result as Map; - state.countryCode.value = result['code']; - state.countryName.value = result['countryName']; - } - }, - ) - : Container(), + ], + ), + ), + onTap: () async { + final result = + await Get.toNamed(Routers.selectCountryRegionPage); + if (result != null) { + result as Map; + state.countryCode.value = result['code']; + state.countryName.value = result['countryName']; + } + }, + ) + else + Container(), getReceiverTFWidget(isEmail ? '请输入Email'.tr : '请输入手机号'.tr, index, isEmail: isEmail) ], @@ -206,7 +209,7 @@ class _NotificationModePageState extends State { // 接受者信息输入框 Widget getReceiverTFWidget(String tfStr, int lineIndex, {required bool isEmail}) { - MsgNoticeModeData msgData = isEmail + final MsgNoticeModeData msgData = isEmail ? state.emailReceiverList.value[lineIndex] : state.phoneReceiverList.value[lineIndex]; msgData.countryCode = state.countryCode.value; @@ -216,7 +219,7 @@ class _NotificationModePageState extends State { height: 65.h, width: 200.w, child: Row( - children: [ + children: [ Expanded( child: TextField( controller: msgData.receiverTF, @@ -247,7 +250,7 @@ class _NotificationModePageState extends State { ), style: TextStyle( fontSize: 22.sp, textBaseline: TextBaseline.alphabetic), - onChanged: (value) { + onChanged: (String value) { if (isEmail) { msgData.receiveEmail = value; state.emailReceiverList.value[lineIndex] = msgData; diff --git a/lib/mine/mine/starLockMine_logic.dart b/lib/mine/mine/starLockMine_logic.dart index 1108883e..b126f569 100755 --- a/lib/mine/mine/starLockMine_logic.dart +++ b/lib/mine/mine/starLockMine_logic.dart @@ -14,7 +14,7 @@ class StarLockMineLogic extends BaseGetXController { //用户信息 Future getUserInfoRequest() async { - MinePersonInfoEntity entity = await ApiRepository.to.getUserInfo(); + final MinePersonInfoEntity entity = await ApiRepository.to.getUserInfo(); if (entity.errorCode!.codeIsSuccessful) { state.mineInfoData.value = entity.data!; state.isVip.value = state.mineInfoData.value.isVip! == 0 ? false : true; @@ -24,7 +24,7 @@ class StarLockMineLogic extends BaseGetXController { //删除账号请求 Future userLogoutRequest() async { - LoginEntity entity = await ApiRepository.to.userLogout(deviceld: ''); + final LoginEntity entity = await ApiRepository.to.userLogout(deviceld: ''); if (entity.errorCode!.codeIsSuccessful) {} } @@ -32,14 +32,15 @@ class StarLockMineLogic extends BaseGetXController { StreamSubscription? _mineInfoChangeRefreshUIEvent; void _mineInfoChangeRefreshUIAction() { // 蓝牙协议通知传输跟蓝牙之外的数据传输类不一样 eventBus - _mineInfoChangeRefreshUIEvent = - eventBus.on().listen((event) { + _mineInfoChangeRefreshUIEvent = eventBus + .on() + .listen((MineInfoChangeRefreshUI event) { getMineInfoData(); }); } getMineInfoData() async { - final data = await Storage.getString(saveUserLoginData); + final String? data = await Storage.getString(saveUserLoginData); if (data != null && data.isNotEmpty) { state.userNickName.value = (await Storage.getNickname())!; state.userMobile.value = (await Storage.getMobile())! ?? ''; diff --git a/lib/mine/mine/starLockMine_page.dart b/lib/mine/mine/starLockMine_page.dart index 74d0fb59..0b5240a6 100755 --- a/lib/mine/mine/starLockMine_page.dart +++ b/lib/mine/mine/starLockMine_page.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/flavors.dart'; +import 'package:star_lock/mine/mine/starLockMine_state.dart'; import 'package:star_lock/tools/commonDataManage.dart'; import '../../appRouters.dart'; @@ -22,8 +23,8 @@ class StarLockMinePage extends StatefulWidget { GlobalKey starLockMineKey = GlobalKey(); class StarLockMinePageState extends State with BaseWidget { - final logic = Get.put(StarLockMineLogic()); - final state = Get.find().state; + final StarLockMineLogic logic = Get.put(StarLockMineLogic()); + final StarLockMineState state = Get.find().state; @override initState() { @@ -36,7 +37,7 @@ class StarLockMinePageState extends State with BaseWidget { return Scaffold( backgroundColor: const Color(0xFFFFFFFF), body: Column( - children: [ + children: [ topWidget(), bottomListWidget(), SizedBox( @@ -54,7 +55,7 @@ class StarLockMinePageState extends State with BaseWidget { color: AppColors.mainColor, // color: Colors.red, child: Stack( - children: [ + children: [ Image.asset( 'images/mine/icon_mine_topBg.png', width: 400.w, @@ -63,7 +64,7 @@ class StarLockMinePageState extends State with BaseWidget { ), Center( child: Column( - children: [ + children: [ SizedBox( height: 120.h, ), @@ -97,7 +98,7 @@ class StarLockMinePageState extends State with BaseWidget { logic.showToast('请先添加锁'); } else { Get.toNamed(Routers.advancedFeaturesWebPage, - arguments: {'isShop': true}); + arguments: {'isShop': true}); } } else { Get.toNamed( @@ -108,7 +109,7 @@ class StarLockMinePageState extends State with BaseWidget { color: Colors.transparent, child: Row( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ Text( state.userNickName.value.isNotEmpty ? state.userNickName.value @@ -122,17 +123,18 @@ class StarLockMinePageState extends State with BaseWidget { SizedBox( width: 5.w, ), - !state.isVip.value - ? Image.asset( - 'images/mine/icon_mine_noPlus.png', - width: 20.w, - height: 20.w, - ) - : Image.asset( - 'images/mine/icon_mine_isPlus.png', - width: 20.w, - height: 20.w, - ), + if (!state.isVip.value) + Image.asset( + 'images/mine/icon_mine_noPlus.png', + width: 20.w, + height: 20.w, + ) + else + Image.asset( + 'images/mine/icon_mine_isPlus.png', + width: 20.w, + height: 20.w, + ), ], ), ), @@ -183,20 +185,22 @@ class StarLockMinePageState extends State with BaseWidget { Get.toNamed(Routers.mineSetPage); }), //上架审核 - F.isLite - ? Container() - : mineItem('images/mine/icon_mine_main_vip.png', - TranslationLoader.lanKeys!.valueAddedServices!.tr, () { - Get.back(); - Get.toNamed(Routers.valueAddedServicesPage); - }), - F.isLite - ? Container() - : mineItem( - 'images/mine/icon_mine_main_shoppingcart.png', "配件商城".tr, () { - Get.back(); - Get.toNamed(Routers.lockMallPage); - }), + if (F.isLite) + Container() + else + mineItem('images/mine/icon_mine_main_vip.png', + TranslationLoader.lanKeys!.valueAddedServices!.tr, () { + Get.back(); + Get.toNamed(Routers.valueAddedServicesPage); + }), + if (F.isLite) + Container() + else + mineItem('images/mine/icon_mine_main_shoppingcart.png', '配件商城'.tr, + () { + Get.back(); + Get.toNamed(Routers.lockMallPage); + }), mineItem('images/mine/icon_mine_main_about.png', TranslationLoader.lanKeys!.about!.tr, () { Get.back(); @@ -209,7 +213,7 @@ class StarLockMinePageState extends State with BaseWidget { Widget keyBottomWidget() { return Column( - children: [ + children: [ SubmitBtn( btnName: TranslationLoader.lanKeys!.logout!.tr, borderRadius: 20.w, @@ -222,7 +226,7 @@ class StarLockMinePageState extends State with BaseWidget { // color: Colors.red, child: Row( mainAxisAlignment: MainAxisAlignment.end, - children: [ + children: [ TextButton( child: Text( TranslationLoader.lanKeys!.deleteAccount!.tr, @@ -246,7 +250,7 @@ class StarLockMinePageState extends State with BaseWidget { return GestureDetector( onTap: action, child: Row( - children: [ + children: [ Center( child: Container( // height: 80.h, @@ -254,7 +258,7 @@ class StarLockMinePageState extends State with BaseWidget { padding: EdgeInsets.all(20.h), color: Colors.white, child: Row( - children: [ + children: [ Image.asset( lockTypeIcon, width: 28.w, diff --git a/lib/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator/addAuthorizedAdministrator_logic.dart b/lib/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator/addAuthorizedAdministrator_logic.dart index e8f01c0e..55150c1a 100755 --- a/lib/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator/addAuthorizedAdministrator_logic.dart +++ b/lib/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator/addAuthorizedAdministrator_logic.dart @@ -1,5 +1,6 @@ import 'package:flutter/cupertino.dart'; import 'package:get/get.dart'; +import 'package:star_lock/main/lockDetail/lockSet/basicInformation/basicInformation/KeyDetailEntity.dart'; import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/tools/baseGetXController.dart'; import 'package:star_lock/translations/trans_lib.dart'; @@ -16,44 +17,46 @@ class AddAuthorizedAdministratorLogic extends BaseGetXController { final RegExp phoneRegExp = RegExp(r'^\d{11}$'); return phoneRegExp.hasMatch(input); } + //发送批量授权管理员 Future addAuthorizedAdminRequest() async { if (state.emailOrPhoneController.text.isEmpty) { - showToast("请输入接收者账号"); + showToast('请输入接收者账号'); return; } if (state.keyNameController.text.isEmpty) { - showToast("请输入接收者姓名"); + showToast('请输入接收者姓名'); return; } - if(state.lockIdList.isEmpty){ - showToast("请选择锁".tr); + if (state.lockIdList.isEmpty) { + showToast('请选择锁'.tr); return; } - var startDate = "0"; - var endDate = "0"; + String startDate = '0'; + String endDate = '0'; if (state.type.value == '0') { - startDate = DateTool().dateToTimestamp(state.beginDate.value, 1).toString(); + startDate = + DateTool().dateToTimestamp(state.beginDate.value, 1).toString(); endDate = DateTool().dateToTimestamp(state.endDate.value, 1).toString(); if (startDate.isEmpty) { - showToast("请选择开始时间"); + showToast('请选择开始时间'); return; } if (endDate.isEmpty) { - showToast("请选择结束时间"); + showToast('请选择结束时间'); return; } if (int.parse(startDate) >= int.parse(endDate)) { - showToast("失效时间要大于生效时间"); + showToast('失效时间要大于生效时间'); return; } } - var entity = await ApiRepository.to.addAuthorizedAdmin( - createUser: state.isCreateUser.value ? "1" : "0", + final KeyDetailEntity entity = await ApiRepository.to.addAuthorizedAdmin( + createUser: state.isCreateUser.value ? '1' : '0', endDate: endDate, isRemoteUnlock: state.isRemoteUnlock.value == true ? '1' : '2', keyGroupIdList: [], @@ -62,9 +65,9 @@ class AddAuthorizedAdministratorLogic extends BaseGetXController { startDate: startDate, userid: state.emailOrPhoneController.text, countryCode: state.countryCode.value, - usernameType: isPhoneNumber(state.emailOrPhoneController.text) == true - ? '1' - : '2', + usernameType: + isPhoneNumber(state.emailOrPhoneController.text) == true ? '1' : '2', + isOnlyManageSelf: state.onlyManageYouCreatesUser.value == true ? 1 : 2, ); if (entity.errorCode!.codeIsSuccessful) { state.isSendSuccess.value = true; @@ -77,7 +80,7 @@ class AddAuthorizedAdministratorLogic extends BaseGetXController { if (entity.errorCode == 425) { //用户未注册 state.isCreateUser.value = true; - _showDialog("${entity.errorMsg}"); + _showDialog('${entity.errorMsg}'); } } } @@ -86,15 +89,13 @@ class AddAuthorizedAdministratorLogic extends BaseGetXController { void _showDialog(String errMsg) { showCupertinoDialog( context: Get.context!, - builder: (context) { + builder: (BuildContext context) { return CupertinoAlertDialog( title: const Text('接收者号码未注册,请重新发送'), - actions: [ + actions: [ CupertinoDialogAction( child: Text(TranslationLoader.lanKeys!.cancel!.tr), - onPressed: () { - Get.back(); - }, + onPressed: Get.back, ), CupertinoDialogAction( child: Text(TranslationLoader.lanKeys!.sure!.tr), diff --git a/lib/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator/addAuthorizedAdministrator_page.dart b/lib/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator/addAuthorizedAdministrator_page.dart index dc737ec3..f6b34274 100755 --- a/lib/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator/addAuthorizedAdministrator_page.dart +++ b/lib/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator/addAuthorizedAdministrator_page.dart @@ -6,10 +6,12 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/appRouters.dart'; import 'package:star_lock/app_settings/app_colors.dart'; +import 'package:star_lock/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator/addAuthorizedAdministrator_state.dart'; import 'package:star_lock/tools/commonItem.dart'; import 'package:star_lock/tools/pickers/pickers.dart'; import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart'; import 'package:star_lock/tools/pickers/time_picker/model/pduration.dart'; +import 'package:star_lock/tools/showTipView.dart'; import 'package:star_lock/tools/submitBtn.dart'; import 'package:star_lock/translations/trans_lib.dart'; @@ -18,10 +20,9 @@ import '../../../../tools/dateTool.dart'; import 'addAuthorizedAdministrator_logic.dart'; class AddAuthorizedAdministratorPage extends StatefulWidget { - String type; - - AddAuthorizedAdministratorPage({Key? key, required this.type}) + AddAuthorizedAdministratorPage({required this.type, Key? key}) : super(key: key); + String type; @override State createState() { @@ -32,8 +33,10 @@ class AddAuthorizedAdministratorPage extends StatefulWidget { class _AddAuthorizedAdministratorPageState extends State with SingleTickerProviderStateMixin { - final logic = Get.put(AddAuthorizedAdministratorLogic()); - final state = Get.find().state; + final AddAuthorizedAdministratorLogic logic = + Get.put(AddAuthorizedAdministratorLogic()); + final AddAuthorizedAdministratorState state = + Get.find().state; @override void initState() { @@ -67,9 +70,9 @@ class _AddAuthorizedAdministratorPageState : state.lockIdList.value.length.toString(), isHaveDirection: true, action: () { - Navigator.pushNamed(context, Routers.massSendLockGroupListPage, arguments: { - "keyLimits":"1" - }).then((value) { + Navigator.pushNamed(context, Routers.massSendLockGroupListPage, + arguments: {'keyLimits': '1'}) + .then((Object? value) { //得到选中的锁ID列表 if (value != null) { value as Map; @@ -82,7 +85,19 @@ class _AddAuthorizedAdministratorPageState SizedBox( height: 10.h, ), - remoteUnlockingWidget(), + CommonItem( + leftTitel: '仅管理自己创建的用户', + rightTitle: '', + isHaveRightWidget: true, + isTipsImg: true, + tipsImgAction: () { + ShowTipView().showSureAlertDialog('授权管理员只能查看和管理自己下发的钥匙、密码等权限'); + }, + rightWidget: SizedBox( + width: 60.w, + height: 50.h, + child: _onlyManageYouCreatesUserSwitch())), + // remoteUnlockingWidget(), SizedBox( height: 20.h, ), @@ -110,9 +125,10 @@ class _AddAuthorizedAdministratorPageState : state.lockIdList.value.length.toString(), isHaveDirection: true, action: () { - Navigator.pushNamed(context, Routers.massSendLockGroupListPage,arguments:{ - "keyLimits":"1", - }).then((value) { + Navigator.pushNamed(context, Routers.massSendLockGroupListPage, + arguments: { + 'keyLimits': '1', + }).then((Object? value) { //得到选中的锁ID列表 if (value != null) { value as Map; @@ -125,7 +141,19 @@ class _AddAuthorizedAdministratorPageState SizedBox( height: 10.h, ), - remoteUnlockingWidget(), + // remoteUnlockingWidget(), + CommonItem( + leftTitel: '仅管理自己创建的用户', + rightTitle: '', + isHaveRightWidget: true, + isTipsImg: true, + tipsImgAction: () { + ShowTipView().showSureAlertDialog('授权管理员只能查看和管理自己下发的钥匙、密码等权限'); + }, + rightWidget: SizedBox( + width: 60.w, + height: 50.h, + child: _onlyManageYouCreatesUserSwitch())), SizedBox( height: 20.h, ), @@ -141,7 +169,7 @@ class _AddAuthorizedAdministratorPageState children: [ CommonItem( leftTitel: TranslationLoader.lanKeys!.accountNumber!.tr, - rightTitle: "", + rightTitle: '', isHaveLine: true, isHaveRightWidget: true, rightWidget: getTFWidget( @@ -150,7 +178,7 @@ class _AddAuthorizedAdministratorPageState state.emailOrPhoneController)), CommonItem( leftTitel: TranslationLoader.lanKeys!.countryAndRegion!.tr, - rightTitle: "", + rightTitle: '', isHaveLine: true, isHaveRightWidget: true, isHaveDirection: true, @@ -173,7 +201,7 @@ class _AddAuthorizedAdministratorPageState ), CommonItem( leftTitel: TranslationLoader.lanKeys!.name!.tr, - rightTitle: "", + rightTitle: '', isHaveRightWidget: true, rightWidget: getTFWidget( false, @@ -228,50 +256,67 @@ class _AddAuthorizedAdministratorPageState SizedBox( width: 10.w, ), - isHaveBtn - ? Container( - width: 30.w, - height: 30.w, - decoration: const BoxDecoration( - color: Colors.white, - image: DecorationImage( - image: AssetImage('images/icon_addressBook.png'), - fit: BoxFit.fill), - ), - alignment: Alignment.center, - child: InkWell( - onTap: () async { - Contact? currentContact = - await state.contactPicker.selectContact(); - setState(() { - if (currentContact!.phoneNumbers!.isNotEmpty) { - state.emailOrPhoneController.text = currentContact - .phoneNumbers![0] - .replaceAll(RegExp(r"\s+\b|\b\s"), ""); - } - }); - }, - ), - ) - : Container() + if (isHaveBtn) + Container( + width: 30.w, + height: 30.w, + decoration: const BoxDecoration( + color: Colors.white, + image: DecorationImage( + image: AssetImage('images/icon_addressBook.png'), + fit: BoxFit.fill), + ), + alignment: Alignment.center, + child: InkWell( + onTap: () async { + final Contact? currentContact = + await state.contactPicker.selectContact(); + setState(() { + if (currentContact!.phoneNumbers!.isNotEmpty) { + state.emailOrPhoneController.text = currentContact + .phoneNumbers![0] + .replaceAll(RegExp(r'\s+\b|\b\s'), ''); + } + }); + }, + ), + ) + else + Container() ], ), ); } // 远程开锁 - Widget remoteUnlockingWidget() { - return Column( - children: [ - CommonItem( - leftTitel: TranslationLoader.lanKeys!.remoteUnlockingAllowed!.tr, - rightTitle: "", - isHaveRightWidget: true, - rightWidget: SizedBox( - width: 60.w, height: 50.h, child: Obx(() => _switch())), - action: () {}), - Container(height: 40.h), - ], + // Widget remoteUnlockingWidget() { + // return Column( + // children: [ + // CommonItem( + // leftTitel: TranslationLoader.lanKeys!.remoteUnlockingAllowed!.tr, + // rightTitle: '', + // isHaveRightWidget: true, + // rightWidget: + // SizedBox(width: 60.w, height: 50.h, child: Obx(_switch)), + // action: () {}), + // Container(height: 40.h), + // ], + // ); + // } + + //仅管理自己创建的用户 + CupertinoSwitch _onlyManageYouCreatesUserSwitch() { + return CupertinoSwitch( + activeColor: CupertinoColors.activeBlue, + trackColor: CupertinoColors.systemGrey5, + thumbColor: CupertinoColors.white, + value: state.onlyManageYouCreatesUser.value, + onChanged: (value) { + setState(() { + state.onlyManageYouCreatesUser.value = + !state.onlyManageYouCreatesUser.value; + }); + }, ); } @@ -285,7 +330,7 @@ class _AddAuthorizedAdministratorPageState isHaveLine: true, isHaveDirection: true, action: () { - PDuration selectDate = + final PDuration selectDate = PDuration.parse(DateTime.tryParse(state.beginDate.value)); Pickers.showDatePicker(context, selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) { @@ -299,7 +344,7 @@ class _AddAuthorizedAdministratorPageState rightTitle: state.endDate.value, isHaveDirection: true, action: () { - PDuration selectDate = + final PDuration selectDate = PDuration.parse(DateTime.tryParse(state.endDate.value)); Pickers.showDatePicker(context, selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) { @@ -314,12 +359,12 @@ class _AddAuthorizedAdministratorPageState Widget keyBottomWidget(String tipStr) { return Column( - children: [ + children: [ Container( padding: EdgeInsets.all(20.w), child: Row( // crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ Expanded( child: Text( tipStr, @@ -341,7 +386,7 @@ class _AddAuthorizedAdministratorPageState // color: Colors.red, child: Row( mainAxisAlignment: MainAxisAlignment.end, - children: [ + children: [ TextButton( onPressed: () { Navigator.pushNamed( @@ -366,7 +411,7 @@ class _AddAuthorizedAdministratorPageState trackColor: CupertinoColors.systemGrey5, thumbColor: CupertinoColors.white, value: state.isRemoteUnlock.value, - onChanged: (value) { + onChanged: (bool value) { state.isRemoteUnlock.value = !state.isRemoteUnlock.value; }, ); @@ -390,7 +435,7 @@ class _AddAuthorizedAdministratorPageState width: 1.sw, color: Colors.white, child: Column( - children: [ + children: [ SizedBox( height: 30.h, ), @@ -406,7 +451,7 @@ class _AddAuthorizedAdministratorPageState mainAxisAlignment: MainAxisAlignment.center, children: [ Text( - "发送成功", + '发送成功', style: TextStyle( fontSize: 26.sp, color: Colors.black, @@ -431,9 +476,9 @@ class _AddAuthorizedAdministratorPageState ), OutLineBtn( btnName: - state.emailOrPhoneController.text.contains("@") ? '邮件通知' : "短信通知", + state.emailOrPhoneController.text.contains('@') ? '邮件通知' : '短信通知', onClick: () { - if (state.emailOrPhoneController.text.contains("@")) { + if (state.emailOrPhoneController.text.contains('@')) { Get.toNamed(Routers.sendEmailNotificationPage); } else { // _openModalBottomSheet(); @@ -468,7 +513,7 @@ class _AddAuthorizedAdministratorPageState } List initBottomSheetList() { - List widgetList = []; + final List widgetList = []; widgetList.add(buildCenter3('images/icon_wechat.png', '微信好友', 0)); widgetList.add(buildCenter3('images/icon_message.png', '短信', 1)); @@ -510,7 +555,7 @@ class _AddAuthorizedAdministratorPageState } //\n生效时间:${itemData.startDate}\n类型:永久\n锁名:${itemData.keyboardPwdName} - _jumpSmartDeviceRoute(int itemIndex) { + void _jumpSmartDeviceRoute(int itemIndex) { Get.back(); switch (itemIndex) { case 0: diff --git a/lib/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator/addAuthorizedAdministrator_state.dart b/lib/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator/addAuthorizedAdministrator_state.dart index f8344c44..4b0a8e17 100755 --- a/lib/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator/addAuthorizedAdministrator_state.dart +++ b/lib/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator/addAuthorizedAdministrator_state.dart @@ -1,4 +1,3 @@ - import 'package:flutter/material.dart'; import 'package:flutter_native_contact_picker/flutter_native_contact_picker.dart'; import 'package:get/get.dart'; @@ -14,26 +13,25 @@ class AddAuthorizedAdministratorState { final FlutterContactPicker contactPicker = FlutterContactPicker(); late Contact contact; - var type = ''.obs; + RxString type = ''.obs; var lockIdList = [].obs; var weekdaysList = [].obs; - var isCreateUser = false.obs; //用户未注册时传1 已注册传0 + RxBool isCreateUser = false.obs; //用户未注册时传1 已注册传0 - var beginDate = DateTool().dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString()).obs; //默认为当前时间 开始时间 - var endDate = DateTool().dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString()).obs;// + RxString beginDate = DateTool() + .dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString()) + .obs; //默认为当前时间 开始时间 + RxString endDate = DateTool() + .dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString()) + .obs; // - var countryName = '中国'.obs; - var countryCode = '86'.obs; - var isSendSuccess = false.obs; - final isRemoteUnlock = false.obs; //是否允许远程开锁 - final isAuthentication = false.obs; //是否允许实名认证 - final keyInfo = LockListInfoItemEntity().obs; + RxString countryName = '中国'.obs; + RxString countryCode = '86'.obs; + RxBool isSendSuccess = false.obs; + final RxBool isRemoteUnlock = false.obs; //是否允许远程开锁 + final RxBool isAuthentication = false.obs; //是否允许实名认证 + final RxBool onlyManageYouCreatesUser = false.obs; //只能管理您创建的用户 + final Rx keyInfo = LockListInfoItemEntity().obs; String pwdShareStr = '您好,您的授权管理员生成成功'; - AddAuthorizedAdministratorState() { - // Map map = Get.arguments; - // if ((map["keyInfo"] != null)) { - // keyInfo.value = map["keyInfo"]; - // } - } } diff --git a/lib/mine/mineSet/authorizedAdministrator/administratorDetails/adminDetailChangeDate_page.dart b/lib/mine/mineSet/authorizedAdministrator/administratorDetails/adminDetailChangeDate_page.dart index 25f3b911..fea078a5 100755 --- a/lib/mine/mineSet/authorizedAdministrator/administratorDetails/adminDetailChangeDate_page.dart +++ b/lib/mine/mineSet/authorizedAdministrator/administratorDetails/adminDetailChangeDate_page.dart @@ -34,8 +34,8 @@ class _AdminDetailChangeDatePage extends State { @override Widget build(BuildContext context) { dynamic obj = ModalRoute.of(context)?.settings.arguments; - if (obj != null && (obj["itemData"] != null)) { - itemData = obj["itemData"]; + if (obj != null && (obj['itemData'] != null)) { + itemData = obj['itemData']; } return Scaffold( @@ -101,14 +101,16 @@ class _AdminDetailChangeDatePage extends State { //更新管理员信息请求 Future updateAdministratorRequest() async { - ElectronicKeyListEntity entity = await ApiRepository.to.updateAdministrator( - itemData.uid.toString(), - '', - _failureDateTime.millisecondsSinceEpoch.toString(), - _effectiveDateTime.millisecondsSinceEpoch.toString(), - ''); + final ElectronicKeyListEntity entity = await ApiRepository.to + .updateAdministrator( + uid: itemData.uid.toString(), + endDate: _failureDateTime.millisecondsSinceEpoch.toString(), + startDate: _effectiveDateTime.millisecondsSinceEpoch.toString(), + keyName: '', + isOnlyManageSelf: + itemData.onlyManageYouCreatesUser == true ? 1 : 2); if (entity.errorCode!.codeIsSuccessful) { - EasyLoading.showToast("修改成功", duration: 2000.milliseconds); + EasyLoading.showToast('修改成功', duration: 2000.milliseconds); setState(() { Navigator.pop(context); }); @@ -116,6 +118,6 @@ class _AdminDetailChangeDatePage extends State { } String intToStr(int v) { - return (v < 10) ? "0$v" : "$v"; + return (v < 10) ? '0$v' : '$v'; } } diff --git a/lib/mine/mineSet/authorizedAdministrator/administratorDetails/administratorDetailEntity.dart b/lib/mine/mineSet/authorizedAdministrator/administratorDetails/administratorDetailEntity.dart index 4a7f89a0..3e3cb627 100755 --- a/lib/mine/mineSet/authorizedAdministrator/administratorDetails/administratorDetailEntity.dart +++ b/lib/mine/mineSet/authorizedAdministrator/administratorDetails/administratorDetailEntity.dart @@ -35,6 +35,7 @@ class Data { int? endDate; int? startDate; int? isRemoteUnlock; + int? isOnlyManageSelf; String? name; String? userid; List? lockList; @@ -46,6 +47,7 @@ class Data { this.endDate, this.startDate, this.isRemoteUnlock, + this.isOnlyManageSelf, this.name, this.userid, this.lockList}); @@ -57,6 +59,7 @@ class Data { endDate = json['endDate']; startDate = json['startDate']; isRemoteUnlock = json['isRemoteUnlock']; + isOnlyManageSelf = json['isOnlyManageSelf']; name = json['name']; userid = json['userid']; if (json['lockList'] != null) { @@ -75,6 +78,7 @@ class Data { data['endDate'] = endDate; data['startDate'] = startDate; data['isRemoteUnlock'] = isRemoteUnlock; + data['isOnlyManageSelf'] = isOnlyManageSelf; data['name'] = name; data['userid'] = userid; if (lockList != null) { diff --git a/lib/mine/mineSet/authorizedAdministrator/administratorDetails/administratorDetails_logic.dart b/lib/mine/mineSet/authorizedAdministrator/administratorDetails/administratorDetails_logic.dart index d6f09a2a..4743fe25 100755 --- a/lib/mine/mineSet/authorizedAdministrator/administratorDetails/administratorDetails_logic.dart +++ b/lib/mine/mineSet/authorizedAdministrator/administratorDetails/administratorDetails_logic.dart @@ -1,4 +1,3 @@ - import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart'; @@ -7,48 +6,59 @@ import '../../../../main/lockDetail/electronicKey/electronicKeyList/entity/Elect import '../../../../network/api_repository.dart'; import '../../../../tools/custom_bottom_sheet.dart'; import '../../../../tools/eventBusEventManage.dart'; -import '../../../../tools/jh_pop_menus.dart'; import '../../../../tools/showTipView.dart'; import '../authorizedAdministrator/authorizedAdminListEntity.dart'; import 'administratorDetailEntity.dart'; import 'administratorDetails_state.dart'; -class AdministratorDetailsLogic extends BaseGetXController{ +class AdministratorDetailsLogic extends BaseGetXController { AdministratorDetailsState state = AdministratorDetailsState(); - //管理员详情请求 Future administratorDetailRequest() async { - AdministratorDetailEntity entity = await ApiRepository.to.authorizedAdminDetail(state.itemData.value.uid ?? 0); + final AdministratorDetailEntity entity = await ApiRepository.to + .authorizedAdminDetail(state.itemData.value.uid ?? 0); if (entity.errorCode!.codeIsSuccessful) { state.lockItemList.value = entity.data!.lockList!; + state.onlyManageYouCreatesUser.value = + entity.data!.isOnlyManageSelf == 1 ? true : false; } } //更新管理员信息请求 - Future updateAdministratorRequest(bool isRemote) async { - String isRemoteUnlock = state.isOnRemote.value == true ? '1' : '2'; - ElectronicKeyListEntity entity = await ApiRepository.to.updateAdministrator( - state.itemData.value.uid.toString(), - state.changeNameController.text, - '', - '', - isRemoteUnlock); + Future updateAdministratorRequest({required bool isChangeName}) async { + int isManageCreateUser = 0; + if (!isChangeName) { + isManageCreateUser = state.onlyManageYouCreatesUser.value == true ? 2 : 1; + } + final ElectronicKeyListEntity entity = await ApiRepository.to + .updateAdministrator( + uid: state.itemData.value.uid.toString(), + keyName: isChangeName + ? state.changeNameController.text + : state.itemData.value.name ?? '', + endDate: '', + startDate: '', + isOnlyManageSelf: isChangeName + ? state.itemData.value.onlyManageYouCreatesUser ?? 0 + : isManageCreateUser); if (entity.errorCode!.codeIsSuccessful) { - showToast("修改成功".tr); - }else{ - state.isOnRemote.value = !state.isOnRemote.value; + if (!isChangeName) { + state.onlyManageYouCreatesUser.value = + !state.onlyManageYouCreatesUser.value; + } + showToast('修改成功'.tr); + administratorDetailRequest(); } } //删除授权管理员请求 是否删除授权管理员发送的钥匙。 1是,0否 Future deleteAdministratorRequest(int includeUnderlings) async { - AuthorizedAdminListEntity entity = await ApiRepository.to.deleteAuthorizedAdmin( - state.itemData.value.uid.toString(), - includeUnderlings.toString() - ); + final AuthorizedAdminListEntity entity = await ApiRepository.to + .deleteAuthorizedAdmin( + state.itemData.value.uid.toString(), includeUnderlings.toString()); if (entity.errorCode!.codeIsSuccessful) { - showToast("删除成功".tr, something: (){ + showToast('删除成功'.tr, something: () { // eventBus.fire(AuthorizedAdministratorListPageRefreshUI()); Get.back(); }); @@ -57,12 +67,11 @@ class AdministratorDetailsLogic extends BaseGetXController{ //冻结 Future freezeKey(int includeUnderlings) async { - ElectronicKeyListEntity entity = await ApiRepository.to.freezeKey( - keyId:state.itemData.value.keyId.toString(), - includeUnderlings: includeUnderlings - ); + final ElectronicKeyListEntity entity = await ApiRepository.to.freezeKey( + keyId: state.itemData.value.keyId.toString(), + includeUnderlings: includeUnderlings); if (entity.errorCode!.codeIsSuccessful) { - showToast("设置成功".tr, something: () { + showToast('设置成功'.tr, something: () { eventBus.fire(ElectronicKeyListRefreshUI()); eventBus.fire(AuthorizedAdminPageRefreshUI()); }); @@ -71,12 +80,11 @@ class AdministratorDetailsLogic extends BaseGetXController{ //取消冻结 Future cancelFreeze(int includeUnderlings) async { - ElectronicKeyListEntity entity = await ApiRepository.to.cancelFreeze( - keyId:state.itemData.value.keyId.toString(), - includeUnderlings: includeUnderlings - ); + final ElectronicKeyListEntity entity = await ApiRepository.to.cancelFreeze( + keyId: state.itemData.value.keyId.toString(), + includeUnderlings: includeUnderlings); if (entity.errorCode!.codeIsSuccessful) { - showToast("设置成功".tr, something: () { + showToast('设置成功'.tr, something: () { eventBus.fire(ElectronicKeyListRefreshUI()); eventBus.fire(AuthorizedAdminPageRefreshUI()); }); @@ -85,11 +93,12 @@ class AdministratorDetailsLogic extends BaseGetXController{ //取消授权管理员 Future cancelAdministrator() async { - ElectronicKeyListEntity entity = await ApiRepository.to.cancelAdministrator( - keyId:state.itemData.value.keyId.toString(), + final ElectronicKeyListEntity entity = + await ApiRepository.to.cancelAdministrator( + keyId: state.itemData.value.keyId.toString(), ); if (entity.errorCode!.codeIsSuccessful) { - showToast("设置成功".tr, something: () { + showToast('设置成功'.tr, something: () { eventBus.fire(ElectronicKeyListRefreshUI()); eventBus.fire(AuthorizedAdminPageRefreshUI()); Get.back(); @@ -97,8 +106,11 @@ class AdministratorDetailsLogic extends BaseGetXController{ } } - Future openModalBottomSheet() async { - var textList = [state.itemData.value.keyStatus == 110405 ? '取消冻结'.tr : "冻结".tr, '取消授权'.tr]; + Future openModalBottomSheet() async { + final List textList = [ + if (state.itemData.value.keyStatus == 110405) '取消冻结'.tr else '冻结'.tr, + '取消授权'.tr + ]; showModalBottomSheet( context: Get.context!, @@ -109,24 +121,25 @@ class AdministratorDetailsLogic extends BaseGetXController{ topTitle: '', items: textList, chooseCallback: (value) { - int index = value; - if(index == 0){ - if(state.itemData.value.keyStatus == 110405){ + final int index = value; + if (index == 0) { + if (state.itemData.value.keyStatus == 110405) { // 取消冻结 - ShowTipView().showDeleteAdministratorIsHaveAllDataDialog('同时解冻其发送的钥匙'.tr, (isAllData) { + ShowTipView().showDeleteAdministratorIsHaveAllDataDialog( + '同时解冻其发送的钥匙'.tr, (isAllData) { cancelFreeze(isAllData ? 1 : 0); }); - }else{ - ShowTipView().showDeleteAdministratorIsHaveAllDataDialog('同时冻结其发送的钥匙'.tr, (isAllData) { + } else { + ShowTipView().showDeleteAdministratorIsHaveAllDataDialog( + '同时冻结其发送的钥匙'.tr, (isAllData) { freezeKey(isAllData ? 1 : 0); }); } - }else{ + } else { // 取消/授权管理员 // 管理员 - ShowTipView().showIosTipWithContentDialog("取消授权会在用户APP连网后生效".tr, (){ - cancelAdministrator(); - }); + ShowTipView().showIosTipWithContentDialog( + '取消授权会在用户APP连网后生效'.tr, cancelAdministrator); } }, ); @@ -138,20 +151,24 @@ class AdministratorDetailsLogic extends BaseGetXController{ String useDateStr = ''; if (indexEntity.keyType == XSConstantMacro.keyTypeTime) { //限期 - DateTime startDateStr = - DateTime.fromMillisecondsSinceEpoch(indexEntity.startDate!); - DateTime endDateStr = - DateTime.fromMillisecondsSinceEpoch(indexEntity.endDate!); + final DateTime startDateStr = + DateTime.fromMillisecondsSinceEpoch(indexEntity.startDate!); + final DateTime endDateStr = + DateTime.fromMillisecondsSinceEpoch(indexEntity.endDate!); useDateStr = - '${startDateStr.toLocal().toString().substring(0, 16)}\n${endDateStr.toLocal().toString().substring(0, 16)}'; + '${startDateStr.toLocal().toString().substring(0, 16)}\n${endDateStr.toLocal().toString().substring(0, 16)}'; } else if (indexEntity.keyType == XSConstantMacro.keyTypeLong) { //永久 - DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.date!); - useDateStr = '${dateStr.toLocal().toString().substring(0, 16)}\n${"永久".tr}'; + final DateTime dateStr = + DateTime.fromMillisecondsSinceEpoch(indexEntity.date!); + useDateStr = + '${dateStr.toLocal().toString().substring(0, 16)}\n${"永久".tr}'; } else if (indexEntity.keyType == XSConstantMacro.keyTypeOnce) { //单次 - DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.date!); - useDateStr = '${dateStr.toLocal().toString().substring(0, 16)} \n${"单次".tr}'; + final DateTime dateStr = + DateTime.fromMillisecondsSinceEpoch(indexEntity.date!); + useDateStr = + '${dateStr.toLocal().toString().substring(0, 16)} \n${"单次".tr}'; } else if (indexEntity.keyType == XSConstantMacro.keyTypeLoop) { //循环 useDateStr = '循环'.tr; @@ -177,7 +194,5 @@ class AdministratorDetailsLogic extends BaseGetXController{ void onClose() { // TODO: implement onClose super.onClose(); - } - -} \ No newline at end of file +} diff --git a/lib/mine/mineSet/authorizedAdministrator/administratorDetails/administratorDetails_page.dart b/lib/mine/mineSet/authorizedAdministrator/administratorDetails/administratorDetails_page.dart index 520fc0ba..ee1da87f 100755 --- a/lib/mine/mineSet/authorizedAdministrator/administratorDetails/administratorDetails_page.dart +++ b/lib/mine/mineSet/authorizedAdministrator/administratorDetails/administratorDetails_page.dart @@ -2,7 +2,8 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; -import 'package:star_lock/tools/jh_pop_menus.dart'; +import 'package:star_lock/mine/mineSet/authorizedAdministrator/administratorDetails/administratorDetails_state.dart'; +import 'package:star_lock/mine/mineSet/authorizedAdministrator/authorizedAdministrator/authorizedAdminListEntity.dart'; import '../../../../../appRouters.dart'; import '../../../../../app_settings/app_colors.dart'; @@ -23,8 +24,9 @@ class AdministratorDetailsPage extends StatefulWidget { } class _AdministratorDetailsPageState extends State { - final logic = Get.put(AdministratorDetailsLogic()); - final state = Get.find().state; + final AdministratorDetailsLogic logic = Get.put(AdministratorDetailsLogic()); + final AdministratorDetailsState state = + Get.find().state; @override void initState() { @@ -33,79 +35,100 @@ class _AdministratorDetailsPageState extends State { @override Widget build(BuildContext context) { - return Scaffold( resizeToAvoidBottomInset: false, backgroundColor: AppColors.mainBackgroundColor, appBar: TitleAppBar( barTitle: '管理员详情'.tr, haveBack: true, - actionsList: [ + actionsList: [ IconButton( icon: Image.asset( 'images/icon_bar_more.png', height: 30.h, width: 10.w, ), - onPressed: () { - logic.openModalBottomSheet(); - }, + onPressed: logic.openModalBottomSheet, ), ], backgroundColor: AppColors.mainColor), - body: Obx(()=>Column( - children: [ - CommonItem( - leftTitel: TranslationLoader.lanKeys!.name!.tr, - rightTitle: state.changeNameController.text.isNotEmpty - ? state.changeNameController.text - : state.itemData.value.name, - isHaveDirection: true, - isHaveLine: true, - action: () { - showCupertinoAlertDialog(context); - }), - CommonItem( - leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr, - allHeight: 90.h, - rightTitle: logic.getUseDateStr(state.itemData.value), - isHaveDirection: true, - action: () { - Navigator.pushNamed(context, Routers.adminDetailChangeDatePage, - arguments: {"itemData": state.itemData.value}); - }), - Container(height: 10.h), - CommonItem( - leftTitel: TranslationLoader.lanKeys!.lock!.tr, - rightTitle: state.itemData.value.lockNum.toString(), - isHaveDirection: false, - action: () { - // //锁列表页面 - // Navigator.pushNamed(context, Routers.lockItemListPage, - // arguments: {'lockList': state.lockItemList}); - }), - Container(height: 10.h), - CommonItem( - leftTitel: TranslationLoader.lanKeys!.remoteUnlocking!.tr, - rightTitle: "", - isHaveRightWidget: true, - rightWidget: SizedBox(width: 60.w, child: _switch()), - action: () {}), - Container(height: 40.h), - SubmitBtn( - btnName: TranslationLoader.lanKeys!.delete!.tr, - borderRadius: 20.w, - isDelete: true, - margin: EdgeInsets.only( - left: 30.w, right: 30.w, top: 30.w, bottom: 30.w), - padding: EdgeInsets.only(top: 25.w, bottom: 25.w), - onClick: () { - ShowTipView().showDeleteAdministratorIsHaveAllDataDialog('同时删除其发送的所有钥匙,钥匙删除后不能恢复'.tr, (isAllData) { - logic.deleteAdministratorRequest(isAllData ? 1 : 0); - }); - }), - ], - )), + body: Obx(() => Column( + children: [ + CommonItem( + leftTitel: TranslationLoader.lanKeys!.name!.tr, + rightTitle: state.changeNameController.text.isNotEmpty + ? state.changeNameController.text + : state.itemData.value.name, + isHaveDirection: true, + isHaveLine: true, + action: () { + showCupertinoAlertDialog(context); + }), + CommonItem( + leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr, + allHeight: 90.h, + rightTitle: logic.getUseDateStr(state.itemData.value), + isHaveDirection: true, + action: () { + Navigator.pushNamed( + context, Routers.adminDetailChangeDatePage, + arguments: { + 'itemData': state.itemData.value + }); + }), + Container(height: 10.h), + CommonItem( + leftTitel: TranslationLoader.lanKeys!.lock!.tr, + rightTitle: state.itemData.value.lockNum.toString(), + isHaveDirection: false, + action: () { + // //锁列表页面 + // Navigator.pushNamed(context, Routers.lockItemListPage, + // arguments: {'lockList': state.lockItemList}); + }), + Container(height: 10.h), + CommonItem( + leftTitel: '仅管理自己创建的用户', + rightTitle: '', + isHaveRightWidget: true, + isTipsImg: true, + tipsImgAction: () { + ShowTipView() + .showSureAlertDialog('授权管理员只能查看和管理自己下发的钥匙、密码等权限'); + }, + rightWidget: SizedBox( + width: 60.w, + height: 50.h, + child: _onlyManageYouCreatesUserSwitch())), + Container(height: 40.h), + SubmitBtn( + btnName: TranslationLoader.lanKeys!.delete!.tr, + borderRadius: 20.w, + isDelete: true, + margin: EdgeInsets.only( + left: 30.w, right: 30.w, top: 30.w, bottom: 30.w), + padding: EdgeInsets.only(top: 25.w, bottom: 25.w), + onClick: () { + ShowTipView().showDeleteAdministratorIsHaveAllDataDialog( + '同时删除其发送的所有钥匙,钥匙删除后不能恢复'.tr, (bool isAllData) { + logic.deleteAdministratorRequest(isAllData ? 1 : 0); + }); + }), + ], + )), + ); + } + + //仅管理自己创建的用户 + CupertinoSwitch _onlyManageYouCreatesUserSwitch() { + return CupertinoSwitch( + activeColor: CupertinoColors.activeBlue, + trackColor: CupertinoColors.systemGrey5, + thumbColor: CupertinoColors.white, + value: state.onlyManageYouCreatesUser.value, + onChanged: (value) { + logic.updateAdministratorRequest(isChangeName: false); + }, ); } @@ -119,14 +142,14 @@ class _AdministratorDetailsPageState extends State { onTap: action, child: Column( // mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ Container( // height: 80.h, color: Colors.white, padding: EdgeInsets.only( left: 20.w, right: 10.w, top: 20.w, bottom: 20.w), child: Row( - children: [ + children: [ SizedBox(width: 20.w), Text( leftTitle, @@ -137,69 +160,57 @@ class _AdministratorDetailsPageState extends State { Expanded( child: Row( mainAxisAlignment: MainAxisAlignment.end, - children: [ - isHaveRightWidget - ? rightWidget! - : Text( - rightTitle, - textAlign: TextAlign.end, - style: TextStyle( - fontSize: 28.sp, fontWeight: FontWeight.w500), - ) + children: [ + if (isHaveRightWidget) + rightWidget! + else + Text( + rightTitle, + textAlign: TextAlign.end, + style: TextStyle( + fontSize: 28.sp, fontWeight: FontWeight.w500), + ) ], ), ), SizedBox(width: 5.w), - isHaveDirection - ? Image.asset( - 'images/icon_right.png', - width: 50.w, - height: 50.w, - ) - : SizedBox(width: 10.w), + if (isHaveDirection) + Image.asset( + 'images/icon_right.png', + width: 50.w, + height: 50.w, + ) + else + SizedBox(width: 10.w), // SizedBox(width:10.w), ], ), ), - isHaveLine - ? Container( - height: 0.5.h, - color: Colors.grey, - ) - : Container() + if (isHaveLine) + Container( + height: 0.5.h, + color: Colors.grey, + ) + else + Container() ], ), ); } - CupertinoSwitch _switch() { - return CupertinoSwitch( - activeColor: CupertinoColors.activeBlue, - trackColor: CupertinoColors.systemGrey5, - thumbColor: CupertinoColors.white, - value: state.isOnRemote.value, - onChanged: (value) { - setState(() { - state.isOnRemote.value = !state.isOnRemote.value; - logic.updateAdministratorRequest(true); - }); - }, - ); - } - void showCupertinoAlertDialog(BuildContext context) { showDialog( context: context, builder: (BuildContext context) { return ShowTFView( title: - "${TranslationLoader.lanKeys!.amend!.tr} ${TranslationLoader.lanKeys!.name!.tr}", - tipTitle: "请输入".tr, + '${TranslationLoader.lanKeys!.amend!.tr} ${TranslationLoader.lanKeys!.name!.tr}', + tipTitle: '请输入'.tr, controller: state.changeNameController, sureClick: () { //发送编辑钥匙名称请求 if (state.changeNameController.text.isNotEmpty) { - logic.updateAdministratorRequest(false); + logic.updateAdministratorRequest(isChangeName: true); } }, cancelClick: () { diff --git a/lib/mine/mineSet/authorizedAdministrator/administratorDetails/administratorDetails_state.dart b/lib/mine/mineSet/authorizedAdministrator/administratorDetails/administratorDetails_state.dart index c0a20dbf..54e5fb6c 100755 --- a/lib/mine/mineSet/authorizedAdministrator/administratorDetails/administratorDetails_state.dart +++ b/lib/mine/mineSet/authorizedAdministrator/administratorDetails/administratorDetails_state.dart @@ -1,22 +1,20 @@ - - import 'package:flutter/material.dart'; import 'package:get/get.dart'; import '../../../../main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupListEntity.dart'; import '../authorizedAdministrator/authorizedAdminListEntity.dart'; -class AdministratorDetailsState{ - final TextEditingController changeNameController = TextEditingController(); - final itemData = AuthorizedAdminListItem().obs; - var isOnRemote = false.obs; - var lockItemList = [].obs; - - AdministratorDetailsState(){ - Map map = Get.arguments; - if (map != null && (map["itemData"] != null)) { - itemData.value = map["itemData"]; - isOnRemote.value = itemData.value.isRemoteUnlock == 1 ? true : false; +class AdministratorDetailsState { + AdministratorDetailsState() { + final Map map = Get.arguments; + if (map['itemData'] != null) { + itemData.value = map['itemData']; + onlyManageYouCreatesUser.value = + itemData.value.onlyManageYouCreatesUser == 1 ? true : false; } } -} \ No newline at end of file + final TextEditingController changeNameController = TextEditingController(); + final Rx itemData = AuthorizedAdminListItem().obs; + RxBool onlyManageYouCreatesUser = false.obs; + RxList lockItemList = [].obs; +} diff --git a/lib/mine/mineSet/authorizedAdministrator/authorizedAdministrator/authorizedAdminListEntity.dart b/lib/mine/mineSet/authorizedAdministrator/authorizedAdministrator/authorizedAdminListEntity.dart index b24895df..272ccdf1 100755 --- a/lib/mine/mineSet/authorizedAdministrator/authorizedAdministrator/authorizedAdminListEntity.dart +++ b/lib/mine/mineSet/authorizedAdministrator/authorizedAdministrator/authorizedAdminListEntity.dart @@ -1,12 +1,6 @@ class AuthorizedAdminListEntity { - int? errorCode; - String? description; - String? errorMsg; - AuthorizedAdminListData? data; - AuthorizedAdminListEntity( {this.errorCode, this.description, this.errorMsg, this.data}); - AuthorizedAdminListEntity.fromJson(Map json) { errorCode = json['errorCode']; description = json['description']; @@ -15,6 +9,10 @@ class AuthorizedAdminListEntity { ? AuthorizedAdminListData.fromJson(json['data']) : null; } + int? errorCode; + String? description; + String? errorMsg; + AuthorizedAdminListData? data; Map toJson() { final Map data = {}; @@ -29,15 +27,8 @@ class AuthorizedAdminListEntity { } class AuthorizedAdminListData { - List? itemList; - int? pageNo; - int? pageSize; - int? pages; - int? total; - AuthorizedAdminListData( {this.itemList, this.pageNo, this.pageSize, this.pages, this.total}); - AuthorizedAdminListData.fromJson(Map json) { if (json['list'] != null) { itemList = []; @@ -50,6 +41,11 @@ class AuthorizedAdminListData { pages = json['pages']; total = json['total']; } + List? itemList; + int? pageNo; + int? pageSize; + int? pages; + int? total; Map toJson() { final Map data = {}; @@ -65,19 +61,6 @@ class AuthorizedAdminListData { } class AuthorizedAdminListItem { - int? uid; - int? keyStatus; - int? lockNum; - int? endDate; - int? startDate; - String? name; - String? headUrl; - String? userid; - int? keyType; - int? date; - int? isRemoteUnlock; - int? keyId; - AuthorizedAdminListItem( {this.uid, this.keyStatus, @@ -90,8 +73,8 @@ class AuthorizedAdminListItem { this.keyType, this.date, this.isRemoteUnlock, - this.keyId}); - + this.keyId, + this.onlyManageYouCreatesUser}); AuthorizedAdminListItem.fromJson(Map json) { uid = json['uid']; keyStatus = json['keyStatus']; @@ -105,7 +88,21 @@ class AuthorizedAdminListItem { date = json['date']; isRemoteUnlock = json['isRemoteUnlock']; keyId = json['keyId']; + onlyManageYouCreatesUser = json['onlyManageYouCreatesUser']; } + int? uid; + int? keyStatus; + int? lockNum; + int? endDate; + int? startDate; + String? name; + String? headUrl; + String? userid; + int? keyType; + int? date; + int? isRemoteUnlock; + int? keyId; + int? onlyManageYouCreatesUser; Map toJson() { final Map data = {}; @@ -121,6 +118,7 @@ class AuthorizedAdminListItem { data['date'] = date; data['isRemoteUnlock'] = isRemoteUnlock; data['keyId'] = keyId; + data['onlyManageYouCreatesUser'] = onlyManageYouCreatesUser; return data; } } diff --git a/lib/mine/mineSet/authorizedAdministrator/authorizedAdministrator/authorizedAdministratorList_logic.dart b/lib/mine/mineSet/authorizedAdministrator/authorizedAdministrator/authorizedAdministratorList_logic.dart index 4153b925..b18616f5 100755 --- a/lib/mine/mineSet/authorizedAdministrator/authorizedAdministrator/authorizedAdministratorList_logic.dart +++ b/lib/mine/mineSet/authorizedAdministrator/authorizedAdministrator/authorizedAdministratorList_logic.dart @@ -1,4 +1,3 @@ - import 'dart:async'; import 'package:star_lock/tools/baseGetXController.dart'; @@ -9,15 +8,13 @@ import '../../../../tools/eventBusEventManage.dart'; import 'authorizedAdminListEntity.dart'; import 'authorizedAdministratorList_state.dart'; -class AuthorizedAdministratorListLogic extends BaseGetXController{ +class AuthorizedAdministratorListLogic extends BaseGetXController { AuthorizedAdministratorListState state = AuthorizedAdministratorListState(); //请求授权管理员列表 Future mockNetworkDataRequest() async { - AuthorizedAdminListEntity entity = await ApiRepository.to.authorizedAdminList( - pageNo.toString(), - pageSize.toString() - ); + final AuthorizedAdminListEntity entity = await ApiRepository.to + .authorizedAdminList(pageNo.toString(), pageSize.toString()); if (entity.errorCode!.codeIsSuccessful) { if (pageNo == 1) { state.itemDataList.value = entity.data!.itemList!; @@ -34,11 +31,12 @@ class AuthorizedAdministratorListLogic extends BaseGetXController{ } //删除授权管理员请求 是否删除授权管理员发送的钥匙。 1是,0否 - Future deleteAdministratorRequest(String uid, int includeUnderlings) async { - AuthorizedAdminListEntity entity = await ApiRepository.to + Future deleteAdministratorRequest( + String uid, int includeUnderlings) async { + final AuthorizedAdminListEntity entity = await ApiRepository.to .deleteAuthorizedAdmin(uid, includeUnderlings.toString()); if (entity.errorCode!.codeIsSuccessful) { - showToast("删除成功", something: (){ + showToast('删除成功', something: () { pageNo = 1; mockNetworkDataRequest(); }); @@ -51,12 +49,12 @@ class AuthorizedAdministratorListLogic extends BaseGetXController{ if (indexEntity.keyType == XSConstantMacro.keyTypeTime) { //限期 if (indexEntity.startDate != null && indexEntity.endDate != null) { - DateTime startDateStr = - DateTime.fromMillisecondsSinceEpoch(indexEntity.startDate!); - DateTime endDateStr = - DateTime.fromMillisecondsSinceEpoch(indexEntity.endDate!); + final DateTime startDateStr = + DateTime.fromMillisecondsSinceEpoch(indexEntity.startDate!); + final DateTime endDateStr = + DateTime.fromMillisecondsSinceEpoch(indexEntity.endDate!); useDateStr = - '${startDateStr.toLocal().toString().substring(0, 16)}-${endDateStr.toLocal().toString().substring(0, 16)}'; + '${startDateStr.toLocal().toString().substring(0, 16)}-${endDateStr.toLocal().toString().substring(0, 16)}'; } else { useDateStr = '限期'; } @@ -77,7 +75,8 @@ class AuthorizedAdministratorListLogic extends BaseGetXController{ StreamSubscription? _authorizedAdministratorListPageRefreshUIEvent; void _authorizedAdministratorListPageRefreshUIAction() { // 蓝牙协议通知传输跟蓝牙之外的数据传输类不一样 eventBus - _authorizedAdministratorListPageRefreshUIEvent = eventBus.on().listen((event) { + _authorizedAdministratorListPageRefreshUIEvent = + eventBus.on().listen((event) { pageNo = 1; mockNetworkDataRequest(); }); @@ -102,5 +101,4 @@ class AuthorizedAdministratorListLogic extends BaseGetXController{ super.onClose(); _authorizedAdministratorListPageRefreshUIEvent?.cancel(); } - -} \ No newline at end of file +} diff --git a/lib/mine/mineSet/authorizedAdministrator/authorizedAdministrator/authorizedAdministratorList_page.dart b/lib/mine/mineSet/authorizedAdministrator/authorizedAdministrator/authorizedAdministratorList_page.dart index c2922066..8463a9b1 100755 --- a/lib/mine/mineSet/authorizedAdministrator/authorizedAdministrator/authorizedAdministratorList_page.dart +++ b/lib/mine/mineSet/authorizedAdministrator/authorizedAdministrator/authorizedAdministratorList_page.dart @@ -3,6 +3,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_slidable/flutter_slidable.dart'; import 'package:get/get.dart'; import 'package:star_lock/mine/mineSet/authorizedAdministrator/authorizedAdministrator/authorizedAdminListEntity.dart'; +import 'package:star_lock/mine/mineSet/authorizedAdministrator/authorizedAdministrator/authorizedAdministratorList_state.dart'; import 'package:star_lock/tools/noData.dart'; import 'package:star_lock/tools/showCupertinoAlertView.dart'; import 'package:star_lock/tools/submitBtn.dart'; @@ -27,11 +28,13 @@ class AuthorizedAdministratorListPage extends StatefulWidget { class _AuthorizedAdministratorListPageState extends State { - final logic = Get.put(AuthorizedAdministratorListLogic()); - final state = Get.find().state; + final AuthorizedAdministratorListLogic logic = + Get.put(AuthorizedAdministratorListLogic()); + final AuthorizedAdministratorListState state = + Get.find().state; Future getHttpData() async { - var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); + final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); if (isDemoMode == false) { logic.mockNetworkDataRequest().then((AuthorizedAdminListEntity value) { setState(() {}); @@ -54,7 +57,7 @@ class _AuthorizedAdministratorListPageState barTitle: TranslationLoader.lanKeys!.authorizedAdmin!.tr, haveBack: true, backgroundColor: AppColors.mainColor, - actionsList: [ + actionsList: [ IconButton( icon: Image.asset( 'images/icon_add_white.png', @@ -65,7 +68,7 @@ class _AuthorizedAdministratorListPageState // 处理操作按钮的点击事件 Navigator.pushNamed( context, Routers.addAuthorizedAdministratorPage) - .then((value) { + .then((Object? value) { setState(() { logic.pageNo = 1; getHttpData(); @@ -84,7 +87,7 @@ class _AuthorizedAdministratorListPageState getHttpData(); }, child: Column( - children: [ + children: [ // _searchWidget(), Expanded(child: _buildMainUI()), ], @@ -95,7 +98,7 @@ class _AuthorizedAdministratorListPageState Widget _buildMainUI() { return Obx(() => state.itemDataList.isEmpty ? Stack( - children: [ + children: [ NoData( noDataHeight: 1.sh - ScreenUtil().statusBarHeight - @@ -111,7 +114,7 @@ class _AuthorizedAdministratorListPageState onClick: () { Navigator.pushNamed( context, Routers.addAuthorizedAdministratorPage) - .then((value) { + .then((Object? value) { setState(() { logic.pageNo = 1; getHttpData(); @@ -125,8 +128,8 @@ class _AuthorizedAdministratorListPageState : SlidableAutoCloseBehavior( child: ListView.separated( itemCount: state.itemDataList.value.length, - itemBuilder: (c, index) { - AuthorizedAdminListItem authorizedAdminListItem = + itemBuilder: (BuildContext c, int index) { + final AuthorizedAdminListItem authorizedAdminListItem = state.itemDataList.value[index]; return Slidable( @@ -134,12 +137,12 @@ class _AuthorizedAdministratorListPageState endActionPane: ActionPane( extentRatio: 0.2, motion: const ScrollMotion(), - children: [ + children: [ SlidableAction( onPressed: (BuildContext context) { ShowTipView() .showDeleteAdministratorIsHaveAllDataDialog( - '同时删除其发送的所有钥匙,钥匙删除后不能恢复', (isAllData) { + '同时删除其发送的所有钥匙,钥匙删除后不能恢复', (bool isAllData) { logic.deleteAdministratorRequest( authorizedAdminListItem.uid.toString(), isAllData ? 1 : 0); @@ -169,10 +172,12 @@ class _AuthorizedAdministratorListPageState return GestureDetector( onTap: () async { //高级功能 - var isVip = await Storage.getBool(saveIsVip); + final bool? isVip = await Storage.getBool(saveIsVip); if (isVip == true) { Get.toNamed(Routers.administratorDetailsPage, - arguments: {'itemData': itemData})?.then((value) { + arguments: { + 'itemData': itemData + })?.then((value) { setState(() { logic.pageNo = 1; getHttpData(); @@ -186,7 +191,7 @@ class _AuthorizedAdministratorListPageState height: 100.h, color: Colors.white, child: Row( - children: [ + children: [ SizedBox( width: 30.w, ), @@ -195,14 +200,14 @@ class _AuthorizedAdministratorListPageState Expanded( child: Column( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ Row( mainAxisAlignment: MainAxisAlignment.start, - children: [ + children: [ SizedBox( width: 1.sw - 110.w - 100.w, child: Row( - children: [ + children: [ Flexible( child: Text(itemData.name ?? '', maxLines: 1, @@ -224,7 +229,7 @@ class _AuthorizedAdministratorListPageState SizedBox(height: 5.h), Row( mainAxisAlignment: MainAxisAlignment.start, - children: [ + children: [ Text( logic.getUseDateStr(itemData), style: TextStyle( diff --git a/lib/network/api_provider.dart b/lib/network/api_provider.dart index c2182fa6..feebd5f6 100755 --- a/lib/network/api_provider.dart +++ b/lib/network/api_provider.dart @@ -591,7 +591,7 @@ class ApiProvider extends BaseProvider { jsonEncode({'uid': uid, 'includeUnderlings': includeUnderlings})); Future updateAdministrator(String uid, String keyName, - String endDate, String startDate, String remoteEnable) => + String endDate, String startDate, int isOnlyManageSelf) => post( updateAdministratorURL.toUrl, jsonEncode({ @@ -599,7 +599,7 @@ class ApiProvider extends BaseProvider { 'keyName': keyName, 'endDate': endDate, 'startDate': startDate, - 'remoteEnable': remoteEnable + 'isOnlyManageSelf': isOnlyManageSelf })); // 设置授权管理员 @@ -1575,7 +1575,8 @@ class ApiProvider extends BaseProvider { String startDate, String userid, String countryCode, - String usernameType) => + String usernameType, + int isOnlyManageSelf) => post( addAuthorizedAdminURL.toUrl, jsonEncode({ @@ -1588,7 +1589,8 @@ class ApiProvider extends BaseProvider { 'startDate': startDate, 'userid': userid, 'countryCode': countryCode, - 'usernameType': usernameType + 'usernameType': usernameType, + 'isOnlyManageSelf': isOnlyManageSelf })); //退出登录 diff --git a/lib/network/api_repository.dart b/lib/network/api_repository.dart index 9288b3c8..5816084e 100755 --- a/lib/network/api_repository.dart +++ b/lib/network/api_repository.dart @@ -618,13 +618,13 @@ class ApiRepository { //更新授权管理员 Future updateAdministrator( - String uid, - String keyName, - String endDate, - String startDate, - String remoteEnable) async { + {required String uid, + required String keyName, + required String endDate, + required String startDate, + required int isOnlyManageSelf}) async { final res = await apiProvider.updateAdministrator( - uid, keyName, endDate, startDate, remoteEnable); + uid, keyName, endDate, startDate, isOnlyManageSelf); return ElectronicKeyListEntity.fromJson(res.body); } @@ -979,7 +979,8 @@ class ApiRepository { required String startDate, required String userid, required String countryCode, - required String usernameType}) async { + required String usernameType, + required int isOnlyManageSelf}) async { final res = await apiProvider.addAuthorizedAdmin( createUser, endDate, @@ -990,7 +991,8 @@ class ApiRepository { startDate, userid, countryCode, - usernameType); + usernameType, + isOnlyManageSelf); return KeyDetailEntity.fromJson(res.body); } diff --git a/lib/tools/regularExpression.dart b/lib/tools/regularExpression.dart new file mode 100644 index 00000000..da965a43 --- /dev/null +++ b/lib/tools/regularExpression.dart @@ -0,0 +1,14 @@ +class RegularExpression { + bool isPhoneNumber(String input) { + // 手机号正则表达式,这里简化为11位数字 + final RegExp phoneRegExp = RegExp(r'^\d{11}$'); + return phoneRegExp.hasMatch(input); + } + + bool isEmail(String input) { + // 邮箱正则表达式,这里简化为常见格式 + final RegExp emailRegExp = + RegExp(r'^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$'); + return emailRegExp.hasMatch(input); + } +} From f288d7d3aa237d35727962d31c0e231314949ea1 Mon Sep 17 00:00:00 2001 From: anfe <448468458@qq.com> Date: Mon, 20 May 2024 18:18:09 +0800 Subject: [PATCH 21/44] =?UTF-8?q?feat:=E8=A7=A3=E5=86=B3=20andorid=20?= =?UTF-8?q?=E6=89=AB=E6=8F=8F=E6=85=A2=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .DS_Store | Bin 6148 -> 6148 bytes lib/blue/blue_manage.dart | 122 ++++++-------------------------------- pubspec.yaml | 3 +- 3 files changed, 20 insertions(+), 105 deletions(-) diff --git a/.DS_Store b/.DS_Store index fce4fcc3b0432e5f39e9c8a2564ff8e890f2dd76..0d0d83d942d5a6afc3f49b36da76e38eed24448a 100755 GIT binary patch delta 25 gcmZoMXffDO$IfAHYNn%LVqi8ogUx>PQFeO)0ASz;JOBUy delta 25 gcmZoMXffDO$IfA7VWOj8Y+*1tgUx>PQFeO)0AQ^LIRF3v diff --git a/lib/blue/blue_manage.dart b/lib/blue/blue_manage.dart index 73a9bdab..8b13c78b 100755 --- a/lib/blue/blue_manage.dart +++ b/lib/blue/blue_manage.dart @@ -179,18 +179,27 @@ class BlueManage { /// 开始指定设备名称的扫描蓝牙设备 Future startScanSingle(String deviceName, int timeout, ScanDevicesCallBack scanDevicesCallBack) async { + final DateTime start = DateTime.now(); FlutterBluePlus.isSupported.then((bool isAvailable) async { if (isAvailable) { if (_adapterState == BluetoothAdapterState.on) { try { - FlutterBluePlus.startScan(timeout: Duration(seconds: timeout)); + //android 扫描比较慢,取样只要 8 分之一 + final int divisor = Platform.isAndroid ? 8 : 1; + FlutterBluePlus.startScan( + continuousDivisor: divisor, + continuousUpdates: true, + timeout: Duration(seconds: timeout)); final Completer completer = Completer(); final StreamSubscription> subscription = FlutterBluePlus.scanResults.listen((List results) { final bool isExit = results.any((ScanResult element) => (element.device.platformName == deviceName) || (element.advertisementData.advName == deviceName)); - AppLog.log('扫描到的设备数:${results.length} 是否查找到 $isExit'); + final int milliseconds = DateTime.now().millisecondsSinceEpoch - + start.millisecondsSinceEpoch; + AppLog.log( + '扫描到的设备数:${results.length} 是否查找到 $isExit 以查找$milliseconds毫秒'); if (isExit) { for (final ScanResult scanResult in results) { if (((scanResult.advertisementData.serviceUuids.isNotEmpty @@ -214,6 +223,7 @@ class BlueManage { } } } + completer.complete(); } }, onError: (e) { @@ -332,7 +342,8 @@ class BlueManage { {bool isAddEquipment = false}) async { FlutterBluePlus.isSupported.then((bool isAvailable) async { if (isAvailable) { - AppLog.log('蓝牙状态 系统蓝牙状态:$_adapterState 蓝牙连接状态:$bluetoothConnectionState'); + AppLog.log( + '蓝牙状态 系统蓝牙状态:$_adapterState 蓝牙连接状态:$bluetoothConnectionState'); if (_adapterState == BluetoothAdapterState.on) { // 蓝牙已开启,可以进行蓝牙操作 if (bluetoothConnectionState != BluetoothConnectionState.connected) { @@ -367,7 +378,7 @@ class BlueManage { element.device.platformName == connectDeviceName || element.advertisementData.advName == connectDeviceName); - if (isAddEquipment == false || isExistDevice == false) { + if (isAddEquipment == false && isExistDevice == false) { //取消缓存直接使用,存在配对场景设备信息会更变 startScanSingle(deviceName, 10, (List scanDevices) { _connectDevice(scanDevices, deviceName, connectStateCallBack, @@ -421,7 +432,7 @@ class BlueManage { } // 重连三次 - final int maxAttempts = 3; + const int maxAttempts = 3; int attempt = 0; while (attempt < maxAttempts) { try { @@ -487,7 +498,8 @@ class BlueManage { List lastTimeData = []; int? dataLen; - _subScribeToCharacteristic(BluetoothCharacteristic characteristic) async { + Future _subScribeToCharacteristic( + BluetoothCharacteristic characteristic) async { final StreamSubscription> subscription = characteristic.onValueReceived.listen((List data) { // AppLog.log("订阅获取的数据:$data"); @@ -530,56 +542,8 @@ class BlueManage { } } }); - -// cleanup: cancel subscription when disconnected bluetoothConnectDevice!.cancelWhenDisconnected(subscription); - -// enable notifications await characteristic.setNotifyValue(true); - - // characteristic.setNotifyValue(true).then((_) { - // AppLog.log("启动对特性的通知。当特性的值发生变化时,设备会发送一个通知"); - // characteristic.lastValueStream.listen((data) { - // AppLog.log("订阅获取的数据:$data"); - // // do something with new value - // if(data == lastTimeData || data.isEmpty){ - // return; - // }else{ - // lastTimeData = data; - // } - // // code to handle incoming data - // // AppLog.log("subscribeToCharacteristic: deviceId = ${characteristic.deviceId} characteristicId =${characteristic.characteristicId}---上报来的数据data = $data"); - // if ((data[0] == 0xEF) && (data[1] == 0x01) && (data[2] == 0xEE) && (data[3] == 0x02)) { - // // 当包有头时 - // // 判断是否需要分包 - // dataLen = data[8] * 256 + data[9]; // 高16位用来指示后面数据块内容的长度 - // // AppLog.log("dataLen1111:$dataLen getDataLength:${data.length}"); - // if (dataLen! + 12 > data.length) { - // // 当前包的长度小于实际的包时 分包添加 不解析 - // allData.addAll(data); - // } else { - // // 当前包的长度小于实际的包时 不分包 解析 - // allData.addAll(data); - // // AppLog.log("dataLen2222:$dataLen getDataLength:${data.length}"); - // CommandReciverManager.appDataReceive(allData); - // // 发送完解析初始化数组 - // allData = []; - // } - // } else { - // // 当包没有头时 是分包的包 直接添加 - // allData.addAll(data); - // // var len = allData[8] * 256 + allData[9]; - // // AppLog.log("dataLen3333:$dataLen"); - // if ((dataLen! + 14) <= allData.length) { - // // AppLog.log("44444数据被解析了"); - // // 当长度小于等于当前包的数据时 直接解析数据 - // CommandReciverManager.appDataReceive(allData); - // // 发送完解析初始化数组 - // allData = []; - // } - // } - // }); - // }); } // 写入 @@ -662,56 +626,6 @@ class BlueManage { // } } - // 写入 - Future writeNull() async { - final List services = - await bluetoothConnectDevice!.discoverServices(); - for (final BluetoothService service in services) { - if (service.uuid == _serviceIdConnect) { - for (final BluetoothCharacteristic characteristic - in service.characteristics) { - if (characteristic.characteristicUuid == _characteristicIdWrite) { - try { - final List valueList = [1]; - AppLog.log('APP写入 writeNull '); - await characteristic.write(valueList); - } on Exception catch (e, s) { - AppLog.log('APP写入失败 writeNull : $e $s'); - rethrow; - } - } - } - } - } - } - - // 读取 - // Future> _readCharacteristic(QualifiedCharacteristic characteristic) async { - // try { - // final result = - // await _flutterReactiveBle!.readCharacteristic(characteristic); - // AppLog.log("readListresult$result"); - // return result; - // } on Exception catch (e, s) { - // AppLog.log( - // 'Error occurred when reading ${characteristic.characteristicId} : $e', - // ); - // rethrow; - // } - // } - - // Future writeCharacteristicWithoutResponse( - // QualifiedCharacteristic characteristic, List value) async { - // try { - // await _flutterReactiveBle! - // .writeCharacteristicWithoutResponse(characteristic, value: value); - // } on Exception catch (e, s) { - // // ignore: avoid_print - // AppLog.log(s); - // rethrow; - // } - // } - // 停止扫描蓝牙设备 Future stopScan() async { try { diff --git a/pubspec.yaml b/pubspec.yaml index ed45adbe..b67320fb 100755 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -51,8 +51,9 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # 1.0.41+2024051705:打包给公司测试 # 1.0.42+2024051801:打包给欧阳回归测试 # 1.0.43+2024052001:打包给公司测试 +# 1.0.44+2024052002:打包给公司测试 -version: 1.0.43+2024052001 +version: 1.0.44+2024052002 environment: sdk: '>=2.12.0 <3.0.0' From 36f872188a639a5328a63b5d00846346f3bb7e42 Mon Sep 17 00:00:00 2001 From: anfe <448468458@qq.com> Date: Mon, 20 May 2024 18:26:57 +0800 Subject: [PATCH 22/44] =?UTF-8?q?feat:=E6=B7=BB=E5=8A=A0=E6=89=93=E5=8C=85?= =?UTF-8?q?=E7=89=88=E6=9C=AC=20=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pubspec.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index b67320fb..be8628b7 100755 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -52,8 +52,9 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # 1.0.42+2024051801:打包给欧阳回归测试 # 1.0.43+2024052001:打包给公司测试 # 1.0.44+2024052002:打包给公司测试 +# 1.0.45+2024052003:打包给公司测试 -version: 1.0.44+2024052002 +version: 1.0.45+2024052003 environment: sdk: '>=2.12.0 <3.0.0' From 3ef9390351315a99e5f28bb209501fd09352a898 Mon Sep 17 00:00:00 2001 From: Daisy <> Date: Tue, 21 May 2024 10:02:55 +0800 Subject: [PATCH 23/44] =?UTF-8?q?1=EF=BC=8C=E6=96=B0=E5=A2=9E=E6=88=91?= =?UTF-8?q?=E7=9A=84-=E6=8E=88=E6=9D=83=E7=AE=A1=E7=90=86=E5=91=98?= =?UTF-8?q?=E6=9B=B4=E6=94=B9=E6=9C=89=E6=95=88=E6=9C=9F=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E5=8F=8A=E6=95=B0=E6=8D=AE=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/appRouters.dart | 5 +- .../electronicKeyDetailChangeDate_page.dart | 1 - .../adminDetailChangeDate_logic.dart | 47 +++++++ .../adminDetailChangeDate_page.dart | 88 +++++++++++++ .../adminDetailChangeDate_state.dart | 34 +++++ .../adminDetailChangeDate_page.dart | 123 ------------------ .../administratorDetails_logic.dart | 33 ++--- .../administratorDetails_page.dart | 18 ++- .../authorizedAdministratorList_logic.dart | 23 ++-- lib/network/api_repository.dart | 11 +- lib/tools/eventBusEventManage.dart | 5 + 11 files changed, 215 insertions(+), 173 deletions(-) create mode 100644 lib/mine/mineSet/authorizedAdministrator/administratorChangeDate/adminDetailChangeDate_logic.dart create mode 100755 lib/mine/mineSet/authorizedAdministrator/administratorChangeDate/adminDetailChangeDate_page.dart create mode 100644 lib/mine/mineSet/authorizedAdministrator/administratorChangeDate/adminDetailChangeDate_state.dart delete mode 100755 lib/mine/mineSet/authorizedAdministrator/administratorDetails/adminDetailChangeDate_page.dart diff --git a/lib/appRouters.dart b/lib/appRouters.dart index f415e1aa..20730494 100755 --- a/lib/appRouters.dart +++ b/lib/appRouters.dart @@ -42,7 +42,7 @@ import 'package:star_lock/mine/about/webviewShow_page.dart'; import 'package:star_lock/mine/mine/safeVerify/safeVerify_page.dart'; import 'package:star_lock/mine/minePersonInfo/minePersonInfoEmail/mineBindPhoneOrEmail_page.dart'; import 'package:star_lock/mine/minePersonInfo/minePersonInfoViewSafetyProblem/minePersonInfoViewSafetyProblem_page.dart'; -import 'package:star_lock/mine/mineSet/authorizedAdministrator/administratorDetails/adminDetailChangeDate_page.dart'; +import 'package:star_lock/mine/mineSet/authorizedAdministrator/administratorChangeDate/adminDetailChangeDate_page.dart'; import 'package:star_lock/mine/mineSet/authorizedAdministrator/administratorDetails/administratorDetails_page.dart'; import 'package:star_lock/mine/mineSet/lockGroup/lockGroupList/lockGroupList_page.dart'; import 'package:star_lock/mine/mineSet/lockUserManage/expireLockList/expireLockManage_page.dart'; @@ -373,7 +373,8 @@ abstract class Routers { static const getDeviceListPage = '/getDeviceListPage'; //设备列表 static const getNameListPage = '/getNameListPage'; //姓名列表 static const authorityManagementPage = '/authorityManagementPage'; //批量授权 - static const massSendLockGroupListPage = '/massSendLockGroupListPage'; //群发锁分组列表 + static const massSendLockGroupListPage = + '/massSendLockGroupListPage'; //群发锁分组列表 static const massSendReceiverPage = '/massSendReceiverPage'; //群发接收人 static const lockUserListPage = '/lockUserListPage'; //锁用户列表 static const administratorDetailsPage = '/administratorDetailsPage'; //管理员详情 diff --git a/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetailChangeDate/electronicKeyDetailChangeDate_page.dart b/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetailChangeDate/electronicKeyDetailChangeDate_page.dart index a04a8fbb..65599936 100755 --- a/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetailChangeDate/electronicKeyDetailChangeDate_page.dart +++ b/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetailChangeDate/electronicKeyDetailChangeDate_page.dart @@ -1,4 +1,3 @@ -import 'package:date_format/date_format.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; diff --git a/lib/mine/mineSet/authorizedAdministrator/administratorChangeDate/adminDetailChangeDate_logic.dart b/lib/mine/mineSet/authorizedAdministrator/administratorChangeDate/adminDetailChangeDate_logic.dart new file mode 100644 index 00000000..1a7b15b1 --- /dev/null +++ b/lib/mine/mineSet/authorizedAdministrator/administratorChangeDate/adminDetailChangeDate_logic.dart @@ -0,0 +1,47 @@ +import 'package:flutter_easyloading/flutter_easyloading.dart'; +import 'package:get/get.dart'; +import 'package:star_lock/mine/mineSet/authorizedAdministrator/administratorChangeDate/adminDetailChangeDate_state.dart'; +import 'package:star_lock/mine/mineSet/authorizedAdministrator/administratorDetails/administratorDetailEntity.dart'; +import 'package:star_lock/network/api_repository.dart'; +import 'package:star_lock/tools/baseGetXController.dart'; +import 'package:star_lock/tools/dateTool.dart'; +import 'package:star_lock/tools/eventBusEventManage.dart'; + +class AdminDetailChangeDateLogic extends BaseGetXController { + AdminDetailChangeDateState state = AdminDetailChangeDateState(); + + //更新管理员信息请求 + Future updateAdministratorRequest() async { + final int beginTimeTimestamp = + DateTool().dateToTimestamp(state.beginTime.value, 1); + final int endTimeTimestamp = + DateTool().dateToTimestamp(state.endTime.value, 1); + if (beginTimeTimestamp > endTimeTimestamp || + beginTimeTimestamp == endTimeTimestamp) { + showToast('失效时间需大于生效时间'.tr); + return; + } + + if (endTimeTimestamp < DateTime.now().millisecondsSinceEpoch) { + showToast('生效时间需大于当前时间'.tr); + return; + } + + final AdministratorDetailEntity entity = await ApiRepository.to + .updateAdministrator( + uid: state.itemData.value.uid.toString(), + endDate: endTimeTimestamp.toString(), + startDate: beginTimeTimestamp.toString(), + keyName: '', + isOnlyManageSelf: + state.itemData.value.onlyManageYouCreatesUser == true ? 1 : 2); + if (entity.errorCode!.codeIsSuccessful) { + EasyLoading.showToast('修改成功', duration: 2000.milliseconds); + eventBus.fire(MineAuthorizedAdminPageRefreshUI()); + Get.back(result: { + 'beginTimeTimestamp': beginTimeTimestamp, + 'endTimeTimestamp': endTimeTimestamp, + }); + } + } +} diff --git a/lib/mine/mineSet/authorizedAdministrator/administratorChangeDate/adminDetailChangeDate_page.dart b/lib/mine/mineSet/authorizedAdministrator/administratorChangeDate/adminDetailChangeDate_page.dart new file mode 100755 index 00000000..e6da7317 --- /dev/null +++ b/lib/mine/mineSet/authorizedAdministrator/administratorChangeDate/adminDetailChangeDate_page.dart @@ -0,0 +1,88 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:get/get.dart'; +import 'package:star_lock/mine/mineSet/authorizedAdministrator/administratorChangeDate/adminDetailChangeDate_logic.dart'; +import 'package:star_lock/mine/mineSet/authorizedAdministrator/administratorChangeDate/adminDetailChangeDate_state.dart'; +import 'package:star_lock/tools/pickers/pickers.dart'; +import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart'; +import 'package:star_lock/tools/pickers/time_picker/model/pduration.dart'; + +import '../../../../../app_settings/app_colors.dart'; +import '../../../../../tools/commonItem.dart'; +import '../../../../../tools/dateTool.dart'; +import '../../../../../tools/titleAppBar.dart'; +import '../../../../../translations/trans_lib.dart'; + +class AdminDetailChangeDatePage extends StatefulWidget { + const AdminDetailChangeDatePage({Key? key}) : super(key: key); + + @override + State createState() => + _AdminDetailChangeDatePageState(); +} + +class _AdminDetailChangeDatePageState extends State { + final AdminDetailChangeDateLogic logic = + Get.put(AdminDetailChangeDateLogic()); + final AdminDetailChangeDateState state = + Get.find().state; + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: AppColors.mainBackgroundColor, + appBar: TitleAppBar( + barTitle: + '${TranslationLoader.lanKeys!.amend!.tr}${TranslationLoader.lanKeys!.periodValidity!.tr}', + haveBack: true, + backgroundColor: AppColors.mainColor, + actionsList: [ + TextButton( + child: Text( + TranslationLoader.lanKeys!.sure!.tr, + style: TextStyle(color: Colors.white, fontSize: 24.sp), + ), + onPressed: logic.updateAdministratorRequest, + ), + ], + ), + body: buildMainUI(), + ); + } + + Widget buildMainUI() { + return Column( + children: [ + Obx(() => CommonItem( + leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr, + rightTitle: state.beginTime.value, + isHaveLine: true, + isHaveDirection: true, + action: () { + final PDuration selectDate = + PDuration.parse(DateTime.tryParse(state.beginTime.value)); + Pickers.showDatePicker(context, + selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) { + setState(() { + state.beginTime.value = DateTool().getYMDHNDateString(p, 1); + }); + }); + })), + Obx(() => CommonItem( + leftTitel: TranslationLoader.lanKeys!.failureTime!.tr, + rightTitle: state.endTime.value, + isHaveDirection: true, + action: () { + final PDuration selectDate = + PDuration.parse(DateTime.tryParse(state.endTime.value)); + Pickers.showDatePicker(context, + selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) { + setState(() { + state.endTime.value = DateTool().getYMDHNDateString(p, 1); + }); + }); + })), + ], + ); + } +} diff --git a/lib/mine/mineSet/authorizedAdministrator/administratorChangeDate/adminDetailChangeDate_state.dart b/lib/mine/mineSet/authorizedAdministrator/administratorChangeDate/adminDetailChangeDate_state.dart new file mode 100644 index 00000000..34846db1 --- /dev/null +++ b/lib/mine/mineSet/authorizedAdministrator/administratorChangeDate/adminDetailChangeDate_state.dart @@ -0,0 +1,34 @@ +import 'package:get/get.dart'; +import 'package:star_lock/mine/mineSet/authorizedAdministrator/authorizedAdministrator/authorizedAdminListEntity.dart'; +import 'package:star_lock/tools/dateTool.dart'; + +class AdminDetailChangeDateState { + AdminDetailChangeDateState() { + final Map map = Get.arguments; + if (map['itemData'] != null) { + itemData.value = map['itemData']; + + keyId.value = itemData.value.keyId!; + + if (itemData.value.startDate == 0 && itemData.value.endDate == 0) { + beginTime.value = DateTool().dateToYMDHNString( + DateTime.now().millisecondsSinceEpoch.toString()); + endTime.value = DateTool().dateToYMDHNString( + DateTime.now().millisecondsSinceEpoch.toString()); + } else { + beginTime.value = + DateTool().dateToYMDHNString(itemData.value.startDate.toString()); + endTime.value = + DateTool().dateToYMDHNString(itemData.value.endDate.toString()); + } + } + } + Rx itemData = AuthorizedAdminListItem().obs; + + var beginTime = ''.obs; // 开始时间 + var endTime = ''.obs; // 结束时间 + + var keyId = 0.obs; + var lockId = 0.obs; + var isOnlyManageSelf = 0.obs; +} diff --git a/lib/mine/mineSet/authorizedAdministrator/administratorDetails/adminDetailChangeDate_page.dart b/lib/mine/mineSet/authorizedAdministrator/administratorDetails/adminDetailChangeDate_page.dart deleted file mode 100755 index fea078a5..00000000 --- a/lib/mine/mineSet/authorizedAdministrator/administratorDetails/adminDetailChangeDate_page.dart +++ /dev/null @@ -1,123 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_easyloading/flutter_easyloading.dart'; -import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:get/get.dart'; -import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart'; -import 'package:star_lock/mine/mineSet/authorizedAdministrator/authorizedAdministrator/authorizedAdminListEntity.dart'; -import 'package:star_lock/network/api_repository.dart'; -import 'package:star_lock/tools/baseGetXController.dart'; -import 'package:star_lock/tools/pickers/pickers.dart'; -import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart'; -import 'package:star_lock/tools/pickers/time_picker/model/pduration.dart'; - -import '../../../../../app_settings/app_colors.dart'; -import '../../../../../tools/commonItem.dart'; -import '../../../../../tools/titleAppBar.dart'; -import '../../../../../translations/trans_lib.dart'; - -class AdminDetailChangeDatePage extends StatefulWidget { - const AdminDetailChangeDatePage({Key? key}) : super(key: key); - - @override - State createState() => - _AdminDetailChangeDatePage(); -} - -class _AdminDetailChangeDatePage extends State { - AuthorizedAdminListItem itemData = AuthorizedAdminListItem(); - - String _selectEffectiveDate = ''; //生效时间 - String _selectFailureDate = ''; //失效时间 - late DateTime _effectiveDateTime; - late DateTime _failureDateTime; - - @override - Widget build(BuildContext context) { - dynamic obj = ModalRoute.of(context)?.settings.arguments; - if (obj != null && (obj['itemData'] != null)) { - itemData = obj['itemData']; - } - - return Scaffold( - backgroundColor: AppColors.mainBackgroundColor, - appBar: TitleAppBar( - barTitle: - "${TranslationLoader.lanKeys!.amend!.tr}${TranslationLoader.lanKeys!.periodValidity!.tr}", - haveBack: true, - backgroundColor: AppColors.mainColor, - actionsList: [ - TextButton( - child: Text( - TranslationLoader.lanKeys!.sure!.tr, - style: TextStyle(color: Colors.white, fontSize: 24.sp), - ), - onPressed: () { - updateAdministratorRequest(); - }, - ), - ], - ), - body: buildMainUI(), - ); - } - - Widget buildMainUI() { - return Column( - children: [ - CommonItem( - leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr, - rightTitle: _selectEffectiveDate, - isHaveLine: true, - isHaveDirection: true, - action: () { - PDuration selectDate = PDuration.parse(_effectiveDateTime); - Pickers.showDatePicker(context, - selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) { - setState(() { - _selectEffectiveDate = - '${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}'; - _effectiveDateTime = DateTime.parse(_selectEffectiveDate); - }); - }); - }), - CommonItem( - leftTitel: TranslationLoader.lanKeys!.failureTime!.tr, - rightTitle: _selectFailureDate, - isHaveDirection: true, - action: () { - PDuration selectDate = PDuration.parse(_failureDateTime); - Pickers.showDatePicker(context, - selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) { - setState(() { - _selectFailureDate = - '${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}'; - _failureDateTime = DateTime.parse(_selectFailureDate); - }); - }); - }), - ], - ); - } - - //更新管理员信息请求 - Future updateAdministratorRequest() async { - final ElectronicKeyListEntity entity = await ApiRepository.to - .updateAdministrator( - uid: itemData.uid.toString(), - endDate: _failureDateTime.millisecondsSinceEpoch.toString(), - startDate: _effectiveDateTime.millisecondsSinceEpoch.toString(), - keyName: '', - isOnlyManageSelf: - itemData.onlyManageYouCreatesUser == true ? 1 : 2); - if (entity.errorCode!.codeIsSuccessful) { - EasyLoading.showToast('修改成功', duration: 2000.milliseconds); - setState(() { - Navigator.pop(context); - }); - } - } - - String intToStr(int v) { - return (v < 10) ? '0$v' : '$v'; - } -} diff --git a/lib/mine/mineSet/authorizedAdministrator/administratorDetails/administratorDetails_logic.dart b/lib/mine/mineSet/authorizedAdministrator/administratorDetails/administratorDetails_logic.dart index 4743fe25..904b5133 100755 --- a/lib/mine/mineSet/authorizedAdministrator/administratorDetails/administratorDetails_logic.dart +++ b/lib/mine/mineSet/authorizedAdministrator/administratorDetails/administratorDetails_logic.dart @@ -31,7 +31,7 @@ class AdministratorDetailsLogic extends BaseGetXController { if (!isChangeName) { isManageCreateUser = state.onlyManageYouCreatesUser.value == true ? 2 : 1; } - final ElectronicKeyListEntity entity = await ApiRepository.to + final AdministratorDetailEntity entity = await ApiRepository.to .updateAdministrator( uid: state.itemData.value.uid.toString(), keyName: isChangeName @@ -147,29 +147,29 @@ class AdministratorDetailsLogic extends BaseGetXController { } //使用期限 - String getUseDateStr(AuthorizedAdminListItem indexEntity) { + String getUseDateStr() { String useDateStr = ''; - if (indexEntity.keyType == XSConstantMacro.keyTypeTime) { + if (state.itemData.value.keyType == XSConstantMacro.keyTypeTime) { //限期 final DateTime startDateStr = - DateTime.fromMillisecondsSinceEpoch(indexEntity.startDate!); + DateTime.fromMillisecondsSinceEpoch(state.itemData.value.startDate!); final DateTime endDateStr = - DateTime.fromMillisecondsSinceEpoch(indexEntity.endDate!); + DateTime.fromMillisecondsSinceEpoch(state.itemData.value.endDate!); useDateStr = '${startDateStr.toLocal().toString().substring(0, 16)}\n${endDateStr.toLocal().toString().substring(0, 16)}'; - } else if (indexEntity.keyType == XSConstantMacro.keyTypeLong) { + } else if (state.itemData.value.keyType == XSConstantMacro.keyTypeLong) { //永久 final DateTime dateStr = - DateTime.fromMillisecondsSinceEpoch(indexEntity.date!); + DateTime.fromMillisecondsSinceEpoch(state.itemData.value.date!); useDateStr = '${dateStr.toLocal().toString().substring(0, 16)}\n${"永久".tr}'; - } else if (indexEntity.keyType == XSConstantMacro.keyTypeOnce) { + } else if (state.itemData.value.keyType == XSConstantMacro.keyTypeOnce) { //单次 final DateTime dateStr = - DateTime.fromMillisecondsSinceEpoch(indexEntity.date!); + DateTime.fromMillisecondsSinceEpoch(state.itemData.value.date!); useDateStr = '${dateStr.toLocal().toString().substring(0, 16)} \n${"单次".tr}'; - } else if (indexEntity.keyType == XSConstantMacro.keyTypeLoop) { + } else if (state.itemData.value.keyType == XSConstantMacro.keyTypeLoop) { //循环 useDateStr = '循环'.tr; } @@ -178,21 +178,8 @@ class AdministratorDetailsLogic extends BaseGetXController { @override void onReady() { - // TODO: implement onReady super.onReady(); administratorDetailRequest(); } - - @override - void onInit() { - // TODO: implement onInit - super.onInit(); - } - - @override - void onClose() { - // TODO: implement onClose - super.onClose(); - } } diff --git a/lib/mine/mineSet/authorizedAdministrator/administratorDetails/administratorDetails_page.dart b/lib/mine/mineSet/authorizedAdministrator/administratorDetails/administratorDetails_page.dart index ee1da87f..ad579644 100755 --- a/lib/mine/mineSet/authorizedAdministrator/administratorDetails/administratorDetails_page.dart +++ b/lib/mine/mineSet/authorizedAdministrator/administratorDetails/administratorDetails_page.dart @@ -67,14 +67,22 @@ class _AdministratorDetailsPageState extends State { CommonItem( leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr, allHeight: 90.h, - rightTitle: logic.getUseDateStr(state.itemData.value), + rightTitle: logic.getUseDateStr(), isHaveDirection: true, - action: () { - Navigator.pushNamed( - context, Routers.adminDetailChangeDatePage, + action: () async { + final data = await Get.toNamed( + Routers.adminDetailChangeDatePage, arguments: { - 'itemData': state.itemData.value + 'itemData': state.itemData.value, }); + if (data != null) { + setState(() { + state.itemData.value.startDate = + data['beginTimeTimestamp']; + state.itemData.value.endDate = data['endTimeTimestamp']; + state.itemData.value.keyType = 2; + }); + } }), Container(height: 10.h), CommonItem( diff --git a/lib/mine/mineSet/authorizedAdministrator/authorizedAdministrator/authorizedAdministratorList_logic.dart b/lib/mine/mineSet/authorizedAdministrator/authorizedAdministrator/authorizedAdministratorList_logic.dart index b18616f5..a9cfb383 100755 --- a/lib/mine/mineSet/authorizedAdministrator/authorizedAdministrator/authorizedAdministratorList_logic.dart +++ b/lib/mine/mineSet/authorizedAdministrator/authorizedAdministrator/authorizedAdministratorList_logic.dart @@ -71,12 +71,13 @@ class AuthorizedAdministratorListLogic extends BaseGetXController { return useDateStr; } - /// 刷新电子钥匙列表 - StreamSubscription? _authorizedAdministratorListPageRefreshUIEvent; - void _authorizedAdministratorListPageRefreshUIAction() { + /// 刷新我的设置-授权管理员列表 + late StreamSubscription _getMineAuthorizedAdminPageRefreshUIEvent; + void _getMineAuthorizedAdminPageRefreshUIEventAction() { // 蓝牙协议通知传输跟蓝牙之外的数据传输类不一样 eventBus - _authorizedAdministratorListPageRefreshUIEvent = - eventBus.on().listen((event) { + _getMineAuthorizedAdminPageRefreshUIEvent = eventBus + .on() + .listen((MineAuthorizedAdminPageRefreshUI event) { pageNo = 1; mockNetworkDataRequest(); }); @@ -84,21 +85,13 @@ class AuthorizedAdministratorListLogic extends BaseGetXController { @override void onReady() { - // TODO: implement onReady super.onReady(); - _authorizedAdministratorListPageRefreshUIAction(); - } - - @override - void onInit() { - // TODO: implement onInit - super.onInit(); + _getMineAuthorizedAdminPageRefreshUIEventAction(); } @override void onClose() { - // TODO: implement onClose super.onClose(); - _authorizedAdministratorListPageRefreshUIEvent?.cancel(); + _getMineAuthorizedAdminPageRefreshUIEvent?.cancel(); } } diff --git a/lib/network/api_repository.dart b/lib/network/api_repository.dart index 099aad41..64818b1f 100755 --- a/lib/network/api_repository.dart +++ b/lib/network/api_repository.dart @@ -421,8 +421,11 @@ class ApiRepository { // 获取锁信息列表 Future getStarLockListInfo( - {required int pageNo, required int pageSize,required bool isUnShowLoading}) async { - final res = await apiProvider.getStarLockListInfo(pageNo, pageSize,isUnShowLoading:isUnShowLoading); + {required int pageNo, + required int pageSize, + required bool isUnShowLoading}) async { + final res = await apiProvider.getStarLockListInfo(pageNo, pageSize, + isUnShowLoading: isUnShowLoading); return LockListInfoEntity.fromJson(res.body); } @@ -617,7 +620,7 @@ class ApiRepository { } //更新授权管理员 - Future updateAdministrator( + Future updateAdministrator( {required String uid, required String keyName, required String endDate, @@ -625,7 +628,7 @@ class ApiRepository { required int isOnlyManageSelf}) async { final res = await apiProvider.updateAdministrator( uid, keyName, endDate, startDate, isOnlyManageSelf); - return ElectronicKeyListEntity.fromJson(res.body); + return AdministratorDetailEntity.fromJson(res.body); } //设置授权管理员 diff --git a/lib/tools/eventBusEventManage.dart b/lib/tools/eventBusEventManage.dart index f6fca01a..bf19c88b 100755 --- a/lib/tools/eventBusEventManage.dart +++ b/lib/tools/eventBusEventManage.dart @@ -137,6 +137,11 @@ class AuthorizedAdminPageRefreshUI { AuthorizedAdminPageRefreshUI(); } +/// 刷新我的设置-授权管理员列表 +class MineAuthorizedAdminPageRefreshUI { + MineAuthorizedAdminPageRefreshUI(); +} + /// 刷新门锁日志列表 class DoorLockLogListRefreshUI { DateTime getDoorLockLogTime; From 0b9583723e1268982f78db5b4bf737bef9781415 Mon Sep 17 00:00:00 2001 From: anfe <448468458@qq.com> Date: Tue, 21 May 2024 11:05:10 +0800 Subject: [PATCH 24/44] =?UTF-8?q?feat:=E4=BC=98=E5=8C=96=E8=93=9D=E7=89=99?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E9=80=9F=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/blue/blue_manage.dart | 15 +- .../lockDetail/lockDetail_logic.dart | 367 +++++++++--------- pubspec.yaml | 3 +- 3 files changed, 207 insertions(+), 178 deletions(-) diff --git a/lib/blue/blue_manage.dart b/lib/blue/blue_manage.dart index 8b13c78b..f39cd228 100755 --- a/lib/blue/blue_manage.dart +++ b/lib/blue/blue_manage.dart @@ -189,6 +189,8 @@ class BlueManage { FlutterBluePlus.startScan( continuousDivisor: divisor, continuousUpdates: true, + // withServiceData:[ServiceDataFilter()], + withKeywords: [deviceName], timeout: Duration(seconds: timeout)); final Completer completer = Completer(); final StreamSubscription> subscription = @@ -374,9 +376,7 @@ class BlueManage { connectDeviceName = deviceName; final List devicesList = scanDevices; - final bool isExistDevice = scanDevices.any((ScanResult element) => - element.device.platformName == connectDeviceName || - element.advertisementData.advName == connectDeviceName); + final bool isExistDevice = isExistScanDevices(connectDeviceName); if (isAddEquipment == false && isExistDevice == false) { //取消缓存直接使用,存在配对场景设备信息会更变 @@ -390,6 +390,15 @@ class BlueManage { } } + //查找缓存里面是否有设备 + bool isExistScanDevices(String connectDeviceName){ + final bool isExistDevice = scanDevices.any((ScanResult element) => + element.device.platformName == connectDeviceName || + element.advertisementData.advName == connectDeviceName); + return isExistDevice; + } + + Future _connectDevice(List devicesList, String deviceName, ConnectStateCallBack connectStateCallBack, {bool isAddEquipment = false}) async { diff --git a/lib/main/lockDetail/lockDetail/lockDetail_logic.dart b/lib/main/lockDetail/lockDetail/lockDetail_logic.dart index 33a21cd5..d8d2c5fc 100755 --- a/lib/main/lockDetail/lockDetail/lockDetail_logic.dart +++ b/lib/main/lockDetail/lockDetail/lockDetail_logic.dart @@ -37,17 +37,17 @@ class LockDetailLogic extends BaseGetXController { void initReplySubscription() { state.replySubscription = EventBusManager().eventBus!.on().listen((Reply reply) async { - // 开门 - if (reply is OpenDoorReply && state.ifCurrentScreen.value == true) { - _replyOpenLock(reply); - } + // 开门 + if (reply is OpenDoorReply && state.ifCurrentScreen.value == true) { + _replyOpenLock(reply); + } - // 开完锁之后上传记录 - if (reply is SenderReferEventRecordTimeReply && - state.ifCurrentScreen.value == true) { - _replyReferEventRecordTime(reply); - } - }); + // 开完锁之后上传记录 + if (reply is SenderReferEventRecordTimeReply && + state.ifCurrentScreen.value == true) { + _replyReferEventRecordTime(reply); + } + }); } // 开门数据解析 @@ -56,8 +56,8 @@ class LockDetailLogic extends BaseGetXController { switch (status) { case 0x00: - //成功 - // _showFullScreenOverlay(Get.context!); + //成功 + // _showFullScreenOverlay(Get.context!); cancelBlueConnetctToastTimer(); state.iSClosedUnlockSuccessfulPopup.value = true; @@ -65,10 +65,10 @@ class LockDetailLogic extends BaseGetXController { // 如果没有点击关闭弹窗,3秒后自动关闭 state.closedUnlockSuccessfulTimer = Timer.periodic(3.seconds, (Timer timer) { - state.iSClosedUnlockSuccessfulPopup.value = false; - timer.cancel(); - eventBus.fire(RefreshLockDetailInfoDataEvent()); - }); + state.iSClosedUnlockSuccessfulPopup.value = false; + timer.cancel(); + eventBus.fire(RefreshLockDetailInfoDataEvent()); + }); // 电量 final int power = reply.data[7]; @@ -86,14 +86,14 @@ class LockDetailLogic extends BaseGetXController { resetOpenDoorState(); break; case 0x06: - //无权限 + //无权限 final List? privateKey = - await Storage.getStringList(saveBluePrivateKey); + await Storage.getStringList(saveBluePrivateKey); final List getPrivateKeyList = - changeStringListToIntList(privateKey!); + changeStringListToIntList(privateKey!); final List? signKey = - await Storage.getStringList(saveBlueSignKey); + await Storage.getStringList(saveBlueSignKey); final List signKeyDataList = changeStringListToIntList(signKey!); final List tokenData = reply.data.sublist(2, 6); @@ -113,14 +113,14 @@ class LockDetailLogic extends BaseGetXController { ); break; case 0x16: - // 正在开锁中... + // 正在开锁中... resetOpenDoorState(); showToast('正在开锁中...'.tr, something: () { cancelBlueConnetctToastTimer(); }); break; case 0x0d: - // 钥匙无效 + // 钥匙无效 showToast('钥匙无效'.tr); // state.animationController!.stop(); resetOpenDoorState(); @@ -128,7 +128,7 @@ class LockDetailLogic extends BaseGetXController { BlueManage().disconnect(); break; case 0x0b: - // 钥匙无效 + // 钥匙无效 showToast('钥匙过期'.tr); resetOpenDoorState(); @@ -136,7 +136,7 @@ class LockDetailLogic extends BaseGetXController { BlueManage().disconnect(); break; case 0x0a: - // 钥匙不存在 + // 钥匙不存在 showToast('钥匙不存在'); resetOpenDoorState(); @@ -144,7 +144,7 @@ class LockDetailLogic extends BaseGetXController { BlueManage().disconnect(); break; case 0x0c: - // 钥匙数量已到上限 + // 钥匙数量已到上限 showToast('钥匙数量已到上限'); resetOpenDoorState(); @@ -152,7 +152,7 @@ class LockDetailLogic extends BaseGetXController { BlueManage().disconnect(); break; case 0x0e: - // 钥匙已存在 + // 钥匙已存在 showToast('钥匙已存在'); resetOpenDoorState(); @@ -160,7 +160,7 @@ class LockDetailLogic extends BaseGetXController { BlueManage().disconnect(); break; case 0x0f: - // 用户已存在 + // 用户已存在 showToast('用户已存在'); resetOpenDoorState(); @@ -168,7 +168,7 @@ class LockDetailLogic extends BaseGetXController { BlueManage().disconnect(); break; default: - //失败 + //失败 AppLog.log('开锁失败'); // state.animationController!.stop(); resetOpenDoorState(); @@ -190,67 +190,67 @@ class LockDetailLogic extends BaseGetXController { Future _replyReferEventRecordTime(Reply reply) async { final int status = reply.data[2]; switch (status) { - case 0x00: - //成功 - final int dataLength = (reply.data[5] << 8) + reply.data[6]; - // AppLog.log("dataLength:$dataLength"); - if (dataLength > 0) { - reply.data.removeRange(0, 7); - // 把得到的数据按17个字节分割成数组 然后塞进一个新的数组里面 - if (reply.data.length < 17) { - return; - } - final List> getList = splitList(reply.data, 17); - // AppLog.log("getList:$getList"); - final List uploadList = []; - for (int i = 0; i < getList.length; i++) { - final List indexList = getList[i]; - // AppLog.log("indexList:$indexList"); - final Map indexMap = {}; - indexMap['type'] = indexList[0].toString(); - int operateDate = 0; - if (indexList[0] == 2) { - final List passwordData = reply.data.sublist(7, 17); - final String password = utf8String(passwordData); - indexMap['user'] = password.toString(); - } else { - final int userNo = (indexList[1] * 256) + indexList[2]; - indexMap['user'] = userNo.toString(); - } + case 0x00: + //成功 + final int dataLength = (reply.data[5] << 8) + reply.data[6]; + // AppLog.log("dataLength:$dataLength"); + if (dataLength > 0) { + reply.data.removeRange(0, 7); + // 把得到的数据按17个字节分割成数组 然后塞进一个新的数组里面 + if (reply.data.length < 17) { + return; + } + final List> getList = splitList(reply.data, 17); + // AppLog.log("getList:$getList"); + final List uploadList = []; + for (int i = 0; i < getList.length; i++) { + final List indexList = getList[i]; + // AppLog.log("indexList:$indexList"); + final Map indexMap = {}; + indexMap['type'] = indexList[0].toString(); + int operateDate = 0; + if (indexList[0] == 2) { + final List passwordData = reply.data.sublist(7, 17); + final String password = utf8String(passwordData); + indexMap['user'] = password.toString(); + } else { + final int userNo = (indexList[1] * 256) + indexList[2]; + indexMap['user'] = userNo.toString(); + } - indexMap['success'] = '1'; + indexMap['success'] = '1'; - final int time = ((0xff & indexList[(3)]) << 24 | - (0xff & indexList[4]) << 16 | - (0xff & indexList[5]) << 8 | - (0xFF & indexList[6])); - operateDate = time * 1000; - indexMap['date'] = '$operateDate'; - uploadList.add(indexMap); + final int time = ((0xff & indexList[(3)]) << 24 | + (0xff & indexList[4]) << 16 | + (0xff & indexList[5]) << 8 | + (0xFF & indexList[6])); + operateDate = time * 1000; + indexMap['date'] = '$operateDate'; + uploadList.add(indexMap); - if (i == getList.length - 1) { - //设置最后的时间戳 - state.operateDate = operateDate; - } - } - lockRecordUploadData(uploadList); + if (i == getList.length - 1) { + //设置最后的时间戳 + state.operateDate = operateDate; + } + } + lockRecordUploadData(uploadList); - if (dataLength == state.logCountPage) { - senderReferEventRecordTime(); - } else { - await BlueManage().disconnect(); - } - } - break; - case 0x06: - //无权限 - BlueManage().disconnect(); - cancelBlueConnetctToastTimer(); - break; - default: - BlueManage().disconnect(); - cancelBlueConnetctToastTimer(); - break; + if (dataLength == state.logCountPage) { + senderReferEventRecordTime(); + } else { + await BlueManage().disconnect(); + } + } + break; + case 0x06: + //无权限 + BlueManage().disconnect(); + cancelBlueConnetctToastTimer(); + break; + default: + BlueManage().disconnect(); + cancelBlueConnetctToastTimer(); + break; } } @@ -262,7 +262,7 @@ class LockDetailLogic extends BaseGetXController { BlueManage().disconnect(); }); final List? privateKey = - await Storage.getStringList(saveBluePrivateKey); + await Storage.getStringList(saveBluePrivateKey); final List getPrivateKeyList = changeStringListToIntList(privateKey!); final List? signKey = await Storage.getStringList(saveBlueSignKey); @@ -274,28 +274,28 @@ class LockDetailLogic extends BaseGetXController { BlueManage() .bludSendData(state.keyInfos.value.bluetooth!.bluetoothDeviceName!, (BluetoothConnectionState deviceConnectionState) async { - if (deviceConnectionState == BluetoothConnectionState.connected) { - IoSenderManage.senderOpenLock( - keyID: BlueManage().connectDeviceName, - userID: await Storage.getUid(), - openMode: state.openDoorModel, - openTime: getUTCNetTime(), - onlineToken: state.lockNetToken, - token: getTokenList, - needAuthor: 1, - signKey: signKeyDataList, - privateKey: getPrivateKeyList, - ); - } else if (deviceConnectionState == - BluetoothConnectionState.disconnected) { - cancelBlueConnetctToastTimer(); - if (state.ifCurrentScreen.value == true) { - showBlueConnetctToast(); - } + if (deviceConnectionState == BluetoothConnectionState.connected) { + IoSenderManage.senderOpenLock( + keyID: BlueManage().connectDeviceName, + userID: await Storage.getUid(), + openMode: state.openDoorModel, + openTime: getUTCNetTime(), + onlineToken: state.lockNetToken, + token: getTokenList, + needAuthor: 1, + signKey: signKeyDataList, + privateKey: getPrivateKeyList, + ); + } else if (deviceConnectionState == + BluetoothConnectionState.disconnected) { + cancelBlueConnetctToastTimer(); + if (state.ifCurrentScreen.value == true) { + showBlueConnetctToast(); + } - resetOpenDoorState(); - } - }); + resetOpenDoorState(); + } + }); } // 查询事件记录(时间查询) @@ -307,49 +307,54 @@ class LockDetailLogic extends BaseGetXController { BlueManage().disconnect(); }); BlueManage().bludSendData(BlueManage().connectDeviceName, - (BluetoothConnectionState connectionState) async { - if (connectionState == BluetoothConnectionState.connected) { - final List? privateKey = + (BluetoothConnectionState connectionState) async { + if (connectionState == BluetoothConnectionState.connected) { + final List? privateKey = await Storage.getStringList(saveBluePrivateKey); - final List getPrivateKeyList = + final List getPrivateKeyList = changeStringListToIntList(privateKey!); - final List? token = await Storage.getStringList(saveBlueToken); - final List getTokenList = changeStringListToIntList(token!); + final List? token = await Storage.getStringList( + saveBlueToken); + final List getTokenList = changeStringListToIntList(token!); - final List? publicKey = + final List? publicKey = await Storage.getStringList(saveBluePublicKey); - final List getPublicKeyList = + final List getPublicKeyList = changeStringListToIntList(publicKey!); - IoSenderManage.senderReferEventRecordTimeCommand( - keyID: BlueManage().connectDeviceName, - userID: await Storage.getUid(), - logsCount: state.logCountPage, - // time:DateTime.now().millisecondsSinceEpoch~/1000, - time: state.operateDate, - token: getTokenList, - needAuthor: 1, - publicKey: getPublicKeyList, - privateKey: getPrivateKeyList, - ); - } - }); + IoSenderManage.senderReferEventRecordTimeCommand( + keyID: BlueManage().connectDeviceName, + userID: await Storage.getUid(), + logsCount: state.logCountPage, + // time:DateTime.now().millisecondsSinceEpoch~/1000, + time: state.operateDate, + token: getTokenList, + needAuthor: 1, + publicKey: getPublicKeyList, + privateKey: getPrivateKeyList, + ); + } + }); } // 从服务器获取锁的时间 开锁时传入 void getServerDatetime() async { final GetServerDatetimeEntity entity = - await ApiRepository.to.getServerDatetimeData(); + await ApiRepository.to.getServerDatetimeData(); if (entity.errorCode!.codeIsSuccessful) { state.differentialTime = entity.data!.date! ~/ 1000 - - DateTime.now().millisecondsSinceEpoch ~/ 1000; + DateTime + .now() + .millisecondsSinceEpoch ~/ 1000; // AppLog.log("entity.data!.date! ~/ 1000:${entity.data!.date! ~/ 1000} DateTime.now().millisecondsSinceEpoch ~/ 1000:${DateTime.now().millisecondsSinceEpoch ~/ 1000} 服务器时间差:${state.differentialTime}"); } } int getUTCNetTime() { - return DateTime.now().millisecondsSinceEpoch ~/ 1000 + + return DateTime + .now() + .millisecondsSinceEpoch ~/ 1000 + state.differentialTime; } @@ -375,11 +380,11 @@ class LockDetailLogic extends BaseGetXController { Future uploadElectricQuantityRequest() async { final KeyOperationRecordEntity entity = await ApiRepository.to .uploadElectricQuantity( - electricQuantity: state.electricQuantity.value.toString(), - electricQuantityStandby: - state.electricQuantityStandby.value.toString(), - lockId: state.keyInfos.value.lockId.toString(), - isUnShowLoading: true); + electricQuantity: state.electricQuantity.value.toString(), + electricQuantityStandby: + state.electricQuantityStandby.value.toString(), + lockId: state.keyInfos.value.lockId.toString(), + isUnShowLoading: true); if (entity.errorCode!.codeIsSuccessful) { SchedulerBinding.instance.addPostFrameCallback((_) { eventBus.fire(RefreshLockListInfoDataEvent(isUnShowLoading: true)); @@ -390,8 +395,8 @@ class LockDetailLogic extends BaseGetXController { // 查询锁记录最后时间 void getLockRecordLastUploadDataTime() async { final LockOperatingRecordGetLastRecordTimeEntity entity = - await ApiRepository.to.getLockRecordLastUploadDataTime( - lockId: state.keyInfos.value.lockId.toString()); + await ApiRepository.to.getLockRecordLastUploadDataTime( + lockId: state.keyInfos.value.lockId.toString()); if (entity.errorCode!.codeIsSuccessful) { state.operateDate = entity.data!.operateDate! ~/ 1000; senderReferEventRecordTime(); @@ -402,7 +407,7 @@ class LockDetailLogic extends BaseGetXController { Future lockRecordUploadData(List list) async { final KeyOperationRecordEntity entity = await ApiRepository.to .lockRecordUploadData( - lockId: state.keyInfos.value.lockId.toString(), records: list); + lockId: state.keyInfos.value.lockId.toString(), records: list); if (entity.errorCode!.codeIsSuccessful) { // mockNetworkDataRequest(); AppLog.log( @@ -418,7 +423,7 @@ class LockDetailLogic extends BaseGetXController { void deletKeyData() async { final ElectronicKeyListEntity entity = await ApiRepository.to .deleteElectronicKey( - keyId: state.keyInfos.value.keyId.toString(), includeUnderlings: 0); + keyId: state.keyInfos.value.keyId.toString(), includeUnderlings: 0); if (entity.errorCode!.codeIsSuccessful) { BlueManage().connectDeviceMacAddress = ''; SchedulerBinding.instance.addPostFrameCallback((_) { @@ -435,50 +440,51 @@ class LockDetailLogic extends BaseGetXController { eventBus .on() .listen((LockSetChangeSetRefreshLockDetailWithType event) { - if (event.type == 0) { - // 0考勤 - state.isAttendance.value = int.parse(event.setResult); - state.keyInfos.value.lockSetting!.attendance = - int.parse(event.setResult); - } else if (event.type == 1) { - // 1 开锁时是否需联网 - state.isOpenLockNeedOnline.value = int.parse(event.setResult); - state.keyInfos.value.lockSetting!.appUnlockOnline = - int.parse(event.setResult); - state.lockNetToken = ''; // 改变开锁时是否联网状态的时候清空token - } else if (event.type == 2) { - // 2 常开模式 - state.isOpenPassageMode.value = int.parse(event.setResult); - state.keyInfos.value.passageMode = int.parse(event.setResult); - } else if (event.type == 3) { - // 3 修改了锁名字 - state.lockAlias.value = event.setResult; - state.keyInfos.value.lockAlias = event.setResult; - Storage.setString(saveLockAlias, state.lockAlias.value); - } else if (event.type == 4) { - // 4 更新了电量 - state.electricQuantity.value = int.parse(event.setResult); - state.keyInfos.value.electricQuantity = int.parse(event.setResult); - } else if (event.type == 5) { - // 5 远程开锁 - state.keyInfos.value.lockSetting!.remoteUnlock = - int.parse(event.setResult); - } - CommonDataManage().currentKeyInfo = state.keyInfos.value; - eventBus.fire(RefreshLockDetailInfoDataEvent()); - }); + if (event.type == 0) { + // 0考勤 + state.isAttendance.value = int.parse(event.setResult); + state.keyInfos.value.lockSetting!.attendance = + int.parse(event.setResult); + } else if (event.type == 1) { + // 1 开锁时是否需联网 + state.isOpenLockNeedOnline.value = int.parse(event.setResult); + state.keyInfos.value.lockSetting!.appUnlockOnline = + int.parse(event.setResult); + state.lockNetToken = ''; // 改变开锁时是否联网状态的时候清空token + } else if (event.type == 2) { + // 2 常开模式 + state.isOpenPassageMode.value = int.parse(event.setResult); + state.keyInfos.value.passageMode = int.parse(event.setResult); + } else if (event.type == 3) { + // 3 修改了锁名字 + state.lockAlias.value = event.setResult; + state.keyInfos.value.lockAlias = event.setResult; + Storage.setString(saveLockAlias, state.lockAlias.value); + } else if (event.type == 4) { + // 4 更新了电量 + state.electricQuantity.value = int.parse(event.setResult); + state.keyInfos.value.electricQuantity = int.parse(event.setResult); + } else if (event.type == 5) { + // 5 远程开锁 + state.keyInfos.value.lockSetting!.remoteUnlock = + int.parse(event.setResult); + } + CommonDataManage().currentKeyInfo = state.keyInfos.value; + eventBus.fire(RefreshLockDetailInfoDataEvent()); + }); } String getKeyStatusTextAndShow() { String text = ''; if (state.keyInfos.value.keyStatus == - XSConstantMacro.keyStatusWaitIneffective || + XSConstantMacro.keyStatusWaitIneffective || state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusFrozen || state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusExpired || state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusDeleted || state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusReset) { text = - "${"你的钥匙".tr}${XSConstantMacro.getKeyStatusStr(state.keyInfos.value.keyStatus!)}"; + "${"你的钥匙".tr}${XSConstantMacro.getKeyStatusStr( + state.keyInfos.value.keyStatus!)}"; } else { text = state.isOpenPassageMode.value == 1 ? '常开模式启动!长按闭锁'.tr @@ -510,5 +516,18 @@ class LockDetailLogic extends BaseGetXController { await PermissionDialog.request(Permission.location); await PermissionDialog.requestBluetooth(); + + final String connectDeviceName = state.keyInfos.value.bluetooth! + .bluetoothDeviceName!; + if (!BlueManage().isExistScanDevices(connectDeviceName)) { + BlueManage().startScanSingle( + connectDeviceName, 15, (List p0) => null); + } + } + + @override + void onInit() { + super.onInit(); + } } diff --git a/pubspec.yaml b/pubspec.yaml index be8628b7..e4da4259 100755 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -53,8 +53,9 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # 1.0.43+2024052001:打包给公司测试 # 1.0.44+2024052002:打包给公司测试 # 1.0.45+2024052003:打包给公司测试 +# 1.0.46+2024052004:打包给公司测试 -version: 1.0.45+2024052003 +version: 1.0.46+2024052004 environment: sdk: '>=2.12.0 <3.0.0' From dd48a36746afae1136c137eb0853c9def6291f05 Mon Sep 17 00:00:00 2001 From: Daisy <> Date: Tue, 21 May 2024 11:07:31 +0800 Subject: [PATCH 25/44] =?UTF-8?q?=E4=BF=AE=E5=A4=8DN=E5=A4=A9=E6=9C=AA?= =?UTF-8?q?=E5=BC=80=E9=97=A8=E4=BB=A5=E5=8F=8A=E6=B7=BB=E5=8A=A0=E5=AE=B6?= =?UTF-8?q?=E4=BA=BAbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../addFamily/addFamily_logic.dart | 64 ++++++++++--------- .../messageWarn/addFamily/addFamily_page.dart | 39 +++++------ .../nDaysUnopened/nDaysUnopened_logic.dart | 41 ++++++------ .../nDaysUnopened/nDaysUnopened_page.dart | 41 ++++++------ .../nDaysUnopened/nDaysUnopened_state.dart | 30 ++++----- .../value_added_services_real_name_page.dart | 31 +++++---- 6 files changed, 131 insertions(+), 115 deletions(-) diff --git a/lib/main/lockDetail/messageWarn/addFamily/addFamily_logic.dart b/lib/main/lockDetail/messageWarn/addFamily/addFamily_logic.dart index 878c7bb2..1f3ddf37 100755 --- a/lib/main/lockDetail/messageWarn/addFamily/addFamily_logic.dart +++ b/lib/main/lockDetail/messageWarn/addFamily/addFamily_logic.dart @@ -1,9 +1,6 @@ -import 'package:flutter/cupertino.dart'; -import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; -import 'package:star_lock/appRouters.dart'; -import 'package:star_lock/app_settings/app_colors.dart'; import 'package:star_lock/main/lockDetail/messageWarn/addFamily/addFamily_state.dart'; +import 'package:star_lock/main/lockDetail/messageWarn/msgNotification/msgNotification/msgNotification_entity.dart'; import 'package:star_lock/main/lockDetail/messageWarn/msgNotification/openDoorNotify/openDoorNotify_entity.dart'; import 'package:star_lock/main/lockDetail/messageWarn/notificationMode/notificationMode_data.dart'; import 'package:star_lock/network/api_repository.dart'; @@ -13,17 +10,24 @@ class AddFamilyLogic extends BaseGetXController { final AddFamilyState state = AddFamilyState(); //添加开门通知 - void addLockNoticeSetting() async { - var entity = await ApiRepository.to.addLockNoticeSetting( + Future addLockNoticeSetting() async { + final MsgNotificationEntity entity = + await ApiRepository.to.addLockNoticeSetting( lockId: state.getLockId.value, noticeType: 10, settingValue: { 'openDoorId': state.lockUserKeys.value.currentOpenDoorID, 'openDoorType': state.lockUserKeys.value.currentKeyType, 'remark': state.lockUserKeys.value.currentKeyName ?? '', - 'noticeWay': [ - {'type': 'mail', 'accounts': getEmailAndSMSAccountList(true)}, - {'type': 'sms', 'accounts': getEmailAndSMSAccountList(false)} + 'noticeWay': >[ + { + 'type': 'mail', + 'accounts': getEmailAndSMSAccountList(true) + }, + { + 'type': 'sms', + 'accounts': getEmailAndSMSAccountList(false) + } ] }, ); @@ -34,8 +38,9 @@ class AddFamilyLogic extends BaseGetXController { } //更新开门通知 - void updateLockNoticeSetting() async { - var entity = await ApiRepository.to.updateLockNoticeSettingAccount( + Future updateLockNoticeSetting() async { + final OpenDoorNotifyEntity entity = + await ApiRepository.to.updateLockNoticeSettingAccount( lockNoticeSettingAccountId: state.familyData.value.id!, settingValue: { 'openDoorId': state.familyData.value.settingValue!.openDoorId!, @@ -52,8 +57,9 @@ class AddFamilyLogic extends BaseGetXController { } //删除开门通知 - void deleteLockNoticeSetting() async { - var entity = await ApiRepository.to.deleteLockNoticeSettingAccount( + Future deleteLockNoticeSetting() async { + final OpenDoorNotifyEntity entity = + await ApiRepository.to.deleteLockNoticeSettingAccount( lockNoticeSettingAccountId: state.familyData.value.id!, ); if (entity.errorCode!.codeIsSuccessful) { @@ -64,14 +70,14 @@ class AddFamilyLogic extends BaseGetXController { //获取到家人信息的请求数组 List getEmailAndSMSAccountList(bool isEmail) { - List list = []; + final List list = []; List accountList = []; isEmail ? accountList = state.emailReceiverList.value : accountList = state.phoneReceiverList.value; for (int i = 0; i < accountList.length; i++) { - MsgNoticeModeData item = accountList[i]; - Map map = {}; + final MsgNoticeModeData item = accountList[i]; + final Map map = {}; map['countryCode'] = isEmail ? 0 : item.countryCode; map['account'] = isEmail ? item.receiveEmail : item.receivePhone; list.add(map); @@ -83,9 +89,9 @@ class AddFamilyLogic extends BaseGetXController { String emailListStr = ''; if (val['emailReceiverList'] != null) { state.emailReceiverList.value = val['emailReceiverList']; - List emailReceiverList = state.emailReceiverList.value; + final List emailReceiverList = state.emailReceiverList.value; for (int i = 0; i < emailReceiverList.length; i++) { - MsgNoticeModeData item = emailReceiverList[i]; + final MsgNoticeModeData item = emailReceiverList[i]; emailListStr += item.receiveEmail; // 检查是否为最后一个元素 if (i < emailReceiverList.length - 1) { @@ -101,9 +107,9 @@ class AddFamilyLogic extends BaseGetXController { if (val['phoneReceiverList'] != null) { state.phoneReceiverList.value = val['phoneReceiverList']; - List phoneReceiverList = state.phoneReceiverList.value; + final List phoneReceiverList = state.phoneReceiverList.value; for (int i = 0; i < phoneReceiverList.length; i++) { - MsgNoticeModeData item = phoneReceiverList[i]; + final MsgNoticeModeData item = phoneReceiverList[i]; phoneListStr += item.receivePhone; // 检查是否为最后一个元素 if (i < phoneReceiverList.length - 1) { @@ -128,7 +134,7 @@ class AddFamilyLogic extends BaseGetXController { //当前钥匙类型 1:电子钥匙 2:密码钥匙 3:指纹钥匙 4:卡钥匙 5:人脸钥匙 String getKeyTypeStr() { - int keyType = state.familyData.value.settingValue!.openDoorType!; + final int keyType = state.familyData.value.settingValue!.openDoorType!; switch (keyType) { case 1: return '电子钥匙'; @@ -147,24 +153,24 @@ class AddFamilyLogic extends BaseGetXController { //根据列表返回值得到邮箱、手机列表 Map> getAccountsMap() { - List mailAccounts = []; - List smsAccounts = []; + final List mailAccounts = []; + final List smsAccounts = []; if (state.familyData.value.settingValue != null) { - for (NoticeWay item + for (final NoticeWay item in state.familyData.value.settingValue!.noticeWayList!) { if (item.type == 'mail' && item.accounts != null) { - for (Accounts account in item.accounts!) { + for (final Accounts account in item.accounts!) { if (account.account != null) { - MsgNoticeModeData msgNoticeModeData = MsgNoticeModeData(); + final MsgNoticeModeData msgNoticeModeData = MsgNoticeModeData(); msgNoticeModeData.receiveEmail = account.account!; mailAccounts.add(msgNoticeModeData); } } } else if (item.type == 'sms' && item.accounts != null) { - for (Accounts account in item.accounts!) { + for (final Accounts account in item.accounts!) { if (account.account != null && account.countryCode != null) { - MsgNoticeModeData msgNoticeModeData = MsgNoticeModeData(); + final MsgNoticeModeData msgNoticeModeData = MsgNoticeModeData(); msgNoticeModeData.receivePhone = account.account!; msgNoticeModeData.countryCode = account.countryCode!; smsAccounts.add(msgNoticeModeData); @@ -174,7 +180,7 @@ class AddFamilyLogic extends BaseGetXController { } } - return { + return >{ 'emailReceiverList': mailAccounts, 'phoneReceiverList': smsAccounts, }; diff --git a/lib/main/lockDetail/messageWarn/addFamily/addFamily_page.dart b/lib/main/lockDetail/messageWarn/addFamily/addFamily_page.dart index 1ea9edab..98259c99 100755 --- a/lib/main/lockDetail/messageWarn/addFamily/addFamily_page.dart +++ b/lib/main/lockDetail/messageWarn/addFamily/addFamily_page.dart @@ -4,8 +4,10 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/appRouters.dart'; import 'package:star_lock/main/lockDetail/messageWarn/addFamily/addFamily_logic.dart'; -import 'package:star_lock/tools/showCupertinoAlertView.dart'; +import 'package:star_lock/main/lockDetail/messageWarn/addFamily/addFamily_state.dart'; +import 'package:star_lock/main/lockDetail/messageWarn/msgNotification/openDoorNotify/openDoorNotify_entity.dart'; import 'package:star_lock/tools/commonItem.dart'; +import 'package:star_lock/tools/showCupertinoAlertView.dart'; import 'package:star_lock/tools/showTFView.dart'; import 'package:star_lock/tools/storage.dart'; import 'package:star_lock/tools/submitBtn.dart'; @@ -22,8 +24,8 @@ class AddFamilyPage extends StatefulWidget { } class _AddFamilyPageState extends State { - final logic = Get.put(AddFamilyLogic()); - final state = Get.find().state; + final AddFamilyLogic logic = Get.put(AddFamilyLogic()); + final AddFamilyState state = Get.find().state; @override Widget build(BuildContext context) { @@ -36,7 +38,7 @@ class _AddFamilyPageState extends State { body: Container( padding: EdgeInsets.all(30.w), child: Column( - children: [ + children: [ Obx(() => CommonItem( leftTitel: '开门方式'.tr, rightTitle: state.isDetail.value @@ -46,9 +48,9 @@ class _AddFamilyPageState extends State { isHaveDirection: true, action: () { //锁用户 - Get.toNamed(Routers.lockUserPage, - arguments: {'getLockId': state.getLockId.value}) - ?.then((val) { + Get.toNamed(Routers.lockUserPage, arguments: { + 'getLockId': state.getLockId.value + })?.then((val) { if (val != null) { state.lockUserKeys.value = val; } @@ -73,8 +75,9 @@ class _AddFamilyPageState extends State { GestureDetector( onTap: () { Get.toNamed(Routers.notificationModePage, - arguments: {'familyData': state.familyData.value}) - ?.then((val) { + arguments: { + 'familyData': state.familyData.value + })?.then((val) { if (val != null) { state.emailListStr.value = logic.getEmailListStr(val); state.phontListStr.value = logic.getPhoneListStr(val); @@ -85,10 +88,10 @@ class _AddFamilyPageState extends State { color: Colors.white, margin: EdgeInsets.only(bottom: 10.h), child: Column( - children: [ + children: [ CommonItem( leftTitel: '提醒方式'.tr, - rightTitle: "", + rightTitle: '', isHaveLine: false, isHaveRightWidget: false, isHaveDirection: true, @@ -117,7 +120,7 @@ class _AddFamilyPageState extends State { : logic.checkBtnDisable(), isDelete: state.isDetail.value, onClick: () async { - var isVip = await Storage.getBool(saveIsVip); + bool? isVip = await Storage.getBool(saveIsVip); if (isVip == true) { if (state.isDetail.value) { logic.deleteLockNoticeSetting(); @@ -148,7 +151,7 @@ class _AddFamilyPageState extends State { borderRadius: BorderRadius.circular(6.0.w), ), child: Row( - children: [ + children: [ Text( notifyTitle, style: TextStyle(color: Colors.black, fontSize: 20.sp), @@ -173,8 +176,8 @@ class _AddFamilyPageState extends State { builder: (BuildContext context) { return ShowTFView( title: - "${TranslationLoader.lanKeys!.amend!.tr}${TranslationLoader.lanKeys!.name!.tr}", - tipTitle: "请输入".tr, + '${TranslationLoader.lanKeys!.amend!.tr}${TranslationLoader.lanKeys!.name!.tr}', + tipTitle: '请输入'.tr, controller: state.changeNameController, sureClick: () { //发送编辑钥匙名称请求 @@ -194,13 +197,13 @@ class _AddFamilyPageState extends State { // 接受者信息输入框 Widget getFamilyWidget(String tfStr) { - TextEditingController emailController = TextEditingController(); + final TextEditingController emailController = TextEditingController(); emailController.text = state.lockUserKeys.value.currentKeyName ?? ''; return SizedBox( height: 50.h, width: 360.w, child: Row( - children: [ + children: [ Expanded( child: TextField( controller: emailController, @@ -231,7 +234,7 @@ class _AddFamilyPageState extends State { ), style: TextStyle( fontSize: 22.sp, textBaseline: TextBaseline.alphabetic), - onChanged: (value) { + onChanged: (String value) { state.lockUserKeys.value.currentKeyName = value; state.lockUserKeys.refresh(); }, diff --git a/lib/main/lockDetail/messageWarn/msgNotification/nDaysUnopened/nDaysUnopened_logic.dart b/lib/main/lockDetail/messageWarn/msgNotification/nDaysUnopened/nDaysUnopened_logic.dart index 797daa1b..640a755b 100755 --- a/lib/main/lockDetail/messageWarn/msgNotification/nDaysUnopened/nDaysUnopened_logic.dart +++ b/lib/main/lockDetail/messageWarn/msgNotification/nDaysUnopened/nDaysUnopened_logic.dart @@ -9,12 +9,13 @@ import 'nDaysUnopened_state.dart'; class NDaysUnopenedLogic extends BaseGetXController { NDaysUnopenedState state = NDaysUnopenedState(); - void lockNoticeSettingAccountList() async { - var entity = await ApiRepository.to.updateNdaysNotCloseDoorNoticeSetting( - lockId: state.getLockId.value, - dayNotOpenDoorState: state.isUnOpenNotice.value == true ? 1 : 0, - dayNotOpenDoorValue: state.unOpenDoorTime.value, - dayNotOpenDoorNoticeWayList: [ + Future lockNoticeSettingAccountList() async { + final OpenDoorNotifyEntity entity = await ApiRepository.to + .updateNdaysNotCloseDoorNoticeSetting( + lockId: state.getLockId.value, + dayNotOpenDoorState: state.isUnOpenNotice.value == true ? 1 : 0, + dayNotOpenDoorValue: state.unOpenDoorTime.value, + dayNotOpenDoorNoticeWayList: [ {'type': 'mail', 'accounts': getEmailAndSMSAccountList(true)}, {'type': 'sms', 'accounts': getEmailAndSMSAccountList(false)} ]); @@ -26,14 +27,14 @@ class NDaysUnopenedLogic extends BaseGetXController { //获取到家人信息的请求数组 List getEmailAndSMSAccountList(bool isEmail) { - List list = []; + final List list = []; List accountList = []; isEmail ? accountList = state.emailReceiverList.value : accountList = state.phoneReceiverList.value; for (int i = 0; i < accountList.length; i++) { - MsgNoticeModeData item = accountList[i]; - Map map = {}; + final MsgNoticeModeData item = accountList[i]; + final Map map = {}; map['countryCode'] = isEmail ? 0 : item.countryCode; map['account'] = isEmail ? item.receiveEmail : item.receivePhone; list.add(map); @@ -45,9 +46,9 @@ class NDaysUnopenedLogic extends BaseGetXController { String emailListStr = ''; if (val['emailReceiverList'] != null) { state.emailReceiverList.value = val['emailReceiverList']; - List emailReceiverList = state.emailReceiverList.value; + final List emailReceiverList = state.emailReceiverList.value; for (int i = 0; i < emailReceiverList.length; i++) { - MsgNoticeModeData item = emailReceiverList[i]; + final MsgNoticeModeData item = emailReceiverList[i]; emailListStr += item.receiveEmail; // 检查是否为最后一个元素 if (i < emailReceiverList.length - 1) { @@ -63,9 +64,9 @@ class NDaysUnopenedLogic extends BaseGetXController { if (val['phoneReceiverList'] != null) { state.phoneReceiverList.value = val['phoneReceiverList']; - List phoneReceiverList = state.phoneReceiverList.value; + final List phoneReceiverList = state.phoneReceiverList.value; for (int i = 0; i < phoneReceiverList.length; i++) { - MsgNoticeModeData item = phoneReceiverList[i]; + final MsgNoticeModeData item = phoneReceiverList[i]; phoneListStr += item.receivePhone; // 检查是否为最后一个元素 if (i < phoneReceiverList.length - 1) { @@ -78,24 +79,24 @@ class NDaysUnopenedLogic extends BaseGetXController { //根据列表返回值得到邮箱、手机列表 Map> getAccountsMap() { - List mailAccounts = []; - List smsAccounts = []; + final List mailAccounts = []; + final List smsAccounts = []; if (state.msgNoticeInfo.value.dayNotOpenDoorNoticeWayList != null) { - for (NoticeWay item + for (final NoticeWay item in state.msgNoticeInfo.value.dayNotOpenDoorNoticeWayList!) { if (item.type == 'mail' && item.accounts != null) { - for (Accounts account in item.accounts!) { + for (final Accounts account in item.accounts!) { if (account.account != null) { - MsgNoticeModeData msgNoticeModeData = MsgNoticeModeData(); + final MsgNoticeModeData msgNoticeModeData = MsgNoticeModeData(); msgNoticeModeData.receiveEmail = account.account!; mailAccounts.add(msgNoticeModeData); } } } else if (item.type == 'sms' && item.accounts != null) { - for (Accounts account in item.accounts!) { + for (final Accounts account in item.accounts!) { if (account.account != null && account.countryCode != null) { - MsgNoticeModeData msgNoticeModeData = MsgNoticeModeData(); + final MsgNoticeModeData msgNoticeModeData = MsgNoticeModeData(); msgNoticeModeData.receivePhone = account.account!; msgNoticeModeData.countryCode = account.countryCode!; smsAccounts.add(msgNoticeModeData); diff --git a/lib/main/lockDetail/messageWarn/msgNotification/nDaysUnopened/nDaysUnopened_page.dart b/lib/main/lockDetail/messageWarn/msgNotification/nDaysUnopened/nDaysUnopened_page.dart index 709b027d..dbfd3b42 100755 --- a/lib/main/lockDetail/messageWarn/msgNotification/nDaysUnopened/nDaysUnopened_page.dart +++ b/lib/main/lockDetail/messageWarn/msgNotification/nDaysUnopened/nDaysUnopened_page.dart @@ -4,10 +4,11 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/appRouters.dart'; import 'package:star_lock/main/lockDetail/messageWarn/msgNotification/msgNotification/msgNotification_entity.dart'; -import 'package:star_lock/tools/showCupertinoAlertView.dart'; +import 'package:star_lock/main/lockDetail/messageWarn/msgNotification/nDaysUnopened/nDaysUnopened_state.dart'; import 'package:star_lock/tools/commonItem.dart'; import 'package:star_lock/tools/pickers/pickers.dart'; import 'package:star_lock/tools/pickers/style/default_style.dart'; +import 'package:star_lock/tools/showCupertinoAlertView.dart'; import 'package:star_lock/tools/storage.dart'; import 'package:star_lock/tools/submitBtn.dart'; @@ -23,8 +24,8 @@ class NDaysUnopenedPage extends StatefulWidget { } class _NDaysUnopenedPageState extends State { - final logic = Get.put(NDaysUnopenedLogic()); - final state = Get.find().state; + final NDaysUnopenedLogic logic = Get.put(NDaysUnopenedLogic()); + final NDaysUnopenedState state = Get.find().state; @override Widget build(BuildContext context) { @@ -36,13 +37,13 @@ class _NDaysUnopenedPageState extends State { backgroundColor: AppColors.mainColor), body: ListView( padding: EdgeInsets.all(30.w), - children: [ + children: [ Row( mainAxisAlignment: MainAxisAlignment.start, - children: [ + children: [ Expanded( child: Text( - "经过以上设定的时间,锁没有被开启,系统会给指定对象发送提醒消息,该功能需要锁联网".tr, + '经过以上设定的时间,锁没有被开启,系统会给指定对象发送提醒消息,该功能需要锁联网'.tr, style: TextStyle( fontSize: 20.sp, color: AppColors.darkGrayTextColor), )), @@ -67,7 +68,7 @@ class _NDaysUnopenedPageState extends State { SubmitBtn( btnName: '保存'.tr, onClick: () async { - var isVip = await Storage.getBool(saveIsVip); + bool? isVip = await Storage.getBool(saveIsVip); if (isVip == false) { ShowCupertinoAlertView().advancedFeatureAlert(); } else { @@ -87,10 +88,10 @@ class _NDaysUnopenedPageState extends State { return Visibility( visible: state.isUnOpenNotice.value, child: Column( - children: [ + children: [ Obx(() => CommonItem( leftTitel: '门未开时间'.tr, - rightTitle: '${state.unOpenDoorTime.value}${'天'.tr}', + rightTitle: '${state.unOpenDoorTime.value}天', isHaveLine: true, isHaveRightWidget: false, isHaveDirection: true, @@ -104,8 +105,9 @@ class _NDaysUnopenedPageState extends State { GestureDetector( onTap: () { Get.toNamed(Routers.notificationModePage, - arguments: {'msgNoticeInfo': state.msgNoticeInfo.value}) - ?.then((val) { + arguments: { + 'msgNoticeInfo': state.msgNoticeInfo.value + })?.then((val) { if (val != null) { state.emailListStr.value = logic.getEmailListStr(val); state.phontListStr.value = logic.getPhoneListStr(val); @@ -116,10 +118,10 @@ class _NDaysUnopenedPageState extends State { color: Colors.white, margin: EdgeInsets.only(bottom: 10.h), child: Column( - children: [ + children: [ CommonItem( leftTitel: '提醒方式'.tr, - rightTitle: "", + rightTitle: '', isHaveLine: false, isHaveRightWidget: false, isHaveDirection: true, @@ -151,7 +153,7 @@ class _NDaysUnopenedPageState extends State { borderRadius: BorderRadius.circular(6.0.w), ), child: Row( - children: [ + children: [ Text( notifyTitle, style: TextStyle(color: Colors.black, fontSize: 20.sp), @@ -175,7 +177,7 @@ class _NDaysUnopenedPageState extends State { trackColor: CupertinoColors.systemGrey5, thumbColor: CupertinoColors.white, value: state.isUnOpenNotice.value, - onChanged: (value) { + onChanged: (bool value) { setState(() { state.isUnOpenNotice.value = value; if (!state.isUnOpenNotice.value) { @@ -187,11 +189,12 @@ class _NDaysUnopenedPageState extends State { } //底部选择pickerView - _openBottomItemSheet(BuildContext context, List dataList) { + void _openBottomItemSheet(BuildContext context, List dataList) { Pickers.showSinglePicker(context, data: dataList, - pickerStyle: DefaultPickerStyle(), onConfirm: (p, position) { - state.unOpenDoorTime.value = p; - }, onChanged: (p, position) {}); + pickerStyle: DefaultPickerStyle(), onConfirm: (p, int position) { + state.unOpenDoorTime.value = + int.parse(state.unopenDoorTimeList[position].replaceAll('天', '')); + }, onChanged: (p, int position) {}); } } diff --git a/lib/main/lockDetail/messageWarn/msgNotification/nDaysUnopened/nDaysUnopened_state.dart b/lib/main/lockDetail/messageWarn/msgNotification/nDaysUnopened/nDaysUnopened_state.dart index 3a23a139..607280bf 100755 --- a/lib/main/lockDetail/messageWarn/msgNotification/nDaysUnopened/nDaysUnopened_state.dart +++ b/lib/main/lockDetail/messageWarn/msgNotification/nDaysUnopened/nDaysUnopened_state.dart @@ -4,21 +4,21 @@ import 'package:star_lock/main/lockDetail/messageWarn/msgNotification/msgNotific class NDaysUnopenedState { final List unopenDoorTimeList = [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, + '1天', + '2天', + '3天', + '4天', + '5天', + '6天', + '7天', + '8天', + '9天', + '10天', + '11天', + '12天', + '13天', + '14天', + '15天', ]; var isUnOpenNotice = false.obs; // 是否N天未开门提醒 diff --git a/lib/mine/valueAddedServices/valueAddedServicesRealName/value_added_services_real_name_page.dart b/lib/mine/valueAddedServices/valueAddedServicesRealName/value_added_services_real_name_page.dart index 6069a372..6bdebbf9 100755 --- a/lib/mine/valueAddedServices/valueAddedServicesRealName/value_added_services_real_name_page.dart +++ b/lib/mine/valueAddedServices/valueAddedServicesRealName/value_added_services_real_name_page.dart @@ -3,6 +3,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/appRouters.dart'; import 'package:star_lock/mine/valueAddedServices/valueAddedServicesRealName/value_added_services_real_name_logic.dart'; +import 'package:star_lock/mine/valueAddedServices/valueAddedServicesRealName/value_added_services_real_name_state.dart'; import 'package:star_lock/mine/valueAddedServices/valueAddedServicesRecord/use_record_list_arg.dart'; import '../../../app_settings/app_colors.dart'; import '../../../tools/commonItem.dart'; @@ -19,8 +20,10 @@ class ValueAddedServicesRealNamePage extends StatefulWidget { class _ValueAddedServicesRealNamePageState extends State { - final logic = Get.put(ValueAddedServicesRealNameLogic()); - final state = Get.find().state; + final ValueAddedServicesRealNameLogic logic = + Get.put(ValueAddedServicesRealNameLogic()); + final ValueAddedServicesRealNameState state = + Get.find().state; @override Widget build(BuildContext context) { @@ -31,7 +34,7 @@ class _ValueAddedServicesRealNamePageState haveBack: true, backgroundColor: AppColors.mainColor), body: Column( - children: [ + children: [ Container( width: 1.sw, padding: EdgeInsets.only( @@ -42,7 +45,7 @@ class _ValueAddedServicesRealNamePageState color: AppColors.darkGrayTextColor, fontSize: 20.sp), )), middleWidget(), - Obx(() => bottomWidget()) + Obx(bottomWidget) ], ), ); @@ -55,15 +58,15 @@ class _ValueAddedServicesRealNamePageState decoration: const BoxDecoration( image: DecorationImage( image: AssetImage( - "images/mine/icon_mine_valueAddedServices_noteTop.png"), + 'images/mine/icon_mine_valueAddedServices_noteTop.png'), fit: BoxFit.cover)), - child: Column(children: [ + child: Column(children: [ Container( margin: const EdgeInsets.only(top: 15, bottom: 15, left: 30, right: 30), child: Row( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ Obx(() => Text( "${'当前剩余数量'.tr}:${state.realNameRemainCount.value}", style: TextStyle(fontSize: 24.sp), @@ -75,7 +78,7 @@ class _ValueAddedServicesRealNamePageState padding: const EdgeInsets.only(top: 10, bottom: 10), child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ + children: [ GestureDetector( onTap: () { Get.toNamed(Routers.valueAddedServicesRecordPage, @@ -92,7 +95,7 @@ class _ValueAddedServicesRealNamePageState GestureDetector( onTap: () { Get.toNamed(Routers.advancedFeaturesWebPage, - arguments: {'isShop': false}); + arguments: {'isShop': false}); }, child: Container( width: 200.w, @@ -115,9 +118,9 @@ class _ValueAddedServicesRealNamePageState color: Colors.white, margin: EdgeInsets.all(20.h), child: Column( - children: [ + children: [ Column( - children: [ + children: [ Container( padding: EdgeInsets.only(top: 20.h, bottom: 20.h, left: 30.w), child: Text( @@ -143,10 +146,10 @@ class _ValueAddedServicesRealNamePageState Widget checkCommonItem( ValueAddedServicesRealNameLogic logic, String text, int clickIndex, {bool isHaveLine = true, bool isHaveRightWidget = true}) { - bool check = logic.state.checkIndex.value == clickIndex; + final bool check = logic.state.checkIndex.value == clickIndex; return CommonItem( leftTitel: text, - rightTitle: "", + rightTitle: '', allHeight: 60.h, isHaveLine: isHaveLine, isHaveRightWidget: isHaveRightWidget, @@ -155,7 +158,7 @@ class _ValueAddedServicesRealNamePageState logic.check(clickIndex); }, child: Row( - children: [ + children: [ Image.asset( check ? 'images/icon_round_select.png' From 9164e2307000524e021bb3caeb1934bc89b37923 Mon Sep 17 00:00:00 2001 From: anfe <448468458@qq.com> Date: Tue, 21 May 2024 11:08:16 +0800 Subject: [PATCH 26/44] =?UTF-8?q?feat:=E5=88=A0=E9=99=A4=E4=B8=80=E4=BA=9B?= =?UTF-8?q?=E6=B3=A8=E9=87=8A=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/blue/blue_manage.dart | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/lib/blue/blue_manage.dart b/lib/blue/blue_manage.dart index f39cd228..746062a1 100755 --- a/lib/blue/blue_manage.dart +++ b/lib/blue/blue_manage.dart @@ -263,18 +263,11 @@ class BlueManage { if (_adapterState == BluetoothAdapterState.on) { try { FlutterBluePlus.startScan(timeout: Duration(seconds: timeout)); - final StreamSubscription> subscription = FlutterBluePlus.scanResults.listen((List results) { scanDevices.clear(); for (final ScanResult scanResult in results) { // 判断名字为空的直接剔除 - // if (scanResult.device.advName.isEmpty) { - // return; - // } - // AppLog.log("scanResult.device.advName:${scanResult.device.advName}" - // " scanResult.advertisementData.serviceUuids:${scanResult.advertisementData.serviceUuids}" - // " rssi:${scanResult.rssi}"); if (((scanResult.advertisementData.serviceUuids.isNotEmpty ? scanResult.advertisementData.serviceUuids[0] : '') @@ -296,23 +289,7 @@ class BlueManage { } } } - - // String listStr = scanDevices - // .where((element) => - // element.advertisementData.advName == 'TMH_dc8f928369ed' || - // element.device.platformName == 'TMH_dc8f928369ed') - // .map((e) => 'advName:${e.advertisementData.advName} ' - // 'serviceUuids:${e.advertisementData.serviceUuids} ' - // '是否被重置:${e.advertisementData.serviceUuids[0].toString()[31]}') - // .join(',') - // .toString(); - // if (listStr.trim() != '') { - // AppLog.log('--->扫描到的设备 ${listStr} '); - // } - scanDevicesCallBack(scanDevices); - // EventBusManager().eventBusFir(scanDevices); - // FlutterBluePlus.stopScan(); }, onError: (e) { AppLog.log( '扫描失败:$e', From f05f74be0f017f9ddef0c340e0715c6776ac7705 Mon Sep 17 00:00:00 2001 From: anfe <448468458@qq.com> Date: Tue, 21 May 2024 11:16:04 +0800 Subject: [PATCH 27/44] =?UTF-8?q?feat:=E6=B7=BB=E5=8A=A0=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .DS_Store | Bin 6148 -> 6148 bytes pubspec.yaml | 3 ++- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.DS_Store b/.DS_Store index 0d0d83d942d5a6afc3f49b36da76e38eed24448a..a15ea27935c7877c7f6966c4a2945ca5e15353ec 100755 GIT binary patch delta 24 fcmZoMXffDO$IfnSX{MuKY%w{V&0+IVc6$K;TKWeJ delta 25 gcmZoMXffDO$IfAHYNn%LVqi8ogUx>PQFeO)0ASz;JOBUy diff --git a/pubspec.yaml b/pubspec.yaml index e4da4259..efb41595 100755 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -54,8 +54,9 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # 1.0.44+2024052002:打包给公司测试 # 1.0.45+2024052003:打包给公司测试 # 1.0.46+2024052004:打包给公司测试 +# 1.0.47+2024052101:打包给欧阳回归测试 -version: 1.0.46+2024052004 +version: 1.0.47+2024052101 environment: sdk: '>=2.12.0 <3.0.0' From 4c68c60f1d4577a1ea91bf57a6cd98b4caa1621e Mon Sep 17 00:00:00 2001 From: anfe <448468458@qq.com> Date: Tue, 21 May 2024 15:33:06 +0800 Subject: [PATCH 28/44] =?UTF-8?q?feat:=E8=A7=A3=E5=86=B3=E7=A1=AC=E4=BB=B6?= =?UTF-8?q?=E5=A4=9A=E6=AC=A1=E5=8F=91=E6=95=B0=E6=8D=AE=E5=8C=85=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/blue/blue_manage.dart | 190 ++------ lib/blue/io_reply.dart | 86 ++-- lib/blue/io_sender.dart | 6 +- lib/blue/reciver_data.dart | 39 +- .../authorizedAdmin_logic.dart | 2 +- .../card/addICCard/addICCard_logic.dart | 4 +- .../card/cardDetail/cardDetail_logic.dart | 2 +- .../card/cardList/cardList_logic.dart | 2 +- .../otherTypeKeyChangeDate_logic.dart | 6 +- .../otherTypeKeyChangeValidityDate_logic.dart | 6 +- .../doorLockLog/doorLockLog_logic.dart | 2 +- .../face/addFace/addFace_logic.dart | 4 +- .../face/faceDetail/faceDetail_logic.dart | 2 +- .../face/faceList/faceList_logic.dart | 2 +- .../addFingerprint/addFingerprint_logic.dart | 4 +- .../fingerprintDetail_logic.dart | 2 +- .../fingerprintList_logic.dart | 6 +- .../iris/irisDetail/irisDetail_logic.dart | 2 +- .../iris/irisList/irisList_logic.dart | 6 +- .../lockDetail/lockDetail_logic.dart | 410 +++++++++--------- .../lockDetail/lockDetail_page.dart | 5 +- .../lockOperatingRecord_logic.dart | 2 +- .../automaticBlocking_logic.dart | 2 +- .../adminOpenLockPassword_logic.dart | 2 +- .../uploadElectricQuantity_logic.dart | 2 +- .../burglarAlarm/burglarAlarm_logic.dart | 2 +- .../configuringWifi_logic.dart | 2 +- .../wifiList/wifiList_logic.dart | 2 +- .../lockEscalation/lockEscalation_logic.dart | 2 +- .../lockSet/lockSet/lockSet_logic.dart | 4 +- .../lockSoundSet/lockSoundSet_logic.dart | 2 +- .../lockSet/lockTime/lockTime_logic.dart | 2 +- .../lockSet/motorPower/motorPower_logic.dart | 4 +- .../normallyOpenMode_logic.dart | 2 +- .../openDoorDirection_logic.dart | 2 +- .../remoteUnlocking_logic.dart | 2 +- .../resetButton/resetButton_logic.dart | 2 +- .../palm/palmDetail/palmDetail_logic.dart | 2 +- .../palm/palmList/palmList_logic.dart | 6 +- .../passwordKeyDetail_logic.dart | 2 +- .../passwordKeyDetailChangeDate_logic.dart | 2 +- .../passwordKeyList_logic.dart | 4 +- .../passwordKey_perpetual_logic.dart | 2 +- .../lockMian/lockList/lockList_logic.dart | 2 +- lib/mine/about/debug/controller.dart | 4 +- .../addLock/nearbyLock/nearbyLock_logic.dart | 6 +- lib/mine/addLock/saveLock/saveLock_logic.dart | 2 +- .../expireCard/expireCard_logic.dart | 2 +- .../expireFingerprint_logic.dart | 2 +- lib/network/response_interceptor_log.dart | 2 +- 50 files changed, 374 insertions(+), 488 deletions(-) diff --git a/lib/blue/blue_manage.dart b/lib/blue/blue_manage.dart index 746062a1..5ae2f0df 100755 --- a/lib/blue/blue_manage.dart +++ b/lib/blue/blue_manage.dart @@ -17,6 +17,12 @@ typedef ConnectStateCallBack = Function( typedef ScanDevicesCallBack = Function(List); class BlueManage { + + factory BlueManage() => shareManager()!; + + BlueManage._init() { + _initBlue(); + } final List scanDevices = []; // 用来写入的服务id @@ -34,12 +40,6 @@ class BlueManage { // 监听发送事件 StreamSubscription? _sendStreamSubscription; - // 监听蓝牙扫描的事件 - // StreamSubscription? _scanSubscription; - // 监听蓝牙连接的事件 - // StreamSubscription? _currentConnectionStream; - - // StreamSubscription>? _scanResultsSubscription; StreamSubscription? _connectionStateSubscription; StreamSubscription? _mtuSubscription; @@ -64,11 +64,14 @@ class BlueManage { BluetoothAdapterState? _adapterState = BluetoothAdapterState.unknown; StreamSubscription? _adapterStateStateSubscription; - static BlueManage? _manager; + // 听上报来的数据,参数来自前面扫描到的结果 + List allData = []; - BlueManage._init() { - _initBlue(); - } + // 保存上一次的数据,用来判断是否收到重复的数据 + List lastTimeData = []; + int? dataLen; + + static BlueManage? _manager; static BlueManage? shareManager() { _manager ??= BlueManage._init(); @@ -76,16 +79,12 @@ class BlueManage { return _manager; } - factory BlueManage() => shareManager()!; - BlueManage? get manager => shareManager(); void _initBlue() { FlutterBluePlus.setLogLevel(LogLevel.error, color: true); _initSendStreamSubscription(); _initAdapterStateStateSubscription(); - // _initListenscanResults(); - // _initListenConnectionState(); } void _initGetMtuSubscription() { @@ -102,45 +101,6 @@ class BlueManage { }); } - // void _initListenscanResults() { - // var subscription = FlutterBluePlus.scanResults.listen((results) { - // scanDevices.clear(); - // for (var scanResult in results) { - // // 判断名字为空的直接剔除 - // // if (scanResult.device.advName.isEmpty) { - // // return; - // // } - // AppLog.log("scanResult.device.advName:${scanResult.device.advName}" - // " scanResult.advertisementData.serviceUuids:${scanResult.advertisementData.serviceUuids}" - // " rssi:${scanResult.rssi}"); - // if (((scanResult.advertisementData.serviceUuids.isNotEmpty ? scanResult.advertisementData.serviceUuids[0] : "").toString().contains("758824")) && (scanResult.rssi >= -100)) { - // // 查询id相同的元素 - // final knownDeviceIndex = scanDevices.indexWhere((d) => d.advertisementData.advName == scanResult.advertisementData.advName); - // // 不存在的时候返回-1 - // if (knownDeviceIndex >= 0) { - // scanDevices[knownDeviceIndex] = scanResult; - // } else { - // scanDevices.add(scanResult); - // } - // } - // } - // EventBusManager().eventBusFir(scanDevices); - // // FlutterBluePlus.stopScan(); - // }, onError: (e) { - // AppLog.log("Scan Error:$e", ); - // }); - // - // FlutterBluePlus.cancelWhenScanComplete(subscription); - - // FlutterBluePlus.isScanning.listen((state) { - // if (state) { - // prAppLog.logint('Scanning'); - // } else { - // AppLog.log('Not scanning'); - // } - // }); - // } - void _initListenConnectionState() { _connectionStateSubscription?.cancel(); _connectionStateSubscription = null; @@ -185,7 +145,7 @@ class BlueManage { if (_adapterState == BluetoothAdapterState.on) { try { //android 扫描比较慢,取样只要 8 分之一 - final int divisor = Platform.isAndroid ? 8 : 1; + final int divisor = Platform.isAndroid ? 3 : 1; FlutterBluePlus.startScan( continuousDivisor: divisor, continuousUpdates: true, @@ -316,7 +276,7 @@ class BlueManage { } /// 调用发送数据 List senderData, - Future bludSendData( + Future blueSendData( String deviceName, ConnectStateCallBack stateCallBack, {bool isAddEquipment = false}) async { FlutterBluePlus.isSupported.then((bool isAvailable) async { @@ -368,14 +328,13 @@ class BlueManage { } //查找缓存里面是否有设备 - bool isExistScanDevices(String connectDeviceName){ + bool isExistScanDevices(String connectDeviceName) { final bool isExistDevice = scanDevices.any((ScanResult element) => - element.device.platformName == connectDeviceName || + element.device.platformName == connectDeviceName || element.advertisementData.advName == connectDeviceName); return isExistDevice; } - Future _connectDevice(List devicesList, String deviceName, ConnectStateCallBack connectStateCallBack, {bool isAddEquipment = false}) async { @@ -400,13 +359,9 @@ class BlueManage { _initGetMtuSubscription(); _initListenConnectionState(); } - // AppLog.log("1 connectDeviceId:$connectDeviceMacAddress connectDeviceName:$connectDeviceName"); - // stopScan(); if (scanResult == null || connectDeviceMacAddress.isEmpty) { - // connectStateCallBack(BluetoothConnectionState.disconnected!); return; } - // AppLog.log("调用了停止扫描的方法"); await stopScan(); @@ -438,28 +393,18 @@ class BlueManage { connectStateCallBack(BluetoothConnectionState.disconnected); } - // await bluetoothConnectDevice!.connect(); if (bluetoothConnectionState == BluetoothConnectionState.connected) { try { bluetoothConnectDevice! .discoverServices() .then((List services) { for (final BluetoothService service in services) { - // AppLog.log("11111service.remoteId:${service.remoteId}" - // " service.uuid:${service.uuid}" - // " service.characteristics:${service.characteristics}" - // " service.includedServices:${service.includedServices}"); if (service.uuid == _serviceIdConnect) { for (final BluetoothCharacteristic characteristic in service.characteristics) { - // Get.log("22222characteristic.remoteId:${characteristic.remoteId}" - // " characteristic.uuid:${characteristic.uuid}" - // " characteristic.secondaryServiceUuid:${characteristic.secondaryServiceUuid}" - // " characteristic.characteristicUuid:${characteristic.characteristicUuid}"); if (characteristic.characteristicUuid == _characteristicIdSubscription) { _subScribeToCharacteristic(characteristic); - // AppLog.log('Discovering services finished'); bluetoothConnectionState = BluetoothConnectionState.connected; connectStateCallBack(bluetoothConnectionState!); } @@ -477,49 +422,41 @@ class BlueManage { } } - // 听上报来的数据,参数来自前面扫描到的结果 - List allData = []; - // 保存上一次的数据,用来判断是否收到重复的数据 - List lastTimeData = []; - int? dataLen; Future _subScribeToCharacteristic( BluetoothCharacteristic characteristic) async { final StreamSubscription> subscription = characteristic.onValueReceived.listen((List data) { - // AppLog.log("订阅获取的数据:$data"); + AppLog.log('订阅获取的数据: $data '); if (data == lastTimeData || data.isEmpty) { return; } else { lastTimeData = data; } - // code to handle incoming data - // AppLog.log("subscribeToCharacteristic: deviceId = ${characteristic.deviceId} characteristicId =${characteristic.characteristicId}---上报来的数据data = $data"); - if ((data[0] == 0xEF) && - (data[1] == 0x01) && - (data[2] == 0xEE) && - (data[3] == 0x02)) { + final bool dataHeadCorrect = isDataHeadCorrect(data); + final bool allDataHeadCorrect = isDataHeadCorrect(allData); + if (dataHeadCorrect && allDataHeadCorrect) { + //缓存数据和新数据都有包头,直接放弃缓存数据 + allData = []; + } + if (dataHeadCorrect) { // 当包有头时 // 判断是否需要分包 dataLen = data[8] * 256 + data[9]; // 高16位用来指示后面数据块内容的长度 - // AppLog.log("dataLen1111:$dataLen getDataLength:${data.length} data:$data"); if (dataLen! + 14 > data.length) { // 当前包的长度小于实际的包时 分包添加 不解析 allData.addAll(data); } else { // 当前包的长度小于实际的包时 不分包 解析 allData.addAll(data); - // AppLog.log("dataLen2222:$dataLen getDataLength:${data.length}"); CommandReciverManager.appDataReceive(allData); // 发送完解析初始化数组 allData = []; } - } else { + } else if (allDataHeadCorrect) { // 当包没有头时 是分包的包 直接添加 allData.addAll(data); - // var len = allData[8] * 256 + allData[9]; - // AppLog.log("dataLen3333:$dataLen allData.length:${allData.length} allData:$allData"); if (((dataLen ?? 0) + 14) <= allData.length) { // 当长度小于等于当前包的数据时 直接解析数据 CommandReciverManager.appDataReceive(allData); @@ -532,24 +469,30 @@ class BlueManage { await characteristic.setNotifyValue(true); } + //判断数据头是否正确 + bool isDataHeadCorrect(List data) { + if (data.length < 4) { + return false; + } + //239, 1, 238, 2, 是数据包头 + if ((data[0] == 0xEF) && + (data[1] == 0x01) && + (data[2] == 0xEE) && + (data[3] == 0x02)) { + return true; + } else { + return false; + } + } + // 写入 Future writeCharacteristicWithResponse(List value) async { final List services = await bluetoothConnectDevice!.discoverServices(); for (final BluetoothService service in services) { - // AppLog.log("33333 service.remoteId:${service.remoteId}" - // " service.uuid:${service.uuid}\n\n" - // " service.characteristics:${service.characteristics}\n\n" - // " service.includedServices:${service.includedServices}"); if (service.uuid == _serviceIdConnect) { for (final BluetoothCharacteristic characteristic in service.characteristics) { - // AppLog.log("44444 characteristic.remoteId:${characteristic.remoteId}" - // " characteristic.uuid:${characteristic.uuid}\n\n" - // " characteristic.secondaryServiceUuid:${characteristic - // .secondaryServiceUuid}\n\n" - // " characteristic.characteristicUuid:${characteristic - // .characteristicUuid}"); if (characteristic.characteristicUuid == _characteristicIdWrite) { try { final List valueList = value; @@ -558,22 +501,10 @@ class BlueManage { for (int i = 0; i < subData.length; i++) { if (characteristic.properties.writeWithoutResponse) { // 使用WRITE_NO_RESPONSE属性写入值 - await characteristic - .write(subData[i], withoutResponse: true) - .then((value) async { - // await Future.delayed(const Duration(milliseconds: 1)).then(( - // value) async { - // AppLog.log('分包发送成功了'); - // }); - }); + await characteristic.write(subData[i], withoutResponse: true); } else if (characteristic.properties.write) { // 使用WRITE属性写入值 - await characteristic.write(subData[i]).then((value) async { - // await Future.delayed(const Duration(milliseconds: 1)).then(( - // value) async { - // AppLog.log('分包发送成功了'); - // }); - }); + await characteristic.write(subData[i]); } else { // 特性不支持写入 throw Exception( @@ -588,28 +519,6 @@ class BlueManage { } } } - // List services = await bluetoothConnectDevice!.discoverServices(); - // BluetoothCharacteristic characteristic = services - // .firstWhere((service) => service.uuid == _serviceIdWrite) - // .characteristics - // .firstWhere((char) => char.uuid == _characteristicIdWrite); - // try { - // List valueList = value; - // List subData = splitList(valueList, _mtuSize!); - // AppLog.log('writeCharacteristicWithResponse 得到的分割数据:$subData'); - // - // for (int i = 0; i < subData.length; i++) { - // await characteristic.write(subData[i]).then((value) async { - // await Future.delayed(const Duration(milliseconds: 1)).then((value) async { - // AppLog.log('分包发送成功了'); - // }); - // }); - // } - // } on Exception catch (e, s) { - // AppLog.log('Error occurred when writing: $e'); - // AppLog.log(s); - // rethrow; - // } } // 停止扫描蓝牙设备 @@ -624,16 +533,12 @@ class BlueManage { // 断开连接 Future disconnect() async { try { - // if(bluetoothConnectDevice != null && bluetoothConnectDevice!.connectionState == BluetoothConnectionState.connected){ connectDeviceMacAddress = ''; if (bluetoothConnectionState == BluetoothConnectionState.connected) { - // await writeNull(); - // await Future.delayed(const Duration(milliseconds: 1000)); //加快蓝牙断连 - await bluetoothConnectDevice!.disconnect(timeout: 2); + await bluetoothConnectDevice!.disconnect(timeout: 3); AppLog.log('断开连接成功'); } - // } } on Exception catch (e, _) { AppLog.log('断开连接失败: $e'); } finally { @@ -641,7 +546,7 @@ class BlueManage { } } - openBlue() async { + Future openBlue() async { if (Platform.isAndroid) { await FlutterBluePlus.turnOn(); } @@ -650,10 +555,9 @@ class BlueManage { } } - disposed() { + void disposed() { _sendStreamSubscription?.cancel(); _mtuSubscription!.cancel(); - // _scanResultsSubscription!.cancel(); _adapterStateStateSubscription!.cancel(); _connectionStateSubscription!.cancel(); } diff --git a/lib/blue/io_reply.dart b/lib/blue/io_reply.dart index 56c93b70..adf8c457 100755 --- a/lib/blue/io_reply.dart +++ b/lib/blue/io_reply.dart @@ -6,6 +6,7 @@ import '../app_settings/app_settings.dart'; import 'io_type.dart'; abstract class Reply{ + Reply.parseData(this.commandType, List dataDetail); CommandType? commandType; @@ -13,122 +14,121 @@ abstract class Reply{ int status = 0; List data = []; static String logTag= '锁 -> App,指令订阅类型 :'; - Reply.parseData(this.commandType, List dataDetail); void errorWithStstus(int status){ switch(status){ case 0x00: // 成功 - AppLog.log("$logTag ${commandType?.typeName} 0x00 成功"); + AppLog.log('$logTag ${commandType?.typeName} 0x00 成功'); break; case 0x01: // 包格式错误 - AppLog.log("$logTag ${commandType!.typeName} 0x01 包格式错误"); - showErrorMessage("包格式错误"); + AppLog.log('$logTag ${commandType!.typeName} 0x01 包格式错误'); + showErrorMessage('包格式错误'); break; case 0x02: // 密码错误 - AppLog.log("$logTag ${commandType!.typeName} 0x02 密码错误"); - showErrorMessage("密码错误"); + AppLog.log('$logTag ${commandType!.typeName} 0x02 密码错误'); + showErrorMessage('密码错误'); break; case 0x03: // 网络中断 - AppLog.log("$logTag ${commandType!.typeName} 0x03 网络中断"); - showErrorMessage("网络中断"); + AppLog.log('$logTag ${commandType!.typeName} 0x03 网络中断'); + showErrorMessage('网络中断'); break; case 0x04: // 用户未登记 - AppLog.log("$logTag ${commandType!.typeName} 0x04 用户未登记"); - showErrorMessage("用户未登记"); + AppLog.log('$logTag ${commandType!.typeName} 0x04 用户未登记'); + showErrorMessage('用户未登记'); break; case 0x05: // 参数错误 - AppLog.log("$logTag ${commandType!.typeName} 0x05 参数错误"); - showErrorMessage("参数错误"); + AppLog.log('$logTag ${commandType!.typeName} 0x05 参数错误'); + showErrorMessage('参数错误'); break; case 0x06: // 需要鉴权 - AppLog.log("$logTag ${commandType!.typeName} 0x06 需要鉴权"); + AppLog.log('$logTag ${commandType!.typeName} 0x06 需要鉴权'); // showErrorMessage("需要鉴权"); break; case 0x07: // 无权限 - AppLog.log("$logTag ${commandType!.typeName} 0x07 无权限"); + AppLog.log('$logTag ${commandType!.typeName} 0x07 无权限'); // showErrorMessage("无权限"); break; case 0x08: // 应答超时 - AppLog.log("$logTag ${commandType!.typeName} 0x08 应答超时"); - showErrorMessage("应答超时"); + AppLog.log('$logTag ${commandType!.typeName} 0x08 应答超时'); + showErrorMessage('应答超时'); break; case 0x09: // 权限校验错误 - AppLog.log("$logTag ${commandType!.typeName} 0x09 权限校验错误"); - showErrorMessage("权限校验错误"); + AppLog.log('$logTag ${commandType!.typeName} 0x09 权限校验错误'); + showErrorMessage('权限校验错误'); break; case 0x0a: // 钥匙不存在 - showErrorMessage("钥匙不存在"); - AppLog.log("$logTag ${commandType!.typeName} 0x0a 钥匙不存在"); + showErrorMessage('钥匙不存在'); + AppLog.log('$logTag ${commandType!.typeName} 0x0a 钥匙不存在'); break; case 0x0b: // 钥匙过期 - showErrorMessage("钥匙过期"); - AppLog.log("$logTag ${commandType!.typeName} 0x0b 钥匙过期"); + showErrorMessage('钥匙过期'); + AppLog.log('$logTag ${commandType!.typeName} 0x0b 钥匙过期'); break; case 0x0c: // 钥匙数量已到上限 - showErrorMessage("钥匙数量已到上限"); - AppLog.log("$logTag ${commandType!.typeName} 0x0c 钥匙数量已到上限"); + showErrorMessage('钥匙数量已到上限'); + AppLog.log('$logTag ${commandType!.typeName} 0x0c 钥匙数量已到上限'); break; case 0x0d: // 钥匙无效 - showErrorMessage("钥匙无效"); - AppLog.log("$logTag ${commandType!.typeName} 0x0d 钥匙无效"); + showErrorMessage('钥匙无效'); + AppLog.log('$logTag ${commandType!.typeName} 0x0d 钥匙无效'); break; case 0x0e: // 钥匙已存在 - showErrorMessage("钥匙已存在"); - AppLog.log("$logTag ${commandType!.typeName} 0x0e 钥匙已存在"); + showErrorMessage('钥匙已存在'); + AppLog.log('$logTag ${commandType!.typeName} 0x0e 钥匙已存在'); break; case 0x0f: // 用户已存在 - AppLog.log("$logTag ${commandType!.typeName} 0x0f 用户已存在"); - showErrorMessage("用户已存在"); + AppLog.log('$logTag ${commandType!.typeName} 0x0f 用户已存在'); + showErrorMessage('用户已存在'); break; case 0x10: // 密码失效 - AppLog.log("$logTag ${commandType!.typeName} 0x11 密码失效"); - showErrorMessage("密码失效"); + AppLog.log('$logTag ${commandType!.typeName} 0x11 密码失效'); + showErrorMessage('密码失效'); break; case 0x11: // 无效指令 - AppLog.log("$logTag ${commandType!.typeName} 0x11 无效指令"); - showErrorMessage("无效指令"); + AppLog.log('$logTag ${commandType!.typeName} 0x11 无效指令'); + showErrorMessage('无效指令'); break; case 0x12: // 门锁时间异常 - AppLog.log("$logTag ${commandType!.typeName} 0x12 门锁时间异常"); - showErrorMessage("门锁时间异常"); + AppLog.log('$logTag ${commandType!.typeName} 0x12 门锁时间异常'); + showErrorMessage('门锁时间异常'); break; case 0x15: // APP(手机)未联网 - AppLog.log("$logTag ${commandType!.typeName} 0x15 APP(手机)未联网"); - showErrorMessage("APP(手机)未联网"); + AppLog.log('$logTag ${commandType!.typeName} 0x15 APP(手机)未联网'); + showErrorMessage('APP(手机)未联网'); break; case 0x16: // 正在开锁中... - AppLog.log("$logTag ${commandType!.typeName} $status 正在开锁中..."); - showErrorMessage("正在开锁中..."); + AppLog.log('$logTag ${commandType!.typeName} $status 正在开锁中...'); + showErrorMessage('正在开锁中...'); break; case 0xff: // 异常,未知错误 - AppLog.log("$logTag ${commandType!.typeName} 0xff 异常,未知错误"); - showErrorMessage("异常,未知错误"); + AppLog.log('$logTag ${commandType!.typeName} 0xff 异常,未知错误'); + showErrorMessage('异常,未知错误'); break; default: //失败 - AppLog.log("$logTag ${commandType!.typeName} $status 蓝牙返回其他错误问题"); + AppLog.log('$logTag ${commandType!.typeName} $status 蓝牙返回其他错误问题'); break; } } diff --git a/lib/blue/io_sender.dart b/lib/blue/io_sender.dart index 098f50a5..ae45e67e 100755 --- a/lib/blue/io_sender.dart +++ b/lib/blue/io_sender.dart @@ -34,9 +34,9 @@ abstract class SenderProtocol extends IOData { } void printLog(List data) { - AppLog.log( - "App -> 锁,指令类型:${commandType!.typeName} ${commandType!.typeValue == 0x3030 - ? '子命令:${data[3]}' : ''} \n参数是:\n${toString()} \n加密之前数据是:\n$data 长度是:${data.length}"); + // AppLog.log( + // "App -> 锁,指令类型:${commandType!.typeName} ${commandType!.typeValue == 0x3030 + // ? '子命令:${data[3]}' : ''} \n参数是:\n${toString()} \n加密之前数据是:\n$data 长度是:${data.length}"); } //TODO:拼装数据Ï diff --git a/lib/blue/reciver_data.dart b/lib/blue/reciver_data.dart index e2aaad2b..4217a096 100755 --- a/lib/blue/reciver_data.dart +++ b/lib/blue/reciver_data.dart @@ -47,12 +47,12 @@ import 'io_tool/manager_event_bus.dart'; import 'sm4Encipher/sm4.dart'; class CommandReciverManager { - static void appDataReceive(List data) async { + static Future appDataReceive(List data) async { ///解析数据 if (data.isEmpty) { return; } - int dataSize = data.length; + final int dataSize = data.length; // 当小于包头加起来13个字节 if (dataSize < 13) { return; @@ -62,20 +62,20 @@ class CommandReciverManager { (data[1] == 0x01) && (data[2] == 0xEE) && (data[3] == 0x02)) { - var tmpType = (data[7] & 0x0f); // 包标识 - // AppLog.log("temType:$tmpType"); + final int tmpType = data[7] & 0x0f; // 包标识 + // AppLog.log('temType:$tmpType'); - var dataLen = data[8] * 256 + data[9]; // 高16位用来指示后面数据块内容的长度 - var oriLen = data[10] * 256 + data[11]; // 低16位用来指示数据加密前的原长度 + final int dataLen = data[8] * 256 + data[9]; // 高16位用来指示后面数据块内容的长度 + final int oriLen = data[10] * 256 + data[11]; // 低16位用来指示数据加密前的原长度 // AppLog.log("dataLen:$dataLen oriLen:$oriLen"); - List oriDataList = []; + List oriDataList = []; switch (tmpType) { case 0: //不加密 // for (var i = 0; i < oriLen ; i++) { // oriDataList.add(data[12 + i]); // } oriDataList = data.sublist(12, 12 + dataLen); - AppLog.log("不加密 :$oriDataList"); + AppLog.log('不加密 :$oriDataList'); break; case 1: //AES128 @@ -83,7 +83,7 @@ class CommandReciverManager { case 2: // SM4(事先约定密钥) // 获取的加密数组 - var getDataList = data.sublist(12, 12 + dataLen); + final List getDataList = data.sublist(12, 12 + dataLen); // 解密 // String key = SM4.createHexKey(key: IoManager().getCurrentDeviceLockId); @@ -91,39 +91,39 @@ class CommandReciverManager { key: utf8.encode(BlueManage().connectDeviceName), mode: SM4CryptoMode.ECB); oriDataList = oriDataList.sublist(0, oriLen); - AppLog.log("APP收到的解密后的数据:$oriDataList"); + AppLog.log('APP收到的解密后的数据:$oriDataList'); break; case 3: //SM4(设备指定密钥) // 获取的加密数组 - var getDataList = data.sublist(12, 12 + dataLen); + final List getDataList = data.sublist(12, 12 + dataLen); - var res = await Storage.getStringList(saveBluePrivateKey); - List getPrivateKeyList = changeStringListToIntList(res!); + final List? res = await Storage.getStringList(saveBluePrivateKey); + final List getPrivateKeyList = changeStringListToIntList(res!); // 解密 oriDataList = SM4.decrypt(getDataList, key: getPrivateKeyList, mode: SM4CryptoMode.ECB); oriDataList = oriDataList.sublist(0, oriLen); - AppLog.log("APP收到的解密后的数据:$oriDataList"); + AppLog.log('APP收到的解密后的数据:$oriDataList data:$data'); break; } parseData(oriDataList).then((Reply? value) async { EasyLoading.dismiss(); await EventBusManager().eventBusFir(value); }).catchError((error) { - AppLog.log("APP解析数据时发生错误: $error"); + AppLog.log('APP解析数据时发生错误: $error'); }); } } static Future parseData(List data) async { if (data.isNotEmpty) { - var cmd = data[0] * 256 + data[1]; - CommandType commandType = ExtensionCommandType.getCommandType(cmd); + final int cmd = data[0] * 256 + data[1]; + final CommandType commandType = ExtensionCommandType.getCommandType(cmd); await IoManager().increaseCommandIndex(); // data.removeRange(0, 2); - var reply; + Reply? reply; switch (commandType) { case CommandType.getLockPublicKey: { @@ -204,7 +204,7 @@ class CommandReciverManager { case CommandType.generalExtendedCommond: { // 子命令类型 - int subType = data[3]; + final int subType = data[3]; switch (subType) { case 2: { @@ -437,5 +437,6 @@ class CommandReciverManager { } return reply; } + return null; } } diff --git a/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_logic.dart b/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_logic.dart index a2e3a7d9..434c7e57 100755 --- a/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_logic.dart +++ b/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_logic.dart @@ -73,7 +73,7 @@ class AuthorizedAdminLogic extends BaseGetXController { // 转移权限 Future transferPermissionsAction() async { - BlueManage().bludSendData(BlueManage().connectDeviceName, + BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState state) async { if (state == BluetoothConnectionState.connected) { var privateKey = await Storage.getStringList(saveBluePrivateKey); diff --git a/lib/main/lockDetail/card/addICCard/addICCard_logic.dart b/lib/main/lockDetail/card/addICCard/addICCard_logic.dart index d35af8ef..f25dbe42 100755 --- a/lib/main/lockDetail/card/addICCard/addICCard_logic.dart +++ b/lib/main/lockDetail/card/addICCard/addICCard_logic.dart @@ -147,7 +147,7 @@ class AddICCardLogic extends BaseGetXController{ showBlueConnetctToastTimer(action: (){ Get.close(1); }); - BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { + BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { if (deviceConnectionState == BluetoothConnectionState.connected){ cancelBlueConnetctToastTimer(); // var publicKey = await Storage.getStringList(saveBluePublicKey); @@ -193,7 +193,7 @@ class AddICCardLogic extends BaseGetXController{ // 取消添加指纹 Future senderCancelAddCardCommand() async { - BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { + BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { if (deviceConnectionState == BluetoothConnectionState.connected){ var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); diff --git a/lib/main/lockDetail/card/cardDetail/cardDetail_logic.dart b/lib/main/lockDetail/card/cardDetail/cardDetail_logic.dart index 91e9a92b..c4c4d51f 100755 --- a/lib/main/lockDetail/card/cardDetail/cardDetail_logic.dart +++ b/lib/main/lockDetail/card/cardDetail/cardDetail_logic.dart @@ -100,7 +100,7 @@ class CardDetailLogic extends BaseGetXController{ dismissEasyLoading(); state.sureBtnState.value = 0; }); - BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { + BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { if (deviceConnectionState == BluetoothConnectionState.connected){ var signKey = await Storage.getStringList(saveBlueSignKey); List signKeyDataList = changeStringListToIntList(signKey!); diff --git a/lib/main/lockDetail/card/cardList/cardList_logic.dart b/lib/main/lockDetail/card/cardList/cardList_logic.dart index c02dce71..b1eabbff 100755 --- a/lib/main/lockDetail/card/cardList/cardList_logic.dart +++ b/lib/main/lockDetail/card/cardList/cardList_logic.dart @@ -229,7 +229,7 @@ class CardListLogic extends BaseGetXController { showBlueConnetctToastTimer(action: (){ dismissEasyLoading(); }); - BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { + BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { if (deviceConnectionState == BluetoothConnectionState.connected){ // var publicKey = await Storage.getStringList(saveBluePublicKey); // List publicKeyDataList = changeStringListToIntList(publicKey!); diff --git a/lib/main/lockDetail/card/otherTypeKeyChangeDate/otherTypeKeyChangeDate_logic.dart b/lib/main/lockDetail/card/otherTypeKeyChangeDate/otherTypeKeyChangeDate_logic.dart index 55a98228..28f18489 100755 --- a/lib/main/lockDetail/card/otherTypeKeyChangeDate/otherTypeKeyChangeDate_logic.dart +++ b/lib/main/lockDetail/card/otherTypeKeyChangeDate/otherTypeKeyChangeDate_logic.dart @@ -105,7 +105,7 @@ class OtherTypeKeyChangeDateLogic extends BaseGetXController{ dismissEasyLoading(); state.sureBtnState.value = 0; }); - BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { + BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { if (deviceConnectionState == BluetoothConnectionState.connected) { var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); @@ -257,7 +257,7 @@ class OtherTypeKeyChangeDateLogic extends BaseGetXController{ dismissEasyLoading(); state.sureBtnState.value = 0; }); - BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { + BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { if (deviceConnectionState == BluetoothConnectionState.connected){ // var publicKey = await Storage.getStringList(saveBluePublicKey); // List publicKeyDataList = changeStringListToIntList(publicKey!); @@ -313,7 +313,7 @@ class OtherTypeKeyChangeDateLogic extends BaseGetXController{ dismissEasyLoading(); state.sureBtnState.value = 0; }); - BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { + BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { if (deviceConnectionState == BluetoothConnectionState.connected){ var signKey = await Storage.getStringList(saveBlueSignKey); diff --git a/lib/main/lockDetail/card/otherTypeKeyChangeValidityDate/otherTypeKeyChangeValidityDate_logic.dart b/lib/main/lockDetail/card/otherTypeKeyChangeValidityDate/otherTypeKeyChangeValidityDate_logic.dart index 7fa54f98..3cde986b 100755 --- a/lib/main/lockDetail/card/otherTypeKeyChangeValidityDate/otherTypeKeyChangeValidityDate_logic.dart +++ b/lib/main/lockDetail/card/otherTypeKeyChangeValidityDate/otherTypeKeyChangeValidityDate_logic.dart @@ -107,7 +107,7 @@ class OtherTypeKeyChangeValidityDateLogic extends BaseGetXController{ dismissEasyLoading(); state.sureBtnState.value = 0; }); - BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { + BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { if (deviceConnectionState == BluetoothConnectionState.connected) { var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); @@ -259,7 +259,7 @@ class OtherTypeKeyChangeValidityDateLogic extends BaseGetXController{ dismissEasyLoading(); state.sureBtnState.value = 0; }); - BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { + BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { if (deviceConnectionState == BluetoothConnectionState.connected){ // var publicKey = await Storage.getStringList(saveBluePublicKey); // List publicKeyDataList = changeStringListToIntList(publicKey!); @@ -315,7 +315,7 @@ class OtherTypeKeyChangeValidityDateLogic extends BaseGetXController{ dismissEasyLoading(); state.sureBtnState.value = 0; }); - BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { + BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { if (deviceConnectionState == BluetoothConnectionState.connected){ var signKey = await Storage.getStringList(saveBlueSignKey); diff --git a/lib/main/lockDetail/doorLockLog/doorLockLog_logic.dart b/lib/main/lockDetail/doorLockLog/doorLockLog_logic.dart index 4852578a..d0184b1c 100755 --- a/lib/main/lockDetail/doorLockLog/doorLockLog_logic.dart +++ b/lib/main/lockDetail/doorLockLog/doorLockLog_logic.dart @@ -106,7 +106,7 @@ class DoorLockLogLogic extends BaseGetXController { showBlueConnetctToastTimer(action: () { dismissEasyLoading(); }); - BlueManage().bludSendData(BlueManage().connectDeviceName, + BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionStateState) async { if (connectionStateState == BluetoothConnectionState.connected) { var privateKey = await Storage.getStringList(saveBluePrivateKey); diff --git a/lib/main/lockDetail/face/addFace/addFace_logic.dart b/lib/main/lockDetail/face/addFace/addFace_logic.dart index b620dcce..0cbecfd2 100755 --- a/lib/main/lockDetail/face/addFace/addFace_logic.dart +++ b/lib/main/lockDetail/face/addFace/addFace_logic.dart @@ -186,7 +186,7 @@ class AddFaceLogic extends BaseGetXController { showBlueConnetctToastTimer(action: () { Get.close(1); }); - BlueManage().bludSendData(BlueManage().connectDeviceName, + BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { if (deviceConnectionState == BluetoothConnectionState.connected) { cancelBlueConnetctToastTimer(); @@ -231,7 +231,7 @@ class AddFaceLogic extends BaseGetXController { // 取消添加指纹 Future senderCancelAddFaceCommand() async { - BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { + BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { if (deviceConnectionState == BluetoothConnectionState.connected){ var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); diff --git a/lib/main/lockDetail/face/faceDetail/faceDetail_logic.dart b/lib/main/lockDetail/face/faceDetail/faceDetail_logic.dart index 55f62580..7e79a191 100755 --- a/lib/main/lockDetail/face/faceDetail/faceDetail_logic.dart +++ b/lib/main/lockDetail/face/faceDetail/faceDetail_logic.dart @@ -97,7 +97,7 @@ class FaceDetailLogic extends BaseGetXController { dismissEasyLoading(); state.sureBtnState.value = 0; }); - BlueManage().bludSendData(BlueManage().connectDeviceName, + BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { if (deviceConnectionState == BluetoothConnectionState.connected) { var privateKey = await Storage.getStringList(saveBluePrivateKey); diff --git a/lib/main/lockDetail/face/faceList/faceList_logic.dart b/lib/main/lockDetail/face/faceList/faceList_logic.dart index 2f2e6708..1a166331 100755 --- a/lib/main/lockDetail/face/faceList/faceList_logic.dart +++ b/lib/main/lockDetail/face/faceList/faceList_logic.dart @@ -256,7 +256,7 @@ class FaceListLogic extends BaseGetXController { showBlueConnetctToastTimer(action: () { dismissEasyLoading(); }); - BlueManage().bludSendData(BlueManage().connectDeviceName, + BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { if (deviceConnectionState == BluetoothConnectionState.connected) { diff --git a/lib/main/lockDetail/fingerprint/addFingerprint/addFingerprint_logic.dart b/lib/main/lockDetail/fingerprint/addFingerprint/addFingerprint_logic.dart index 5f7f5e0b..f01eb892 100755 --- a/lib/main/lockDetail/fingerprint/addFingerprint/addFingerprint_logic.dart +++ b/lib/main/lockDetail/fingerprint/addFingerprint/addFingerprint_logic.dart @@ -185,7 +185,7 @@ class AddFingerprintLogic extends BaseGetXController { showBlueConnetctToastTimer(action: (){ Get.close(1); }); - BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { + BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { if (deviceConnectionState == BluetoothConnectionState.connected){ var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); @@ -227,7 +227,7 @@ class AddFingerprintLogic extends BaseGetXController { // 取消添加指纹 Future senderCancelAddFingerprintCommand() async { - BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { + BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { if (deviceConnectionState == BluetoothConnectionState.connected){ var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); diff --git a/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_logic.dart b/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_logic.dart index b720e72a..67989e56 100755 --- a/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_logic.dart +++ b/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_logic.dart @@ -98,7 +98,7 @@ class FingerprintDetailLogic extends BaseGetXController{ dismissEasyLoading(); state.sureBtnState.value = 0; }); - BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { + BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { if (deviceConnectionState == BluetoothConnectionState.connected){ // var publicKey = await Storage.getStringList(saveBluePublicKey); // List publicKeyDataList = changeStringListToIntList(publicKey!); diff --git a/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_logic.dart b/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_logic.dart index fa4f92e5..4bffbc07 100755 --- a/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_logic.dart +++ b/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_logic.dart @@ -189,7 +189,7 @@ class FingerprintListLogic extends BaseGetXController{ } // 获取指纹状态 Future senderQueryingFingerprintStatus() async { - BlueManage().bludSendData(BlueManage().connectDeviceName,(BluetoothConnectionState state) async { + BlueManage().blueSendData(BlueManage().connectDeviceName,(BluetoothConnectionState state) async { if (state == BluetoothConnectionState.connected) { var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); @@ -217,7 +217,7 @@ class FingerprintListLogic extends BaseGetXController{ // 查询用户、指纹、密码、卡片数量(用于判断是否同步) Future senderCheckingUserInfoCount() async { - BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState state) async { + BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState state) async { if (state == BluetoothConnectionState.connected) { var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); @@ -248,7 +248,7 @@ class FingerprintListLogic extends BaseGetXController{ showBlueConnetctToastTimer(action: (){ dismissEasyLoading(); }); - BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { + BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { if (deviceConnectionState == BluetoothConnectionState.connected){ // var publicKey = await Storage.getStringList(saveBluePublicKey); // List publicKeyDataList = changeStringListToIntList(publicKey!); diff --git a/lib/main/lockDetail/iris/irisDetail/irisDetail_logic.dart b/lib/main/lockDetail/iris/irisDetail/irisDetail_logic.dart index 4cff3b34..e5309102 100755 --- a/lib/main/lockDetail/iris/irisDetail/irisDetail_logic.dart +++ b/lib/main/lockDetail/iris/irisDetail/irisDetail_logic.dart @@ -90,7 +90,7 @@ class IrisDetailLogic extends BaseGetXController { dismissEasyLoading(); state.sureBtnState.value = 0; }); - BlueManage().bludSendData(BlueManage().connectDeviceName, + BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { if (deviceConnectionState == BluetoothConnectionState.connected) { // var publicKey = await Storage.getStringList(saveBluePublicKey); diff --git a/lib/main/lockDetail/iris/irisList/irisList_logic.dart b/lib/main/lockDetail/iris/irisList/irisList_logic.dart index 228e0e45..f0b2f68c 100755 --- a/lib/main/lockDetail/iris/irisList/irisList_logic.dart +++ b/lib/main/lockDetail/iris/irisList/irisList_logic.dart @@ -189,7 +189,7 @@ class IrisListLogic extends BaseGetXController { // 获取人脸状态 Future senderQueryingFaceStatus() async { - BlueManage().bludSendData(BlueManage().connectDeviceName, + BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState state) async { if (state == BluetoothConnectionState.connected) { var privateKey = await Storage.getStringList(saveBluePrivateKey); @@ -218,7 +218,7 @@ class IrisListLogic extends BaseGetXController { // 查询用户、指纹、密码、卡片数量(用于判断是否同步) Future senderCheckingUserInfoCount() async { - BlueManage().bludSendData(BlueManage().connectDeviceName, + BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState state) async { if (state == BluetoothConnectionState.connected) { var privateKey = await Storage.getStringList(saveBluePrivateKey); @@ -250,7 +250,7 @@ class IrisListLogic extends BaseGetXController { showBlueConnetctToastTimer(action: () { dismissEasyLoading(); }); - BlueManage().bludSendData(BlueManage().connectDeviceName, + BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { if (deviceConnectionState == BluetoothConnectionState.connected) { var signKey = await Storage.getStringList(saveBlueSignKey); diff --git a/lib/main/lockDetail/lockDetail/lockDetail_logic.dart b/lib/main/lockDetail/lockDetail/lockDetail_logic.dart index d8d2c5fc..aeae0a6a 100755 --- a/lib/main/lockDetail/lockDetail/lockDetail_logic.dart +++ b/lib/main/lockDetail/lockDetail/lockDetail_logic.dart @@ -33,21 +33,22 @@ import 'lockNetToken_entity.dart'; class LockDetailLogic extends BaseGetXController { final LockDetailState state = LockDetailState(); + // 监听设备返回的数据 void initReplySubscription() { state.replySubscription = EventBusManager().eventBus!.on().listen((Reply reply) async { - // 开门 - if (reply is OpenDoorReply && state.ifCurrentScreen.value == true) { - _replyOpenLock(reply); - } + // 开门 + if (reply is OpenDoorReply && state.ifCurrentScreen.value == true) { + _replyOpenLock(reply); + } - // 开完锁之后上传记录 - if (reply is SenderReferEventRecordTimeReply && - state.ifCurrentScreen.value == true) { - _replyReferEventRecordTime(reply); - } - }); + // 开完锁之后上传记录 + if (reply is SenderReferEventRecordTimeReply && + state.ifCurrentScreen.value == true) { + _replyReferEventRecordTime(reply); + } + }); } // 开门数据解析 @@ -56,8 +57,8 @@ class LockDetailLogic extends BaseGetXController { switch (status) { case 0x00: - //成功 - // _showFullScreenOverlay(Get.context!); + //成功 + // _showFullScreenOverlay(Get.context!); cancelBlueConnetctToastTimer(); state.iSClosedUnlockSuccessfulPopup.value = true; @@ -65,10 +66,10 @@ class LockDetailLogic extends BaseGetXController { // 如果没有点击关闭弹窗,3秒后自动关闭 state.closedUnlockSuccessfulTimer = Timer.periodic(3.seconds, (Timer timer) { - state.iSClosedUnlockSuccessfulPopup.value = false; - timer.cancel(); - eventBus.fire(RefreshLockDetailInfoDataEvent()); - }); + state.iSClosedUnlockSuccessfulPopup.value = false; + timer.cancel(); + eventBus.fire(RefreshLockDetailInfoDataEvent()); + }); // 电量 final int power = reply.data[7]; @@ -86,14 +87,14 @@ class LockDetailLogic extends BaseGetXController { resetOpenDoorState(); break; case 0x06: - //无权限 + //无权限 final List? privateKey = - await Storage.getStringList(saveBluePrivateKey); + await Storage.getStringList(saveBluePrivateKey); final List getPrivateKeyList = - changeStringListToIntList(privateKey!); + changeStringListToIntList(privateKey!); final List? signKey = - await Storage.getStringList(saveBlueSignKey); + await Storage.getStringList(saveBlueSignKey); final List signKeyDataList = changeStringListToIntList(signKey!); final List tokenData = reply.data.sublist(2, 6); @@ -113,71 +114,58 @@ class LockDetailLogic extends BaseGetXController { ); break; case 0x16: - // 正在开锁中... + // 正在开锁中... resetOpenDoorState(); showToast('正在开锁中...'.tr, something: () { cancelBlueConnetctToastTimer(); }); break; case 0x0d: - // 钥匙无效 + // 钥匙无效 showToast('钥匙无效'.tr); - // state.animationController!.stop(); - resetOpenDoorState(); - cancelBlueConnetctToastTimer(); - BlueManage().disconnect(); + openDoorError(); break; case 0x0b: - // 钥匙无效 + // 钥匙无效 showToast('钥匙过期'.tr); - resetOpenDoorState(); - - cancelBlueConnetctToastTimer(); - BlueManage().disconnect(); + openDoorError(); break; case 0x0a: - // 钥匙不存在 + // 钥匙不存在 showToast('钥匙不存在'); - resetOpenDoorState(); - - cancelBlueConnetctToastTimer(); - BlueManage().disconnect(); + openDoorError(); break; case 0x0c: - // 钥匙数量已到上限 + // 钥匙数量已到上限 showToast('钥匙数量已到上限'); - resetOpenDoorState(); - - cancelBlueConnetctToastTimer(); - BlueManage().disconnect(); + openDoorError(); break; case 0x0e: - // 钥匙已存在 + // 钥匙已存在 showToast('钥匙已存在'); - resetOpenDoorState(); - - cancelBlueConnetctToastTimer(); - BlueManage().disconnect(); + openDoorError(); break; case 0x0f: - // 用户已存在 + // 用户已存在 showToast('用户已存在'); - resetOpenDoorState(); - - cancelBlueConnetctToastTimer(); - BlueManage().disconnect(); + openDoorError(); break; default: - //失败 + //失败 AppLog.log('开锁失败'); - // state.animationController!.stop(); - resetOpenDoorState(); - cancelBlueConnetctToastTimer(); - BlueManage().disconnect(); + openDoorError(); break; } } + //开门指令失败 + void openDoorError() { + resetOpenDoorState(); + state.animationController!.stop(); + cancelBlueConnetctToastTimer(); + BlueManage().disconnect(); + } + //清除开锁动画以及状态 void closeLuckStatus() { state.openLockBtnState.value = 0; @@ -190,67 +178,67 @@ class LockDetailLogic extends BaseGetXController { Future _replyReferEventRecordTime(Reply reply) async { final int status = reply.data[2]; switch (status) { - case 0x00: - //成功 - final int dataLength = (reply.data[5] << 8) + reply.data[6]; - // AppLog.log("dataLength:$dataLength"); - if (dataLength > 0) { - reply.data.removeRange(0, 7); - // 把得到的数据按17个字节分割成数组 然后塞进一个新的数组里面 - if (reply.data.length < 17) { - return; - } - final List> getList = splitList(reply.data, 17); - // AppLog.log("getList:$getList"); - final List uploadList = []; - for (int i = 0; i < getList.length; i++) { - final List indexList = getList[i]; - // AppLog.log("indexList:$indexList"); - final Map indexMap = {}; - indexMap['type'] = indexList[0].toString(); - int operateDate = 0; - if (indexList[0] == 2) { - final List passwordData = reply.data.sublist(7, 17); - final String password = utf8String(passwordData); - indexMap['user'] = password.toString(); - } else { - final int userNo = (indexList[1] * 256) + indexList[2]; - indexMap['user'] = userNo.toString(); - } + case 0x00: + //成功 + final int dataLength = (reply.data[5] << 8) + reply.data[6]; + // AppLog.log("dataLength:$dataLength"); + if (dataLength > 0) { + reply.data.removeRange(0, 7); + // 把得到的数据按17个字节分割成数组 然后塞进一个新的数组里面 + if (reply.data.length < 17) { + return; + } + final List> getList = splitList(reply.data, 17); + // AppLog.log("getList:$getList"); + final List uploadList = []; + for (int i = 0; i < getList.length; i++) { + final List indexList = getList[i]; + // AppLog.log("indexList:$indexList"); + final Map indexMap = {}; + indexMap['type'] = indexList[0].toString(); + int operateDate = 0; + if (indexList[0] == 2) { + final List passwordData = reply.data.sublist(7, 17); + final String password = utf8String(passwordData); + indexMap['user'] = password.toString(); + } else { + final int userNo = (indexList[1] * 256) + indexList[2]; + indexMap['user'] = userNo.toString(); + } - indexMap['success'] = '1'; + indexMap['success'] = '1'; - final int time = ((0xff & indexList[(3)]) << 24 | - (0xff & indexList[4]) << 16 | - (0xff & indexList[5]) << 8 | - (0xFF & indexList[6])); - operateDate = time * 1000; - indexMap['date'] = '$operateDate'; - uploadList.add(indexMap); + final int time = ((0xff & indexList[(3)]) << 24 | + (0xff & indexList[4]) << 16 | + (0xff & indexList[5]) << 8 | + (0xFF & indexList[6])); + operateDate = time * 1000; + indexMap['date'] = '$operateDate'; + uploadList.add(indexMap); - if (i == getList.length - 1) { - //设置最后的时间戳 - state.operateDate = operateDate; - } - } - lockRecordUploadData(uploadList); + if (i == getList.length - 1) { + //设置最后的时间戳 + state.operateDate = operateDate; + } + } + lockRecordUploadData(uploadList); - if (dataLength == state.logCountPage) { - senderReferEventRecordTime(); - } else { - await BlueManage().disconnect(); - } - } - break; - case 0x06: - //无权限 - BlueManage().disconnect(); - cancelBlueConnetctToastTimer(); - break; - default: - BlueManage().disconnect(); - cancelBlueConnetctToastTimer(); - break; + if (dataLength == state.logCountPage) { + senderReferEventRecordTime(); + } else { + await BlueManage().disconnect(); + } + } + break; + case 0x06: + //无权限 + BlueManage().disconnect(); + cancelBlueConnetctToastTimer(); + break; + default: + BlueManage().disconnect(); + cancelBlueConnetctToastTimer(); + break; } } @@ -258,11 +246,11 @@ class LockDetailLogic extends BaseGetXController { Future openDoorAction() async { showBlueConnetctToastTimer(action: () { resetOpenDoorState(); - // BlueManage().stopScan(); + closeLuckStatus(); BlueManage().disconnect(); }); final List? privateKey = - await Storage.getStringList(saveBluePrivateKey); + await Storage.getStringList(saveBluePrivateKey); final List getPrivateKeyList = changeStringListToIntList(privateKey!); final List? signKey = await Storage.getStringList(saveBlueSignKey); @@ -272,89 +260,83 @@ class LockDetailLogic extends BaseGetXController { final List getTokenList = changeStringListToIntList(token!); BlueManage() - .bludSendData(state.keyInfos.value.bluetooth!.bluetoothDeviceName!, + .blueSendData(state.keyInfos.value.bluetooth!.bluetoothDeviceName!, (BluetoothConnectionState deviceConnectionState) async { - if (deviceConnectionState == BluetoothConnectionState.connected) { - IoSenderManage.senderOpenLock( - keyID: BlueManage().connectDeviceName, - userID: await Storage.getUid(), - openMode: state.openDoorModel, - openTime: getUTCNetTime(), - onlineToken: state.lockNetToken, - token: getTokenList, - needAuthor: 1, - signKey: signKeyDataList, - privateKey: getPrivateKeyList, - ); - } else if (deviceConnectionState == - BluetoothConnectionState.disconnected) { - cancelBlueConnetctToastTimer(); - if (state.ifCurrentScreen.value == true) { - showBlueConnetctToast(); - } + if (deviceConnectionState == BluetoothConnectionState.connected) { + IoSenderManage.senderOpenLock( + keyID: BlueManage().connectDeviceName, + userID: await Storage.getUid(), + openMode: state.openDoorModel, + openTime: getUTCNetTime(), + onlineToken: state.lockNetToken, + token: getTokenList, + needAuthor: 1, + signKey: signKeyDataList, + privateKey: getPrivateKeyList, + ); + } else if (deviceConnectionState == + BluetoothConnectionState.disconnected) { + cancelBlueConnetctToastTimer(); + if (state.ifCurrentScreen.value == true) { + showBlueConnetctToast(); + } - resetOpenDoorState(); - } - }); + resetOpenDoorState(); + } + }); } // 查询事件记录(时间查询) Future senderReferEventRecordTime() async { showBlueConnetctToastTimer( isShowBlueConnetctToast: false, - outTimer: 10, action: () { BlueManage().disconnect(); }); - BlueManage().bludSendData(BlueManage().connectDeviceName, - (BluetoothConnectionState connectionState) async { - if (connectionState == BluetoothConnectionState.connected) { - final List? privateKey = + BlueManage().blueSendData(BlueManage().connectDeviceName, + (BluetoothConnectionState connectionState) async { + if (connectionState == BluetoothConnectionState.connected) { + final List? privateKey = await Storage.getStringList(saveBluePrivateKey); - final List getPrivateKeyList = + final List getPrivateKeyList = changeStringListToIntList(privateKey!); - final List? token = await Storage.getStringList( - saveBlueToken); - final List getTokenList = changeStringListToIntList(token!); + final List? token = await Storage.getStringList(saveBlueToken); + final List getTokenList = changeStringListToIntList(token!); - final List? publicKey = + final List? publicKey = await Storage.getStringList(saveBluePublicKey); - final List getPublicKeyList = + final List getPublicKeyList = changeStringListToIntList(publicKey!); - IoSenderManage.senderReferEventRecordTimeCommand( - keyID: BlueManage().connectDeviceName, - userID: await Storage.getUid(), - logsCount: state.logCountPage, - // time:DateTime.now().millisecondsSinceEpoch~/1000, - time: state.operateDate, - token: getTokenList, - needAuthor: 1, - publicKey: getPublicKeyList, - privateKey: getPrivateKeyList, - ); - } - }); + IoSenderManage.senderReferEventRecordTimeCommand( + keyID: BlueManage().connectDeviceName, + userID: await Storage.getUid(), + logsCount: state.logCountPage, + // time:DateTime.now().millisecondsSinceEpoch~/1000, + time: state.operateDate, + token: getTokenList, + needAuthor: 1, + publicKey: getPublicKeyList, + privateKey: getPrivateKeyList, + ); + } + }); } // 从服务器获取锁的时间 开锁时传入 void getServerDatetime() async { final GetServerDatetimeEntity entity = - await ApiRepository.to.getServerDatetimeData(); + await ApiRepository.to.getServerDatetimeData(); if (entity.errorCode!.codeIsSuccessful) { state.differentialTime = entity.data!.date! ~/ 1000 - - DateTime - .now() - .millisecondsSinceEpoch ~/ 1000; + DateTime.now().millisecondsSinceEpoch ~/ 1000; // AppLog.log("entity.data!.date! ~/ 1000:${entity.data!.date! ~/ 1000} DateTime.now().millisecondsSinceEpoch ~/ 1000:${DateTime.now().millisecondsSinceEpoch ~/ 1000} 服务器时间差:${state.differentialTime}"); } } int getUTCNetTime() { - return DateTime - .now() - .millisecondsSinceEpoch ~/ 1000 + + return DateTime.now().millisecondsSinceEpoch ~/ 1000 + state.differentialTime; } @@ -380,11 +362,11 @@ class LockDetailLogic extends BaseGetXController { Future uploadElectricQuantityRequest() async { final KeyOperationRecordEntity entity = await ApiRepository.to .uploadElectricQuantity( - electricQuantity: state.electricQuantity.value.toString(), - electricQuantityStandby: - state.electricQuantityStandby.value.toString(), - lockId: state.keyInfos.value.lockId.toString(), - isUnShowLoading: true); + electricQuantity: state.electricQuantity.value.toString(), + electricQuantityStandby: + state.electricQuantityStandby.value.toString(), + lockId: state.keyInfos.value.lockId.toString(), + isUnShowLoading: true); if (entity.errorCode!.codeIsSuccessful) { SchedulerBinding.instance.addPostFrameCallback((_) { eventBus.fire(RefreshLockListInfoDataEvent(isUnShowLoading: true)); @@ -395,8 +377,8 @@ class LockDetailLogic extends BaseGetXController { // 查询锁记录最后时间 void getLockRecordLastUploadDataTime() async { final LockOperatingRecordGetLastRecordTimeEntity entity = - await ApiRepository.to.getLockRecordLastUploadDataTime( - lockId: state.keyInfos.value.lockId.toString()); + await ApiRepository.to.getLockRecordLastUploadDataTime( + lockId: state.keyInfos.value.lockId.toString()); if (entity.errorCode!.codeIsSuccessful) { state.operateDate = entity.data!.operateDate! ~/ 1000; senderReferEventRecordTime(); @@ -407,7 +389,7 @@ class LockDetailLogic extends BaseGetXController { Future lockRecordUploadData(List list) async { final KeyOperationRecordEntity entity = await ApiRepository.to .lockRecordUploadData( - lockId: state.keyInfos.value.lockId.toString(), records: list); + lockId: state.keyInfos.value.lockId.toString(), records: list); if (entity.errorCode!.codeIsSuccessful) { // mockNetworkDataRequest(); AppLog.log( @@ -423,7 +405,7 @@ class LockDetailLogic extends BaseGetXController { void deletKeyData() async { final ElectronicKeyListEntity entity = await ApiRepository.to .deleteElectronicKey( - keyId: state.keyInfos.value.keyId.toString(), includeUnderlings: 0); + keyId: state.keyInfos.value.keyId.toString(), includeUnderlings: 0); if (entity.errorCode!.codeIsSuccessful) { BlueManage().connectDeviceMacAddress = ''; SchedulerBinding.instance.addPostFrameCallback((_) { @@ -440,51 +422,50 @@ class LockDetailLogic extends BaseGetXController { eventBus .on() .listen((LockSetChangeSetRefreshLockDetailWithType event) { - if (event.type == 0) { - // 0考勤 - state.isAttendance.value = int.parse(event.setResult); - state.keyInfos.value.lockSetting!.attendance = - int.parse(event.setResult); - } else if (event.type == 1) { - // 1 开锁时是否需联网 - state.isOpenLockNeedOnline.value = int.parse(event.setResult); - state.keyInfos.value.lockSetting!.appUnlockOnline = - int.parse(event.setResult); - state.lockNetToken = ''; // 改变开锁时是否联网状态的时候清空token - } else if (event.type == 2) { - // 2 常开模式 - state.isOpenPassageMode.value = int.parse(event.setResult); - state.keyInfos.value.passageMode = int.parse(event.setResult); - } else if (event.type == 3) { - // 3 修改了锁名字 - state.lockAlias.value = event.setResult; - state.keyInfos.value.lockAlias = event.setResult; - Storage.setString(saveLockAlias, state.lockAlias.value); - } else if (event.type == 4) { - // 4 更新了电量 - state.electricQuantity.value = int.parse(event.setResult); - state.keyInfos.value.electricQuantity = int.parse(event.setResult); - } else if (event.type == 5) { - // 5 远程开锁 - state.keyInfos.value.lockSetting!.remoteUnlock = - int.parse(event.setResult); - } - CommonDataManage().currentKeyInfo = state.keyInfos.value; - eventBus.fire(RefreshLockDetailInfoDataEvent()); - }); + if (event.type == 0) { + // 0考勤 + state.isAttendance.value = int.parse(event.setResult); + state.keyInfos.value.lockSetting!.attendance = + int.parse(event.setResult); + } else if (event.type == 1) { + // 1 开锁时是否需联网 + state.isOpenLockNeedOnline.value = int.parse(event.setResult); + state.keyInfos.value.lockSetting!.appUnlockOnline = + int.parse(event.setResult); + state.lockNetToken = ''; // 改变开锁时是否联网状态的时候清空token + } else if (event.type == 2) { + // 2 常开模式 + state.isOpenPassageMode.value = int.parse(event.setResult); + state.keyInfos.value.passageMode = int.parse(event.setResult); + } else if (event.type == 3) { + // 3 修改了锁名字 + state.lockAlias.value = event.setResult; + state.keyInfos.value.lockAlias = event.setResult; + Storage.setString(saveLockAlias, state.lockAlias.value); + } else if (event.type == 4) { + // 4 更新了电量 + state.electricQuantity.value = int.parse(event.setResult); + state.keyInfos.value.electricQuantity = int.parse(event.setResult); + } else if (event.type == 5) { + // 5 远程开锁 + state.keyInfos.value.lockSetting!.remoteUnlock = + int.parse(event.setResult); + } + CommonDataManage().currentKeyInfo = state.keyInfos.value; + eventBus.fire(RefreshLockDetailInfoDataEvent()); + }); } String getKeyStatusTextAndShow() { String text = ''; if (state.keyInfos.value.keyStatus == - XSConstantMacro.keyStatusWaitIneffective || + XSConstantMacro.keyStatusWaitIneffective || state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusFrozen || state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusExpired || state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusDeleted || state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusReset) { text = - "${"你的钥匙".tr}${XSConstantMacro.getKeyStatusStr( - state.keyInfos.value.keyStatus!)}"; + "${"你的钥匙".tr}${XSConstantMacro.getKeyStatusStr(state.keyInfos.value.keyStatus!)}"; } else { text = state.isOpenPassageMode.value == 1 ? '常开模式启动!长按闭锁'.tr @@ -517,8 +498,8 @@ class LockDetailLogic extends BaseGetXController { await PermissionDialog.request(Permission.location); await PermissionDialog.requestBluetooth(); - final String connectDeviceName = state.keyInfos.value.bluetooth! - .bluetoothDeviceName!; + final String connectDeviceName = + state.keyInfos.value.bluetooth!.bluetoothDeviceName!; if (!BlueManage().isExistScanDevices(connectDeviceName)) { BlueManage().startScanSingle( connectDeviceName, 15, (List p0) => null); @@ -528,6 +509,5 @@ class LockDetailLogic extends BaseGetXController { @override void onInit() { super.onInit(); - } } diff --git a/lib/main/lockDetail/lockDetail/lockDetail_page.dart b/lib/main/lockDetail/lockDetail/lockDetail_page.dart index f179465c..8ad51780 100755 --- a/lib/main/lockDetail/lockDetail/lockDetail_page.dart +++ b/lib/main/lockDetail/lockDetail/lockDetail_page.dart @@ -1249,9 +1249,10 @@ class _LockDetailPageState extends State ), Positioned( top: 180.h, - left: 55.w, + width: 358.w, child: Column( mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.center, children: [ Text( state.keyInfos.value.lockAlias!, @@ -1318,7 +1319,7 @@ class _LockDetailPageState extends State } } - void startOpenLock() { + void startOpenLock() { if (state.openLockBtnState.value == 1) { return; } diff --git a/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_logic.dart b/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_logic.dart index ebb452f9..b3abc8b5 100755 --- a/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_logic.dart +++ b/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_logic.dart @@ -97,7 +97,7 @@ class LockOperatingRecordLogic extends BaseGetXController { showBlueConnetctToastTimer(action: (){ dismissEasyLoading(); }); - BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionStateState) async { + BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionStateState) async { if (connectionStateState == BluetoothConnectionState.connected) { var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); diff --git a/lib/main/lockDetail/lockSet/automaticBlocking/automaticBlocking_logic.dart b/lib/main/lockDetail/lockSet/automaticBlocking/automaticBlocking_logic.dart index 4195839e..fafc4bc8 100755 --- a/lib/main/lockDetail/lockSet/automaticBlocking/automaticBlocking_logic.dart +++ b/lib/main/lockDetail/lockSet/automaticBlocking/automaticBlocking_logic.dart @@ -116,7 +116,7 @@ class AutomaticBlockingLogic extends BaseGetXController{ dismissEasyLoading(); state.sureBtnState.value = 0; }); - BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async { + BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async { if (connectionState == BluetoothConnectionState.connected) { var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); diff --git a/lib/main/lockDetail/lockSet/basicInformation/adminOpenLockPassword/adminOpenLockPassword_logic.dart b/lib/main/lockDetail/lockSet/basicInformation/adminOpenLockPassword/adminOpenLockPassword_logic.dart index 51e88f6a..2c1f9b47 100755 --- a/lib/main/lockDetail/lockSet/basicInformation/adminOpenLockPassword/adminOpenLockPassword_logic.dart +++ b/lib/main/lockDetail/lockSet/basicInformation/adminOpenLockPassword/adminOpenLockPassword_logic.dart @@ -188,7 +188,7 @@ class AdminOpenLockPasswordLogic extends BaseGetXController{ dismissEasyLoading(); state.sureBtnState.value = 0; }); - BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { + BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { if (deviceConnectionState == BluetoothConnectionState.connected) { var signKey = await Storage.getStringList(saveBlueSignKey); List signKeyDataList = changeStringListToIntList(signKey!); diff --git a/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_logic.dart b/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_logic.dart index 819af46a..95244889 100755 --- a/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_logic.dart +++ b/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_logic.dart @@ -50,7 +50,7 @@ class UploadElectricQuantityLogic extends BaseGetXController { dismissEasyLoading(); state.sureBtnState.value = 0; }); - BlueManage().bludSendData(BlueManage().connectDeviceName, + BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { if (deviceConnectionState == BluetoothConnectionState.connected) { dismissEasyLoading(); diff --git a/lib/main/lockDetail/lockSet/burglarAlarm/burglarAlarm_logic.dart b/lib/main/lockDetail/lockSet/burglarAlarm/burglarAlarm_logic.dart index 1d008567..ec231e32 100755 --- a/lib/main/lockDetail/lockSet/burglarAlarm/burglarAlarm_logic.dart +++ b/lib/main/lockDetail/lockSet/burglarAlarm/burglarAlarm_logic.dart @@ -99,7 +99,7 @@ class BurglarAlarmLogic extends BaseGetXController{ dismissEasyLoading(); state.sureBtnState.value = 0; }); - BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async { + BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async { if (connectionState == BluetoothConnectionState.connected) { var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); diff --git a/lib/main/lockDetail/lockSet/configuringWifi/configuringWifi/configuringWifi_logic.dart b/lib/main/lockDetail/lockSet/configuringWifi/configuringWifi/configuringWifi_logic.dart index 68f4810c..340ccc1b 100755 --- a/lib/main/lockDetail/lockSet/configuringWifi/configuringWifi/configuringWifi_logic.dart +++ b/lib/main/lockDetail/lockSet/configuringWifi/configuringWifi/configuringWifi_logic.dart @@ -136,7 +136,7 @@ class ConfiguringWifiLogic extends BaseGetXController{ dismissEasyLoading(); state.sureBtnState.value = 0; }); - BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async { + BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async { if (connectionState == BluetoothConnectionState.connected){ var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); diff --git a/lib/main/lockDetail/lockSet/configuringWifi/wifiList/wifiList_logic.dart b/lib/main/lockDetail/lockSet/configuringWifi/wifiList/wifiList_logic.dart index 5f814347..77456721 100755 --- a/lib/main/lockDetail/lockSet/configuringWifi/wifiList/wifiList_logic.dart +++ b/lib/main/lockDetail/lockSet/configuringWifi/wifiList/wifiList_logic.dart @@ -113,7 +113,7 @@ class WifiListLogic extends BaseGetXController { dismissEasyLoading(); state.sureBtnState.value = 0; }); - BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async { + BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async { if (connectionState == BluetoothConnectionState.connected){ var token = await Storage.getStringList(saveBlueToken); List getTokenList = changeStringListToIntList(token!); diff --git a/lib/main/lockDetail/lockSet/lockEscalation/lockEscalation_logic.dart b/lib/main/lockDetail/lockSet/lockEscalation/lockEscalation_logic.dart index 62f4c274..db0570b1 100755 --- a/lib/main/lockDetail/lockSet/lockEscalation/lockEscalation_logic.dart +++ b/lib/main/lockDetail/lockSet/lockEscalation/lockEscalation_logic.dart @@ -80,7 +80,7 @@ class LockEscalationLogic extends BaseGetXController { //蓝牙操作 ota 升级 void blueOTAUpgrade(Map data, List token) { - BlueManage().bludSendData(BlueManage().connectDeviceName, + BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { if (deviceConnectionState == BluetoothConnectionState.connected) { var privateKey = await Storage.getStringList(saveBluePrivateKey); diff --git a/lib/main/lockDetail/lockSet/lockSet/lockSet_logic.dart b/lib/main/lockDetail/lockSet/lockSet/lockSet_logic.dart index f2dff1ce..e0b17943 100755 --- a/lib/main/lockDetail/lockSet/lockSet/lockSet_logic.dart +++ b/lib/main/lockDetail/lockSet/lockSet/lockSet_logic.dart @@ -245,7 +245,7 @@ class LockSetLogic extends BaseGetXController { dismissEasyLoading(); showDeletAlertTipDialog(); }); - BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async { + BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async { if (connectionState == BluetoothConnectionState.connected) { var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); @@ -306,7 +306,7 @@ class LockSetLogic extends BaseGetXController { showBlueConnetctToastTimer(action: (){ dismissEasyLoading(); }); - BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async { + BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async { if (connectionState == BluetoothConnectionState.connected) { var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); diff --git a/lib/main/lockDetail/lockSet/lockSoundSet/lockSoundSet_logic.dart b/lib/main/lockDetail/lockSet/lockSoundSet/lockSoundSet_logic.dart index d2ea4555..7333c47c 100755 --- a/lib/main/lockDetail/lockSet/lockSoundSet/lockSoundSet_logic.dart +++ b/lib/main/lockDetail/lockSet/lockSoundSet/lockSoundSet_logic.dart @@ -103,7 +103,7 @@ class LockSoundSetLogic extends BaseGetXController { dismissEasyLoading(); state.sureBtnState.value = 0; }); - BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async { + BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async { if (connectionState == BluetoothConnectionState.connected) { var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); diff --git a/lib/main/lockDetail/lockSet/lockTime/lockTime_logic.dart b/lib/main/lockDetail/lockSet/lockTime/lockTime_logic.dart index 9bccc128..961bdf42 100755 --- a/lib/main/lockDetail/lockSet/lockTime/lockTime_logic.dart +++ b/lib/main/lockDetail/lockSet/lockTime/lockTime_logic.dart @@ -103,7 +103,7 @@ class LockTimeLogic extends BaseGetXController{ dismissEasyLoading(); state.sureBtnState.value = 0; }); - BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async { + BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async { if (connectionState == BluetoothConnectionState.connected) { var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); diff --git a/lib/main/lockDetail/lockSet/motorPower/motorPower_logic.dart b/lib/main/lockDetail/lockSet/motorPower/motorPower_logic.dart index e75f83b8..943480f9 100755 --- a/lib/main/lockDetail/lockSet/motorPower/motorPower_logic.dart +++ b/lib/main/lockDetail/lockSet/motorPower/motorPower_logic.dart @@ -84,7 +84,7 @@ class MotorPowerLogic extends BaseGetXController { // 读取支持功能-带参数 Future _readSupportFunctionsNoParameters() async { - BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async { + BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async { if (connectionState == BluetoothConnectionState.connected) { var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); @@ -110,7 +110,7 @@ class MotorPowerLogic extends BaseGetXController { // 设置支持功能(带参数) Future sendOpenDoorDirection() async { - BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async { + BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async { if (connectionState == BluetoothConnectionState.connected) { var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); diff --git a/lib/main/lockDetail/lockSet/normallyOpenMode/normallyOpenMode_logic.dart b/lib/main/lockDetail/lockSet/normallyOpenMode/normallyOpenMode_logic.dart index fa9ed712..37aaba23 100755 --- a/lib/main/lockDetail/lockSet/normallyOpenMode/normallyOpenMode_logic.dart +++ b/lib/main/lockDetail/lockSet/normallyOpenMode/normallyOpenMode_logic.dart @@ -120,7 +120,7 @@ class NormallyOpenModeLogic extends BaseGetXController{ dismissEasyLoading(); state.sureBtnState.value = 0; }); - BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async { + BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async { if (connectionState == BluetoothConnectionState.connected) { var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); diff --git a/lib/main/lockDetail/lockSet/openDoorDirection/openDoorDirection_logic.dart b/lib/main/lockDetail/lockSet/openDoorDirection/openDoorDirection_logic.dart index da169195..b9dce4b6 100755 --- a/lib/main/lockDetail/lockSet/openDoorDirection/openDoorDirection_logic.dart +++ b/lib/main/lockDetail/lockSet/openDoorDirection/openDoorDirection_logic.dart @@ -86,7 +86,7 @@ class OpenDoorDirectionLogic extends BaseGetXController { // 设置支持功能(带参数) Future sendOpenDoorDirection() async { showEasyLoading(); - BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async { + BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async { dismissEasyLoading(); if (connectionState == BluetoothConnectionState.connected) { var privateKey = await Storage.getStringList(saveBluePrivateKey); diff --git a/lib/main/lockDetail/lockSet/remoteUnlocking/remoteUnlocking_logic.dart b/lib/main/lockDetail/lockSet/remoteUnlocking/remoteUnlocking_logic.dart index 1362d523..fd65a94e 100755 --- a/lib/main/lockDetail/lockSet/remoteUnlocking/remoteUnlocking_logic.dart +++ b/lib/main/lockDetail/lockSet/remoteUnlocking/remoteUnlocking_logic.dart @@ -109,7 +109,7 @@ class RemoteUnlockingLogic extends BaseGetXController { dismissEasyLoading(); state.sureBtnState.value = 0; }); - BlueManage().bludSendData(BlueManage().connectDeviceName, + BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async { if (connectionState == BluetoothConnectionState.connected) { var privateKey = await Storage.getStringList(saveBluePrivateKey); diff --git a/lib/main/lockDetail/lockSet/resetButton/resetButton_logic.dart b/lib/main/lockDetail/lockSet/resetButton/resetButton_logic.dart index 0b6a57a4..233f464a 100755 --- a/lib/main/lockDetail/lockSet/resetButton/resetButton_logic.dart +++ b/lib/main/lockDetail/lockSet/resetButton/resetButton_logic.dart @@ -98,7 +98,7 @@ class ResetButtonLogic extends BaseGetXController{ dismissEasyLoading(); state.sureBtnState.value = 0; }); - BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async { + BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async { if (connectionState == BluetoothConnectionState.connected) { var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); diff --git a/lib/main/lockDetail/palm/palmDetail/palmDetail_logic.dart b/lib/main/lockDetail/palm/palmDetail/palmDetail_logic.dart index 51faf569..c92a3a67 100755 --- a/lib/main/lockDetail/palm/palmDetail/palmDetail_logic.dart +++ b/lib/main/lockDetail/palm/palmDetail/palmDetail_logic.dart @@ -89,7 +89,7 @@ class PalmDetailLogic extends BaseGetXController { dismissEasyLoading(); state.sureBtnState.value = 0; }); - BlueManage().bludSendData(BlueManage().connectDeviceName, + BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { if (deviceConnectionState == BluetoothConnectionState.connected) { // var publicKey = await Storage.getStringList(saveBluePublicKey); diff --git a/lib/main/lockDetail/palm/palmList/palmList_logic.dart b/lib/main/lockDetail/palm/palmList/palmList_logic.dart index 6ae1c428..8e51ff12 100755 --- a/lib/main/lockDetail/palm/palmList/palmList_logic.dart +++ b/lib/main/lockDetail/palm/palmList/palmList_logic.dart @@ -185,7 +185,7 @@ class PalmListLogic extends BaseGetXController { // 获取人脸状态 Future senderQueryingFaceStatus() async { - BlueManage().bludSendData(BlueManage().connectDeviceName, + BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState state) async { if (state == BluetoothConnectionState.connected) { var privateKey = await Storage.getStringList(saveBluePrivateKey); @@ -214,7 +214,7 @@ class PalmListLogic extends BaseGetXController { // 查询用户、指纹、密码、卡片数量(用于判断是否同步) Future senderCheckingUserInfoCount() async { - BlueManage().bludSendData(BlueManage().connectDeviceName, + BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState state) async { if (state == BluetoothConnectionState.connected) { var privateKey = await Storage.getStringList(saveBluePrivateKey); @@ -246,7 +246,7 @@ class PalmListLogic extends BaseGetXController { showBlueConnetctToastTimer(action: () { dismissEasyLoading(); }); - BlueManage().bludSendData(BlueManage().connectDeviceName, + BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { if (deviceConnectionState == BluetoothConnectionState.connected) { var signKey = await Storage.getStringList(saveBlueSignKey); diff --git a/lib/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_logic.dart b/lib/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_logic.dart index 34a698cc..28c999e7 100755 --- a/lib/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_logic.dart +++ b/lib/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_logic.dart @@ -127,7 +127,7 @@ class PasswordKeyDetailLogic extends BaseGetXController { dismissEasyLoading(); state.sureBtnState.value = 0; }); - BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { + BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { if (deviceConnectionState == BluetoothConnectionState.connected) { var signKey = await Storage.getStringList(saveBlueSignKey); List signKeyDataList = changeStringListToIntList(signKey!); diff --git a/lib/main/lockDetail/passwordKey/passwordKeyDetailChangeDate/passwordKeyDetailChangeDate_logic.dart b/lib/main/lockDetail/passwordKey/passwordKeyDetailChangeDate/passwordKeyDetailChangeDate_logic.dart index 963515a1..f583fdb2 100755 --- a/lib/main/lockDetail/passwordKey/passwordKeyDetailChangeDate/passwordKeyDetailChangeDate_logic.dart +++ b/lib/main/lockDetail/passwordKey/passwordKeyDetailChangeDate/passwordKeyDetailChangeDate_logic.dart @@ -121,7 +121,7 @@ class PasswordKeyDetailChangeDateLogic extends BaseGetXController { dismissEasyLoading(); state.sureBtnState.value = 0; }); - BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { + BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { if (deviceConnectionState == BluetoothConnectionState.connected) { var signKey = await Storage.getStringList(saveBlueSignKey); List signKeyDataList = changeStringListToIntList(signKey!); diff --git a/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_logic.dart b/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_logic.dart index 71a95cbe..fe252ea0 100755 --- a/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_logic.dart +++ b/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_logic.dart @@ -128,7 +128,7 @@ class PasswordKeyListLogic extends BaseGetXController { showBlueConnetctToastTimer(action: (){ dismissEasyLoading(); }); - BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { + BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { if (deviceConnectionState == BluetoothConnectionState.connected) { var signKey = await Storage.getStringList(saveBlueSignKey); List signKeyDataList = changeStringListToIntList(signKey!); @@ -177,7 +177,7 @@ class PasswordKeyListLogic extends BaseGetXController { dismissEasyLoading(); state.sureBtnState.value = 0; }); - BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { + BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { if (deviceConnectionState == BluetoothConnectionState.connected) { var signKey = await Storage.getStringList(saveBlueSignKey); List signKeyDataList = changeStringListToIntList(signKey!); diff --git a/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_logic.dart b/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_logic.dart index 48a5c689..0d6122d3 100755 --- a/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_logic.dart +++ b/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_logic.dart @@ -342,7 +342,7 @@ class PasswordKeyPerpetualLogic extends BaseGetXController { dismissEasyLoading(); state.sureBtnState.value = 0; }); - BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { + BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { if (deviceConnectionState == BluetoothConnectionState.connected) { var signKey = await Storage.getStringList(saveBlueSignKey); List signKeyDataList = changeStringListToIntList(signKey!); diff --git a/lib/main/lockMian/lockList/lockList_logic.dart b/lib/main/lockMian/lockList/lockList_logic.dart index db7de770..fff0e86b 100755 --- a/lib/main/lockMian/lockList/lockList_logic.dart +++ b/lib/main/lockMian/lockList/lockList_logic.dart @@ -181,7 +181,7 @@ class LockListLogic extends BaseGetXController{ dismissEasyLoading(); showDeletAlertTipDialog(); }); - BlueManage().bludSendData(state.lockListInfoItemEntity.lockName!, (BluetoothConnectionState connectionState) async { + BlueManage().blueSendData(state.lockListInfoItemEntity.lockName!, (BluetoothConnectionState connectionState) async { if (connectionState == BluetoothConnectionState.connected) { List publicKeyData = state.lockListInfoItemEntity.bluetooth!.publicKey!.cast(); var saveStrList = changeIntListToStringList(publicKeyData); diff --git a/lib/mine/about/debug/controller.dart b/lib/mine/about/debug/controller.dart index 04b324b0..b5c67ff1 100755 --- a/lib/mine/about/debug/controller.dart +++ b/lib/mine/about/debug/controller.dart @@ -108,7 +108,7 @@ class DebugConsoleController { return; } - BlueManage().bludSendData(BlueManage().connectDeviceName, + BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { if (deviceConnectionState == BluetoothConnectionState.connected) { var privateKey = await Storage.getStringList(saveBluePrivateKey); @@ -179,7 +179,7 @@ class DebugConsoleController { tokenList = changeStringListToIntList(tokenKey!); } - BlueManage().bludSendData(BlueManage().connectDeviceName, + BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { if (deviceConnectionState == BluetoothConnectionState.connected) { IoSenderManage.senderCleanUpUsersCommand( diff --git a/lib/mine/addLock/nearbyLock/nearbyLock_logic.dart b/lib/mine/addLock/nearbyLock/nearbyLock_logic.dart index 2f5533fa..f703e39a 100755 --- a/lib/mine/addLock/nearbyLock/nearbyLock_logic.dart +++ b/lib/mine/addLock/nearbyLock/nearbyLock_logic.dart @@ -54,7 +54,7 @@ class NearbyLockLogic extends BaseGetXController { dismissEasyLoading(); // state.sureBtnState.value = 0; }); - BlueManage().bludSendData(deviceName, + BlueManage().blueSendData(deviceName, (BluetoothConnectionState state) async { AppLog.log("点击要添加的设备了"); if (state == BluetoothConnectionState.connected) { @@ -415,7 +415,7 @@ class NearbyLockLogic extends BaseGetXController { void oTAUpgrade(String deviceName) { showTitleEasyLoading("连接设备中..."); this.deviceName = deviceName; - BlueManage().bludSendData(deviceName, + BlueManage().blueSendData(deviceName, (BluetoothConnectionState state) async { AppLog.log("连接设备"); if (state == BluetoothConnectionState.connected) { @@ -460,7 +460,7 @@ class NearbyLockLogic extends BaseGetXController { AppLog.log('blueOTAUpgrade:设备名字为 null'); return; } - BlueManage().bludSendData(deviceName!, + BlueManage().blueSendData(deviceName!, (BluetoothConnectionState deviceConnectionState) async { if (deviceConnectionState == BluetoothConnectionState.connected) { String uid = await Storage.getUid() ?? ''; diff --git a/lib/mine/addLock/saveLock/saveLock_logic.dart b/lib/mine/addLock/saveLock/saveLock_logic.dart index c7d5269a..58f6c5aa 100755 --- a/lib/mine/addLock/saveLock/saveLock_logic.dart +++ b/lib/mine/addLock/saveLock/saveLock_logic.dart @@ -212,7 +212,7 @@ class SaveLockLogic extends BaseGetXController { showBlueConnetctToast(); } }); - BlueManage().bludSendData(BlueManage().connectDeviceName, + BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { if (deviceConnectionState == BluetoothConnectionState.connected) { // 私钥 diff --git a/lib/mine/mineSet/lockUserManage/expireLockList/expireCard/expireCard_logic.dart b/lib/mine/mineSet/lockUserManage/expireLockList/expireCard/expireCard_logic.dart index 7829c717..065a0285 100755 --- a/lib/mine/mineSet/lockUserManage/expireLockList/expireCard/expireCard_logic.dart +++ b/lib/mine/mineSet/lockUserManage/expireLockList/expireCard/expireCard_logic.dart @@ -94,7 +94,7 @@ class ExpireCardLogic extends BaseGetXController { dismissEasyLoading(); state.sureBtnState.value = 0; }); - BlueManage().bludSendData(state.deletExpireCardItemEntity.lockInfo!.btDeviceName!, (BluetoothConnectionState deviceConnectionState) async { + BlueManage().blueSendData(state.deletExpireCardItemEntity.lockInfo!.btDeviceName!, (BluetoothConnectionState deviceConnectionState) async { if (deviceConnectionState == BluetoothConnectionState.connected){ // var publicKey = await Storage.getStringList(saveBluePublicKey); // List publicKeyDataList = changeStringListToIntList(publicKey!); diff --git a/lib/mine/mineSet/lockUserManage/expireLockList/expireFingerprint/expireFingerprint_logic.dart b/lib/mine/mineSet/lockUserManage/expireLockList/expireFingerprint/expireFingerprint_logic.dart index bfacb509..e9ebb90d 100755 --- a/lib/mine/mineSet/lockUserManage/expireLockList/expireFingerprint/expireFingerprint_logic.dart +++ b/lib/mine/mineSet/lockUserManage/expireLockList/expireFingerprint/expireFingerprint_logic.dart @@ -95,7 +95,7 @@ class ExpireFingerprintLogic extends BaseGetXController { dismissEasyLoading(); state.sureBtnState.value = 0; }); - BlueManage().bludSendData(state.deletExpireFingerprintItemEntity.lockInfo!.btDeviceName!, (BluetoothConnectionState deviceConnectionState) async { + BlueManage().blueSendData(state.deletExpireFingerprintItemEntity.lockInfo!.btDeviceName!, (BluetoothConnectionState deviceConnectionState) async { if (deviceConnectionState == BluetoothConnectionState.connected){ // var publicKey = await Storage.getStringList(saveBluePublicKey); // List publicKeyDataList = changeStringListToIntList(publicKey!); diff --git a/lib/network/response_interceptor_log.dart b/lib/network/response_interceptor_log.dart index 85890536..f24553c4 100755 --- a/lib/network/response_interceptor_log.dart +++ b/lib/network/response_interceptor_log.dart @@ -5,7 +5,7 @@ import 'package:get/get_connect/http/src/request/request.dart'; import 'package:star_lock/app_settings/app_settings.dart'; FutureOr responseLogInterceptor(Request request, Response response) { - AppLog.log('HTTP request:${request.url}\n RESPONSE => stataCode:${response.statusCode} ${response.bodyString}'); // \n ${response.headers} + // AppLog.log('HTTP request:${request.url}\n RESPONSE => stataCode:${response.statusCode} ${response.bodyString}'); // \n ${response.headers} EasyLoading.dismiss(animation: true); return response; } From 408f2e46b7dba3bbd51b33543d2be9d35ecfb7d7 Mon Sep 17 00:00:00 2001 From: anfe <448468458@qq.com> Date: Tue, 21 May 2024 16:09:54 +0800 Subject: [PATCH 29/44] =?UTF-8?q?feat:=E8=A7=A3=E5=86=B3=E5=A4=9A=E6=AC=A1?= =?UTF-8?q?=E5=BC=80=E9=97=A8=E5=90=8E=EF=BC=8C=E5=8A=A8=E7=94=BB=E4=BC=9A?= =?UTF-8?q?=E4=B8=80=E7=9B=B4=E4=B8=8D=E5=81=9C=E7=9A=84=E6=97=8B=E8=BD=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/blue/io_sender.dart | 8 ++++---- lib/main/lockDetail/lockDetail/lockDetail_logic.dart | 10 +++++----- lib/main/lockDetail/lockDetail/lockDetail_page.dart | 2 -- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/lib/blue/io_sender.dart b/lib/blue/io_sender.dart index ae45e67e..5270d56d 100755 --- a/lib/blue/io_sender.dart +++ b/lib/blue/io_sender.dart @@ -34,12 +34,12 @@ abstract class SenderProtocol extends IOData { } void printLog(List data) { - // AppLog.log( - // "App -> 锁,指令类型:${commandType!.typeName} ${commandType!.typeValue == 0x3030 - // ? '子命令:${data[3]}' : ''} \n参数是:\n${toString()} \n加密之前数据是:\n$data 长度是:${data.length}"); + AppLog.log( + "App -> 锁,指令类型:${commandType!.typeName} ${commandType!.typeValue == 0x3030 + ? '子命令:${data[3]}' : ''} \n参数是:\n${toString()} \n加密之前数据是:\n$data 长度是:${data.length}"); } - //TODO:拼装数据Ï + //TODO:拼装数据 List packageData() { commandData = messageDetail(); List commandList = []; diff --git a/lib/main/lockDetail/lockDetail/lockDetail_logic.dart b/lib/main/lockDetail/lockDetail/lockDetail_logic.dart index aeae0a6a..2e35c767 100755 --- a/lib/main/lockDetail/lockDetail/lockDetail_logic.dart +++ b/lib/main/lockDetail/lockDetail/lockDetail_logic.dart @@ -33,7 +33,6 @@ import 'lockNetToken_entity.dart'; class LockDetailLogic extends BaseGetXController { final LockDetailState state = LockDetailState(); - // 监听设备返回的数据 void initReplySubscription() { state.replySubscription = @@ -59,9 +58,8 @@ class LockDetailLogic extends BaseGetXController { case 0x00: //成功 // _showFullScreenOverlay(Get.context!); - cancelBlueConnetctToastTimer(); - state.iSClosedUnlockSuccessfulPopup.value = true; + cancelBlueConnetctToastTimer(); state.closedUnlockSuccessfulTimer?.cancel(); // 如果没有点击关闭弹窗,3秒后自动关闭 state.closedUnlockSuccessfulTimer = @@ -82,9 +80,10 @@ class LockDetailLogic extends BaseGetXController { } // 更新电量 uploadElectricQuantityRequest(); - + //锁数据更新 getLockRecordLastUploadDataTime(); resetOpenDoorState(); + state.animationController!.stop(); break; case 0x06: //无权限 @@ -287,10 +286,11 @@ class LockDetailLogic extends BaseGetXController { } // 查询事件记录(时间查询) - Future senderReferEventRecordTime() async { + void senderReferEventRecordTime() { showBlueConnetctToastTimer( isShowBlueConnetctToast: false, action: () { + closeLuckStatus(); BlueManage().disconnect(); }); BlueManage().blueSendData(BlueManage().connectDeviceName, diff --git a/lib/main/lockDetail/lockDetail/lockDetail_page.dart b/lib/main/lockDetail/lockDetail/lockDetail_page.dart index 8ad51780..97d42890 100755 --- a/lib/main/lockDetail/lockDetail/lockDetail_page.dart +++ b/lib/main/lockDetail/lockDetail/lockDetail_page.dart @@ -1324,7 +1324,6 @@ class _LockDetailPageState extends State return; } state.iSOpenLock.value = true; - state.iSClosedUnlockSuccessfulPopup.value = false; state.openLockBtnState.value = 1; state.animationController!.forward(); @@ -1347,7 +1346,6 @@ class _LockDetailPageState extends State return; } state.iSOpenLock.value = false; - state.iSClosedUnlockSuccessfulPopup.value = false; state.openLockBtnState.value = 1; state.animationController!.forward(); From af2ef694df2014bd145194ed01895edcf31f7eb9 Mon Sep 17 00:00:00 2001 From: anfe <448468458@qq.com> Date: Tue, 21 May 2024 17:11:56 +0800 Subject: [PATCH 30/44] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=20=E5=85=B6?= =?UTF-8?q?=E4=BB=96-=E6=8E=88=E6=9D=83=E7=AE=A1=E7=90=86=E5=91=98-?= =?UTF-8?q?=E7=94=B5=E5=AD=90=E9=92=A5=E5=8C=99=E9=87=8C=E7=9A=84=E6=8E=88?= =?UTF-8?q?=E6=9D=83=E7=AE=A1=E7=90=86=E5=91=98=E8=AF=A6=E6=83=85=E5=A4=9A?= =?UTF-8?q?=E4=BA=86=E5=8F=96=E6=B6=88=E6=8E=88=E6=9D=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/common/XSConstantMacro/XSConstantMacro.dart | 9 +++++++++ .../electronicKeyDetail/electronicKeyDetail_logic.dart | 8 +++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/common/XSConstantMacro/XSConstantMacro.dart b/lib/common/XSConstantMacro/XSConstantMacro.dart index a3d32886..e54e7b70 100755 --- a/lib/common/XSConstantMacro/XSConstantMacro.dart +++ b/lib/common/XSConstantMacro/XSConstantMacro.dart @@ -70,4 +70,13 @@ class XSConstantMacro { static int catEyeWorkModeStayCapture = 2; //逗留抓拍模式 static int catEyeWorkModeRealTimeMonitoring = 3; //实时监控模式 static int catEyeWorkModeCustom = 4; //自定义模式 + + //管理员类型 + static int userTypeSuperAdmin = 110301; //超级管理员 + static int userTypeAuthorizedAdmin = 110302; //授权管理员 + + + //电子钥匙类型 + static int keyRightAdmin = 1; //管理钥匙 + static int keyRightOrdinary = 2; //普通钥匙 } diff --git a/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_logic.dart b/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_logic.dart index 708938d8..6b38b259 100755 --- a/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_logic.dart +++ b/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_logic.dart @@ -255,16 +255,18 @@ class ElectronicKeyDetailLogic extends BaseGetXController { Future openModalBottomSheet(BuildContext context) async { List textList = []; - if (state.itemData.value.keyRight == 1) { + final bool isAdminKey = state.itemData.value.keyRight == 1; + final bool isLockOwner = CommonDataManage().currentKeyInfo.isLockOwner == 1; + if (isAdminKey) { // 授权管理员 textList = [ if (state.itemData.value.keyStatus == XSConstantMacro.keyStatusFrozen) '取消冻结'.tr else '冻结'.tr, - // '取消授权'.tr + if (isLockOwner) '取消授权'.tr ]; - } else if (CommonDataManage().currentKeyInfo.isLockOwner == 1) { + } else if (isLockOwner) { // 锁拥有者 if (state.keyType.value == 1 || state.keyType.value == 2) { textList = [ From 626c9eea4589557b3d8fefc5425ee3471c843f2b Mon Sep 17 00:00:00 2001 From: anfe <448468458@qq.com> Date: Tue, 21 May 2024 17:56:50 +0800 Subject: [PATCH 31/44] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=20=E5=BC=80?= =?UTF-8?q?=E9=94=81=E9=A1=B5-=E8=80=83=E5=8B=A4-=E8=AE=BE=E7=BD=AE-?= =?UTF-8?q?=E5=91=98=E5=B7=A5=20=E5=BC=80=E9=94=81=E9=A1=B5-=E8=80=83?= =?UTF-8?q?=E5=8B=A4-=E5=91=98=E5=B7=A5-=E7=BC=96=E8=BE=91=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../checkingInSet/checkingInSet_logic.dart | 74 +++++++++---------- .../checkingInSet/checkingInSet_page.dart | 14 +--- .../checkingInAddStaff_logic.dart | 19 ++--- .../checkingInAddStaff_page.dart | 13 ++-- 4 files changed, 54 insertions(+), 66 deletions(-) diff --git a/lib/main/lockDetail/checkingIn/checkingInSet/checkingInSet_logic.dart b/lib/main/lockDetail/checkingIn/checkingInSet/checkingInSet_logic.dart index ceaf5b91..6d61b06d 100755 --- a/lib/main/lockDetail/checkingIn/checkingInSet/checkingInSet_logic.dart +++ b/lib/main/lockDetail/checkingIn/checkingInSet/checkingInSet_logic.dart @@ -1,7 +1,9 @@ - import 'dart:async'; import 'package:get/get.dart'; +import 'package:star_lock/login/login/entity/LoginEntity.dart'; +import 'package:star_lock/main/lockDetail/checkingIn/checkingInSet/checkingInSet_entity.dart'; +import 'package:star_lock/main/lockDetail/lockSet/lockSet/checkingInInfoData_entity.dart'; import '../../../../network/api_repository.dart'; import '../../../../tools/baseGetXController.dart'; @@ -9,96 +11,94 @@ import '../../../../tools/dateTool.dart'; import '../../../../tools/eventBusEventManage.dart'; import 'checkingInSet_state.dart'; -class CheckingInSetLogic extends BaseGetXController{ +class CheckingInSetLogic extends BaseGetXController { CheckingInSetState state = CheckingInSetState(); // 开启考勤获取是否有公司 - void openCheckingInData() async{ - var entity = await ApiRepository.to.openCheckingInData( - lockId:state.getKeyInfosData.value.lockId.toString(), + Future openCheckingInData() async { + final CheckingInInfoDataEntity entity = await ApiRepository.to.openCheckingInData( + lockId: state.getKeyInfosData.value.lockId.toString(), ); - if(entity.errorCode!.codeIsSuccessful){ + if (entity.errorCode!.codeIsSuccessful) { state.companyId.value = entity.data!.companyId.toString(); getCheckInSetInfoData(); } } // 获取获取考勤设置信息 - void getCheckInSetInfoData() async{ - var entity = await ApiRepository.to.getCheckInSetInfoData( + Future getCheckInSetInfoData() async { + final CheckingInSetEntity entity = await ApiRepository.to.getCheckInSetInfoData( companyId: state.companyId.value, ); - if(entity.errorCode!.codeIsSuccessful){ + if (entity.errorCode!.codeIsSuccessful) { state.checkingInSetInfo.value = entity.data!; - state.beginTime.value = DateTool().dateToHNString(state.checkingInSetInfo.value.workStartTime.toString()); - state.endTime.value = DateTool().dateToHNString(state.checkingInSetInfo.value.workEndTime.toString()); - state.beginTimeTimestamp.value = state.checkingInSetInfo.value.workStartTime.toString(); - state.endTimeTimestamp.value = state.checkingInSetInfo.value.workEndTime.toString(); + state.beginTime.value = DateTool().dateToHNString( + state.checkingInSetInfo.value.workStartTime.toString()); + state.endTime.value = DateTool() + .dateToHNString(state.checkingInSetInfo.value.workEndTime.toString()); + state.beginTimeTimestamp.value = + state.checkingInSetInfo.value.workStartTime.toString(); + state.endTimeTimestamp.value = + state.checkingInSetInfo.value.workEndTime.toString(); state.weekDays.value = state.checkingInSetInfo.value.workDay!; - state.weekDaysStr.value = state.weekDays.value.join(","); - state.isCustom.value = (state.checkingInSetInfo.value.attendanceType! == 0) ? true : false; + state.weekDaysStr.value = state.weekDays.join(','); + state.isCustom.value = state.checkingInSetInfo.value.attendanceType! == 0; - state.staffNumber.value = state.checkingInSetInfo.value.staffNum!.toString(); + state.staffNumber.value = + state.checkingInSetInfo.value.staffNum!.toString(); state.companyName.value = state.checkingInSetInfo.value.companyName!; state.changeNameController.text = state.companyName.value; } } // 编辑考勤设置信息 - void editCheckInSetInfoData() async{ - var entity = await ApiRepository.to.editCheckInSetInfoData( + Future editCheckInSetInfoData() async { + final LoginEntity entity = await ApiRepository.to.editCheckInSetInfoData( attendanceType: state.checkingInSetInfo.value.attendanceType.toString(), companyId: state.checkingInSetInfo.value.companyId.toString(), - type: "1", + type: '1', companyName: state.changeNameController.text, workEndTime: state.checkingInSetInfo.value.workEndTime.toString(), workStartTime: state.checkingInSetInfo.value.workStartTime.toString(), - workDay:state.checkingInSetInfo.value.workDay!, + workDay: state.checkingInSetInfo.value.workDay!, ); - if(entity.errorCode!.codeIsSuccessful){ + if (entity.errorCode!.codeIsSuccessful) { state.companyName.value = state.changeNameController.text; - showToast("修改成功"); + showToast('修改成功'); } } // 删除公司 - void deletCompanyData() async{ - var entity = await ApiRepository.to.deletCompanyData( - companyId:state.checkingInSetInfo.value.companyId!, + Future deletCompanyData() async { + final CheckingInInfoDataEntity entity = await ApiRepository.to.deletCompanyData( + companyId: state.checkingInSetInfo.value.companyId!, ); - if(entity.errorCode!.codeIsSuccessful){ - eventBus.fire(LockSetChangeSetRefreshLockDetailWithType(0, "0")); + if (entity.errorCode!.codeIsSuccessful) { + eventBus.fire(LockSetChangeSetRefreshLockDetailWithType(0, '0')); Get.close(2); } } late StreamSubscription _teamEvent; + void _initLoadDataAction() { - _teamEvent = eventBus.on().listen((event) { + _teamEvent = eventBus.on().listen((RefreshCheckInSetDataEvent event) { getCheckInSetInfoData(); }); } @override void onReady() { - // TODO: implement onReady super.onReady(); - _initLoadDataAction(); openCheckingInData(); } - @override - void onInit() { - // TODO: implement onInit - super.onInit(); - } @override void onClose() { - // TODO: implement onClose _teamEvent.cancel(); } -} \ No newline at end of file +} diff --git a/lib/main/lockDetail/checkingIn/checkingInSet/checkingInSet_page.dart b/lib/main/lockDetail/checkingIn/checkingInSet/checkingInSet_page.dart index da4c5f2c..f4674bb8 100755 --- a/lib/main/lockDetail/checkingIn/checkingInSet/checkingInSet_page.dart +++ b/lib/main/lockDetail/checkingIn/checkingInSet/checkingInSet_page.dart @@ -73,13 +73,7 @@ class _CheckingInSetPageState extends State { 'checkingInSetInfo': state.checkingInSetInfo.value, }); if(data != null) { - setState(() { - // state.beginTime.value = data["beginTime"]; - // state.endTime.value = data["endTime"]; - // state.beginTimeTimestamp.value = data["beginTimeTimestamp"]; - // state.endTimeTimestamp.value = data["endTimeTimestamp"]; - logic.getCheckInSetInfoData(); - }); + setState(logic.getCheckInSetInfoData); } })), Obx(() => CommonItem( @@ -98,7 +92,7 @@ class _CheckingInSetPageState extends State { if(data != null) { state.isCustom.value = data['attendanceType']; state.weekDays.value = data['weekDays']; - state.weekDaysStr.value = state.weekDays.value.join(','); + state.weekDaysStr.value = state.weekDays.join(','); } })), CommonItem( @@ -125,9 +119,7 @@ class _CheckingInSetPageState extends State { margin: EdgeInsets.only(left: 30.w, right: 30.w, top: 20.w), padding: EdgeInsets.only(top: 20.w, bottom: 20.w), onClick: () { - ShowTipView().showIosTipWithContentDialog('是否删除?'.tr, () { - logic.deletCompanyData(); - }); + ShowTipView().showIosTipWithContentDialog('是否删除?'.tr, logic.deletCompanyData); // showDeletCompanyAlertDialog(context); }), ), diff --git a/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_logic.dart b/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_logic.dart index 6f21bf4e..0b8cde56 100755 --- a/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_logic.dart +++ b/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_logic.dart @@ -1,9 +1,7 @@ import 'dart:async'; -import 'dart:ffi'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; -import 'package:star_lock/app_settings/app_settings.dart'; import 'package:star_lock/login/login/entity/LoginEntity.dart'; import 'package:star_lock/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyEntity.dart'; import 'package:star_lock/tools/baseGetXController.dart'; @@ -72,7 +70,7 @@ class CheckingInAddStaffLogic extends BaseGetXController { ); if (entity.errorCode!.codeIsSuccessful) { state.keyEntity.value = entity.data!; - kyClickCallback(state.keyEntity.value); + kyClickCallback(state.keyEntity); } } @@ -82,6 +80,11 @@ class CheckingInAddStaffLogic extends BaseGetXController { if (state.appUnHaveAccount.value && state.staffAccount.contains('@')) { usernameType = '2'; } + // 当是app且没有钥匙时,直接把账号赋值给attendanceWayNumber + if (state.appUnHaveAccount.value && + state.selectPrintingMethodType.value == '1') { + state.attendanceWayNumber.value = state.staffAccountController.text; + } final LoginEntity entity = await ApiRepository.to.editStaffData( attendanceType: state.selectPrintingMethodType.value, @@ -151,25 +154,15 @@ class CheckingInAddStaffLogic extends BaseGetXController { @override void onReady() { - // TODO: implement onReady super.onReady(); _initLoadDataAction(); - changeInput(state.staffNameController); - - } - @override - void onInit() { - super.onInit(); - } @override void onClose() { - // TODO: implement onClose super.onClose(); - _getNumberEvent!.cancel(); } } diff --git a/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_page.dart b/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_page.dart index e8aee62b..c6e9539f 100755 --- a/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_page.dart +++ b/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_page.dart @@ -214,15 +214,18 @@ class _CheckingInAddStaffPageState extends State { child: Container( height: 40.h, padding: EdgeInsets.only( - left: 25.w, right: 25.w, top: 2.h), + left: 25.w, + right: 25.w, + ), decoration: BoxDecoration( color: AppColors.mainColor, borderRadius: BorderRadius.circular(20.h), ), - child: Text(addStaffSelectKeyType(), - textAlign: TextAlign.center, - style: TextStyle( - color: Colors.white, fontSize: 22.sp)), + child: Center( + child: Text(addStaffSelectKeyType(), + style: TextStyle( + color: Colors.white, fontSize: 22.sp)), + ), ), ), ], From 8d949e6a06fd5b31c7ce2338f409e8bb92a800a4 Mon Sep 17 00:00:00 2001 From: anfe <448468458@qq.com> Date: Tue, 21 May 2024 18:11:26 +0800 Subject: [PATCH 32/44] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=20=E8=B4=A6?= =?UTF-8?q?=E5=8F=B7=E7=99=BB=E5=BD=95=E5=90=8E=E6=89=AB=E6=8F=8F=E7=9A=84?= =?UTF-8?q?=E8=AE=BE=E5=A4=87=E7=BC=93=E5=AD=98=E6=B2=A1=E6=9C=89=E8=A2=AB?= =?UTF-8?q?=E6=B8=85=E9=99=A4=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/login/login/starLock_login_logic.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/login/login/starLock_login_logic.dart b/lib/login/login/starLock_login_logic.dart index 508c1f15..2e3cc55e 100755 --- a/lib/login/login/starLock_login_logic.dart +++ b/lib/login/login/starLock_login_logic.dart @@ -4,6 +4,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_bugly_plugin/flutter_bugly_plugin.dart'; import 'package:get/get.dart'; import 'package:star_lock/appRouters.dart'; +import 'package:star_lock/blue/blue_manage.dart'; import 'package:star_lock/login/login/entity/LoginEntity.dart'; import 'package:star_lock/mine/mine/starLockMine_state.dart'; import 'package:star_lock/tools/baseGetXController.dart'; @@ -47,11 +48,10 @@ class StarLockLoginLogic extends BaseGetXController { Storage.saveLoginData(entity.data); Storage.setBool(saveIsVip, entity.data!.isVip == 0 ? false : true); eventBus.fire(MineInfoChangeRefreshUI()); - // Get.back(); - // Get.toNamed(Routers.starLockMain); XSJPushProvider().initJPushService(); XSJPushProvider().initLocalNotification(false); Get.offNamedUntil(Routers.starLockMain, (Route route) => false); + BlueManage().scanDevices.clear(); //清除设备缓存 } } From c31afd3ef65217d3875e14171236c53c7f5d8896 Mon Sep 17 00:00:00 2001 From: anfe <448468458@qq.com> Date: Tue, 21 May 2024 18:35:10 +0800 Subject: [PATCH 33/44] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=20=E5=91=98?= =?UTF-8?q?=E5=B7=A5=E5=88=97=E8=A1=A8=E6=B2=A1=E6=9C=89=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E5=A4=B4=E5=83=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../checkingInStaffList_page.dart | 18 +++++++++++++++--- .../lockDetail/lockDetail/lockDetail_page.dart | 2 -- .../lockMian/entity/lockListInfo_entity.dart | 5 +++++ 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_page.dart b/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_page.dart index 2b0e1afe..9f58f45e 100755 --- a/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_page.dart +++ b/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_page.dart @@ -145,9 +145,21 @@ class _CheckingInStaffListPageState extends State { SizedBox( width: 20.w, ), - // CustomNetworkImage(url: staffListItem.headurl!, width: 40.w , height: 40.w), - Image.asset(getTypeIcon(staffListItem.attendanceType!), - width: 60.w, height: 60.w), + if (staffListItem.headurl == null || staffListItem.headurl == '') + Image.asset( + getTypeIcon(staffListItem.attendanceType!), + width: 60.w, + height: 60.w, + ) + else + ClipRRect( + borderRadius: BorderRadius.circular(100.w), + child: Image.network( + staffListItem.headurl!, + width: 60.w, + height: 60.w, + ), + ), SizedBox( width: 20.w, ), diff --git a/lib/main/lockDetail/lockDetail/lockDetail_page.dart b/lib/main/lockDetail/lockDetail/lockDetail_page.dart index 97d42890..4f7db2a3 100755 --- a/lib/main/lockDetail/lockDetail/lockDetail_page.dart +++ b/lib/main/lockDetail/lockDetail/lockDetail_page.dart @@ -1326,7 +1326,6 @@ class _LockDetailPageState extends State state.iSOpenLock.value = true; state.openLockBtnState.value = 1; state.animationController!.forward(); - AppLog.log('点击开锁'); if (state.isOpenLockNeedOnline.value == 0) { // 不需要联网 @@ -1348,7 +1347,6 @@ class _LockDetailPageState extends State state.iSOpenLock.value = false; state.openLockBtnState.value = 1; state.animationController!.forward(); - EasyLoading.showToast('正在尝试闭锁……'.tr, duration: 2000.milliseconds); AppLog.log('长按闭锁'); if (state.isOpenLockNeedOnline.value == 0) { diff --git a/lib/main/lockMian/entity/lockListInfo_entity.dart b/lib/main/lockMian/entity/lockListInfo_entity.dart index 950d7639..4e484fc3 100755 --- a/lib/main/lockMian/entity/lockListInfo_entity.dart +++ b/lib/main/lockMian/entity/lockListInfo_entity.dart @@ -252,6 +252,11 @@ class LockListInfoItemEntity { data['hasGateway'] = hasGateway; return data; } + + //是否是锁拥有者 也代表是超级管理员 + bool isLockOwnerBool(){ + return isLockOwner== 1; + } } class Bluetooth { From 4e81381b37ae2e05e296fdb6bd23bccd37ea0345 Mon Sep 17 00:00:00 2001 From: Daisy <> Date: Wed, 22 May 2024 09:16:25 +0800 Subject: [PATCH 34/44] =?UTF-8?q?1=EF=BC=8C=E8=A7=A3=E5=86=B3N=E5=A4=A9?= =?UTF-8?q?=E6=9C=AA=E5=BC=80=E9=97=A8=E7=82=B9=E5=87=BB=E6=97=A0=E6=95=88?= =?UTF-8?q?=E9=97=AE=E9=A2=98=202=EF=BC=8C=E4=BF=AE=E5=A4=8D=E5=AE=9E?= =?UTF-8?q?=E5=90=8D=E8=AE=A4=E8=AF=81=E4=BD=BF=E7=94=A8=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../addFamily/addFamily_logic.dart | 87 +++---- .../messageWarn/addFamily/addFamily_page.dart | 2 +- .../addFamily/addFamily_state.dart | 6 +- .../nDaysUnopened/nDaysUnopened_page.dart | 215 +++++++++--------- .../advancedFunctionRecord_entity.dart | 6 +- .../use_record_list_entity.dart | 3 + .../value_added_services_record_logic.dart | 10 +- .../value_added_services_record_page.dart | 166 ++++++-------- 8 files changed, 235 insertions(+), 260 deletions(-) diff --git a/lib/main/lockDetail/messageWarn/addFamily/addFamily_logic.dart b/lib/main/lockDetail/messageWarn/addFamily/addFamily_logic.dart index 1f3ddf37..8bdf205f 100755 --- a/lib/main/lockDetail/messageWarn/addFamily/addFamily_logic.dart +++ b/lib/main/lockDetail/messageWarn/addFamily/addFamily_logic.dart @@ -11,32 +11,39 @@ class AddFamilyLogic extends BaseGetXController { //添加开门通知 Future addLockNoticeSetting() async { + final Map settingValue = { + 'openDoorId': state.lockUserKeys.value.currentOpenDoorID, + 'openDoorType': state.lockUserKeys.value.currentKeyType, + 'remark': state.lockUserKeys.value.currentKeyName ?? '', + 'noticeWay': getNoticeWayList(), + }; + final MsgNotificationEntity entity = await ApiRepository.to.addLockNoticeSetting( lockId: state.getLockId.value, noticeType: 10, - settingValue: { - 'openDoorId': state.lockUserKeys.value.currentOpenDoorID, - 'openDoorType': state.lockUserKeys.value.currentKeyType, - 'remark': state.lockUserKeys.value.currentKeyName ?? '', - 'noticeWay': >[ - { - 'type': 'mail', - 'accounts': getEmailAndSMSAccountList(true) - }, - { - 'type': 'sms', - 'accounts': getEmailAndSMSAccountList(false) - } - ] - }, + settingValue: settingValue, ); + if (entity.errorCode!.codeIsSuccessful) { showToast('添加成功'.tr); Get.back(result: true); } } + List> getNoticeWayList() { + return >[ + { + 'type': 'mail', + 'accounts': getEmailAndSMSAccountList(true) + }, + { + 'type': 'sms', + 'accounts': getEmailAndSMSAccountList(false) + }, + ]; + } + //更新开门通知 Future updateLockNoticeSetting() async { final OpenDoorNotifyEntity entity = @@ -122,14 +129,14 @@ class AddFamilyLogic extends BaseGetXController { //检查按钮是否可用 bool checkBtnDisable() { - if ((state.emailListStr.value.isEmpty || - state.phontListStr.value.isEmpty) || - state.lockUserKeys.value.currentKeyTypeStr!.isEmpty || - state.lockUserKeys.value.currentKeyName!.isEmpty) { + final String? keyTypeStr = state.lockUserKeys.value.currentKeyTypeStr; + final String? keyName = state.lockUserKeys.value.currentKeyName; + + if (keyTypeStr == null || keyName == null) { return false; - } else { - return true; } + + return keyTypeStr.isNotEmpty && keyName.isNotEmpty; } //当前钥匙类型 1:电子钥匙 2:密码钥匙 3:指纹钥匙 4:卡钥匙 5:人脸钥匙 @@ -156,29 +163,27 @@ class AddFamilyLogic extends BaseGetXController { final List mailAccounts = []; final List smsAccounts = []; - if (state.familyData.value.settingValue != null) { - for (final NoticeWay item - in state.familyData.value.settingValue!.noticeWayList!) { - if (item.type == 'mail' && item.accounts != null) { - for (final Accounts account in item.accounts!) { - if (account.account != null) { - final MsgNoticeModeData msgNoticeModeData = MsgNoticeModeData(); - msgNoticeModeData.receiveEmail = account.account!; - mailAccounts.add(msgNoticeModeData); - } + state.familyData.value.settingValue?.noticeWayList + ?.forEach((NoticeWay item) { + if (item.type == 'mail') { + item.accounts?.forEach((Accounts account) { + if (account.account != null) { + final MsgNoticeModeData msgNoticeModeData = MsgNoticeModeData(); + msgNoticeModeData.receiveEmail = account.account!; + mailAccounts.add(msgNoticeModeData); } - } else if (item.type == 'sms' && item.accounts != null) { - for (final Accounts account in item.accounts!) { - if (account.account != null && account.countryCode != null) { - final MsgNoticeModeData msgNoticeModeData = MsgNoticeModeData(); - msgNoticeModeData.receivePhone = account.account!; - msgNoticeModeData.countryCode = account.countryCode!; - smsAccounts.add(msgNoticeModeData); - } + }); + } else if (item.type == 'sms') { + item.accounts?.forEach((Accounts account) { + if (account.account != null && account.countryCode != null) { + final MsgNoticeModeData msgNoticeModeData = MsgNoticeModeData(); + msgNoticeModeData.receivePhone = account.account!; + msgNoticeModeData.countryCode = account.countryCode!; + smsAccounts.add(msgNoticeModeData); } - } + }); } - } + }); return >{ 'emailReceiverList': mailAccounts, diff --git a/lib/main/lockDetail/messageWarn/addFamily/addFamily_page.dart b/lib/main/lockDetail/messageWarn/addFamily/addFamily_page.dart index 98259c99..4e7f53f3 100755 --- a/lib/main/lockDetail/messageWarn/addFamily/addFamily_page.dart +++ b/lib/main/lockDetail/messageWarn/addFamily/addFamily_page.dart @@ -120,7 +120,7 @@ class _AddFamilyPageState extends State { : logic.checkBtnDisable(), isDelete: state.isDetail.value, onClick: () async { - bool? isVip = await Storage.getBool(saveIsVip); + final bool? isVip = await Storage.getBool(saveIsVip); if (isVip == true) { if (state.isDetail.value) { logic.deleteLockNoticeSetting(); diff --git a/lib/main/lockDetail/messageWarn/addFamily/addFamily_state.dart b/lib/main/lockDetail/messageWarn/addFamily/addFamily_state.dart index a8bfce2b..63380b14 100755 --- a/lib/main/lockDetail/messageWarn/addFamily/addFamily_state.dart +++ b/lib/main/lockDetail/messageWarn/addFamily/addFamily_state.dart @@ -5,9 +5,9 @@ import 'package:star_lock/main/lockDetail/messageWarn/msgNotification/openDoorNo class AddFamilyState { final TextEditingController changeNameController = TextEditingController(); - var getLockId = 0.obs; - var lockUserKeys = LockUserListKeys().obs; - var emailReceiverList = [].obs; + RxInt getLockId = 0.obs; + Rx lockUserKeys = LockUserListKeys().obs; + RxList emailReceiverList = [].obs; var phoneReceiverList = [].obs; var emailListStr = ''.obs; var phontListStr = ''.obs; diff --git a/lib/main/lockDetail/messageWarn/msgNotification/nDaysUnopened/nDaysUnopened_page.dart b/lib/main/lockDetail/messageWarn/msgNotification/nDaysUnopened/nDaysUnopened_page.dart index dbfd3b42..1aed9f7c 100755 --- a/lib/main/lockDetail/messageWarn/msgNotification/nDaysUnopened/nDaysUnopened_page.dart +++ b/lib/main/lockDetail/messageWarn/msgNotification/nDaysUnopened/nDaysUnopened_page.dart @@ -3,6 +3,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/appRouters.dart'; +import 'package:star_lock/app_settings/app_settings.dart'; import 'package:star_lock/main/lockDetail/messageWarn/msgNotification/msgNotification/msgNotification_entity.dart'; import 'package:star_lock/main/lockDetail/messageWarn/msgNotification/nDaysUnopened/nDaysUnopened_state.dart'; import 'package:star_lock/tools/commonItem.dart'; @@ -32,122 +33,113 @@ class _NDaysUnopenedPageState extends State { return Scaffold( backgroundColor: AppColors.mainBackgroundColor, appBar: TitleAppBar( - barTitle: 'N天未开门'.tr, - haveBack: true, - backgroundColor: AppColors.mainColor), - body: ListView( + barTitle: 'N天未开门'.tr, + haveBack: true, + backgroundColor: AppColors.mainColor, + ), + body: Padding( padding: EdgeInsets.all(30.w), - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Expanded( + child: Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Expanded( child: Text( - '经过以上设定的时间,锁没有被开启,系统会给指定对象发送提醒消息,该功能需要锁联网'.tr, - style: TextStyle( - fontSize: 20.sp, color: AppColors.darkGrayTextColor), - )), - ], - ), - SizedBox( - height: 20.h, - ), - CommonItem( + '经过以上设定的时间,锁没有被开启,系统会给指定对象发送提醒消息,该功能需要锁联网'.tr, + style: TextStyle( + fontSize: 20.sp, color: AppColors.darkGrayTextColor), + ), + ), + ], + ), + SizedBox(height: 20.h), + CommonItem( leftTitel: 'N天未开门提醒'.tr, rightTitle: '', isHaveLine: true, isHaveDirection: false, isHaveRightWidget: true, - rightWidget: _unOpenDoorSwitch(), - action: () {}), - _buildOpenNoticeWidget(), - Expanded( - child: SizedBox( - height: 20.h, - )), - SubmitBtn( - btnName: '保存'.tr, - onClick: () async { - bool? isVip = await Storage.getBool(saveIsVip); - if (isVip == false) { - ShowCupertinoAlertView().advancedFeatureAlert(); - } else { - logic.lockNoticeSettingAccountList(); - } - }, - ), - SizedBox( - height: 60.h, - ) - ], + rightWidget: Obx(_unOpenDoorSwitch), + ), + Obx(_buildOpenNoticeWidget), + Expanded(child: Container()), + SubmitBtn( + btnName: '保存'.tr, + onClick: () async { + final bool? isVip = await Storage.getBool(saveIsVip); + if (isVip == false) { + ShowCupertinoAlertView().advancedFeatureAlert(); + } else { + logic.lockNoticeSettingAccountList(); + } + }, + ), + SizedBox(height: 60.h), + ], + ), ), ); } Widget _buildOpenNoticeWidget() { return Visibility( - visible: state.isUnOpenNotice.value, - child: Column( - children: [ - Obx(() => CommonItem( - leftTitel: '门未开时间'.tr, - rightTitle: '${state.unOpenDoorTime.value}天', - isHaveLine: true, - isHaveRightWidget: false, - isHaveDirection: true, - action: () { - _openBottomItemSheet(context, state.unopenDoorTimeList); - }, - )), - SizedBox( - height: 20.h, - ), - GestureDetector( - onTap: () { - Get.toNamed(Routers.notificationModePage, - arguments: { - 'msgNoticeInfo': state.msgNoticeInfo.value - })?.then((val) { - if (val != null) { - state.emailListStr.value = logic.getEmailListStr(val); - state.phontListStr.value = logic.getPhoneListStr(val); - } - }); - }, - child: Container( - color: Colors.white, - margin: EdgeInsets.only(bottom: 10.h), - child: Column( - children: [ - CommonItem( - leftTitel: '提醒方式'.tr, - rightTitle: '', - isHaveLine: false, - isHaveRightWidget: false, - isHaveDirection: true, - ), - _buildNotifyContain('APP推送'.tr, '管理员'.tr), - Obx(() => state.emailListStr.value.isNotEmpty - ? _buildNotifyContain( - '邮件提醒'.tr, state.emailListStr.value) - : Container()), - Obx(() => state.phontListStr.value.isNotEmpty - ? _buildNotifyContain( - '短信提醒'.tr, state.phontListStr.value) - : Container()), - ], - ), + visible: state.isUnOpenNotice.value, + child: Column( + children: [ + CommonItem( + leftTitel: '门未开时间'.tr, + rightTitle: '${state.unOpenDoorTime.value}天', + isHaveLine: true, + isHaveRightWidget: false, + isHaveDirection: true, + action: () { + _openBottomItemSheet(context, state.unopenDoorTimeList); + }, + ), + SizedBox(height: 20.h), + GestureDetector( + onTap: () { + Get.toNamed(Routers.notificationModePage, + arguments: { + 'msgNoticeInfo': state.msgNoticeInfo.value + })?.then((val) { + if (val != null) { + state.emailListStr.value = logic.getEmailListStr(val); + state.phontListStr.value = logic.getPhoneListStr(val); + } + }); + }, + child: Container( + color: Colors.white, + margin: EdgeInsets.only(bottom: 10.h), + child: Column( + children: [ + CommonItem( + leftTitel: '提醒方式'.tr, + rightTitle: '', + isHaveLine: false, + isHaveRightWidget: false, + isHaveDirection: true, + ), + _buildNotifyContain('APP推送'.tr, '管理员'.tr), + if (state.emailListStr.value.isNotEmpty) + _buildNotifyContain('邮件提醒'.tr, state.emailListStr.value), + if (state.phontListStr.value.isNotEmpty) + _buildNotifyContain('短信提醒'.tr, state.phontListStr.value), + ], ), ), - ], - )); + ), + ], + ), + ); } Widget _buildNotifyContain(String notifyTitle, String notifyContent) { return Container( - padding: - EdgeInsets.only(left: 10.w, right: 10.w, top: 12.h, bottom: 12.h), - margin: EdgeInsets.only(bottom: 20.h, top: 10.h, left: 20.w, right: 20.w), + padding: EdgeInsets.symmetric(horizontal: 10.w, vertical: 12.h), + margin: EdgeInsets.symmetric(vertical: 10.h, horizontal: 20.w), decoration: BoxDecoration( color: AppColors.mainBackgroundColor, borderRadius: BorderRadius.circular(6.0.w), @@ -158,14 +150,13 @@ class _NDaysUnopenedPageState extends State { notifyTitle, style: TextStyle(color: Colors.black, fontSize: 20.sp), ), - Expanded( - child: SizedBox( - width: 20.w, - )), - Text(notifyContent, - textAlign: TextAlign.end, - style: TextStyle( - color: AppColors.placeholderTextColor, fontSize: 20.sp)), + Expanded(child: Container()), + Text( + notifyContent, + textAlign: TextAlign.end, + style: TextStyle( + color: AppColors.placeholderTextColor, fontSize: 20.sp), + ), ], ), ); @@ -178,23 +169,21 @@ class _NDaysUnopenedPageState extends State { thumbColor: CupertinoColors.white, value: state.isUnOpenNotice.value, onChanged: (bool value) { - setState(() { - state.isUnOpenNotice.value = value; - if (!state.isUnOpenNotice.value) { - state.msgNoticeInfo.value = MsgNoticeData(); - } - }); + state.isUnOpenNotice.value = value; + if (!state.isUnOpenNotice.value) { + state.msgNoticeInfo.value = MsgNoticeData(); + } }, ); } - //底部选择pickerView + // 底部选择pickerView void _openBottomItemSheet(BuildContext context, List dataList) { Pickers.showSinglePicker(context, data: dataList, pickerStyle: DefaultPickerStyle(), onConfirm: (p, int position) { state.unOpenDoorTime.value = int.parse(state.unopenDoorTimeList[position].replaceAll('天', '')); - }, onChanged: (p, int position) {}); + }); } } diff --git a/lib/mine/valueAddedServices/advancedFunctionRecord/advancedFunctionRecord_entity.dart b/lib/mine/valueAddedServices/advancedFunctionRecord/advancedFunctionRecord_entity.dart index a68e73b6..72e4de70 100755 --- a/lib/mine/valueAddedServices/advancedFunctionRecord/advancedFunctionRecord_entity.dart +++ b/lib/mine/valueAddedServices/advancedFunctionRecord/advancedFunctionRecord_entity.dart @@ -72,6 +72,7 @@ class RecordItem { String? amount; String? createdAt; String? updatedAt; + String? useDate; RecordItem( {this.id, @@ -86,7 +87,8 @@ class RecordItem { this.vipYear, this.amount, this.createdAt, - this.updatedAt}); + this.updatedAt, + this.useDate}); RecordItem.fromJson(Map json) { id = json['id']; @@ -102,6 +104,7 @@ class RecordItem { amount = json['amount']; createdAt = json['created_at']; updatedAt = json['updated_at']; + useDate = json['useDate']; } Map toJson() { @@ -119,6 +122,7 @@ class RecordItem { data['amount'] = amount; data['created_at'] = createdAt; data['updated_at'] = updatedAt; + data['useDate'] = useDate; return data; } } diff --git a/lib/mine/valueAddedServices/valueAddedServicesRecord/use_record_list_entity.dart b/lib/mine/valueAddedServices/valueAddedServicesRecord/use_record_list_entity.dart index 6acd6ea7..d0d6092a 100755 --- a/lib/mine/valueAddedServices/valueAddedServicesRecord/use_record_list_entity.dart +++ b/lib/mine/valueAddedServices/valueAddedServicesRecord/use_record_list_entity.dart @@ -70,6 +70,7 @@ class UseItemData { int? consCount; String? createdAt; String? updatedAt; + String? useDate; UseItemData( {this.id, @@ -96,6 +97,7 @@ class UseItemData { consCount = json['cons_count']; createdAt = json['created_at']; updatedAt = json['updated_at']; + useDate = json['useDate']; } Map toJson() { @@ -111,6 +113,7 @@ class UseItemData { data['cons_count'] = consCount; data['created_at'] = createdAt; data['updated_at'] = updatedAt; + data['useDate'] = useDate; return data; } } diff --git a/lib/mine/valueAddedServices/valueAddedServicesRecord/value_added_services_record_logic.dart b/lib/mine/valueAddedServices/valueAddedServicesRecord/value_added_services_record_logic.dart index f7573588..c493bcb6 100755 --- a/lib/mine/valueAddedServices/valueAddedServicesRecord/value_added_services_record_logic.dart +++ b/lib/mine/valueAddedServices/valueAddedServicesRecord/value_added_services_record_logic.dart @@ -18,7 +18,7 @@ class ValueAddedServicesRecordLogic extends BaseGetXController { @override void onInit() { super.onInit(); - dynamic data = Get.arguments; + final dynamic data = Get.arguments; if (data is! Map || data['type'] is! String) { Get.back(); return; @@ -31,7 +31,7 @@ class ValueAddedServicesRecordLogic extends BaseGetXController { if (!load) { buyPageNo = 1; } - AdvancedFunctionRecordEntity entity = + final AdvancedFunctionRecordEntity entity = await ApiRepository.to.getBuyRecordList( type: type, recordType: 10, @@ -48,7 +48,7 @@ class ValueAddedServicesRecordLogic extends BaseGetXController { if (!load) { usePageNo = 1; } - UseRecordListEntity entity = await ApiRepository.to.getUseRecordList( + final UseRecordListEntity entity = await ApiRepository.to.getUseRecordList( type: type, pageNo: buyPageNo, ); @@ -62,7 +62,7 @@ class ValueAddedServicesRecordLogic extends BaseGetXController { void onReady() { super.onReady(); - loadBuyRecordList(true); - loadUseRecordList(true); + loadBuyRecordList(false); + loadUseRecordList(false); } } diff --git a/lib/mine/valueAddedServices/valueAddedServicesRecord/value_added_services_record_page.dart b/lib/mine/valueAddedServices/valueAddedServicesRecord/value_added_services_record_page.dart index a4cbd4c2..b8aba35b 100755 --- a/lib/mine/valueAddedServices/valueAddedServicesRecord/value_added_services_record_page.dart +++ b/lib/mine/valueAddedServices/valueAddedServicesRecord/value_added_services_record_page.dart @@ -10,16 +10,14 @@ import '../../../app_settings/app_colors.dart'; import '../../../tools/titleAppBar.dart'; class ValueAddedServicesRecordPage extends StatefulWidget { - const ValueAddedServicesRecordPage({ - Key? key, - }) : super(key: key); + const ValueAddedServicesRecordPage({Key? key}) : super(key: key); @override State createState() => - _ValueAddedServicesRealNamePageState(); + _ValueAddedServicesRecordPageState(); } -class _ValueAddedServicesRealNamePageState +class _ValueAddedServicesRecordPageState extends State { @override Widget build(BuildContext context) { @@ -43,16 +41,16 @@ class _ValueAddedServicesRealNamePageState labelColor: AppColors.mainColor, unselectedLabelColor: AppColors.darkGrayTextColor, ), - Obx(() => Expanded( - child: TabBarView(children: [ + Expanded( + child: Obx(() => TabBarView(children: [ _PurchaseRecords( buyRecordList: logic.state.buyRecordList.value, ), _UseRecordsTable( useRecordList: logic.state.useRecordList.value, ), - ]), - )), + ])), + ), ], ), ), @@ -63,7 +61,7 @@ class _ValueAddedServicesRealNamePageState Widget tabTextItem(String tabText) { return Container( - margin: EdgeInsets.only(top: 16.h, bottom: 16.h), + margin: EdgeInsets.symmetric(vertical: 16.h), child: Text( tabText, style: TextStyle(fontSize: 24.sp), @@ -71,29 +69,27 @@ Widget tabTextItem(String tabText) { ); } -//购买记录 -class _PurchaseRecords extends StatefulWidget { +// 购买记录 +class _PurchaseRecords extends StatelessWidget { + const _PurchaseRecords({required this.buyRecordList}); final List buyRecordList; - const _PurchaseRecords({required this.buyRecordList}); - - @override - State<_PurchaseRecords> createState() => _PurchaseRecordsState(); -} - -class _PurchaseRecordsState extends State<_PurchaseRecords> { @override Widget build(BuildContext context) { return GetBuilder( builder: (ValueAddedServicesRecordLogic logic) { return EasyRefresh( - onRefresh: () async {}, - onLoad: () async {}, - child: widget.buyRecordList.isNotEmpty + onRefresh: () async { + logic.loadBuyRecordList(false); + }, + onLoad: () async { + logic.loadBuyRecordList(true); + }, + child: buyRecordList.isNotEmpty ? ListView.builder( - itemCount: widget.buyRecordList.length, + itemCount: buyRecordList.length, itemBuilder: (BuildContext context, int index) { - return _recordKeyItem(widget.buyRecordList[index]); + return _recordKeyItem(buyRecordList[index]); }) : NoData(), ); @@ -103,17 +99,15 @@ class _PurchaseRecordsState extends State<_PurchaseRecords> { Widget _recordKeyItem(RecordItem itemData) { return Container( color: Colors.white, - margin: EdgeInsets.only(left: 20.w, right: 20.w, top: 10.h), - padding: - EdgeInsets.only(left: 20.w, right: 20.w, top: 16.h, bottom: 16.h), + margin: EdgeInsets.symmetric(horizontal: 20.w, vertical: 10.h), + padding: EdgeInsets.all(20.w), child: Column( - children: [ + crossAxisAlignment: CrossAxisAlignment.start, + children: [ Row( - children: [ + children: [ Text( - itemData.createdAt!.length > 10 - ? itemData.createdAt!.substring(0, 10) - : itemData.createdAt!, + itemData.createdAt?.substring(0, 10) ?? '', style: TextStyle( fontSize: 24.sp, color: AppColors.blackColor, @@ -127,60 +121,53 @@ class _PurchaseRecordsState extends State<_PurchaseRecords> { fontWeight: FontWeight.bold)), ], ), - SizedBox( - height: 8.h, - ), - Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Text('实名认证/${itemData.cloudauthCount}次', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: 22.sp, color: AppColors.darkGrayTextColor)) - ], - ), + SizedBox(height: 8.h), + Text('实名认证/${itemData.cloudauthCount}次', + style: TextStyle( + fontSize: 22.sp, color: AppColors.darkGrayTextColor)), ], ), ); } } -//使用记录 -class _UseRecordsTable extends StatefulWidget { +// 使用记录 +class _UseRecordsTable extends StatelessWidget { + const _UseRecordsTable({required this.useRecordList}); final List useRecordList; - const _UseRecordsTable({required this.useRecordList}); - - @override - State<_UseRecordsTable> createState() => _UseRecordsTableState(); -} - -class _UseRecordsTableState extends State<_UseRecordsTable> { @override Widget build(BuildContext context) { - return EasyRefresh( - onRefresh: () async {}, - onLoad: () async {}, - child: widget.useRecordList.isNotEmpty - ? ListView.builder( - itemCount: widget.useRecordList.length, - itemBuilder: (BuildContext context, int index) { - return _recordKeyItem(widget.useRecordList[index]); - }) - : NoData(), - ); + return GetBuilder( + builder: (ValueAddedServicesRecordLogic logic) { + return EasyRefresh( + onRefresh: () async { + logic.loadUseRecordList(false); + }, + onLoad: () async { + logic.loadUseRecordList(true); + }, + child: useRecordList.isNotEmpty + ? ListView.builder( + itemCount: useRecordList.length, + itemBuilder: (BuildContext context, int index) { + return _recordKeyItem(useRecordList[index]); + }) + : NoData(), + ); + }); } Widget _recordKeyItem(UseItemData itemData) { return Container( color: Colors.white, - margin: EdgeInsets.only(left: 20.w, right: 20.w, top: 10.h), - padding: - EdgeInsets.only(left: 20.w, right: 20.w, top: 16.h, bottom: 16.h), + margin: EdgeInsets.symmetric(horizontal: 20.w, vertical: 10.h), + padding: EdgeInsets.all(20.w), child: Column( - children: [ + crossAxisAlignment: CrossAxisAlignment.start, + children: [ Row( - children: [ + children: [ Text( '${itemData.lockName ?? ""} ${itemData.realName ?? ""}', style: TextStyle( @@ -189,35 +176,22 @@ class _UseRecordsTableState extends State<_UseRecordsTable> { fontWeight: FontWeight.bold), ), Expanded(child: Container()), - itemData.authStatus == 0 - ? Container( - padding: EdgeInsets.only( - right: 6.w, left: 6.w, top: 2.h, bottom: 2.h), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(5.w), - color: AppColors.toBeReceiveBgColor, - ), - child: Text('失败', - style: TextStyle(fontSize: 16.sp, color: Colors.red)), - ) - : Container() - ], - ), - SizedBox( - height: 8.h, - ), - Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Text( - itemData.createdAt!.length > 10 - ? itemData.createdAt!.substring(0, 10) - : itemData.createdAt!, - textAlign: TextAlign.left, - style: TextStyle( - fontSize: 22.sp, color: AppColors.darkGrayTextColor)) + if (itemData.authStatus == 0) + Container( + padding: EdgeInsets.symmetric(horizontal: 6.w, vertical: 2.h), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5.w), + color: AppColors.toBeReceiveBgColor, + ), + child: Text('失败', + style: TextStyle(fontSize: 16.sp, color: Colors.red)), + ), ], ), + SizedBox(height: 8.h), + Text(itemData.useDate ?? '', + style: TextStyle( + fontSize: 22.sp, color: AppColors.darkGrayTextColor)), ], ), ); From cc69f1d90e78f15b508f5a976ff89fde875e5f86 Mon Sep 17 00:00:00 2001 From: anfe <448468458@qq.com> Date: Wed, 22 May 2024 10:33:07 +0800 Subject: [PATCH 35/44] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=20=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE-=E8=87=AA=E5=8A=A8=E9=97=AD=E9=94=81=E9=80=BB?= =?UTF-8?q?=E8=BE=91=EF=BC=8C=E6=B7=BB=E5=8A=A0=E6=97=B6=E9=97=B4=E5=85=B3?= =?UTF-8?q?=E9=97=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- images/lan/lan_en.json | 2 +- images/lan/lan_keys.json | 2 +- images/lan/lan_zh.json | 2 +- .../automaticBlocking_logic.dart | 121 ++++++----- .../automaticBlocking_page.dart | 203 +++++++++--------- lib/tools/baseGetXController.dart | 7 +- lib/tools/storage.dart | 139 ++++++------ lib/widget/permission/permission_dialog.dart | 103 +++++---- 8 files changed, 304 insertions(+), 275 deletions(-) diff --git a/images/lan/lan_en.json b/images/lan/lan_en.json index f0754730..630c677c 100755 --- a/images/lan/lan_en.json +++ b/images/lan/lan_en.json @@ -608,7 +608,7 @@ "卡详情": "Card details", "请输入": "Please enter", "关闭后,智能锁将设置为全天常开模式,直到手动关闭": "After closing, the smart lock will be set to all-day open mode until manually closed", - "请输入小于1000的数字": "Please enter a number less than 1000", + "请输入小于或等于60的数字": "Please enter a number less than 60", "操作成功": "Operation success", "管理员密码相同,无需修改": "The administrator password is the same and does not need to be modified", "修改密码": "Modify password", diff --git a/images/lan/lan_keys.json b/images/lan/lan_keys.json index 9e5a1a1d..e470018b 100755 --- a/images/lan/lan_keys.json +++ b/images/lan/lan_keys.json @@ -633,7 +633,7 @@ "卡详情": "卡详情", "请输入": "请输入", "关闭后,智能锁将设置为全天常开模式,直到手动关闭": "关闭后,智能锁将设置为全天常开模式,直到手动关闭", - "请输入小于1000的数字": "请输入小于1000的数字", + "请输入小于或等于60的数字": "请输入小于或等于60的数字", "操作成功": "操作成功", "管理员密码相同,无需修改": "管理员密码相同,无需修改", "修改密码": "修改密码", diff --git a/images/lan/lan_zh.json b/images/lan/lan_zh.json index 73152201..b83194c6 100755 --- a/images/lan/lan_zh.json +++ b/images/lan/lan_zh.json @@ -608,7 +608,7 @@ "卡详情": "卡详情", "请输入": "请输入", "关闭后,智能锁将设置为全天常开模式,直到手动关闭": "关闭后,智能锁将设置为全天常开模式,直到手动关闭", - "请输入小于1000的数字": "请输入小于1000的数字", + "请输入小于或等于60的数字": "请输入小于或等于60的数字", "操作成功": "操作成功", "管理员密码相同,无需修改": "管理员密码相同,无需修改", "修改密码": "修改密码", diff --git a/lib/main/lockDetail/lockSet/automaticBlocking/automaticBlocking_logic.dart b/lib/main/lockDetail/lockSet/automaticBlocking/automaticBlocking_logic.dart index fafc4bc8..4dc59725 100755 --- a/lib/main/lockDetail/lockSet/automaticBlocking/automaticBlocking_logic.dart +++ b/lib/main/lockDetail/lockSet/automaticBlocking/automaticBlocking_logic.dart @@ -1,9 +1,10 @@ - import 'dart:async'; import 'package:flutter_blue_plus/flutter_blue_plus.dart'; +import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:get/get.dart'; import 'package:star_lock/blue/io_protocol/io_setSupportFunctionsWithParameters.dart'; +import 'package:star_lock/login/login/entity/LoginEntity.dart'; import 'package:star_lock/tools/baseGetXController.dart'; import '../../../../blue/blue_manage.dart'; import '../../../../blue/io_reply.dart'; @@ -15,47 +16,50 @@ import '../../../../tools/eventBusEventManage.dart'; import '../../../../tools/storage.dart'; import 'automaticBlocking_state.dart'; -class AutomaticBlockingLogic extends BaseGetXController{ +class AutomaticBlockingLogic extends BaseGetXController { final AutomaticBlockingState state = AutomaticBlockingState(); - void setAutoUnLock() async{ + Future setAutoUnLock() async { String autoTime; - if(state.isOpen.value == false){ - autoTime = "0"; - }else{ - if(state.isCustomLockTime.value == true){ + if (state.isOpen.value == false) { + autoTime = '0'; + } else { + if (state.isCustomLockTime.value == true) { autoTime = state.timeController.text; - if(int.parse(autoTime) >= 1000){ - showToast("请输入小于1000的数字".tr); + if (int.parse(autoTime) > 60) { + showToast('请输入小于或等于60的数字'.tr); return; } - }else{ + } else { autoTime = state.autoLockTime.value; } } - var entity = await ApiRepository.to.setAutoUnlock( - lockId: state.lockSetInfoData.value.lockId!, - autoLock:state.isOpen.value == true ? 1 : 0, - autoLockSecond: int.parse(autoTime), + final LoginEntity entity = await ApiRepository.to.setAutoUnlock( + lockId: state.lockSetInfoData.value.lockId!, + autoLock: state.isOpen.value == true ? 1 : 0, + autoLockSecond: int.parse(autoTime), ); - if(entity.errorCode!.codeIsSuccessful){ - + if (entity.errorCode!.codeIsSuccessful) { state.autoLockTime.value = autoTime; - state.lockSetInfoData.value.lockSettingInfo!.autoLockSecond = int.parse(state.autoLockTime.value); - showToast("操作成功".tr, something: (){ + state.lockSetInfoData.value.lockSettingInfo!.autoLockSecond = + int.parse(state.autoLockTime.value); + showToast('操作成功'.tr, something: () { eventBus.fire(RefreshLockListInfoDataEvent()); - eventBus.fire(PassCurrentLockInformationEvent(state.lockSetInfoData.value)); + eventBus + .fire(PassCurrentLockInformationEvent(state.lockSetInfoData.value)); Get.back(); - }); + }, maskType: EasyLoadingMaskType.clear); } } // 获取解析后的数据 late StreamSubscription _replySubscription; + void _initReplySubscription() { - _replySubscription = EventBusManager().eventBus!.on().listen((reply) { - if(reply is SetSupportFunctionsWithParametersReply) { + _replySubscription = + EventBusManager().eventBus!.on().listen((Reply reply) { + if (reply is SetSupportFunctionsWithParametersReply) { _replySetSupportFunctionsWithParameters(reply); } @@ -86,10 +90,10 @@ class AutomaticBlockingLogic extends BaseGetXController{ // 设置自动落锁数据解析 Future _replySetSupportFunctionsWithParameters(Reply reply) async { - int status = reply.data[2]; - switch(status){ + final int status = reply.data[2]; + switch (status) { case 0x00: - //成功 + //成功 state.sureBtnState.value = 0; cancelBlueConnetctToastTimer(); dismissEasyLoading(); @@ -106,34 +110,39 @@ class AutomaticBlockingLogic extends BaseGetXController{ // 设置支持功能(带参数) Future sendAutoLock() async { - if(state.sureBtnState.value == 1){ + if (state.sureBtnState.value == 1) { return; } state.sureBtnState.value = 1; showEasyLoading(); - showBlueConnetctToastTimer(action: (){ + showBlueConnetctToastTimer(action: () { dismissEasyLoading(); state.sureBtnState.value = 0; }); - BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async { + BlueManage().blueSendData(BlueManage().connectDeviceName, + (BluetoothConnectionState connectionState) async { if (connectionState == BluetoothConnectionState.connected) { - var privateKey = await Storage.getStringList(saveBluePrivateKey); - List getPrivateKeyList = changeStringListToIntList(privateKey!); + final List? privateKey = + await Storage.getStringList(saveBluePrivateKey); + final List getPrivateKeyList = + changeStringListToIntList(privateKey!); - var token = await Storage.getStringList(saveBlueToken); - List getTokenList = changeStringListToIntList(token!); + final List? token = await Storage.getStringList(saveBlueToken); + final List getTokenList = changeStringListToIntList(token!); - var publicKey = await Storage.getStringList(saveBluePublicKey); - List getPublicKeyList = changeStringListToIntList(publicKey!); + final List? publicKey = + await Storage.getStringList(saveBluePublicKey); + final List getPublicKeyList = + changeStringListToIntList(publicKey!); String autoTime; - if(state.isOpen.value == false){ - autoTime = "0"; - }else{ - if(state.isCustomLockTime.value == true){ + if (state.isOpen.value == false) { + autoTime = '0'; + } else { + if (state.isCustomLockTime.value == true) { autoTime = state.timeController.text; - }else{ + } else { autoTime = state.autoLockTime.value; } } @@ -142,7 +151,7 @@ class AutomaticBlockingLogic extends BaseGetXController{ userID: await Storage.getUid(), featureBit: 29, featureParaLength: 2, - featureData: [int.parse(autoTime)], + featureData: [int.parse(autoTime)], token: getTokenList, needAuthor: 1, publicKey: getPublicKeyList, @@ -151,7 +160,7 @@ class AutomaticBlockingLogic extends BaseGetXController{ dismissEasyLoading(); cancelBlueConnetctToastTimer(); state.sureBtnState.value = 0; - if(state.ifCurrentScreen.value == true){ + if (state.ifCurrentScreen.value == true) { showBlueConnetctToast(); } } @@ -159,36 +168,42 @@ class AutomaticBlockingLogic extends BaseGetXController{ } void ifCanNext() { - if(((state.isOpen.value != (state.lockSetInfoData.value.lockSettingInfo!.autoLock! == 1 ? true : false)) && - (state.autoLockTime.value != state.lockSetInfoData.value.lockSettingInfo!.autoLockSecond!.toString()) && - (state.isJustForShow.value == false)) || ((state.isOpen.value = true) && (state.lockSetInfoData.value.lockSettingInfo!.autoLock! == 1) && - (state.autoLockTime.value != state.lockSetInfoData.value.lockSettingInfo!.autoLockSecond!.toString()) && - (state.isJustForShow.value == false))){ + final int autoLock = state.lockSetInfoData.value.lockSettingInfo!.autoLock!; + final String autoLockSecond = + state.lockSetInfoData.value.lockSettingInfo!.autoLockSecond!.toString(); + final bool openLock = autoLock == 1; + final bool isNotJustForShow = state.isJustForShow.value == false; + final bool isEditAutoLockSecond = + state.autoLockTime.value != autoLockSecond; + + if (!isNotJustForShow) { + //普通用户 + state.canNext.value = false; + return; + } + + if (state.isOpen.value != openLock || isEditAutoLockSecond) { state.canNext.value = true; - }else{ + } else { state.canNext.value = false; } } @override void onReady() { - // TODO: implement onReady super.onReady(); - _initReplySubscription(); + Storage.getAutomaticLockOffTime() + .then((String value) => state.timeController.text = value); } @override void onInit() { - // TODO: implement onInit super.onInit(); - - // _readSupportFunctionsWithParameters(); } @override void onClose() { - // TODO: implement onClose super.onClose(); _replySubscription.cancel(); } diff --git a/lib/main/lockDetail/lockSet/automaticBlocking/automaticBlocking_page.dart b/lib/main/lockDetail/lockSet/automaticBlocking/automaticBlocking_page.dart index 3d03acac..b559145d 100755 --- a/lib/main/lockDetail/lockSet/automaticBlocking/automaticBlocking_page.dart +++ b/lib/main/lockDetail/lockSet/automaticBlocking/automaticBlocking_page.dart @@ -4,9 +4,10 @@ import 'package:flutter/material.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; +import 'package:star_lock/main/lockDetail/lockSet/automaticBlocking/automaticBlocking_state.dart'; +import 'package:star_lock/tools/storage.dart'; import '../../../../app_settings/app_colors.dart'; -import '../../../../blue/blue_manage.dart'; import '../../../../tools/appRouteObserver.dart'; import '../../../../tools/commonItem.dart'; import '../../../../tools/showBottomSheetTool.dart'; @@ -22,9 +23,10 @@ class AutomaticBlockingPage extends StatefulWidget { State createState() => _AutomaticBlockingPageState(); } -class _AutomaticBlockingPageState extends State with RouteAware { - final logic = Get.put(AutomaticBlockingLogic()); - final state = Get.find().state; +class _AutomaticBlockingPageState extends State + with RouteAware { + final AutomaticBlockingLogic logic = Get.put(AutomaticBlockingLogic()); + final AutomaticBlockingState state = Get.find().state; @override Widget build(BuildContext context) { @@ -33,85 +35,90 @@ class _AutomaticBlockingPageState extends State with Rout appBar: TitleAppBar( barTitle: TranslationLoader.lanKeys!.automaticBlocking!.tr, haveBack: true, - actionsList: [ + actionsList: [ Obx(() => TextButton( - onPressed: state.canNext.value == false ? null :() { - // if(state.isJustForShow.value == true){ - // return; - // } - // if(state.isCustomLockTime.value == true && state.timeController.text.isEmpty){ - // logic.showToast("请输入自定义时间"); - // return; - // } - - if(state.isOpen.value == false){ - ShowTipView().showIosTipWithContentDialog('关闭后,智能锁将设置为全天常开模式,直到手动关闭'.tr, (){ - logic.sendAutoLock(); - }); - }else{ - logic.sendAutoLock(); - } - }, - child: Text( - state.canNext.value == false ? "" : TranslationLoader.lanKeys!.save!.tr, - style: TextStyle(color: Colors.white, fontSize: 24.sp), - ), - )), + onPressed: state.canNext.value == false + ? null + : () { + if (state.isOpen.value == false) { + ShowTipView().showIosTipWithContentDialog( + '关闭后,智能锁将设置为全天常开模式,直到手动关闭'.tr, + logic.sendAutoLock); + } else { + logic.sendAutoLock(); + } + }, + child: Text( + state.canNext.value == false + ? '' + : TranslationLoader.lanKeys!.save!.tr, + style: TextStyle(color: Colors.white, fontSize: 24.sp), + ), + )), ], backgroundColor: AppColors.mainColor), body: ListView( - children: [ - Obx(() => CommonItem( - leftTitel: TranslationLoader.lanKeys!.automaticBlocking!.tr, - isHaveLine: false, - isHaveRightWidget: true, - rightWidget: - SizedBox(width: 60.w, height: 50.h, child: _switch())),), + children: [ + Obx( + () => CommonItem( + leftTitel: TranslationLoader.lanKeys!.automaticBlocking!.tr, + isHaveLine: false, + isHaveRightWidget: true, + rightWidget: + SizedBox(width: 60.w, height: 50.h, child: _switch())), + ), Visibility( - visible: state.isOpen.value == true ? true : false, + visible: state.isOpen.value == true, child: Column( - children: [ - Container(height: 10.h,), - Builder(builder: (context) { + children: [ + Container( + height: 10.h, + ), + Builder(builder: (BuildContext context) { return Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.delayTime!.tr, - rightTitle: state.isCustomLockTime.value == true ? "自定义".tr : (state.autoLockTime.value.isNotEmpty && state.autoLockTime.value != "0") ? "${state.autoLockTime}s" : "", + rightTitle: state.isCustomLockTime.value == true + ? '自定义'.tr + : (state.autoLockTime.value.isNotEmpty && + state.autoLockTime.value != '0') + ? '${state.autoLockTime}s' + : '', isHaveLine: false, isHaveDirection: true, action: () { - if(state.isJustForShow.value == true){ + if (state.isJustForShow.value == true) { return; } - var list = [ - "5", - "10", - "15", - "30", - "60", + final List list = [ + '5', + '10', + '15', + '30', + '60', TranslationLoader.lanKeys!.custom!.tr ]; ShowBottomSheetTool().showSingleRowPicker( - //上下文 + //上下文 context, //默认的索引 normalIndex: 0, title: TranslationLoader.lanKeys!.time!.tr, - cancelTitle: TranslationLoader.lanKeys!.cancel!.tr, + cancelTitle: + TranslationLoader.lanKeys!.cancel!.tr, sureTitle: TranslationLoader.lanKeys!.sure!.tr, //要显示的列表 - //可自定义数据适配器 - //adapter: PickerAdapter(), data: list, //选择事件的回调 - clickCallBack: (int index, var str) { - if(index != 5){ - state.isCustomLockTime.value = false; - state.autoLockTime.value = str.toString(); - }else{ - state.isCustomLockTime.value = true; - } - logic.ifCanNext(); - }); + clickCallBack: (int index, Object str) { + if (index != 5) { + state.isCustomLockTime.value = false; + state.autoLockTime.value = str.toString(); + Storage.saveAutomaticLockOffTime(str.toString()); + } else { + state.isCustomLockTime.value = true; + } + logic.ifCanNext(); + }); })); }), Container(height: 10.h), @@ -122,37 +129,37 @@ class _AutomaticBlockingPageState extends State with Rout padding: EdgeInsets.only( left: 30.w, top: 10.w, right: 30.w, bottom: 10.w), child: Column( - children: [ + children: [ Row( - children: [ + children: [ Text( - "${TranslationLoader.lanKeys!.pleaseEnter!.tr}${TranslationLoader.lanKeys!.time!.tr}(S)", + '${TranslationLoader.lanKeys!.pleaseEnter!.tr}${TranslationLoader.lanKeys!.time!.tr}(S)', style: TextStyle(fontSize: 24.sp), ), ], ), Obx(() => TextField( - //输入框一行 - maxLines: 1, - controller: state.timeController, - keyboardType: TextInputType.number, - autofocus: false, - readOnly: state.isJustForShow.value == true ? true : false, - onChanged: (value) { - state.autoLockTime.value = value; - logic.ifCanNext(); - }, - decoration: InputDecoration( - //输入里面输入文字内边距设置 - contentPadding: - const EdgeInsets.only(top: 12.0, bottom: 8.0), - hintText: - "${TranslationLoader.lanKeys!.pleaseEnter!.tr}${TranslationLoader.lanKeys!.time!.tr}(S)", - hintStyle: TextStyle(fontSize: 24.sp), - //不需要输入框下划线 - border: InputBorder.none, - ), - )), + //输入框一行 + maxLines: 1, + controller: state.timeController, + keyboardType: TextInputType.number, + autofocus: false, + readOnly: state.isJustForShow.value == true, + onChanged: (String value) { + state.autoLockTime.value = value; + logic.ifCanNext(); + }, + decoration: InputDecoration( + //输入里面输入文字内边距设置 + contentPadding: const EdgeInsets.only( + top: 12.0, bottom: 8.0), + hintText: + '${TranslationLoader.lanKeys!.pleaseEnter!.tr}${TranslationLoader.lanKeys!.time!.tr}(S)', + hintStyle: TextStyle(fontSize: 24.sp), + //不需要输入框下划线 + border: InputBorder.none, + ), + )), Container( height: 0.5.h, color: Colors.grey, @@ -167,7 +174,7 @@ class _AutomaticBlockingPageState extends State with Rout padding: EdgeInsets.all(30.w), child: Row( mainAxisAlignment: MainAxisAlignment.start, - children: [ + children: [ Expanded( child: Text( TranslationLoader.lanKeys!.automaticBlockingTip!.tr, @@ -186,21 +193,19 @@ class _AutomaticBlockingPageState extends State with Rout trackColor: CupertinoColors.systemGrey5, thumbColor: CupertinoColors.white, value: state.isOpen.value, - onChanged: state.isJustForShow.value == true ? null : (value){ - setState(() { - state.isOpen.value = value; - if(state.isOpen.value == false){ - state.autoLockTime.value = ""; - } - logic.ifCanNext(); - }); - }, + onChanged: state.isJustForShow.value == true + ? null + : (bool value) { + setState(() { + state.isOpen.value = value; + logic.ifCanNext(); + }); + }, ); } @override void didChangeDependencies() { - // TODO: implement didChangeDependencies super.didChangeDependencies(); /// 路由订阅 @@ -209,7 +214,6 @@ class _AutomaticBlockingPageState extends State with Rout @override void dispose() { - // TODO: implement dispose /// 取消路由订阅 AppRouteObserver().routeObserver.unsubscribe(this); super.dispose(); @@ -227,7 +231,9 @@ class _AutomaticBlockingPageState extends State with Rout void didPop() { super.didPop(); logic.cancelBlueConnetctToastTimer(); - if (EasyLoading.isShow) EasyLoading.dismiss(animation: true); + if (EasyLoading.isShow) { + EasyLoading.dismiss(animation: true); + } state.ifCurrentScreen.value = false; state.sureBtnState.value = 0; } @@ -244,9 +250,10 @@ class _AutomaticBlockingPageState extends State with Rout void didPushNext() { super.didPushNext(); logic.cancelBlueConnetctToastTimer(); - if (EasyLoading.isShow) EasyLoading.dismiss(animation: true); + if (EasyLoading.isShow) { + EasyLoading.dismiss(animation: true); + } state.ifCurrentScreen.value = false; state.sureBtnState.value = 0; } - } diff --git a/lib/tools/baseGetXController.dart b/lib/tools/baseGetXController.dart index 4c04428c..b20208b3 100755 --- a/lib/tools/baseGetXController.dart +++ b/lib/tools/baseGetXController.dart @@ -98,8 +98,11 @@ class BaseGetXController extends GetxController { "${'操作失败,请确认锁是否在附近,或重启手机蓝牙后再试。'.tr}${isContains == true ? "如果是全自动锁,请使屏幕变亮" : ""}"); } - void showToast(String status, {Function? something}) { - EasyLoading.showToast(status, duration: 2000.milliseconds); + void showToast(String status, + {Function? something, + EasyLoadingMaskType maskType = EasyLoadingMaskType.none}) { + EasyLoading.showToast(status, + duration: 2000.milliseconds, maskType: maskType); if (something != null) { delay(duration: 2100.milliseconds, something: something); } diff --git a/lib/tools/storage.dart b/lib/tools/storage.dart index fdfb542d..09cefe43 100755 --- a/lib/tools/storage.dart +++ b/lib/tools/storage.dart @@ -8,37 +8,35 @@ import 'package:shared_preferences/shared_preferences.dart'; import '../login/login/entity/LoginData.dart'; import '../main/lockMian/entity/lockListInfo_entity.dart'; -const saveBluePublicKey = "BluePublicKey"; -const saveBluePrivateKey = "BluePrivateKey"; -const saveBlueSignKey = "BlueSignKey"; -const saveBlueToken = "BlueGetToken"; -const currentConnectionLockId = "CurrentConnectionLockId"; -const currentConnectionMacAddress = "CurrentConnectionMacAddress"; -const ifIsDemoModeOrNot = "IfIsDemoModeOrNot"; -const isAgreePrivacy = "isAgreePrivacy"; //是否同意隐私协议弹窗 -const isAgreePosition = "isAgreePosition"; //是否同意获取位置弹窗 -const isAgreeCamera = "isAgreeCamera"; //是否同意获取相机/相册弹窗 +const String saveBluePublicKey = 'BluePublicKey'; +const String saveBluePrivateKey = 'BluePrivateKey'; +const String saveBlueSignKey = 'BlueSignKey'; +const String saveBlueToken = 'BlueGetToken'; +const String currentConnectionLockId = 'CurrentConnectionLockId'; +const String currentConnectionMacAddress = 'CurrentConnectionMacAddress'; +const String ifIsDemoModeOrNot = 'IfIsDemoModeOrNot'; +const String isAgreePrivacy = 'isAgreePrivacy'; //是否同意隐私协议弹窗 +const String isAgreePosition = 'isAgreePosition'; //是否同意获取位置弹窗 +const String isAgreeCamera = 'isAgreeCamera'; //是否同意获取相机/相册弹窗 -const isShowUpdateVersion = "isShowUpdateVersion"; //是否更新弹窗 -const saveLockAlias = "saveLockAlias"; //锁别名 -const pushDeviceID = 'pushDeviceID'; //推送设备ID -const saveIsVip = "saveIsVip"; //是否是VIP +const String isShowUpdateVersion = 'isShowUpdateVersion'; //是否更新弹窗 +const String saveLockAlias = 'saveLockAlias'; //锁别名 +const String pushDeviceID = 'pushDeviceID'; //推送设备ID +const String saveIsVip = 'saveIsVip'; //是否是VIP -const saveUserLoginData = "userLoginData"; -const saveLockMainListData = "lockMainListData"; -const isOpenDeBug = "isOpenDeBug"; //是否打开 debug +const String saveUserLoginData = 'userLoginData'; +const String saveLockMainListData = 'lockMainListData'; +const String isOpenDeBug = 'isOpenDeBug'; //是否打开 debug +const String automaticLockOffTime = 'automaticLockOffTime'; //自动关锁时间 class Storage { - Storage._internal(); - factory Storage() => _instance; + Storage._internal(); + static late final Storage _instance = Storage._internal(); - static late SharedPreferences _preferences; - static Future getInstance() async { - _preferences = await SharedPreferences.getInstance(); return _instance; } @@ -73,127 +71,124 @@ class Storage { // } // int - static Future setInt(key, value) async { - SharedPreferences sp = await SharedPreferences.getInstance(); + static Future setInt(String key, dynamic value) async { + final SharedPreferences sp = await SharedPreferences.getInstance(); sp.setInt(key, value); } - static Future getInt(key) async { - SharedPreferences sp = await SharedPreferences.getInstance(); + static Future getInt(String key) async { + final SharedPreferences sp = await SharedPreferences.getInstance(); return sp.getInt(key); } // bool - static Future setBool(key, value) async { - SharedPreferences sp = await SharedPreferences.getInstance(); + static Future setBool(String key, dynamic value) async { + final SharedPreferences sp = await SharedPreferences.getInstance(); sp.setBool(key, value); } - static Future getBool(key) async { - SharedPreferences sp = await SharedPreferences.getInstance(); + static Future getBool(String key) async { + final SharedPreferences sp = await SharedPreferences.getInstance(); return sp.getBool(key); } // double - static Future setDouble(key, value) async { - SharedPreferences sp = await SharedPreferences.getInstance(); + static Future setDouble(String key, dynamic value) async { + final SharedPreferences sp = await SharedPreferences.getInstance(); sp.setDouble(key, value); } - static Future getDouble(key) async { - SharedPreferences sp = await SharedPreferences.getInstance(); + static Future getDouble(String key) async { + final SharedPreferences sp = await SharedPreferences.getInstance(); return sp.getDouble(key); } // string - static Future setString(key, value) async { - SharedPreferences sp = await SharedPreferences.getInstance(); + static Future setString(String key, dynamic value) async { + final SharedPreferences sp = await SharedPreferences.getInstance(); sp.setString(key, value); } - static Future getString(key) async { - SharedPreferences sp = await SharedPreferences.getInstance(); + static Future getString(String key) async { + final SharedPreferences sp = await SharedPreferences.getInstance(); return sp.getString(key); } // 字符串数组 - static Future setStringList(key, value) async { - SharedPreferences sp = await SharedPreferences.getInstance(); + static Future setStringList(String key, dynamic value) async { + final SharedPreferences sp = await SharedPreferences.getInstance(); sp.setStringList(key, value); } - static Future?> getStringList(key) async { - SharedPreferences sp = await SharedPreferences.getInstance(); + static Future?> getStringList(String key) async { + final SharedPreferences sp = await SharedPreferences.getInstance(); return sp.getStringList(key); } // 判断本地是否包含某个key - static Future ifHaveKey(key) async { - SharedPreferences sp = await SharedPreferences.getInstance(); - bool isContainKey = sp.containsKey(key) ?? false; + static Future ifHaveKey(String key) async { + final SharedPreferences sp = await SharedPreferences.getInstance(); + final bool isContainKey = sp.containsKey(key); // AppLog.log(isContainKey); return isContainKey; } // 移除数据 - static Future removeData(key) async { - SharedPreferences sp = await SharedPreferences.getInstance(); + static Future removeData(String key) async { + final SharedPreferences sp = await SharedPreferences.getInstance(); sp.remove(key); } // 移除所有的键值对 static Future clearAll() async { - SharedPreferences sp = await SharedPreferences.getInstance(); + final SharedPreferences sp = await SharedPreferences.getInstance(); sp.clear(); - // 重新设置需要保留的数据 - if (isAgreePrivacy != null) { - //退出登录不清除隐私协议同意状态 - await setString(isAgreePrivacy, isAgreePrivacy); - } + //退出登录不清除隐私协议同意状态 + await setString(isAgreePrivacy, isAgreePrivacy); } static Future getUid() async { - LoginData? loginData = await getLoginData(); - String? uid = loginData!.uid.toString(); + final LoginData? loginData = await getLoginData(); + final String uid = loginData!.uid.toString(); // AppLog.log("pubUid:$uid"); return uid; } static Future getUserid() async { - LoginData? loginData = await getLoginData(); - String? userid = loginData!.userid.toString(); + final LoginData? loginData = await getLoginData(); + final String userid = loginData!.userid.toString(); // AppLog.log("pubUid:$uid"); return userid; } static Future getMobile() async { - LoginData? loginData = await getLoginData(); - String? mobile = loginData!.mobile; + final LoginData? loginData = await getLoginData(); + final String? mobile = loginData!.mobile; return mobile ?? ''; } static Future getEmail() async { - LoginData? loginData = await getLoginData(); - String? email = loginData!.email; + final LoginData? loginData = await getLoginData(); + final String? email = loginData!.email; return email; } static Future getNickname() async { - LoginData? loginData = await getLoginData(); - String? nickname = loginData!.nickname; + final LoginData? loginData = await getLoginData(); + final String? nickname = loginData!.nickname; return nickname; } static Future getHeadUrl() async { - LoginData? loginData = await getLoginData(); - String? headUrl = loginData!.headUrl; + final LoginData? loginData = await getLoginData(); + final String? headUrl = loginData!.headUrl; return headUrl; } static Future getLoginData() async { LoginData? loginData; - final data = await Storage.getString(saveUserLoginData); + final String? data = await Storage.getString(saveUserLoginData); if (data != null && data.isNotEmpty) { loginData = LoginData.fromJson(jsonDecode(data)); } @@ -211,11 +206,21 @@ class Storage { static Future getLockMainListData() async { LockListInfoGroupEntity? lockListInfoGroupEntity; - final data = await Storage.getString(saveLockMainListData); + final String? data = await Storage.getString(saveLockMainListData); if (data != null && data.isNotEmpty) { lockListInfoGroupEntity = LockListInfoGroupEntity.fromJson(jsonDecode(data)); } return lockListInfoGroupEntity; } + + //设置自动关锁时间 + static Future saveAutomaticLockOffTime(String data) async { + await Storage.setString(automaticLockOffTime, data); + } + + static Future getAutomaticLockOffTime() async { + final String data = await Storage.getString(automaticLockOffTime) ?? '0'; + return data; + } } diff --git a/lib/widget/permission/permission_dialog.dart b/lib/widget/permission/permission_dialog.dart index b2f413c0..50d7fab2 100755 --- a/lib/widget/permission/permission_dialog.dart +++ b/lib/widget/permission/permission_dialog.dart @@ -1,5 +1,4 @@ import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:permission_handler/permission_handler.dart'; import 'package:star_lock/app_settings/app_settings.dart'; @@ -7,7 +6,7 @@ import 'package:star_lock/tools/storage.dart'; import 'package:star_lock/translations/trans_lib.dart'; class PermissionDialog { - static Map titles = { + static Map titles = { Permission.camera: '相机'.tr, Permission.photos: '相册'.tr, Permission.storage: '读写'.tr, @@ -17,7 +16,7 @@ class PermissionDialog { Permission.bluetoothConnect: '蓝牙'.tr, }; - static Map contents = { + static Map contents = { Permission.camera: '需要访问相机权限才能拍照上传文件例如头像上传'.tr, Permission.photos: '需要访问相机权限才能使用相册图片上传文件上传头像'.tr, Permission.storage: '需要访问读写权限才能使用本地图片上传头像'.tr, @@ -32,18 +31,18 @@ class PermissionDialog { return false; } bool application = true; - List permissions = [ + final List permissions = [ Permission.bluetooth, Permission.bluetoothScan, Permission.bluetoothConnect, ]; Future getPermissionStatus(List permissions) async { bool isGranted = true; - List permissionStatus = []; - for (Permission per in permissions) { + final List permissionStatus = []; + for (final Permission per in permissions) { permissionStatus.add(await per.status); } - for (PermissionStatus per in permissionStatus) { + for (final PermissionStatus per in permissionStatus) { isGranted = isGranted && per.isGranted; } if (GetPlatform.isIOS) { @@ -52,19 +51,19 @@ class PermissionDialog { return isGranted; } - Permission permission = Permission.bluetoothScan; - dynamic cache = await Storage.getString(titles[permission]); - bool isGranted = await getPermissionStatus(permissions); + const Permission permission = Permission.bluetoothScan; + final dynamic cache = await Storage.getString(titles[permission]!); + final bool isGranted = await getPermissionStatus(permissions); if (GetPlatform.isAndroid && !isGranted && cache is! String) { application = await showCupertinoDialog( context: Get.context!, - builder: (context) { + builder: (BuildContext context) { return PopScope( canPop: false, child: CupertinoAlertDialog( title: Text('${'申请'.tr}${titles[permission] ?? ''}${'权限'.tr}'), content: Text(contents[permission] ?? ''), - actions: [ + actions: [ CupertinoDialogAction( child: Text('不允许'.tr), onPressed: () { @@ -83,12 +82,12 @@ class PermissionDialog { ); if (application) { - await Storage.setString(titles[permission], titles[permission]); + await Storage.setString(titles[permission]!, titles[permission]); } } else if (cache is! String) { - await Storage.setString(titles[permission], titles[permission]); + await Storage.setString(titles[permission]!, titles[permission]); } else { - bool isGranted = await getPermissionStatus(permissions); + final bool isGranted = await getPermissionStatus(permissions); if (!isGranted) { showSet(permission); return false; @@ -96,7 +95,7 @@ class PermissionDialog { } if (application) { await permissions.request(); - bool isGranted = await getPermissionStatus(permissions); + final bool isGranted = await getPermissionStatus(permissions); return isGranted; } return false; @@ -107,20 +106,20 @@ class PermissionDialog { if (Get.context == null) { return false; } - bool isAndroid33 = + final bool isAndroid33 = AppPlatform.isAndroid && AppPlatform.getSdkIntValue() >= 33; //通用的局部函数 List requestPermission() { List permissions; if (isAndroid33) { - permissions = [ + permissions = [ Permission.mediaLibrary, Permission.photos, Permission.videos, ]; } else { - permissions = [ + permissions = [ Permission.storage, ]; } @@ -129,7 +128,7 @@ class PermissionDialog { Future permissionStatus(List permissions) async { bool isGranted = true; - for (Permission permission in permissions) { + for (final Permission permission in permissions) { isGranted = isGranted && (await permission.status) == PermissionStatus.granted; } @@ -142,20 +141,20 @@ class PermissionDialog { } bool application = true; - Permission permission = Permission.photos; - List permissions = requestPermission(); - dynamic cache = await Storage.getString(titles[permission]); - bool isGranted = await permissionStatus(permissions); + const Permission permission = Permission.photos; + final List permissions = requestPermission(); + final dynamic cache = await Storage.getString(titles[permission]??''); + final bool isGranted = await permissionStatus(permissions); if (AppPlatform.isAndroid && !isGranted && cache is! String) { application = await showCupertinoDialog( context: Get.context!, - builder: (context) { + builder: (BuildContext context) { return PopScope( canPop: false, child: CupertinoAlertDialog( title: Text('${'申请'.tr}${titles[permission] ?? ''}${'权限'.tr}'), content: Text(contents[permission] ?? ''), - actions: [ + actions: [ CupertinoDialogAction( child: Text('不允许'.tr), onPressed: () { @@ -173,18 +172,18 @@ class PermissionDialog { }, ); if (application) { - await Storage.setString(titles[permission], titles[permission]); + await Storage.setString(titles[permission]!, titles[permission]); } } else if (cache is String) { - bool isDenied = !(await permissionStatus(permissions)); + final bool isDenied = !(await permissionStatus(permissions)); if (isDenied) { showSet(permission); return false; } } if (application) { - Map statuses = await permissions.request(); - bool isGranted = await permissionStatus(statuses.keys.toList()); + final Map statuses = await permissions.request(); + final bool isGranted = await permissionStatus(statuses.keys.toList()); return isGranted; } return false; @@ -195,14 +194,14 @@ class PermissionDialog { if (Get.context == null) { return false; } - bool isAndroid33 = + final bool isAndroid33 = AppPlatform.isAndroid && AppPlatform.getSdkIntValue() >= 33; //通用的局部函数 List requestPermission() { List permissions; if (isAndroid33) { - permissions = [ + permissions = [ Permission.mediaLibrary, Permission.photos, // Permission.audio, @@ -210,7 +209,7 @@ class PermissionDialog { Permission.manageExternalStorage, ]; } else { - permissions = [ + permissions = [ Permission.storage, ]; } @@ -219,7 +218,7 @@ class PermissionDialog { Future permissionStatus(List permissions) async { bool isGranted = true; - for (Permission permission in permissions) { + for (final Permission permission in permissions) { isGranted = isGranted && (await permission.status) == PermissionStatus.granted; } @@ -234,20 +233,20 @@ class PermissionDialog { } bool application = true; - Permission permission = Permission.photos; - List permissions = requestPermission(); - dynamic cache = await Storage.getString(titles[permission]); - bool isGranted = await permissionStatus(permissions); + const Permission permission = Permission.photos; + final List permissions = requestPermission(); + final dynamic cache = await Storage.getString(titles[permission]??''); + final bool isGranted = await permissionStatus(permissions); if (AppPlatform.isAndroid && !isGranted && cache is! String) { application = await showCupertinoDialog( context: Get.context!, - builder: (context) { + builder: (BuildContext context) { return PopScope( canPop: false, child: CupertinoAlertDialog( title: Text('${'申请'.tr}${titles[permission] ?? ''}${'权限'.tr}'), content: Text('需要访问读写权限才能使用手动升级固件'.tr), - actions: [ + actions: [ CupertinoDialogAction( child: Text('不允许'.tr), onPressed: () { @@ -265,18 +264,18 @@ class PermissionDialog { }, ); if (application) { - await Storage.setString(titles[permission], titles[permission]); + await Storage.setString(titles[permission]??'', titles[permission]); } } else if (cache is String) { - bool isDenied = !(await permissionStatus(permissions)); + final bool isDenied = !(await permissionStatus(permissions)); if (isDenied) { showSet(permission); return false; } } if (application) { - Map statuses = await permissions.request(); - bool isGranted = await permissionStatus(statuses.keys.toList()); + final Map statuses = await permissions.request(); + final bool isGranted = await permissionStatus(statuses.keys.toList()); return isGranted; } return false; @@ -288,18 +287,18 @@ class PermissionDialog { return false; } bool application = true; - PermissionStatus status = await permission.status; - dynamic cache = await Storage.getString(titles[permission]); + final PermissionStatus status = await permission.status; + final dynamic cache = await Storage.getString(titles[permission]??''); if (AppPlatform.isAndroid && !status.isGranted && cache is! String) { application = await showCupertinoDialog( context: Get.context!, - builder: (context) { + builder: (BuildContext context) { return PopScope( canPop: false, child: CupertinoAlertDialog( title: Text('${'申请'.tr}${titles[permission] ?? ''}${'权限'.tr}'), content: Text(content ?? contents[permission] ?? ''), - actions: [ + actions: [ CupertinoDialogAction( child: Text('不允许'.tr), onPressed: () { @@ -317,7 +316,7 @@ class PermissionDialog { }, ); if (application) { - await Storage.setString(titles[permission], titles[permission]); + await Storage.setString(titles[permission]??'', titles[permission]); } } else if (cache is String) { if (status.isDenied) { @@ -326,7 +325,7 @@ class PermissionDialog { } } if (application) { - PermissionStatus status = await permission.request(); + final PermissionStatus status = await permission.request(); return status.isGranted; } return false; @@ -339,14 +338,14 @@ class PermissionDialog { } showCupertinoDialog( context: Get.context!, - builder: (context) { + builder: (BuildContext context) { return PopScope( canPop: false, child: CupertinoAlertDialog( title: Text('${titles[permission] ?? ''}${'权限被拒绝'.tr}'), content: Text( '${contents[permission] ?? ''},${'请手动在系统设置中开启'.tr}${titles[permission]}${'权限以继续使用应用'.tr}'), - actions: [ + actions: [ CupertinoDialogAction( child: Text('去设置'.tr), onPressed: () { From 3deceacdf89b0b243da735ca65fab1cdaf50c8ae Mon Sep 17 00:00:00 2001 From: Daisy <> Date: Wed, 22 May 2024 10:41:44 +0800 Subject: [PATCH 36/44] =?UTF-8?q?=E5=AE=9E=E5=90=8D=E8=AE=A4=E8=AF=81?= =?UTF-8?q?=E9=83=A8=E5=88=86=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../aliyunRealNameAuthHandle.dart | 103 ++++++++++-------- .../realNameVertify_entity.dart | 12 +- .../serviceAuthResult_entity.dart | 16 ++- 3 files changed, 67 insertions(+), 64 deletions(-) diff --git a/lib/tools/aliyunRealNameAuth/aliyunRealNameAuthHandle.dart b/lib/tools/aliyunRealNameAuth/aliyunRealNameAuthHandle.dart index 95a210e4..68de9a93 100755 --- a/lib/tools/aliyunRealNameAuth/aliyunRealNameAuthHandle.dart +++ b/lib/tools/aliyunRealNameAuth/aliyunRealNameAuthHandle.dart @@ -1,5 +1,4 @@ import 'dart:convert'; - import 'package:aliyun_face_plugin/aliyun_face_plugin.dart'; import 'package:flutter/services.dart'; import 'package:star_lock/app_settings/app_settings.dart'; @@ -10,79 +9,87 @@ import 'package:star_lock/tools/aliyunRealNameAuth/serviceAuthResult_entity.dart import 'package:star_lock/tools/baseGetXController.dart'; class AliyunRealNameAuthProvider { - final aliyunFacePlugin = AliyunFacePlugin(); //实名认证初始化 - var infos = ''; //打印信息 - var metainfosMap = {}; //认证信息 - var certifyId = ''; //认证ID - var getLockInfo = LockListInfoItemEntity(); //锁信息 - final Function(bool, int) onCertifyResultWithTime; //认证结果及下次认证时间 + AliyunRealNameAuthProvider({ + required this.getLockInfo, + required this.onCertifyResultWithTime, + }); + final AliyunFacePlugin aliyunFacePlugin = AliyunFacePlugin(); + final Function(bool, int) onCertifyResultWithTime; //认证结果及下次认证时间回调 + final LockListInfoItemEntity getLockInfo; //锁信息 - AliyunRealNameAuthProvider( - {required this.getLockInfo, required this.onCertifyResultWithTime}); + String infos = ''; //打印信息 + Map metainfosMap = {}; //认证信息 + String certifyId = ''; //认证ID - //初始化 - initAliyunRealNameAuth() { + void initAliyunRealNameAuth() { aliyunFacePlugin.init(); getMetaInfos(); } - // 获取客户端metainfos,将信息发送到服务器端,调用服务器端相关接口获取认证ID,即CertifyId。 + // 获取客户端metainfos,将信息发送到服务器端, Future getMetaInfos() async { - String metainfos; - try { - metainfos = await aliyunFacePlugin.getMetaInfos() ?? 'Unknown metainfos'; + final String metainfos = + await aliyunFacePlugin.getMetaInfos() ?? 'Unknown metainfos'; metainfosMap = jsonDecode(metainfos); + infos = 'metainfos: $metainfos'; + AppLog.log(infos); + await getFaceCertifyId(); } on PlatformException { - metainfos = 'Failed to get metainfos.'; + infos = '获取metainfos失败。'; + AppLog.log(infos); } - - infos = "metainfos: $metainfos"; - AppLog.log(infos); - getFaceCertifyId(); } - // 获取人脸认证certifyId - void getFaceCertifyId() async { - LockCertifyEntity entity = await ApiRepository.to.getFaceCertifyId( +//调用服务器端相关接口获取认证ID,即CertifyId + Future getFaceCertifyId() async { + try { + final LockCertifyEntity entity = await ApiRepository.to.getFaceCertifyId( lockId: getLockInfo.lockId ?? 0, keyId: getLockInfo.keyId ?? 0, - metaInfo: metainfosMap); - if (entity.errorCode!.codeIsSuccessful) { - certifyId = entity.data!.certifyId!; - startVerify(); + metaInfo: metainfosMap, + ); + if (entity.errorCode!.codeIsSuccessful) { + certifyId = entity.data!.certifyId!; + await startVerify(); + } else { + AppLog.log('获取certifyId失败: ${entity.errorCode}'); + } + } catch (e) { + AppLog.log('getFaceCertifyId中出现异常: $e'); } } // 调用认证接口,CertifyId需要调用服务器端接口获取。 Future startVerify() async { - String verifyResult; try { - // 每个CertifyId只能使用一次,否则会返回code: "2002(iOS), 1001(Android)"。 - verifyResult = - await aliyunFacePlugin.verify("certifyId", certifyId) ?? '-1,error'; + final String verifyResult = + await aliyunFacePlugin.verify('certifyId', certifyId) ?? '-1,error'; + infos = 'verifyResult: $verifyResult'; + AppLog.log(infos); + await getServiceCheckCertify(); } on PlatformException { - verifyResult = '-2,exception'; + infos = '验证过程中出现异常。'; + AppLog.log(infos); } - - infos = "verifyResult: $verifyResult"; - AppLog.log(infos); - getServiceCheckCertify(); } - // 检测certifyId是否完成认证 +// 检测certifyId是否完成认证 Future getServiceCheckCertify() async { - ServiceAuthResultEntity entity = - await ApiRepository.to.getServiceCheckCertify( - certifyId: certifyId, - keyId: getLockInfo.keyId ?? 0, - ); - if (entity.errorCode!.codeIsSuccessful) { - // 如果认证成功,则调用回调函数,将结果传递给调用处 - onCertifyResultWithTime(true, entity.data!.nextFaceValidateTime!); - } else { - // 如果认证失败 - // await startVerify(); + try { + final ServiceAuthResultEntity entity = + await ApiRepository.to.getServiceCheckCertify( + certifyId: certifyId, + keyId: getLockInfo.keyId ?? 0, + ); + if (entity.errorCode!.codeIsSuccessful) { + onCertifyResultWithTime(true, entity.data!.nextFaceValidateTime!); + } else { + AppLog.log('认证失败: ${entity.errorCode}'); + // 可选:在这里处理重试逻辑 + } + } catch (e) { + AppLog.log('getServiceCheckCertify中出现异常: $e'); } } } diff --git a/lib/tools/aliyunRealNameAuth/realNameVertify_entity.dart b/lib/tools/aliyunRealNameAuth/realNameVertify_entity.dart index 32cfc37f..784a47c6 100755 --- a/lib/tools/aliyunRealNameAuth/realNameVertify_entity.dart +++ b/lib/tools/aliyunRealNameAuth/realNameVertify_entity.dart @@ -1,9 +1,4 @@ class LockCertifyEntity { - int? errorCode; - String? description; - String? errorMsg; - Data? data; - LockCertifyEntity( {this.errorCode, this.description, this.errorMsg, this.data}); @@ -13,6 +8,10 @@ class LockCertifyEntity { errorMsg = json['errorMsg']; data = json['data'] != null ? Data.fromJson(json['data']) : null; } + int? errorCode; + String? description; + String? errorMsg; + Data? data; Map toJson() { final Map data = {}; @@ -27,13 +26,12 @@ class LockCertifyEntity { } class Data { - String? certifyId; - Data({this.certifyId}); Data.fromJson(Map json) { certifyId = json['certifyId']; } + String? certifyId; Map toJson() { final Map data = {}; diff --git a/lib/tools/aliyunRealNameAuth/serviceAuthResult_entity.dart b/lib/tools/aliyunRealNameAuth/serviceAuthResult_entity.dart index 837256ac..f893db51 100755 --- a/lib/tools/aliyunRealNameAuth/serviceAuthResult_entity.dart +++ b/lib/tools/aliyunRealNameAuth/serviceAuthResult_entity.dart @@ -1,9 +1,4 @@ class ServiceAuthResultEntity { - int? errorCode; - String? description; - String? errorMsg; - Data? data; - ServiceAuthResultEntity( {this.errorCode, this.description, this.errorMsg, this.data}); @@ -13,6 +8,10 @@ class ServiceAuthResultEntity { errorMsg = json['errorMsg']; data = json['data'] != null ? Data.fromJson(json['data']) : null; } + int? errorCode; + String? description; + String? errorMsg; + Data? data; Map toJson() { final Map data = {}; @@ -27,14 +26,13 @@ class ServiceAuthResultEntity { } class Data { - int? nextFaceValidateTime; - - Data({this.nextFaceValidateTime}); - Data.fromJson(Map json) { nextFaceValidateTime = json['nextFaceValidateTime']; } + Data({this.nextFaceValidateTime}); + int? nextFaceValidateTime; + Map toJson() { final Map data = {}; data['nextFaceValidateTime'] = nextFaceValidateTime; From 6c7e96d2cbb91ea6261ffce1fbda11d5801c8632 Mon Sep 17 00:00:00 2001 From: anfe <448468458@qq.com> Date: Wed, 22 May 2024 10:44:26 +0800 Subject: [PATCH 37/44] =?UTF-8?q?feat:=E6=B7=BB=E5=8A=A0=E6=89=93=E5=8C=85?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pubspec.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index efb41595..dfc6975b 100755 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -55,8 +55,9 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # 1.0.45+2024052003:打包给公司测试 # 1.0.46+2024052004:打包给公司测试 # 1.0.47+2024052101:打包给欧阳回归测试 +# 1.0.48+2024052201:打包给欧阳回归测试 -version: 1.0.47+2024052101 +version: 1.0.48+2024052201 environment: sdk: '>=2.12.0 <3.0.0' From 624a43fde2ca1a4e3056709e3bb6d1de147c2392 Mon Sep 17 00:00:00 2001 From: anfe <448468458@qq.com> Date: Wed, 22 May 2024 14:07:42 +0800 Subject: [PATCH 38/44] =?UTF-8?q?feat:=E6=81=A2=E5=A4=8D=20http=20?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E6=89=93=E5=8D=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../authorizedAdminList_page.dart | 49 +++++++++--------- .../notice_template_entity.dart | 50 +++++++++++++++++++ .../volumeAuthorizationLock_logic.dart | 20 ++++++-- .../volumeAuthorizationLock_page.dart | 43 +++------------- lib/network/api.dart | 2 + lib/network/api_provider.dart | 26 +++++++--- lib/network/api_repository.dart | 11 ++++ lib/network/response_interceptor_log.dart | 2 +- 8 files changed, 133 insertions(+), 70 deletions(-) create mode 100644 lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/notice_template_entity.dart diff --git a/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_page.dart b/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_page.dart index 752a1115..1fa9edf5 100755 --- a/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_page.dart +++ b/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_page.dart @@ -4,6 +4,7 @@ import 'package:flutter_slidable/flutter_slidable.dart'; import 'package:get/get.dart'; import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart'; import 'package:star_lock/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_logic.dart'; +import 'package:star_lock/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_state.dart'; import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart'; import 'package:star_lock/tools/noData.dart'; import 'package:star_lock/tools/storage.dart'; @@ -25,8 +26,8 @@ class AuthorizedAdminListPage extends StatefulWidget { } class _AuthorizedAdminListPageState extends State { - final logic = Get.put(AuthorizedAdminListLogic()); - final state = Get.find().state; + final AuthorizedAdminListLogic logic = Get.put(AuthorizedAdminListLogic()); + final AuthorizedAdminListState state = Get.find().state; @override void initState() { @@ -37,7 +38,7 @@ class _AuthorizedAdminListPageState extends State { Future mockRequest() async { // 获取是否是演示模式 演示模式不获取接口 - var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); + final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); if (isDemoMode == false) { logic.mockNetworkDataRequest().then((ElectronicKeyListEntity value) { setState(() {}); @@ -63,7 +64,7 @@ class _AuthorizedAdminListPageState extends State { mockRequest(); }, child: Column( - children: [ + children: [ Expanded(child: _buildMainUI()), SizedBox( height: 20.h, @@ -72,7 +73,7 @@ class _AuthorizedAdminListPageState extends State { btnName: TranslationLoader.lanKeys!.addAuthorizedAdmin!.tr, onClick: () { Navigator.pushNamed(context, Routers.authorizedAdminPage) - .then((val) { + .then((Object? val) { if (val != null) { logic.pageNo = 1; mockRequest(); @@ -89,14 +90,14 @@ class _AuthorizedAdminListPageState extends State { } Widget _buildMainUI() { - return Obx(() => state.itemDataList.value.isEmpty + return Obx(() => state.itemDataList.isEmpty ? NoData(noDataHeight: 1.sh - ScreenUtil().statusBarHeight - 90) : SlidableAutoCloseBehavior( child: ListView.separated( - itemCount: state.itemDataList.value.length, - itemBuilder: (c, index) { - ElectronicKeyListItem indexEntity = - state.itemDataList.value[index]; + itemCount: state.itemDataList.length, + itemBuilder: (BuildContext c, int index) { + final ElectronicKeyListItem indexEntity = + state.itemDataList[index]; String useDateStr = ''; //使用期限 String keyStatus = ''; //钥匙状态 @@ -116,16 +117,16 @@ class _AuthorizedAdminListPageState extends State { } return Slidable( - key: ValueKey(indexEntity.keyId), + key: ValueKey(indexEntity.keyId), endActionPane: ActionPane( extentRatio: 0.2, motion: const ScrollMotion(), - children: [ + children: [ SlidableAction( onPressed: (BuildContext context) { ShowTipView() .showDeleteAdministratorIsHaveAllDataDialog( - '同时删除其发送的所有钥匙,钥匙删除后不能恢复', (isAllData) { + '同时删除其发送的所有钥匙,钥匙删除后不能恢复', (bool isAllData) { logic.deleteKeyRequest(indexEntity.keyId.toString(), isAllData ? 1 : 0); }); @@ -145,9 +146,9 @@ class _AuthorizedAdminListPageState extends State { isAdminKey, () { Navigator.pushNamed( context, Routers.electronicKeyDetailPage, - arguments: { - "itemData": indexEntity, - }).then((val) { + arguments: { + 'itemData': indexEntity, + }).then((Object? val) { if (val != null) { logic.mockNetworkDataRequest(); setState(() {}); @@ -172,14 +173,14 @@ class _AuthorizedAdminListPageState extends State { if (indexEntity.keyType == XSConstantMacro.keyTypeTime) { //限期 - DateTime startDateStr = + final DateTime startDateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.startDate!); - DateTime endDateStr = + final DateTime endDateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.endDate!); useDateStr = '${startDateStr.toLocal().toString().substring(0, 16)}-${endDateStr.toLocal().toString().substring(0, 16)}'; } else if (indexEntity.keyType == XSConstantMacro.keyTypeLong) { - useDateStr = "永久"; + useDateStr = '永久'; } return useDateStr; } @@ -192,7 +193,7 @@ class _AuthorizedAdminListPageState extends State { color: Colors.white, height: 100.h, child: Row( - children: [ + children: [ SizedBox(width: 30.w), Image.asset( avatarURL, @@ -203,13 +204,13 @@ class _AuthorizedAdminListPageState extends State { Expanded( child: Column( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ Row( - children: [ + children: [ SizedBox( width: 1.sw - 110.w - 100.w, child: Row( - children: [ + children: [ Flexible( child: Text(receiveUser, maxLines: 1, @@ -231,7 +232,7 @@ class _AuthorizedAdminListPageState extends State { SizedBox(height: 10.h), Row( mainAxisAlignment: MainAxisAlignment.start, - children: [ + children: [ Text( useDate, style: TextStyle( diff --git a/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/notice_template_entity.dart b/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/notice_template_entity.dart new file mode 100644 index 00000000..54905b3e --- /dev/null +++ b/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/notice_template_entity.dart @@ -0,0 +1,50 @@ +class NoticeTemplateEntity { + + int? errorCode; + String? description; + String? errorMsg; + Data? data; + + NoticeTemplateEntity( + {this.errorCode, this.description, this.errorMsg, this.data}); + + NoticeTemplateEntity.fromJson(Map json) { + errorCode = json['errorCode']; + description = json['description']; + errorMsg = json['errorMsg']; + if (json['data'] is Map) { + data = Data.fromJson(json['data']); + } + } + + Map toJson() { + final Map data = {}; + data['errorCode'] = errorCode; + data['description'] = description; + data['errorMsg'] = errorMsg; + data['data'] = this.data; + return data; + } +} + +class Data { + List? userNos = []; + + Data({ + this.userNos, + }); + + Data.fromJson(Map json) { + if (json['userNos'] is List) { + json['userNos'].forEach((element) { + userNos?.add(element); + }); + } + } + + Map toJson() { + final Map data = {}; + data['userNos'] = userNos; + return data; + } +} \ No newline at end of file diff --git a/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_logic.dart b/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_logic.dart index 99472fb2..a6043d15 100755 --- a/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_logic.dart +++ b/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_logic.dart @@ -2,19 +2,21 @@ import 'dart:ffi'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:get/get.dart'; +import 'package:star_lock/main/lockDetail/lockSet/basicInformation/basicInformation/KeyDetailEntity.dart'; import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/tools/baseGetXController.dart'; +import 'package:star_lock/tools/commonDataManage.dart'; import 'volumeAuthorizationLock_state.dart'; class VolumeAuthorizationLockLogic extends BaseGetXController { - final state = VolumeAuthorizationLockState(); + final VolumeAuthorizationLockState state = VolumeAuthorizationLockState(); //发送批量授权管理员 Future addAuthorizedAdminRequest() async { String getFailureDateTime = '0'; String getEffectiveDateTime = '0'; - if (state.selectWidgetType == '1') { + if (state.selectWidgetType.value == '1') { getFailureDateTime = state.failureDateTime.value.millisecondsSinceEpoch.toString(); getEffectiveDateTime = @@ -25,11 +27,11 @@ class VolumeAuthorizationLockLogic extends BaseGetXController { showToast('请选择锁'.tr); return; } - var entity = await ApiRepository.to.addAuthorizedAdmin( + final KeyDetailEntity entity = await ApiRepository.to.addAuthorizedAdmin( createUser: state.isCreateUser.value ? '1' : '0', endDate: getFailureDateTime, isRemoteUnlock: '0', - keyGroupIdList: [], + keyGroupIdList: [], lockIdList: state.lockIdList.value, name: state.keyNameController.text, startDate: getEffectiveDateTime, @@ -49,4 +51,14 @@ class VolumeAuthorizationLockLogic extends BaseGetXController { } } } + + //发送消息 + Future sendMsg({required bool isPhone}) async { + if (isPhone) { + } else {} + var entity = await ApiRepository.to.getNoticeTemplate( + lockId: CommonDataManage().currentKeyInfo.lockId!, + keyId: CommonDataManage().currentKeyInfo.keyId!, + channelType: 1); + } } diff --git a/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_page.dart b/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_page.dart index 2aa60e45..b553ad90 100755 --- a/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_page.dart +++ b/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_page.dart @@ -181,7 +181,7 @@ class _VolumeAuthorizationLockPageState children: [ CommonItem( leftTitel: TranslationLoader.lanKeys!.lock!.tr, - rightTitle: state.lockIdList.value.isEmpty + rightTitle: state.lockIdList.isEmpty ? TranslationLoader.lanKeys!.pleaseSelect!.tr : state.lockIdList.length.toString(), isHaveDirection: true, @@ -190,11 +190,12 @@ class _VolumeAuthorizationLockPageState arguments: {'keyLimits': '1'}) .then((Object? value) { //得到选中的锁ID列表 - if (value != null) { - value as Map; - state.lockIdList.value = value['selectLockIdList']; - - // setState(() {}); + if (value is Map && value['selectLockIdList'] is List) { + state.lockIdList.clear(); + value['selectLockIdList'].forEach((element) { + state.lockIdList.add(element); + }); + setState(() {}); } }); }), @@ -211,13 +212,6 @@ class _VolumeAuthorizationLockPageState width: 60.w, height: 50.h, child: _onlyManageYouCreatesUserSwitch())), - - // CommonItem( - // leftTitel: TranslationLoader.lanKeys!.remoteUnlockingAllowed!.tr, - // rightTitle: '', - // isHaveRightWidget: true, - // rightWidget: SizedBox(width: 60.w, height: 50.h, child: _switch()), - // action: () {}), Container(height: 10.h), ], ); @@ -375,31 +369,10 @@ class _VolumeAuthorizationLockPageState btnName: '微信通知', onClick: () {}, ), - SizedBox( - height: 10.h, - ), - OutLineBtn( - btnName: '标记为已入住', - onClick: () {}, - ), ], ); } - // CupertinoSwitch _switch() { - // return CupertinoSwitch( - // activeColor: CupertinoColors.activeBlue, - // trackColor: CupertinoColors.systemGrey5, - // thumbColor: CupertinoColors.white, - // value: state.isRemoteUnlock.value, - // onChanged: (bool value) { - // setState(() { - // _isRemoteUnlock = !_isRemoteUnlock; - // }); - // }, - // ); - // } - //仅管理自己创建的用户 CupertinoSwitch _onlyManageYouCreatesUserSwitch() { return CupertinoSwitch( @@ -407,7 +380,7 @@ class _VolumeAuthorizationLockPageState trackColor: CupertinoColors.systemGrey5, thumbColor: CupertinoColors.white, value: state.onlyManageYouCreatesUser.value, - onChanged: (value) { + onChanged: (bool value) { setState(() { state.onlyManageYouCreatesUser.value = !state.onlyManageYouCreatesUser.value; diff --git a/lib/network/api.dart b/lib/network/api.dart index 16d06347..845f7107 100755 --- a/lib/network/api.dart +++ b/lib/network/api.dart @@ -235,4 +235,6 @@ abstract class Api { final String getUserNoList = '/key/getUserNoList'; //获取指定锁下所有userNo + final String getNoticeTemplateURL = '/key/getNoticeTemplate'; //获取短信或者邮箱模板 + } diff --git a/lib/network/api_provider.dart b/lib/network/api_provider.dart index c44115cb..d2347c6d 100755 --- a/lib/network/api_provider.dart +++ b/lib/network/api_provider.dart @@ -374,12 +374,15 @@ class ApiProvider extends BaseProvider { })); // 获取锁信息列表 - Future getStarLockListInfo(int pageNo, int pageSize,{bool isUnShowLoading = true}) => post( - getStarLockInfoURL.toUrl, - jsonEncode({ - "pageNo": pageNo, - 'pageSize': pageSize, - }),isUnShowLoading: isUnShowLoading); + Future getStarLockListInfo(int pageNo, int pageSize, + {bool isUnShowLoading = true}) => + post( + getStarLockInfoURL.toUrl, + jsonEncode({ + "pageNo": pageNo, + 'pageSize': pageSize, + }), + isUnShowLoading: isUnShowLoading); // 获取所有锁设置信息 Future getLockSettingInfoData(String lockId) => post( @@ -2078,6 +2081,17 @@ class ApiProvider extends BaseProvider { // 获取指定锁下所有userNo Future getLockUserNoList(int lockId) => post(getUserNoList.toUrl, jsonEncode({'lockId': lockId})); + + // 获取短信或者邮箱模板 + Future> getNoticeTemplate( + int lockId, int keyId, int channelType) => + post( + getNoticeTemplateURL.toUrl, + jsonEncode({ + 'lockId': lockId, + 'keyId': keyId, + 'channelType': channelType, + })); } extension ExtensionString on String { diff --git a/lib/network/api_repository.dart b/lib/network/api_repository.dart index 64818b1f..1a1f2819 100755 --- a/lib/network/api_repository.dart +++ b/lib/network/api_repository.dart @@ -2112,4 +2112,15 @@ class ApiRepository { final res = await apiProvider.getLockUserNoList(lockId); return LockUserNoListEntity.fromJson(res.body); } + + // 检测certifyId是否完成认证 + Future getNoticeTemplate({ + required int lockId, + required int keyId, + required int channelType, + }) async { + final Response res = + await apiProvider.getNoticeTemplate(lockId, keyId, channelType); + return LockUserNoListEntity.fromJson(res.body); + } } diff --git a/lib/network/response_interceptor_log.dart b/lib/network/response_interceptor_log.dart index f24553c4..85890536 100755 --- a/lib/network/response_interceptor_log.dart +++ b/lib/network/response_interceptor_log.dart @@ -5,7 +5,7 @@ import 'package:get/get_connect/http/src/request/request.dart'; import 'package:star_lock/app_settings/app_settings.dart'; FutureOr responseLogInterceptor(Request request, Response response) { - // AppLog.log('HTTP request:${request.url}\n RESPONSE => stataCode:${response.statusCode} ${response.bodyString}'); // \n ${response.headers} + AppLog.log('HTTP request:${request.url}\n RESPONSE => stataCode:${response.statusCode} ${response.bodyString}'); // \n ${response.headers} EasyLoading.dismiss(animation: true); return response; } From 25598cd2704a248a67b79a5edb581fcce342c013 Mon Sep 17 00:00:00 2001 From: anfe <448468458@qq.com> Date: Wed, 22 May 2024 14:40:07 +0800 Subject: [PATCH 39/44] =?UTF-8?q?feat:=E4=BF=AE=E6=94=B9=E6=89=B9=E9=87=8F?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=AE=A1=E7=90=86=E5=91=98=E5=AE=8C=E6=88=90?= =?UTF-8?q?=E6=8C=89=E9=92=AE=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../authorizedAdmin_logic.dart | 2 +- .../authorizedAdmin/authorizedAdmin_page.dart | 170 +++++++++--------- .../notice_template_entity.dart | 55 ++++-- .../volumeAuthorizationLock_logic.dart | 10 +- .../volumeAuthorizationLock_page.dart | 19 +- lib/network/api_repository.dart | 7 +- 6 files changed, 132 insertions(+), 131 deletions(-) diff --git a/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_logic.dart b/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_logic.dart index 434c7e57..3869b32f 100755 --- a/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_logic.dart +++ b/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_logic.dart @@ -10,8 +10,8 @@ import 'package:star_lock/tools/dateTool.dart'; import 'package:star_lock/tools/showCupertinoAlertView.dart'; import '../../../../blue/blue_manage.dart'; -import '../../../../blue/io_reply.dart'; import '../../../../blue/io_protocol/io_transferPermissions.dart'; +import '../../../../blue/io_reply.dart'; import '../../../../blue/io_tool/io_tool.dart'; import '../../../../blue/io_tool/manager_event_bus.dart'; import '../../../../blue/sender_manage.dart'; diff --git a/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_page.dart b/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_page.dart index 8eb565c0..6f3d0d2f 100755 --- a/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_page.dart +++ b/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_page.dart @@ -4,6 +4,7 @@ import 'package:flutter/services.dart'; import 'package:flutter_native_contact_picker/flutter_native_contact_picker.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; +import 'package:star_lock/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_state.dart'; import 'package:star_lock/tools/dateTool.dart'; import 'package:star_lock/tools/pickers/pickers.dart'; @@ -31,8 +32,8 @@ class AuthorizedAdminPage extends StatefulWidget { class _AuthorizedAdminPageState extends State with SingleTickerProviderStateMixin { - final logic = Get.put(AuthorizedAdminLogic()); - final state = Get.find().state; + final AuthorizedAdminLogic logic = Get.put(AuthorizedAdminLogic()); + final AuthorizedAdminState state = Get.find().state; @override void initState() { @@ -60,7 +61,7 @@ class _AuthorizedAdminPageState extends State haveBack: true, backgroundColor: AppColors.mainColor), body: Column( - children: [ + children: [ _tabBar(), _pageWidget(), ], @@ -78,7 +79,7 @@ class _AuthorizedAdminPageState extends State // 限时 return SingleChildScrollView( child: Column( - children: [ + children: [ keyInfoWidget(), keyTimeWidget(), keyOnlyManageWidget(), @@ -92,7 +93,7 @@ class _AuthorizedAdminPageState extends State // 永久 return SingleChildScrollView( child: Column( - children: [ + children: [ keyInfoWidget(), keyOnlyManageWidget(), keyBottomWidget( @@ -107,17 +108,17 @@ class _AuthorizedAdminPageState extends State // 顶部钥匙信息widget Widget keyInfoWidget() { return Column( - children: [ + children: [ CommonItem( leftTitel: TranslationLoader.lanKeys!.receiver!.tr, - rightTitle: "", + rightTitle: '', isHaveLine: true, isHaveRightWidget: true, rightWidget: getTFWidget(true, TranslationLoader.lanKeys!.pleaseEnterNumberOrEmail!.tr, 1)), CommonItem( leftTitel: TranslationLoader.lanKeys!.countryAndRegion!.tr, - rightTitle: "", + rightTitle: '', isHaveLine: true, isHaveRightWidget: true, isHaveDirection: true, @@ -128,7 +129,7 @@ class _AuthorizedAdminPageState extends State TextStyle(fontSize: 22.sp, color: AppColors.darkGrayTextColor), ), action: () async { - var result = await Navigator.pushNamed( + final Object? result = await Navigator.pushNamed( context, Routers.selectCountryRegionPage); if (result != null) { result as Map; @@ -140,7 +141,7 @@ class _AuthorizedAdminPageState extends State ), CommonItem( leftTitel: TranslationLoader.lanKeys!.name!.tr, - rightTitle: "", + rightTitle: '', isHaveRightWidget: true, rightWidget: getTFWidget( false, TranslationLoader.lanKeys!.enterYourName!.tr, 2)), @@ -152,17 +153,18 @@ class _AuthorizedAdminPageState extends State // 生效失效时间 Widget keyTimeWidget() { return Column( - children: [ + children: [ CommonItem( leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr, rightTitle: state.beginDate.value, isHaveLine: true, isHaveDirection: true, action: () { - PDuration selectDate = + final PDuration selectDate = PDuration.parse(DateTime.tryParse(state.beginDate.value)); Pickers.showDatePicker(context, - selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) { + selectDate: selectDate, + mode: DateMode.YMDHM, onConfirm: (PDuration p) { setState(() { state.beginDate.value = DateTool().getYMDHNDateString(p, 1); }); @@ -173,10 +175,11 @@ class _AuthorizedAdminPageState extends State rightTitle: state.endDate.value, isHaveDirection: true, action: () { - PDuration selectDate = + final PDuration selectDate = PDuration.parse(DateTime.tryParse(state.endDate.value)); Pickers.showDatePicker(context, - selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) { + selectDate: selectDate, + mode: DateMode.YMDHM, onConfirm: (PDuration p) { setState(() { state.endDate.value = DateTool().getYMDHNDateString(p, 1); }); @@ -190,14 +193,14 @@ class _AuthorizedAdminPageState extends State // 实名认证 Widget keyOnlyManageWidget() { return Column( - children: [ + children: [ CommonItem( - leftTitel: "仅管理自己创建的用户", - rightTitle: "", + leftTitel: '仅管理自己创建的用户', + rightTitle: '', isHaveRightWidget: true, isTipsImg: true, tipsImgAction: () { - ShowTipView().showSureAlertDialog("授权管理员只能查看和管理自己下发的钥匙、密码等权限"); + ShowTipView().showSureAlertDialog('授权管理员只能查看和管理自己下发的钥匙、密码等权限'); }, rightWidget: SizedBox( width: 60.w, @@ -212,11 +215,11 @@ class _AuthorizedAdminPageState extends State Widget keyBottomWidget(String tipStr) { return Column( - children: [ + children: [ Container( padding: EdgeInsets.all(20.w), child: Row( - children: [ + children: [ Expanded( child: Text( tipStr, @@ -233,26 +236,27 @@ class _AuthorizedAdminPageState extends State SubmitBtn( btnName: TranslationLoader.lanKeys!.send!.tr, onClick: () async { - var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); + final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); if (isDemoMode == false) { //发送钥匙请求 logic.sendElectronicKeyRequest(); } else { - logic.showToast("演示模式"); + logic.showToast('演示模式'); } }), Container( padding: EdgeInsets.only(right: 30.w), child: Row( mainAxisAlignment: MainAxisAlignment.end, - children: [ + children: [ TextButton( onPressed: () async { - var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); + final bool? isDemoMode = + await Storage.getBool(ifIsDemoModeOrNot); if (isDemoMode == false) { Get.toNamed(Routers.volumeAuthorizationLockManagePage); } else { - logic.showToast("演示模式"); + logic.showToast('演示模式'); } }, child: Text( @@ -270,16 +274,15 @@ class _AuthorizedAdminPageState extends State // 实名认证 Widget keyRealNameWidget() { return Column( - children: [ + children: [ Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.realNameAuthentication!.tr, - rightTitle: "", + rightTitle: '', isTipsImg: true, - isHaveLine: - logic.state.isRequireAuth.value == true ? true : false, + isHaveLine: logic.state.isRequireAuth.value == true, tipsImgAction: () { ShowTipView().showSureAlertDialog( - "人脸实名认证指的是用户在使用手机APP开锁时,需要先进行本人人脸验证,验证通过才能开锁。".tr); + '人脸实名认证指的是用户在使用手机APP开锁时,需要先进行本人人脸验证,验证通过才能开锁。'.tr); }, isHaveRightWidget: true, rightWidget: SizedBox( @@ -289,7 +292,7 @@ class _AuthorizedAdminPageState extends State visible: logic.state.isRequireAuth.value, child: CommonItem( leftTitel: '真实姓名'.tr, - rightTitle: "", + rightTitle: '', isHaveRightWidget: true, isHaveLine: true, rightWidget: getTFWidget(false, '请输入真实姓名'.tr, 3)))), @@ -297,7 +300,7 @@ class _AuthorizedAdminPageState extends State visible: logic.state.isRequireAuth.value, child: CommonItem( leftTitel: '身份证号'.tr, - rightTitle: "", + rightTitle: '', isHaveRightWidget: true, rightWidget: getTFWidget(false, '请输入身份证号'.tr, 4)))), ], @@ -307,13 +310,13 @@ class _AuthorizedAdminPageState extends State // 发送电子钥匙成功 Widget sendElectronicKeySucceed() { return Column( - children: [ + children: [ Container( height: 250.h, width: 1.sw, color: Colors.white, child: Column( - children: [ + children: [ SizedBox( height: 30.h, ), @@ -327,9 +330,9 @@ class _AuthorizedAdminPageState extends State ), Row( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ Text( - "发送成功", + '发送成功', style: TextStyle( fontSize: 26.sp, color: Colors.black, @@ -354,9 +357,9 @@ class _AuthorizedAdminPageState extends State ), OutLineBtn( btnName: - state.emailOrPhoneController.text.contains("@") ? '邮件通知' : "短信通知", + state.emailOrPhoneController.text.contains('@') ? '邮件通知' : '短信通知', onClick: () { - if (state.emailOrPhoneController.text.contains("@")) { + if (state.emailOrPhoneController.text.contains('@')) { Get.toNamed(Routers.sendEmailNotificationPage); } else { NativeInteractionTool() @@ -387,7 +390,7 @@ class _AuthorizedAdminPageState extends State height: 65.h, width: 300.w, child: Row( - children: [ + children: [ Expanded( child: TextField( //输入框一行 @@ -425,38 +428,37 @@ class _AuthorizedAdminPageState extends State SizedBox( width: 10.w, ), - isHaveBtn - ? Container( - width: 30.w, - height: 30.w, - decoration: const BoxDecoration( - color: Colors.white, - image: DecorationImage( - image: AssetImage('images/icon_addressBook.png'), - fit: BoxFit.fill), - ), - alignment: Alignment.center, - child: InkWell( - onTap: () async { - Contact? currentContact = - await state.contactPicker.selectContact(); - setState(() { - state.contact = currentContact!; - if (currentContact.phoneNumbers!.isNotEmpty) { - state.emailOrPhoneController.text = currentContact - .phoneNumbers![0] - .replaceAll(RegExp(r"\s+\b|\b\s"), ""); - } - - if (currentContact.fullName!.isNotEmpty) { - state.keyNameController.text = - currentContact.fullName!; - } - }); - }, - ), - ) - : Container() + if (isHaveBtn) + Container( + width: 30.w, + height: 30.w, + decoration: const BoxDecoration( + color: Colors.white, + image: DecorationImage( + image: AssetImage('images/icon_addressBook.png'), + fit: BoxFit.fill), + ), + alignment: Alignment.center, + child: InkWell( + onTap: () async { + final Contact? currentContact = + await state.contactPicker.selectContact(); + setState(() { + state.contact = currentContact!; + if (currentContact.phoneNumbers!.isNotEmpty) { + state.emailOrPhoneController.text = currentContact + .phoneNumbers![0] + .replaceAll(RegExp(r'\s+\b|\b\s'), ''); + } + if (currentContact.fullName!.isNotEmpty) { + state.keyNameController.text = currentContact.fullName!; + } + }); + }, + ), + ) + else + Container() ], ), ); @@ -469,7 +471,7 @@ class _AuthorizedAdminPageState extends State trackColor: CupertinoColors.systemGrey5, thumbColor: CupertinoColors.white, value: state.isAuthentication.value, - onChanged: (value) { + onChanged: (bool value) { setState(() { if (logic.state.isAuthentication.value == false) { logic.keyCheckFace(); @@ -489,7 +491,7 @@ class _AuthorizedAdminPageState extends State trackColor: CupertinoColors.systemGrey5, thumbColor: CupertinoColors.white, value: state.onlyManageYouCreatesUser.value, - onChanged: (value) { + onChanged: (bool value) { setState(() { state.onlyManageYouCreatesUser.value = !state.onlyManageYouCreatesUser.value; @@ -498,7 +500,7 @@ class _AuthorizedAdminPageState extends State ); } - Future _openModalBottomSheet() async { + void _openModalBottomSheet() { showModalBottomSheet( context: context, shape: RoundedRectangleBorder( @@ -506,7 +508,7 @@ class _AuthorizedAdminPageState extends State constraints: BoxConstraints(maxHeight: 270.h), builder: (BuildContext context) { return Column( - children: [ + children: [ SizedBox( width: ScreenUtil().screenWidth, height: 180.h, @@ -537,7 +539,7 @@ class _AuthorizedAdminPageState extends State } List initBottomSheetList() { - List widgetList = []; + final List widgetList = []; widgetList.add(buildCenter3('images/icon_wechat.png', '微信好友', 0)); widgetList.add(buildCenter3('images/icon_message.png', '短信', 1)); @@ -557,7 +559,7 @@ class _AuthorizedAdminPageState extends State EdgeInsets.only(top: 20.w, bottom: 20.w, left: 10.w, right: 10.w), child: Column( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ Image.asset( imageName, width: 50.w, @@ -579,7 +581,7 @@ class _AuthorizedAdminPageState extends State } //\n生效时间:${itemData.startDate}\n类型:永久\n锁名:${itemData.keyboardPwdName} - _jumpSmartDeviceRoute(int itemIndex) { + dynamic _jumpSmartDeviceRoute(int itemIndex) { Get.back(); switch (itemIndex) { case 0: @@ -613,8 +615,8 @@ class _AuthorizedAdminPageState extends State TabBar _tabBar() { return TabBar( controller: state.tabController, - tabs: _itemTabs.map((ItemView item) => _tab(item)).toList(), - onTap: (index) { + tabs: _itemTabs.map(_tab).toList(), + onTap: (int index) { FocusScope.of(context).requestFocus(FocusNode()); }, isScrollable: true, @@ -655,14 +657,14 @@ class _AuthorizedAdminPageState extends State child: TabBarView( controller: state.tabController, children: _itemTabs - .map((ItemView item) => Obx(() => indexChangeWidget())) + .map((ItemView item) => Obx(indexChangeWidget)) .toList()), ); } final List _itemTabs = [ - ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, type: "0"), - ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, type: "1"), + ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, type: '0'), + ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, type: '1'), ]; } diff --git a/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/notice_template_entity.dart b/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/notice_template_entity.dart index 54905b3e..e876778b 100644 --- a/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/notice_template_entity.dart +++ b/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/notice_template_entity.dart @@ -1,10 +1,4 @@ class NoticeTemplateEntity { - - int? errorCode; - String? description; - String? errorMsg; - Data? data; - NoticeTemplateEntity( {this.errorCode, this.description, this.errorMsg, this.data}); @@ -17,6 +11,11 @@ class NoticeTemplateEntity { } } + int? errorCode; + String? description; + String? errorMsg; + Data? data; + Map toJson() { final Map data = {}; data['errorCode'] = errorCode; @@ -28,23 +27,45 @@ class NoticeTemplateEntity { } class Data { - List? userNos = []; - - Data({ - this.userNos, - }); - Data.fromJson(Map json) { - if (json['userNos'] is List) { - json['userNos'].forEach((element) { - userNos?.add(element); + if (json['list'] is List) { + json['list'].forEach((dynamic element) { + list?.add(Item.fromJson(element)); }); } } + List? list = []; + Map toJson() { final Map data = {}; - data['userNos'] = userNos; + data['list'] = list; return data; } -} \ No newline at end of file +} + +class Item { + Item.fromJson(Map json) { + type = json['type']; + name = json['name']; + template = json['template']; + isUse = json['isUse']; + fee = json['fee']; + } + + String? type; + String? name; + String? template; + int? isUse; + int? fee; + + Map toJson() { + final Map data = {}; + data['type'] = type; + data['name'] = name; + data['template'] = template; + data['isUse'] = isUse; + data['fee'] = fee; + return data; + } +} diff --git a/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_logic.dart b/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_logic.dart index a6043d15..d75cd07c 100755 --- a/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_logic.dart +++ b/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_logic.dart @@ -2,6 +2,7 @@ import 'dart:ffi'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:get/get.dart'; +import 'package:star_lock/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/notice_template_entity.dart'; import 'package:star_lock/main/lockDetail/lockSet/basicInformation/basicInformation/KeyDetailEntity.dart'; import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/tools/baseGetXController.dart'; @@ -52,13 +53,4 @@ class VolumeAuthorizationLockLogic extends BaseGetXController { } } - //发送消息 - Future sendMsg({required bool isPhone}) async { - if (isPhone) { - } else {} - var entity = await ApiRepository.to.getNoticeTemplate( - lockId: CommonDataManage().currentKeyInfo.lockId!, - keyId: CommonDataManage().currentKeyInfo.keyId!, - channelType: 1); - } } diff --git a/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_page.dart b/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_page.dart index b553ad90..cf0c27ed 100755 --- a/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_page.dart +++ b/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_page.dart @@ -190,7 +190,8 @@ class _VolumeAuthorizationLockPageState arguments: {'keyLimits': '1'}) .then((Object? value) { //得到选中的锁ID列表 - if (value is Map && value['selectLockIdList'] is List) { + if (value is Map && + value['selectLockIdList'] is List) { state.lockIdList.clear(); value['selectLockIdList'].forEach((element) { state.lockIdList.add(element); @@ -353,22 +354,6 @@ class _VolumeAuthorizationLockPageState state.isSendSuccess.value = false; Navigator.pop(context, true); }), - SizedBox( - height: 10.h, - ), - OutLineBtn( - btnName: '邮件通知', - onClick: () { - Navigator.pushNamed(context, Routers.sendEmailNotificationPage); - }, - ), - SizedBox( - height: 10.h, - ), - OutLineBtn( - btnName: '微信通知', - onClick: () {}, - ), ], ); } diff --git a/lib/network/api_repository.dart b/lib/network/api_repository.dart index 1a1f2819..d102f7be 100755 --- a/lib/network/api_repository.dart +++ b/lib/network/api_repository.dart @@ -1,6 +1,7 @@ import 'package:get/get.dart'; import 'package:star_lock/blue/entity/lock_user_no_list_entity.dart'; import 'package:star_lock/login/selectCountryRegion/common/countryRegionEntity.dart'; +import 'package:star_lock/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/notice_template_entity.dart'; import 'package:star_lock/main/lockDetail/doorLockLog/doorLockLog_entity.dart'; import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart'; import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/lockUserList/lockUserList_entity.dart'; @@ -2113,14 +2114,14 @@ class ApiRepository { return LockUserNoListEntity.fromJson(res.body); } - // 检测certifyId是否完成认证 - Future getNoticeTemplate({ + // 电子钥匙获取短信模板 + Future getNoticeTemplate({ required int lockId, required int keyId, required int channelType, }) async { final Response res = await apiProvider.getNoticeTemplate(lockId, keyId, channelType); - return LockUserNoListEntity.fromJson(res.body); + return NoticeTemplateEntity.fromJson(res.body); } } From b84c448d5efb4b9bc03cae649de03e156af67b5d Mon Sep 17 00:00:00 2001 From: Daisy <> Date: Wed, 22 May 2024 15:17:25 +0800 Subject: [PATCH 40/44] =?UTF-8?q?1=EF=BC=8C=E6=96=B0=E5=A2=9E=E6=88=91?= =?UTF-8?q?=E7=9A=84=E8=AE=BE=E7=BD=AE--=E6=8E=88=E6=9D=83=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=91=98=E5=85=B3=E8=81=94=E9=94=81=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=202=EF=BC=8C=E8=8E=B7=E5=8F=96=E6=8E=88?= =?UTF-8?q?=E6=9D=83=E7=AE=A1=E7=90=86=E5=91=98=E4=B8=8B=E9=94=81=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E6=8E=A5=E5=8F=A3=E5=AF=B9=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/appRouters.dart | 6 ++ .../administratorAssociationLock_logic.dart | 47 ++++++++ .../administratorAssociationLock_page.dart | 102 ++++++++++++++++++ .../administratorAssociationLock_state.dart | 15 +++ .../administratorDetails_page.dart | 9 +- lib/network/api.dart | 3 +- lib/network/api_provider.dart | 19 ++-- lib/network/api_repository.dart | 7 ++ 8 files changed, 197 insertions(+), 11 deletions(-) create mode 100644 lib/mine/mineSet/authorizedAdministrator/administratorAssociationLock/administratorAssociationLock_logic.dart create mode 100644 lib/mine/mineSet/authorizedAdministrator/administratorAssociationLock/administratorAssociationLock_page.dart create mode 100644 lib/mine/mineSet/authorizedAdministrator/administratorAssociationLock/administratorAssociationLock_state.dart diff --git a/lib/appRouters.dart b/lib/appRouters.dart index 20730494..d2d4e3c3 100755 --- a/lib/appRouters.dart +++ b/lib/appRouters.dart @@ -42,6 +42,7 @@ import 'package:star_lock/mine/about/webviewShow_page.dart'; import 'package:star_lock/mine/mine/safeVerify/safeVerify_page.dart'; import 'package:star_lock/mine/minePersonInfo/minePersonInfoEmail/mineBindPhoneOrEmail_page.dart'; import 'package:star_lock/mine/minePersonInfo/minePersonInfoViewSafetyProblem/minePersonInfoViewSafetyProblem_page.dart'; +import 'package:star_lock/mine/mineSet/authorizedAdministrator/administratorAssociationLock/administratorAssociationLock_page.dart'; import 'package:star_lock/mine/mineSet/authorizedAdministrator/administratorChangeDate/adminDetailChangeDate_page.dart'; import 'package:star_lock/mine/mineSet/authorizedAdministrator/administratorDetails/administratorDetails_page.dart'; import 'package:star_lock/mine/mineSet/lockGroup/lockGroupList/lockGroupList_page.dart'; @@ -448,6 +449,8 @@ abstract class Routers { static const advancedFeaturesWebPage = '/advancedFeaturesWebPage'; // 高级功能 static const advancedFunctionRecordPage = '/advancedFunctionRecordPage'; //高级功能购买记录 + static const String administratorAssociationLockPage = + '/administratorAssociationLockPage'; //我的设置-授权管理员-关联锁 } abstract class AppRouters { @@ -1070,5 +1073,8 @@ abstract class AppRouters { GetPage( name: Routers.advancedFunctionRecordPage, page: (() => const AdvancedFunctionRecordPage())), + GetPage( + name: Routers.administratorAssociationLockPage, + page: () => const AdministratorAssociationLockPage()), ]; } diff --git a/lib/mine/mineSet/authorizedAdministrator/administratorAssociationLock/administratorAssociationLock_logic.dart b/lib/mine/mineSet/authorizedAdministrator/administratorAssociationLock/administratorAssociationLock_logic.dart new file mode 100644 index 00000000..09e42583 --- /dev/null +++ b/lib/mine/mineSet/authorizedAdministrator/administratorAssociationLock/administratorAssociationLock_logic.dart @@ -0,0 +1,47 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_easyloading/flutter_easyloading.dart'; +import 'package:get/get.dart'; +import 'package:star_lock/mine/mineSet/authorizedAdministrator/administratorAssociationLock/administratorAssociationLock_state.dart'; +import 'package:star_lock/network/api_repository.dart'; +import 'package:star_lock/tools/baseGetXController.dart'; +import 'package:star_lock/tools/custom_bottom_sheet.dart'; + +class AdministratorAssociationLockLogic extends BaseGetXController { + AdministratorAssociationLockState state = AdministratorAssociationLockState(); + + //获取授权管理员下锁列表 + Future administratorOwnLockListRequest() async { + var entity = await ApiRepository.to.administratorOwnLockList( + uid: state.itemData.value.uid ?? 0, + ); + if (entity.errorCode!.codeIsSuccessful) { + EasyLoading.showToast('修改成功', duration: 2000.milliseconds); + } + } + + Future openModalBottomSheet() async { + final List textList = ['添加'.tr, '删除'.tr]; + + showModalBottomSheet( + context: Get.context!, + shape: RoundedRectangleBorder( + borderRadius: BorderRadiusDirectional.circular(10)), + builder: (BuildContext context) { + return AlertBottomWidget( + topTitle: '', + items: textList, + chooseCallback: (int value) { + final int index = value; + if (index == 0) { + } else {} + }); + }); + } + + @override + void onReady() { + super.onReady(); + + administratorOwnLockListRequest(); + } +} diff --git a/lib/mine/mineSet/authorizedAdministrator/administratorAssociationLock/administratorAssociationLock_page.dart b/lib/mine/mineSet/authorizedAdministrator/administratorAssociationLock/administratorAssociationLock_page.dart new file mode 100644 index 00000000..2e624d04 --- /dev/null +++ b/lib/mine/mineSet/authorizedAdministrator/administratorAssociationLock/administratorAssociationLock_page.dart @@ -0,0 +1,102 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:get/get.dart'; +import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupCell.dart'; +import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupListEntity.dart'; +import 'package:star_lock/mine/mineSet/authorizedAdministrator/administratorAssociationLock/administratorAssociationLock_logic.dart'; +import 'package:star_lock/mine/mineSet/authorizedAdministrator/administratorAssociationLock/administratorAssociationLock_state.dart'; +import 'package:star_lock/tools/ExpandedListView.dart'; + +import '../../../../../app_settings/app_colors.dart'; +import '../../../../../tools/titleAppBar.dart'; + +class AdministratorAssociationLockPage extends StatefulWidget { + const AdministratorAssociationLockPage({Key? key}) : super(key: key); + + @override + State createState() => + _AdministratorAssociationLockPageState(); +} + +class _AdministratorAssociationLockPageState + extends State { + final AdministratorAssociationLockLogic logic = + Get.put(AdministratorAssociationLockLogic()); + final AdministratorAssociationLockState state = + Get.find().state; + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: AppColors.mainBackgroundColor, + appBar: TitleAppBar( + barTitle: '锁'.tr, + haveBack: true, + backgroundColor: AppColors.mainColor, + actionsList: [ + IconButton( + icon: Image.asset( + 'images/icon_bar_more.png', + height: 30.h, + width: 10.w, + ), + onPressed: logic.openModalBottomSheet, + ), + ], + ), + body: _buildListView(), + ); + } + + Widget _buildListView() { + return ListView.separated( + itemCount: state.itemLockList.length, + itemBuilder: (BuildContext context, int index) { + final GroupListItem itemData = state.itemLockList[index]; + return _buildLockExpandedList(context, index, itemData); + }, + shrinkWrap: true, + separatorBuilder: (BuildContext context, int index) { + return const Divider( + height: 1, + color: AppColors.greyLineColor, + ); + }); + } + +//设备多层级列表 + Widget _buildLockExpandedList(context, index, GroupListItem itemData) { + List lockItemList = itemData.lockList ?? []; + return ExpandedListTile( + onTap: () { + //是否选中组 + if (itemData.isChecked) { + var selectList = itemData.lockList; + for (LockListItem lockListItem in selectList!) { + lockListItem.isChecked = true; + state.selectLockIdList.value.add(lockListItem.lockId); + } + } else { + var selectList = itemData.lockList; + for (LockListItem lockListItem in selectList!) { + lockListItem.isChecked = false; + state.selectLockIdList.value.remove(lockListItem.lockId); + } + } + setState(() {}); + }, + typeImgList: const [], + groupItem: itemData, + child: massSendLockGroupCell(index, + currentIndex: index, lockListByGroup: lockItemList, isVip: true, + selectLockAction: (int selectIndex, String selectLockId) { + final LockListItem lockItem = lockItemList[selectIndex]; + lockItem.isChecked = !lockItem.isChecked; + if (lockItem.isChecked) { + state.selectLockIdList.value.add(lockItem.lockId); + } + setState(() {}); + }), + ); + } +} diff --git a/lib/mine/mineSet/authorizedAdministrator/administratorAssociationLock/administratorAssociationLock_state.dart b/lib/mine/mineSet/authorizedAdministrator/administratorAssociationLock/administratorAssociationLock_state.dart new file mode 100644 index 00000000..e60ce178 --- /dev/null +++ b/lib/mine/mineSet/authorizedAdministrator/administratorAssociationLock/administratorAssociationLock_state.dart @@ -0,0 +1,15 @@ +import 'package:get/get.dart'; +import 'package:star_lock/mine/mineSet/authorizedAdministrator/authorizedAdministrator/authorizedAdminListEntity.dart'; + +class AdministratorAssociationLockState { + AdministratorAssociationLockState() { + final Map map = Get.arguments; + if (map['itemData'] != null) { + itemData.value = map['itemData']; + } + } + + RxList itemLockList = [].obs; + Rx itemData = AuthorizedAdminListItem().obs; + RxList selectLockIdList = [].obs; +} diff --git a/lib/mine/mineSet/authorizedAdministrator/administratorDetails/administratorDetails_page.dart b/lib/mine/mineSet/authorizedAdministrator/administratorDetails/administratorDetails_page.dart index ad579644..1fa5d48e 100755 --- a/lib/mine/mineSet/authorizedAdministrator/administratorDetails/administratorDetails_page.dart +++ b/lib/mine/mineSet/authorizedAdministrator/administratorDetails/administratorDetails_page.dart @@ -88,11 +88,12 @@ class _AdministratorDetailsPageState extends State { CommonItem( leftTitel: TranslationLoader.lanKeys!.lock!.tr, rightTitle: state.itemData.value.lockNum.toString(), - isHaveDirection: false, + isHaveDirection: true, action: () { - // //锁列表页面 - // Navigator.pushNamed(context, Routers.lockItemListPage, - // arguments: {'lockList': state.lockItemList}); + Get.toNamed(Routers.administratorAssociationLockPage, + arguments: { + 'itemData': state.itemData.value, + }); }), Container(height: 10.h), CommonItem( diff --git a/lib/network/api.dart b/lib/network/api.dart index 16d06347..81e7c5c7 100755 --- a/lib/network/api.dart +++ b/lib/network/api.dart @@ -143,6 +143,8 @@ abstract class Api { final String canSendKeyURL = '/keyUser/canSendKey'; //群发钥匙检查 final String batchSendKeyURL = '/key/batchSend'; //批处理群发钥匙 final String addAuthorizedAdminURL = '/authorizedAdmin/add'; //增加授权管理员 + final String administratorOwnLockListURL = + '/authorizedAdmin/ownLockList'; //获取授权管理员下锁列表 final String keyListByUserURL = '/keyUser/listByUse'; //用户拥有的锁 final String authorizedAdminListURL = '/authorizedAdmin/list'; //授权管理员列表 final String authorizedAdminDetailURL = '/authorizedAdmin/detail'; //授权管理员详情 @@ -234,5 +236,4 @@ abstract class Api { final String deleteLockCloudStorageURL = '/lockCloudStorage/delete'; //删除云存 final String getUserNoList = '/key/getUserNoList'; //获取指定锁下所有userNo - } diff --git a/lib/network/api_provider.dart b/lib/network/api_provider.dart index c44115cb..2f15be18 100755 --- a/lib/network/api_provider.dart +++ b/lib/network/api_provider.dart @@ -374,12 +374,15 @@ class ApiProvider extends BaseProvider { })); // 获取锁信息列表 - Future getStarLockListInfo(int pageNo, int pageSize,{bool isUnShowLoading = true}) => post( - getStarLockInfoURL.toUrl, - jsonEncode({ - "pageNo": pageNo, - 'pageSize': pageSize, - }),isUnShowLoading: isUnShowLoading); + Future getStarLockListInfo(int pageNo, int pageSize, + {bool isUnShowLoading = true}) => + post( + getStarLockInfoURL.toUrl, + jsonEncode({ + "pageNo": pageNo, + 'pageSize': pageSize, + }), + isUnShowLoading: isUnShowLoading); // 获取所有锁设置信息 Future getLockSettingInfoData(String lockId) => post( @@ -1499,6 +1502,10 @@ class ApiProvider extends BaseProvider { Future authorizedAdminDetail(int uid) => post(authorizedAdminDetailURL.toUrl, jsonEncode({'uid': uid})); +//获取授权管理员下锁列表 + Future administratorOwnLockList(int uid) => + post(administratorOwnLockListURL.toUrl, jsonEncode({'uid': uid})); + Future deleteAuthorizedAdmin( String uid, String includeUnderlings) => post(deleteAdministratorURL.toUrl, diff --git a/lib/network/api_repository.dart b/lib/network/api_repository.dart index 64818b1f..72bf24f1 100755 --- a/lib/network/api_repository.dart +++ b/lib/network/api_repository.dart @@ -1012,6 +1012,13 @@ class ApiRepository { return AdministratorDetailEntity.fromJson(res.body); } + //获取授权管理员下锁列表 + Future administratorOwnLockList( + {required int uid}) async { + final res = await apiProvider.administratorOwnLockList(uid); + return AuthorizedAdminListEntity.fromJson(res.body); + } + //删除授权管理员 Future deleteAuthorizedAdmin( String uid, String includeUnderlings) async { From 9a56b0ae1d18b1b9e71bd4d6e00180c75e1d489f Mon Sep 17 00:00:00 2001 From: anfe <448468458@qq.com> Date: Wed, 22 May 2024 15:23:44 +0800 Subject: [PATCH 41/44] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=20=E6=89=B9?= =?UTF-8?q?=E9=87=8F=E6=8E=88=E6=9D=83=E9=94=81=20=E5=8F=91=E9=80=81?= =?UTF-8?q?=E5=AE=8C=E5=BA=94=E6=B2=A1=E6=9C=89=E7=9F=AD=E4=BF=A1=E3=80=81?= =?UTF-8?q?=E9=82=AE=E4=BB=B6=E3=80=81=E5=BE=AE=E4=BF=A1=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=EF=BC=8C=E5=BA=94=E7=9B=B4=E6=8E=A5=E6=8F=90=E7=A4=BA=E6=93=8D?= =?UTF-8?q?=E4=BD=9C=E6=88=90=E5=8A=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../authorizedAdmin_logic.dart | 180 +++++++++++------- .../authorizedAdmin/authorizedAdmin_page.dart | 7 +- .../authorizedAdmin_state.dart | 24 +-- .../notice_template_entity.dart | 0 .../volumeAuthorizationLock_logic.dart | 2 +- lib/network/api_repository.dart | 2 +- lib/tools/NativeInteractionTool.dart | 26 +-- 7 files changed, 141 insertions(+), 100 deletions(-) rename lib/main/lockDetail/authorizedAdmin/{volumeAuthorizationLock => authorizedAdmin}/notice_template_entity.dart (100%) diff --git a/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_logic.dart b/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_logic.dart index 3869b32f..c0eb4073 100755 --- a/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_logic.dart +++ b/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_logic.dart @@ -5,7 +5,11 @@ import 'package:flutter_blue_plus/flutter_blue_plus.dart'; import 'package:get/get.dart'; import 'package:star_lock/appRouters.dart'; import 'package:star_lock/app_settings/app_settings.dart'; +import 'package:star_lock/login/login/entity/LoginEntity.dart'; +import 'package:star_lock/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_entity.dart'; +import 'package:star_lock/main/lockDetail/authorizedAdmin/authorizedAdmin/notice_template_entity.dart'; import 'package:star_lock/mine/valueAddedServices/advancedFunctionRecord/advancedFunctionRecord_entity.dart'; +import 'package:star_lock/tools/NativeInteractionTool.dart'; import 'package:star_lock/tools/dateTool.dart'; import 'package:star_lock/tools/showCupertinoAlertView.dart'; @@ -26,18 +30,21 @@ import 'authorizedAdmin_state.dart'; class AuthorizedAdminLogic extends BaseGetXController { final AuthorizedAdminState state = AuthorizedAdminState(); + int? keyId; + // 监听设备返回的数据 late StreamSubscription _replySubscription; + void _initReplySubscription() { _replySubscription = - EventBusManager().eventBus!.on().listen((reply) async { + EventBusManager().eventBus!.on().listen((Reply reply) async { // 转移权限 if (reply is TransferPermissionsReply) { - var token = reply.data.sublist(2, 6); - var saveStrList = changeIntListToStringList(token); + final List token = reply.data.sublist(2, 6); + final List saveStrList = changeIntListToStringList(token); Storage.setStringList(saveBlueToken, saveStrList); - int status = reply.data[6]; + final int status = reply.data[6]; switch (status) { case 0x00: @@ -45,20 +52,24 @@ class AuthorizedAdminLogic extends BaseGetXController { break; case 0x06: //无权限 - var privateKey = await Storage.getStringList(saveBluePrivateKey); - List getPrivateKeyList = + final List? privateKey = + await Storage.getStringList(saveBluePrivateKey); + final List getPrivateKeyList = changeStringListToIntList(privateKey!); - var publicKey = await Storage.getStringList(saveBluePublicKey); - List publicKeyDataList = changeStringListToIntList(publicKey!); + final List? publicKey = + await Storage.getStringList(saveBluePublicKey); + final List publicKeyDataList = + changeStringListToIntList(publicKey!); - var token = await Storage.getStringList(saveBlueToken); - List getTokenList = changeStringListToIntList(token!); + final List? token = + await Storage.getStringList(saveBlueToken); + final List getTokenList = changeStringListToIntList(token!); IoSenderManage.senderFactoryDataReset( lockID: BlueManage().connectDeviceName, userID: await Storage.getUid(), - keyID: "1", + keyID: '1', needAuthor: 1, publicKey: publicKeyDataList, privateKey: getPrivateKeyList, @@ -76,21 +87,25 @@ class AuthorizedAdminLogic extends BaseGetXController { BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState state) async { if (state == BluetoothConnectionState.connected) { - var privateKey = await Storage.getStringList(saveBluePrivateKey); - List getPrivateKeyList = changeStringListToIntList(privateKey!); + final List? privateKey = + await Storage.getStringList(saveBluePrivateKey); + final List getPrivateKeyList = + changeStringListToIntList(privateKey!); - var publicKey = await Storage.getStringList(saveBluePublicKey); - List publicKeyDataList = changeStringListToIntList(publicKey!); + final List? publicKey = + await Storage.getStringList(saveBluePublicKey); + final List publicKeyDataList = + changeStringListToIntList(publicKey!); - var token = await Storage.getStringList(saveBlueToken); - List getTokenList = changeStringListToIntList(token!); + final List? token = await Storage.getStringList(saveBlueToken); + final List getTokenList = changeStringListToIntList(token!); IoSenderManage.senderTransferPermissions( lockID: BlueManage().connectDeviceName, authUserID: await Storage.getUid(), - keyID: "1", + keyID: '1', oldUserID: await Storage.getUid(), - newUserID: "100002", + newUserID: '100002', needAuthor: 1, publicKey: publicKeyDataList, privateKey: getPrivateKeyList, @@ -102,40 +117,40 @@ class AuthorizedAdminLogic extends BaseGetXController { //发送授权管理员列表请求 Future sendElectronicKeyRequest() async { if (state.emailOrPhoneController.text.isEmpty) { - showToast("请输入接收者账号"); + showToast('请输入接收者账号'); return; } if (state.keyNameController.text.isEmpty) { - showToast("请输入接收者姓名"); + showToast('请输入接收者姓名'); return; } - var startDate = "0"; - var endDate = "0"; - var startTime = "0"; - var endTime = "0"; - AppLog.log("state.type.value:${state.seletType.value}"); - String getKeyType = "1"; + String startDate = '0'; + String endDate = '0'; + String startTime = '0'; + String endTime = '0'; + AppLog.log('state.type.value:${state.seletType.value}'); + String getKeyType = '1'; if (state.seletType.value == 0) { - getKeyType = "2"; + getKeyType = '2'; startDate = DateTool().dateToTimestamp(state.beginDate.value, 1).toString(); endDate = DateTool().dateToTimestamp(state.endDate.value, 1).toString(); - startTime = "0"; - endTime = "0"; + startTime = '0'; + endTime = '0'; if (startDate.isEmpty) { - showToast("请选择开始时间"); + showToast('请选择开始时间'); return; } if (endDate.isEmpty) { - showToast("请选择结束时间"); + showToast('请选择结束时间'); return; } if (int.parse(startDate) >= int.parse(endDate)) { - showToast("失效时间要大于生效时间"); + showToast('失效时间要大于生效时间'); return; } } @@ -143,12 +158,12 @@ class AuthorizedAdminLogic extends BaseGetXController { //如果打开了实名认证,需要弹出输入身份证信息框 if (state.isAuthentication.value == true) { if (state.realNameController.text.isEmpty) { - showToast("请输入真实姓名".tr); + showToast('请输入真实姓名'.tr); return; } if (state.idCardController.text.isEmpty) { - showToast("请输入身份证号".tr); + showToast('请输入身份证号'.tr); return; } //弹出身份证信息确认框 @@ -179,38 +194,39 @@ class AuthorizedAdminLogic extends BaseGetXController { required String startDate, required String startTime, required String endTime}) async { - var entity = await ApiRepository.to.sendElectronicKey( - createUser: state.isCreateUser.value ? "1" : "0", - countryCode: state.countryCode.value, - usernameType: '1', - endDate: int.parse(endDate), - faceAuthentication: state.isAuthentication.value == true ? '1' : '2', - isCameraEnable: '2', - isRemoteUnlock: '2', - keyNameForAdmin: state.keyNameController.text, - keyRight: '1', - keyType: getKeyType, - lockId: CommonDataManage().currentKeyInfo.lockId!.toString(), - operatorUid: '', - receiverUsername: state.emailOrPhoneController.text, - remarks: '', - startDate: int.parse(startDate), - weekDays: state.weekdaysList, - startTime: int.parse(startTime), - endTime: int.parse(endTime), - isOnlyManageSelf: state.onlyManageYouCreatesUser.value ? 1 : 0, - realName: state.isRequireAuth.value == true - ? state.realNameController.text - : "", - idCardNumber: state.isRequireAuth.value == true - ? state.idCardController.text - : ""); + final AuthorizedAdminSendEntity entity = await ApiRepository.to + .sendElectronicKey( + createUser: state.isCreateUser.value ? '1' : '0', + countryCode: state.countryCode.value, + usernameType: '1', + endDate: int.parse(endDate), + faceAuthentication: + state.isAuthentication.value == true ? '1' : '2', + isCameraEnable: '2', + isRemoteUnlock: '2', + keyNameForAdmin: state.keyNameController.text, + keyRight: '1', + keyType: getKeyType, + lockId: CommonDataManage().currentKeyInfo.lockId!.toString(), + operatorUid: '', + receiverUsername: state.emailOrPhoneController.text, + remarks: '', + startDate: int.parse(startDate), + weekDays: state.weekdaysList, + startTime: int.parse(startTime), + endTime: int.parse(endTime), + isOnlyManageSelf: state.onlyManageYouCreatesUser.value ? 1 : 0, + realName: state.isRequireAuth.value == true + ? state.realNameController.text + : '', + idCardNumber: state.isRequireAuth.value == true + ? state.idCardController.text + : ''); if (entity.errorCode!.codeIsSuccessful) { state.isCreateUser.value = false; state.isSendSuccess.value = true; - // Toast.show(msg: "添加成功"); state.addUserId.value = entity.data!.receiverUser!.id.toString(); - // addUserConnectBlue(state.addUserId.value); + keyId = entity.data!.keyId; eventBus.fire(AuthorizedAdminPageRefreshUI()); } else { if (entity.errorCode == 425) { @@ -218,16 +234,15 @@ class AuthorizedAdminLogic extends BaseGetXController { state.isCreateUser.value = true; ShowTipView().showIosTipWithContentDialog( '${"是否发送授权管理员给未注册账号".tr}\n${state.emailOrPhoneController.text}', - () { - sendElectronicKeyRequest(); - }); + sendElectronicKeyRequest); } } } //检测实名认证是否支持开启 Future keyCheckFace() async { - AdvancedFunctionRecordEntity entity = await ApiRepository.to.keyCheckFace( + final AdvancedFunctionRecordEntity entity = + await ApiRepository.to.keyCheckFace( lockId: CommonDataManage().currentKeyInfo.lockId ?? 0, ); if (entity.errorCode!.codeIsSuccessful) { @@ -240,7 +255,7 @@ class AuthorizedAdminLogic extends BaseGetXController { titleStr: '实名认证为付费功能,请购买后再使用'.tr, sureClick: () { Get.toNamed(Routers.advancedFeaturesWebPage, - arguments: {'isShop': false}); + arguments: {'isShop': false}); }); } else if (entity.errorCode == 433) { //需联系管理员购买 @@ -250,12 +265,12 @@ class AuthorizedAdminLogic extends BaseGetXController { //标记房间为已入住 isOn:已入住: 1 空闲:2 Future updateRoomCheckIn() async { - var entity = await ApiRepository.to.setRoomStatusData( + final LoginEntity entity = await ApiRepository.to.setRoomStatusData( lockId: CommonDataManage().currentKeyInfo.lockId!, roomStatus: 1, ); if (entity.errorCode!.codeIsSuccessful) { - showToast("标记成功"); + showToast('标记成功'); } } @@ -279,6 +294,31 @@ class AuthorizedAdminLogic extends BaseGetXController { return currentController; } + //发送消息 + Future sendMsg({required bool isPhone}) async { + if (keyId == null) { + return; + } + final NoticeTemplateEntity entity = await ApiRepository.to + .getNoticeTemplate( + lockId: CommonDataManage().currentKeyInfo.lockId!, + keyId: keyId!, + channelType: isPhone ? 1 : 2); + if (entity.errorCode!.codeIsSuccessful) { + final List list = + entity.data!.list!.where((Item item) => item.isUse == 0).toList(); + if (list.isNotEmpty) { + final Item item = list.first!; + final String template = item.template ?? ''; + NativeInteractionTool().loadNativeShare(shareText: template); + } else { + showToast('获取模板失败 0x02'); + } + } else { + showToast('获取模板失败 0x01'); + } + } + @override void onReady() { // TODO: implement onReady diff --git a/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_page.dart b/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_page.dart index 6f3d0d2f..d1e2bb3d 100755 --- a/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_page.dart +++ b/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_page.dart @@ -362,8 +362,7 @@ class _AuthorizedAdminPageState extends State if (state.emailOrPhoneController.text.contains('@')) { Get.toNamed(Routers.sendEmailNotificationPage); } else { - NativeInteractionTool() - .loadNativeShare(shareText: state.pwdShareStr); + logic.sendMsg(isPhone: true); } }, ), @@ -373,8 +372,8 @@ class _AuthorizedAdminPageState extends State OutLineBtn( btnName: '微信通知', onClick: () { - NativeInteractionTool() - .loadNativeShare(shareText: state.pwdShareStr); + logic.sendMsg( + isPhone: state.emailOrPhoneController.text.contains('@')); }, ), SizedBox( diff --git a/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_state.dart b/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_state.dart index 0a350e43..36dceadf 100755 --- a/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_state.dart +++ b/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_state.dart @@ -15,25 +15,25 @@ class AuthorizedAdminState { final FlutterContactPicker contactPicker = FlutterContactPicker(); late Contact contact; - var isAuthentication = false.obs; //是否可以实名认证 - final onlyManageYouCreatesUser = false.obs; // 只能管理自己创建的用户 + RxBool isAuthentication = false.obs; //是否可以实名认证 + final RxBool onlyManageYouCreatesUser = false.obs; // 只能管理自己创建的用户 - var beginDate = DateTool() + RxString beginDate = DateTool() .dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString()) .obs; //默认为当前时间 开始时间 - var endDate = DateTool() + RxString endDate = DateTool() .dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString()) .obs; //默认为当前时间 结束时间 - var isSendSuccess = false.obs; - var countryName = '中国'.obs; - var countryCode = '86'.obs; - var weekdaysList = [].obs; - var isCreateUser = false.obs; //用户未注册时传1 已注册传0 + RxBool isSendSuccess = false.obs; + RxString countryName = '中国'.obs; + RxString countryCode = '86'.obs; + RxList weekdaysList = [].obs; + RxBool isCreateUser = false.obs; //用户未注册时传1 已注册传0 - var seletType = 0.obs; + RxInt seletType = 0.obs; String pwdShareStr = '您好,您的授权管理员生成成功'; - var addUserId = ''.obs; - var isRequireAuth = false.obs; //是否需要实名认证的必填项 + RxString addUserId = ''.obs; + RxBool isRequireAuth = false.obs; //是否需要实名认证的必填项 } diff --git a/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/notice_template_entity.dart b/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/notice_template_entity.dart similarity index 100% rename from lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/notice_template_entity.dart rename to lib/main/lockDetail/authorizedAdmin/authorizedAdmin/notice_template_entity.dart diff --git a/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_logic.dart b/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_logic.dart index d75cd07c..0c4ab05b 100755 --- a/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_logic.dart +++ b/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_logic.dart @@ -2,7 +2,7 @@ import 'dart:ffi'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:get/get.dart'; -import 'package:star_lock/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/notice_template_entity.dart'; +import 'package:star_lock/main/lockDetail/authorizedAdmin/authorizedAdmin/notice_template_entity.dart'; import 'package:star_lock/main/lockDetail/lockSet/basicInformation/basicInformation/KeyDetailEntity.dart'; import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/tools/baseGetXController.dart'; diff --git a/lib/network/api_repository.dart b/lib/network/api_repository.dart index d102f7be..133fdcea 100755 --- a/lib/network/api_repository.dart +++ b/lib/network/api_repository.dart @@ -1,7 +1,7 @@ import 'package:get/get.dart'; import 'package:star_lock/blue/entity/lock_user_no_list_entity.dart'; import 'package:star_lock/login/selectCountryRegion/common/countryRegionEntity.dart'; -import 'package:star_lock/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/notice_template_entity.dart'; +import 'package:star_lock/main/lockDetail/authorizedAdmin/authorizedAdmin/notice_template_entity.dart'; import 'package:star_lock/main/lockDetail/doorLockLog/doorLockLog_entity.dart'; import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart'; import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/lockUserList/lockUserList_entity.dart'; diff --git a/lib/tools/NativeInteractionTool.dart b/lib/tools/NativeInteractionTool.dart index a94cf5e7..f971cfac 100755 --- a/lib/tools/NativeInteractionTool.dart +++ b/lib/tools/NativeInteractionTool.dart @@ -1,34 +1,38 @@ - import 'package:flutter/services.dart'; import '../app_settings/app_settings.dart'; ///原生交互配置 -class NativeInteractionConfig{ +class NativeInteractionConfig { static String methodSendChannel = 'starLockFlutterSend'; static String receiveEventChannel = 'starLockFlutterReceive'; } ///原生交互flutter向原生发送消息 typedef BlockBlueStatus = void Function(String status); -class NativeInteractionTool{ - var sendChannel = MethodChannel(NativeInteractionConfig.methodSendChannel); - var receiveChannel = MethodChannel(NativeInteractionConfig.receiveEventChannel); + +class NativeInteractionTool { + MethodChannel sendChannel = + MethodChannel(NativeInteractionConfig.methodSendChannel); + MethodChannel receiveChannel = + MethodChannel(NativeInteractionConfig.receiveEventChannel); ///加载原生分享 - loadNativeShare({required String shareText}){ - sendChannel.invokeMethod('loadNativeShare', {'shareText':shareText}); + void loadNativeShare({required String shareText}) { + sendChannel.invokeMethod( + 'loadNativeShare', {'shareText': shareText}); } ///获取设备蓝牙状态 - sendGetBlueStatus(){ + void sendGetBlueStatus() { sendChannel.invokeMethod('sendGetBlueStatus'); } ///获取设备蓝牙是否打开 - receiveChannelBlueIsOnEvent(BlockBlueStatus blockBlueStatus){ + void receiveChannelBlueIsOnEvent(BlockBlueStatus blockBlueStatus) { receiveChannel.setMethodCallHandler((MethodCall call) async { - AppLog.log('收到原生发送的信息call.method: ${call.method} call.arguments:${call.arguments}'); + AppLog.log( + '收到原生发送的信息call.method: ${call.method} call.arguments:${call.arguments}'); switch (call.method) { case 'getBlueStatus': // 获取设备蓝牙开启/关闭状态 @@ -42,5 +46,3 @@ class NativeInteractionTool{ }); } } - - From 2c3a744a144f320567e06cad27277244a3bcd2e0 Mon Sep 17 00:00:00 2001 From: anfe <448468458@qq.com> Date: Wed, 22 May 2024 17:19:38 +0800 Subject: [PATCH 42/44] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=20=E9=94=81?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E4=BF=AE=E6=94=B9=E8=AE=BE=E5=A4=87=E5=90=8E?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E6=BB=91=E5=8A=A8=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lockMian/lockList/lockList_logic.dart | 184 ++++++++++-------- lib/main/lockMian/lockList/lockList_page.dart | 131 ++++++------- .../lockMian/lockList/lockList_xhj_page.dart | 139 ++++++------- .../lockMian/lockMain/lockMain_logic.dart | 18 +- lib/main/lockMian/lockMain/lockMain_page.dart | 2 +- .../addLock/nearbyLock/nearbyLock_logic.dart | 120 ++++++------ 6 files changed, 312 insertions(+), 282 deletions(-) diff --git a/lib/main/lockMian/lockList/lockList_logic.dart b/lib/main/lockMian/lockList/lockList_logic.dart index fff0e86b..49a87d25 100755 --- a/lib/main/lockMian/lockList/lockList_logic.dart +++ b/lib/main/lockMian/lockList/lockList_logic.dart @@ -4,7 +4,6 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/scheduler.dart'; import 'package:flutter_blue_plus/flutter_blue_plus.dart'; import 'package:get/get.dart'; -import 'package:star_lock/blue/io_type.dart'; import 'package:star_lock/tools/baseGetXController.dart'; import '../../../blue/blue_manage.dart'; @@ -23,26 +22,43 @@ import '../../../translations/trans_lib.dart'; import '../entity/lockListInfo_entity.dart'; import 'lockList_state.dart'; -class LockListLogic extends BaseGetXController{ +class LockListLogic extends BaseGetXController { + LockListLogic(this.entity); + LockListState state = LockListState(); + List groupDataList = []; + LockListInfoGroupEntity? entity; + + //设置数据 + void setLockListInfoGroupEntity(LockListInfoGroupEntity entity) { + this.entity = entity; + if (entity.pageNo == 1) { + groupDataList = []; + } + groupDataList.addAll(entity.groupList!); + update(); + } // 监听蓝牙协议返回结果 late StreamSubscription _replySubscription; + void _initReplySubscription() { - _replySubscription = EventBusManager().eventBus!.on().listen((reply) async { + _replySubscription = + EventBusManager().eventBus!.on().listen((Reply reply) async { // 恢复出厂设置 - if ((reply is FactoryDataResetReply) && (state.ifCurrentScreen.value == true)) { + if ((reply is FactoryDataResetReply) && + (state.ifCurrentScreen.value == true)) { _replyFactoryDataResetKey(reply); } }); } Future _replyFactoryDataResetKey(Reply reply) async { - var token = reply.data.sublist(2, 6); - var saveStrList = changeIntListToStringList(token); + final List token = reply.data.sublist(2, 6); + final List saveStrList = changeIntListToStringList(token); Storage.setStringList(saveBlueToken, saveStrList); - int status = reply.data[6]; + final int status = reply.data[6]; switch (status) { case 0x00: //成功 @@ -52,22 +68,24 @@ class LockListLogic extends BaseGetXController{ break; case 0x06: //无权限 - var token = await Storage.getStringList(saveBlueToken); - List getTokenList = changeStringListToIntList(token!); + final List? token = await Storage.getStringList(saveBlueToken); + final List getTokenList = changeStringListToIntList(token!); IoSenderManage.senderFactoryDataReset( lockID: BlueManage().connectDeviceName, userID: await Storage.getUid(), - keyID: "1", + keyID: '1', needAuthor: 1, - publicKey: state.lockListInfoItemEntity.bluetooth!.publicKey!.cast(), - privateKey: state.lockListInfoItemEntity.bluetooth!.privateKey!.cast(), + publicKey: + state.lockListInfoItemEntity.bluetooth!.publicKey!.cast(), + privateKey: + state.lockListInfoItemEntity.bluetooth!.privateKey!.cast(), token: getTokenList); break; case 0x07: //无权限 dismissEasyLoading(); - showToast("用户无权限"); + showToast('用户无权限'); break; case 0x09: // 权限校验错误 @@ -82,62 +100,63 @@ class LockListLogic extends BaseGetXController{ } } - String showElectricIcon (int electricnumber){ - if(electricnumber >= 100){ + String showElectricIcon(int electricnumber) { + if (electricnumber >= 100) { return 'images/main/icon_lockElectricLevel_5.png'; - }else if((electricnumber > 50) && (electricnumber < 100)){ + } else if ((electricnumber > 50) && (electricnumber < 100)) { return 'images/main/icon_lockElectricLevel_4.png'; - }else if((electricnumber > 25) && (electricnumber <= 50)){ + } else if ((electricnumber > 25) && (electricnumber <= 50)) { return 'images/main/icon_lockElectricLevel_3.png'; - }else if((electricnumber > 5) && (electricnumber <= 25)){ + } else if ((electricnumber > 5) && (electricnumber <= 25)) { return 'images/main/icon_lockElectricLevel_2.png'; - }else if(electricnumber <= 5){ + } else if (electricnumber <= 5) { return 'images/main/icon_lockElectricLevel_1.png'; } return 'images/main/icon_lockElectricLevel_5.png'; } - String getKeyEffective(LockListInfoItemEntity keyInfo){ + String getKeyEffective(LockListInfoItemEntity keyInfo) { // 当是限时、循环的时候 - if(keyInfo.keyType == XSConstantMacro.keyTypeTime || keyInfo.keyType == XSConstantMacro.keyTypeLoop){ + if (keyInfo.keyType == XSConstantMacro.keyTypeTime || + keyInfo.keyType == XSConstantMacro.keyTypeLoop) { // 当是正常使用跟待接收状态的时候 - if(keyInfo.keyStatus == XSConstantMacro.keyStatusNormalUse || keyInfo.keyStatus == XSConstantMacro.keyStatusWaitReceive) { + if (keyInfo.keyStatus == XSConstantMacro.keyStatusNormalUse || + keyInfo.keyStatus == XSConstantMacro.keyStatusWaitReceive) { return "${"余".tr}${DateTool().compareTimeGetDaysFromNow(keyInfo.endDate!)}${"天".tr}"; } else { return XSConstantMacro.getKeyStatusStr(keyInfo.keyStatus!); } } - return ""; + return ''; } -/// 以下为删除逻辑 - deleyLockLogicOfRoles(){ + /// 以下为删除逻辑 + void deleyLockLogicOfRoles() { if (state.lockListInfoItemEntity.isLockOwner == 1) { // 超级管理员必须通过连接蓝牙删除 - ShowTipView().showIosTipWithContentDialog("删除锁后,所有信息都会一起删除,确定删除锁吗?".tr, (){ + ShowTipView().showIosTipWithContentDialog('删除锁后,所有信息都会一起删除,确定删除锁吗?'.tr, + () { // 删除锁 - ShowTipView().showTFViewAlertDialog(state.passwordTF, "请输入登录密码".tr, "请输入登录密码".tr, (){ - checkLoginPassword(); - }); + ShowTipView().showTFViewAlertDialog( + state.passwordTF, '请输入登录密码'.tr, '请输入登录密码'.tr, checkLoginPassword); }); - } else if (state.lockListInfoItemEntity.keyRight == 1){ + } else if (state.lockListInfoItemEntity.keyRight == 1) { // 授权管理员弹框提示 - ShowTipView().showDeleteAdministratorIsHaveAllDataDialog("同时删除其发送的所有钥匙,钥匙删除后不能恢复".tr, (a){ + ShowTipView().showDeleteAdministratorIsHaveAllDataDialog( + '同时删除其发送的所有钥匙,钥匙删除后不能恢复'.tr, (bool a) { // 授权管理员删除 state.deleteAdministratorIsHaveAllData.value = a; deletKeyData(); }); - } else{ + } else { // 普通用户直接删除 - ShowTipView().showIosTipWithContentDialog("是否删除钥匙?".tr, (){ - deletKeyData(); - }); + ShowTipView().showIosTipWithContentDialog('是否删除钥匙?'.tr, deletKeyData); } } // 查询账户密码 - void checkLoginPassword() async { - var entity = await ApiRepository.to.checkLoginPassword( + Future checkLoginPassword() async { + final LockListInfoEntity entity = await ApiRepository.to.checkLoginPassword( password: state.passwordTF.text, ); if (entity.errorCode!.codeIsSuccessful) { @@ -147,12 +166,12 @@ class LockListLogic extends BaseGetXController{ } // 当是锁拥有者的时候,删除锁 - void deletLockInfoData() async { - var entity = await ApiRepository.to.deletOwnerLockData( + Future deletLockInfoData() async { + final LockListInfoEntity entity = await ApiRepository.to.deletOwnerLockData( lockId: state.lockListInfoItemEntity.lockId!, ); if (entity.errorCode!.codeIsSuccessful) { - BlueManage().connectDeviceMacAddress = ""; + BlueManage().connectDeviceMacAddress = ''; SchedulerBinding.instance.addPostFrameCallback((_) { eventBus.fire(RefreshLockListInfoDataEvent()); }); @@ -160,14 +179,14 @@ class LockListLogic extends BaseGetXController{ } // 普通用户或者授权管理员删除钥匙 - void deletKeyData() async { - var entity = await ApiRepository.to.deletOwnerKeyData( + Future deletKeyData() async { + final LockListInfoEntity entity = await ApiRepository.to.deletOwnerKeyData( lockId: state.lockListInfoItemEntity.lockId.toString(), keyId: state.lockListInfoItemEntity.keyId.toString(), - includeUnderlings: state.deleteAdministratorIsHaveAllData.value == true ? 1 : 0 - ); + includeUnderlings: + state.deleteAdministratorIsHaveAllData.value == true ? 1 : 0); if (entity.errorCode!.codeIsSuccessful) { - BlueManage().connectDeviceMacAddress = ""; + BlueManage().connectDeviceMacAddress = ''; SchedulerBinding.instance.addPostFrameCallback((_) { eventBus.fire(RefreshLockListInfoDataEvent()); }); @@ -177,62 +196,74 @@ class LockListLogic extends BaseGetXController{ // 恢复出厂设置 Future factoryDataResetAction() async { showEasyLoading(); - showBlueConnetctToastTimer(isShowBlueConnetctToast: false, action: (){ - dismissEasyLoading(); - showDeletAlertTipDialog(); - }); - BlueManage().blueSendData(state.lockListInfoItemEntity.lockName!, (BluetoothConnectionState connectionState) async { + showBlueConnetctToastTimer( + isShowBlueConnetctToast: false, + action: () { + dismissEasyLoading(); + showDeletAlertTipDialog(); + }); + BlueManage().blueSendData(state.lockListInfoItemEntity.lockName!, + (BluetoothConnectionState connectionState) async { if (connectionState == BluetoothConnectionState.connected) { - List publicKeyData = state.lockListInfoItemEntity.bluetooth!.publicKey!.cast(); - var saveStrList = changeIntListToStringList(publicKeyData); + final List publicKeyData = + state.lockListInfoItemEntity.bluetooth!.publicKey!.cast(); + final List saveStrList = + changeIntListToStringList(publicKeyData); Storage.setStringList(saveBluePublicKey, saveStrList); // 私钥 - List privateKeyData = state.lockListInfoItemEntity.bluetooth!.privateKey!.cast(); - var savePrivateKeyList = changeIntListToStringList(privateKeyData); + final List privateKeyData = + state.lockListInfoItemEntity.bluetooth!.privateKey!.cast(); + final List savePrivateKeyList = + changeIntListToStringList(privateKeyData); Storage.setStringList(saveBluePrivateKey, savePrivateKeyList); // signKey - List signKeyData = state.lockListInfoItemEntity.bluetooth!.signKey!.cast(); - var saveSignKeyList = changeIntListToStringList(signKeyData); + final List signKeyData = + state.lockListInfoItemEntity.bluetooth!.signKey!.cast(); + final List saveSignKeyList = + changeIntListToStringList(signKeyData); Storage.setStringList(saveBlueSignKey, saveSignKeyList); - var saveTokenList = changeIntListToStringList([0, 0, 0, 0]); + final List saveTokenList = + changeIntListToStringList([0, 0, 0, 0]); Storage.setStringList(saveBlueToken, saveTokenList); IoSenderManage.senderFactoryDataReset( lockID: BlueManage().connectDeviceName, userID: await Storage.getUid(), - keyID: "1", + keyID: '1', needAuthor: 1, - publicKey: state.lockListInfoItemEntity.bluetooth!.publicKey!.cast(), - privateKey: state.lockListInfoItemEntity.bluetooth!.privateKey!.cast(), - token: [0,0,0,0]); + publicKey: + state.lockListInfoItemEntity.bluetooth!.publicKey!.cast(), + privateKey: + state.lockListInfoItemEntity.bluetooth!.privateKey!.cast(), + token: [0, 0, 0, 0]); } else if (connectionState == BluetoothConnectionState.disconnected) { dismissEasyLoading(); cancelBlueConnetctToastTimer(); - if(state.ifCurrentScreen.value == true){ + if (state.ifCurrentScreen.value == true) { showDeletAlertTipDialog(); } } }); } - void showDeletAlertTipDialog({String? showContent = ""}) { + void showDeletAlertTipDialog({String? showContent = ''}) { // bool isContains = BlueManage().connectDeviceName!.contains("T9A"); - var content = showContent!.isEmpty ? "${"删除设备失败,请确保在设备附近,设备未被连接,设备已打开".tr}${BlueManage().connectDeviceName!.contains("T9A") == true ? "。如果是全自动锁,请使屏幕变亮".tr : ""}" : showContent; + final String content = showContent!.isEmpty + ? "${"删除设备失败,请确保在设备附近,设备未被连接,设备已打开".tr}${BlueManage().connectDeviceName.contains("T9A") == true ? "。如果是全自动锁,请使屏幕变亮".tr : ""}" + : showContent; showCupertinoDialog( context: Get.context!, - builder: (context) { + builder: (BuildContext context) { return CupertinoAlertDialog( - title: Text("提示".tr), + title: Text('提示'.tr), content: Text(content), - actions: [ + actions: [ CupertinoDialogAction( child: Text(TranslationLoader.lanKeys!.sure!.tr), - onPressed: () { - Get.back(); - }, + onPressed: Get.back, ), ], ); @@ -242,23 +273,12 @@ class LockListLogic extends BaseGetXController{ @override void onReady() { - // TODO: implement onReady super.onReady(); - _initReplySubscription(); } - @override - void onInit() { - // TODO: implement onInit - super.onInit(); - } - @override void onClose() { - // TODO: implement onClose - _replySubscription.cancel(); } - -} \ No newline at end of file +} diff --git a/lib/main/lockMian/lockList/lockList_page.dart b/lib/main/lockMian/lockList/lockList_page.dart index 38416753..53717840 100755 --- a/lib/main/lockMian/lockList/lockList_page.dart +++ b/lib/main/lockMian/lockList/lockList_page.dart @@ -3,6 +3,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_slidable/flutter_slidable.dart'; import 'package:get/get.dart'; import 'package:star_lock/flavors.dart'; +import 'package:star_lock/main/lockMian/lockList/lockList_state.dart'; import '../../../appRouters.dart'; import '../../../app_settings/app_colors.dart'; @@ -14,50 +15,53 @@ import 'lockListGroup_view.dart'; import 'lockList_logic.dart'; class LockListPage extends StatefulWidget { - final LockListInfoGroupEntity lockListInfoGroupEntity; - const LockListPage({Key? key, required this.lockListInfoGroupEntity}) + const LockListPage({required this.lockListInfoGroupEntity, Key? key}) : super(key: key); + final LockListInfoGroupEntity lockListInfoGroupEntity; @override State createState() => _LockListPageState(); } class _LockListPageState extends State with RouteAware { - final logic = Get.put(LockListLogic()); - final state = Get.find().state; + late LockListLogic logic; + late LockListState state; - var groupDataList = []; + @override + void initState() { + super.initState(); + logic = Get.put(LockListLogic(widget.lockListInfoGroupEntity)); + state = Get.find().state; + } @override Widget build(BuildContext context) { - if (widget.lockListInfoGroupEntity.pageNo == 1) { - groupDataList = []; - } - groupDataList.addAll( - widget.lockListInfoGroupEntity.groupList as Iterable); - - return Scaffold( - body: ListView.separated( - itemCount: groupDataList.length, - itemBuilder: (context, index) { - GroupList itemData = groupDataList[index]; - return _buildLockExpandedList(context, index, itemData); - }, - shrinkWrap: true, - physics: const AlwaysScrollableScrollPhysics(), - separatorBuilder: (context, index) { - return const Divider( - height: 1, - color: AppColors.greyLineColor, - ); - }), - ); + return GetBuilder(builder: (LockListLogic logic) { + return Scaffold( + body: ListView.separated( + itemCount: logic.groupDataList.length, + itemBuilder: (BuildContext context, int index) { + final GroupList itemData = logic.groupDataList[index]; + return _buildLockExpandedList(context, index, itemData); + }, + shrinkWrap: true, + physics: const AlwaysScrollableScrollPhysics(), + separatorBuilder: (BuildContext context, int index) { + return const Divider( + height: 1, + color: AppColors.greyLineColor, + ); + }), + ); + }); } //设备多层级列表 - Widget _buildLockExpandedList(context, index, GroupList itemData) { - List lockItemList = itemData.lockList ?? []; + Widget _buildLockExpandedList( + BuildContext context, int index, GroupList itemData) { + final List lockItemList = + itemData.lockList ?? []; return LockListGroupView( onTap: () { //是否选中组 @@ -65,28 +69,28 @@ class _LockListPageState extends State with RouteAware { } else {} setState(() {}); }, - typeImgList: const [], + typeImgList: const [], groupItem: itemData, child: ListView.separated( itemCount: lockItemList.length, shrinkWrap: true, physics: const NeverScrollableScrollPhysics(), - separatorBuilder: (context, index) { + separatorBuilder: (BuildContext context, int index) { return const Divider(height: 1, color: AppColors.greyLineColor); }, - itemBuilder: (c, index) { - LockListInfoItemEntity keyInfo = lockItemList[index]; + itemBuilder: (BuildContext c, int index) { + final LockListInfoItemEntity keyInfo = lockItemList[index]; bool isLast = false; if (lockItemList.length == index + 1) { isLast = true; } return Slidable( - key: ValueKey(keyInfo.keyId), + key: ValueKey(keyInfo.keyId), endActionPane: ActionPane( extentRatio: 0.2, motion: const ScrollMotion(), - children: [ + children: [ SlidableAction( onPressed: (BuildContext context) { state.lockListInfoItemEntity = keyInfo; @@ -104,26 +108,27 @@ class _LockListPageState extends State with RouteAware { keyInfo.keyType == XSConstantMacro.keyTypeLoop) && (keyInfo.keyStatus == XSConstantMacro.keyStatusWaitIneffective)) { - logic.showToast("您的钥匙未生效".tr); + logic.showToast('您的钥匙未生效'.tr); return; } if ((keyInfo.keyType == XSConstantMacro.keyTypeTime || keyInfo.keyType == XSConstantMacro.keyTypeLoop) && (keyInfo.keyStatus == XSConstantMacro.keyStatusFrozen)) { - logic.showToast("您的钥匙已冻结".tr); + logic.showToast('您的钥匙已冻结'.tr); return; } if ((keyInfo.keyType == XSConstantMacro.keyTypeTime || keyInfo.keyType == XSConstantMacro.keyTypeLoop) && (keyInfo.keyStatus == XSConstantMacro.keyStatusExpired)) { - logic.showToast("您的钥匙已过期".tr); + logic.showToast('您的钥匙已过期'.tr); return; } - Get.toNamed(Routers.lockDetailMainPage, arguments: { - // "lockMainEntity": widget.lockMainEntity, - "keyInfo": keyInfo, - "isOnlyOneData": false, - }); + Get.toNamed(Routers.lockDetailMainPage, + arguments: { + // "lockMainEntity": widget.lockMainEntity, + 'keyInfo': keyInfo, + 'isOnlyOneData': false, + }); }), ); }), @@ -152,18 +157,18 @@ class _LockListPageState extends State with RouteAware { ), child: Column( // mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ SizedBox( height: 20.h, ), Row( - children: [ + children: [ SizedBox(width: 30.w), Expanded( child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ Text( keyInfo.lockAlias!, style: TextStyle( @@ -184,7 +189,7 @@ class _LockListPageState extends State with RouteAware { ), SizedBox(width: 2.w), Text( - "${keyInfo.electricQuantity!}%", + '${keyInfo.electricQuantity!}%', style: TextStyle( fontSize: 18.sp, color: AppColors.darkGrayTextColor), ), @@ -193,9 +198,9 @@ class _LockListPageState extends State with RouteAware { ), SizedBox(height: 5.h), Visibility( - visible: keyInfo.passageMode == 1 ? true : false, + visible: keyInfo.passageMode == 1, child: Row( - children: [ + children: [ SizedBox(width: 30.w), Container( padding: EdgeInsets.only(right: 5.w, left: 5.w), @@ -203,7 +208,7 @@ class _LockListPageState extends State with RouteAware { borderRadius: BorderRadius.circular(5.w), color: AppColors.openPassageModeColor, ), - child: Text("常开模式开启".tr, + child: Text('常开模式开启'.tr, style: TextStyle( fontSize: 18.sp, color: AppColors.appBarIconColor)), @@ -212,12 +217,12 @@ class _LockListPageState extends State with RouteAware { )), SizedBox(height: 5.h), Visibility( - visible: keyInfo.lockSetting!.remoteUnlock == 1 ? true : false, + visible: keyInfo.lockSetting!.remoteUnlock == 1, child: Row( - children: [ + children: [ SizedBox(width: 30.w), Text( - "远程开锁".tr, + '远程开锁'.tr, style: TextStyle( fontSize: 18.sp, color: AppColors.darkGrayTextColor), ), @@ -225,19 +230,15 @@ class _LockListPageState extends State with RouteAware { )), SizedBox(height: 20.h), Visibility( - visible: ((keyInfo.keyType == XSConstantMacro.keyTypeTime || - keyInfo.keyType == XSConstantMacro.keyTypeLoop) && - (keyInfo.keyStatus == - XSConstantMacro.keyStatusWaitIneffective || - keyInfo.keyStatus == - XSConstantMacro.keyStatusFrozen || - keyInfo.keyStatus == - XSConstantMacro.keyStatusExpired)) - ? true - : false, + visible: (keyInfo.keyType == XSConstantMacro.keyTypeTime || + keyInfo.keyType == XSConstantMacro.keyTypeLoop) && + (keyInfo.keyStatus == + XSConstantMacro.keyStatusWaitIneffective || + keyInfo.keyStatus == XSConstantMacro.keyStatusFrozen || + keyInfo.keyStatus == XSConstantMacro.keyStatusExpired), // visible: true, child: Row( - children: [ + children: [ SizedBox(width: 30.w), Container( padding: EdgeInsets.only(right: 5.w, left: 5.w), @@ -257,7 +258,7 @@ class _LockListPageState extends State with RouteAware { )), SizedBox(height: 5.h), Row( - children: [ + children: [ SizedBox(width: 30.w), Text( "${logic.getUseKeyTypeStr(keyInfo.startDate, keyInfo.endDate, keyInfo.keyType)}/${keyInfo.isLockOwner == 1 ? '超级管理员'.tr : (keyInfo.keyRight == 1 ? "授权管理员".tr : "普通用户".tr)}", diff --git a/lib/main/lockMian/lockList/lockList_xhj_page.dart b/lib/main/lockMian/lockList/lockList_xhj_page.dart index 6bdd40b6..54f439e8 100755 --- a/lib/main/lockMian/lockList/lockList_xhj_page.dart +++ b/lib/main/lockMian/lockList/lockList_xhj_page.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_slidable/flutter_slidable.dart'; import 'package:get/get.dart'; -import 'package:star_lock/flavors.dart'; +import 'package:star_lock/main/lockMian/lockList/lockList_state.dart'; import '../../../appRouters.dart'; import '../../../app_settings/app_colors.dart'; @@ -14,87 +14,90 @@ import 'lockListGroup_view.dart'; import 'lockList_logic.dart'; class LockListXHJPage extends StatefulWidget { - final LockListInfoGroupEntity lockListInfoGroupEntity; - const LockListXHJPage({Key? key, required this.lockListInfoGroupEntity}) + const LockListXHJPage({required this.lockListInfoGroupEntity, Key? key}) : super(key: key); + final LockListInfoGroupEntity lockListInfoGroupEntity; @override State createState() => _LockListXHJPageState(); } class _LockListXHJPageState extends State with RouteAware { - final logic = Get.put(LockListLogic()); - final state = Get.find().state; + late LockListLogic logic; + late LockListState state; - var groupDataList = []; + @override + void initState() { + super.initState(); + logic = Get.put(LockListLogic(widget.lockListInfoGroupEntity)); + state = Get.find().state; + } @override Widget build(BuildContext context) { - if (widget.lockListInfoGroupEntity.pageNo == 1) { - groupDataList = []; - } - groupDataList.addAll( - widget.lockListInfoGroupEntity.groupList as Iterable); - return SafeArea( - bottom: false, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Align( - alignment: Alignment.topRight, - child: IconButton( - onPressed: () { - Get.toNamed(Routers.selectLockTypePage); - }, - icon: Icon( - Icons.add_circle, - size: 48.w, - color: AppColors.mainColor, - )), - ), - Padding( - padding: EdgeInsets.only(left: 45.w), - child: Text( - '常用程序'.tr, - style: TextStyle( - fontSize: 32.sp, - color: AppColors.blackColor, - fontWeight: FontWeight.w600, + return GetBuilder(builder: (LockListLogic logic) { + return SafeArea( + bottom: false, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Align( + alignment: Alignment.topRight, + child: IconButton( + onPressed: () { + Get.toNamed(Routers.selectLockTypePage); + }, + icon: Icon( + Icons.add_circle, + size: 48.w, + color: AppColors.mainColor, + )), + ), + Padding( + padding: EdgeInsets.only(left: 45.w), + child: Text( + '常用程序'.tr, + style: TextStyle( + fontSize: 32.sp, + color: AppColors.blackColor, + fontWeight: FontWeight.w600, + ), ), ), - ), - Expanded( - child: ListView.separated( - itemCount: groupDataList.length, - itemBuilder: (context, index) { - GroupList itemData = groupDataList[index]; - return _buildLockExpandedList(context, index, itemData); - }, - shrinkWrap: true, - physics: const AlwaysScrollableScrollPhysics(), - separatorBuilder: (context, index) { - return const Divider( - height: 1, - color: AppColors.greyLineColor, - ); - }), - ), - ], - ), - ); + Expanded( + child: ListView.separated( + itemCount: logic.groupDataList.length, + itemBuilder: (BuildContext context, int index) { + final GroupList itemData = logic.groupDataList[index]; + return _buildLockExpandedList(context, index, itemData); + }, + shrinkWrap: true, + physics: const AlwaysScrollableScrollPhysics(), + separatorBuilder: (BuildContext context, int index) { + return const Divider( + height: 1, + color: AppColors.greyLineColor, + ); + }), + ), + ], + ), + ); + }); } //设备多层级列表 Widget _buildLockExpandedList(context, index, GroupList itemData) { - List lockItemList = itemData.lockList ?? []; + final List lockItemList = + itemData.lockList ?? []; return LockListGroupView( onTap: () { setState(() {}); }, textStyle: TextStyle(fontSize: 28.sp, fontWeight: FontWeight.w600), backgroundColor: Colors.transparent, - typeImgList: const [], + typeImgList: const [], groupItem: itemData, child: GridView.extent( padding: EdgeInsets.symmetric(vertical: 15.h, horizontal: 15.w), @@ -109,9 +112,9 @@ class _LockListXHJPageState extends State with RouteAware { } List forItems(List lockItemList) { - List list = []; + final List list = []; for (int i = 0, j = 0; i < lockItemList.length; i++, j++) { - LockListInfoItemEntity keyInfo = lockItemList[i]; + final LockListInfoItemEntity keyInfo = lockItemList[i]; bool isLast = false; if (lockItemList.length == i + 1) { isLast = true; @@ -121,7 +124,7 @@ class _LockListXHJPageState extends State with RouteAware { endActionPane: ActionPane( extentRatio: 0.2, motion: const ScrollMotion(), - children: [ + children: [ SlidableAction( onPressed: (BuildContext context) { state.lockListInfoItemEntity = keyInfo; @@ -153,7 +156,7 @@ class _LockListXHJPageState extends State with RouteAware { logic.showToast("您的钥匙已过期".tr); return; } - Get.toNamed(Routers.lockDetailMainPage, arguments: { + Get.toNamed(Routers.lockDetailMainPage, arguments: { "keyInfo": keyInfo, "isOnlyOneData": false, }); @@ -189,9 +192,9 @@ class _LockListXHJPageState extends State with RouteAware { child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ Row( - children: [ + children: [ Image.asset( 'images/icon_lock_circle.png', width: 32.r, @@ -218,7 +221,7 @@ class _LockListXHJPageState extends State with RouteAware { child: Padding( padding: EdgeInsets.only(top: 5.h), child: Row( - children: [ + children: [ Container( padding: EdgeInsets.only(right: 5.w, left: 5.w), decoration: BoxDecoration( @@ -239,7 +242,7 @@ class _LockListXHJPageState extends State with RouteAware { child: Padding( padding: EdgeInsets.only(top: 5.h), child: Row( - children: [ + children: [ Text( "远程开锁".tr, style: TextStyle( @@ -263,7 +266,7 @@ class _LockListXHJPageState extends State with RouteAware { child: Padding( padding: EdgeInsets.only(top: 20.h), child: Row( - children: [ + children: [ Container( padding: EdgeInsets.only(right: 5.w, left: 5.w), decoration: BoxDecoration( @@ -284,7 +287,7 @@ class _LockListXHJPageState extends State with RouteAware { )), SizedBox(height: 5.h), Row( - children: [ + children: [ Expanded( child: Text( keyInfo.isLockOwner == 1 diff --git a/lib/main/lockMian/lockMain/lockMain_logic.dart b/lib/main/lockMian/lockMain/lockMain_logic.dart index af2032bf..50c0c767 100755 --- a/lib/main/lockMian/lockMain/lockMain_logic.dart +++ b/lib/main/lockMian/lockMain/lockMain_logic.dart @@ -1,7 +1,7 @@ - import 'dart:async'; import 'package:connectivity_plus/connectivity_plus.dart'; import 'package:get/get.dart'; +import 'package:star_lock/main/lockMian/lockList/lockList_logic.dart'; import '../../../app_settings/app_settings.dart'; import '../../../blue/blue_manage.dart'; @@ -15,7 +15,8 @@ import 'lockMain_state.dart'; class LockMainLogic extends BaseGetXController { final LockMainState state = LockMainState(); - Future getStarLockInfo({bool isUnShowLoading = false}) async { + Future getStarLockInfo( + {bool isUnShowLoading = false}) async { LockListInfoEntity entity = await ApiRepository.to.getStarLockListInfo( pageNo: pageNo, pageSize: 50, @@ -35,11 +36,11 @@ class LockMainLogic extends BaseGetXController { return entity; } - Future loadMainDataLogic(LockListInfoGroupEntity entity){ + void loadMainDataLogic(LockListInfoGroupEntity entity) { if (entity.groupList!.isEmpty) { state.dataLength.value = 0; } else if (entity.groupList!.length == 1) { - GroupList groupList = entity.groupList![0]; + final GroupList groupList = entity.groupList![0]; if (groupList.lockList!.length > 1) { state.dataLength.value = 2; } else { @@ -49,7 +50,11 @@ class LockMainLogic extends BaseGetXController { state.dataLength.value = 2; } state.lockListInfoGroupEntity.value = entity; - return Future.value(); + //检测控制器是否存在 + if (Get.isRegistered()) { + //设置控制器数据并刷新 + Get.find().setLockListInfoGroupEntity(entity); + } } /// 获取联网类型 @@ -81,7 +86,8 @@ class LockMainLogic extends BaseGetXController { connectListener() async { Connectivity().onConnectivityChanged.listen((ConnectivityResult result) { AppLog.log("设置网络切换监听:$result"); - if (state.networkConnectionStatus.value == 0 && result != ConnectivityResult.none) { + if (state.networkConnectionStatus.value == 0 && + result != ConnectivityResult.none) { // 从无网络到有网络 state.networkConnectionStatus.value = 1; getStarLockInfo(); diff --git a/lib/main/lockMian/lockMain/lockMain_page.dart b/lib/main/lockMian/lockMain/lockMain_page.dart index d8d7b3cb..43ec0957 100755 --- a/lib/main/lockMian/lockMain/lockMain_page.dart +++ b/lib/main/lockMian/lockMain/lockMain_page.dart @@ -43,7 +43,7 @@ class _StarLockMainPageState extends State with BaseWidget { await Storage.getLockMainListData(); if (lockListInfoGroupEntity != null) { var localLockListInfoGroupEntity = lockListInfoGroupEntity; - await logic.loadMainDataLogic(localLockListInfoGroupEntity); + logic.loadMainDataLogic(localLockListInfoGroupEntity); } await logic.getStarLockInfo(isUnShowLoading: isUnShowLoading); await Future.delayed(const Duration(milliseconds: 200)); diff --git a/lib/mine/addLock/nearbyLock/nearbyLock_logic.dart b/lib/mine/addLock/nearbyLock/nearbyLock_logic.dart index f703e39a..cd8e1f3a 100755 --- a/lib/mine/addLock/nearbyLock/nearbyLock_logic.dart +++ b/lib/mine/addLock/nearbyLock/nearbyLock_logic.dart @@ -43,7 +43,7 @@ class NearbyLockLogic extends BaseGetXController { // 点击连接设备 void connect(String deviceName) { - showTitleEasyLoading("获取锁信息 1/3"); + showTitleEasyLoading('获取锁信息 1/3'); // if(state.sureBtnState.value == 1){ // return; // } @@ -56,9 +56,9 @@ class NearbyLockLogic extends BaseGetXController { }); BlueManage().blueSendData(deviceName, (BluetoothConnectionState state) async { - AppLog.log("点击要添加的设备了"); + AppLog.log('点击要添加的设备了'); if (state == BluetoothConnectionState.connected) { - AppLog.log("开始获取公钥"); + AppLog.log('开始获取公钥'); IoSenderManage.getPublicKey(lockId: deviceName); } else if (state == BluetoothConnectionState.disconnected) { dismissEasyLoading(); @@ -108,18 +108,18 @@ class NearbyLockLogic extends BaseGetXController { switch (reply.status) { case 0x00: //成功 - AppLog.log("获取公钥成功"); + AppLog.log('获取公钥成功'); // 储存公钥 var publicKey = reply.data.sublist(3); var saveStrList = changeIntListToStringList(publicKey); Storage.setStringList(saveBluePublicKey, saveStrList); // 获取私钥 - AppLog.log("开始获取私钥"); - showTitleEasyLoading("获取锁信息 2/3"); + AppLog.log('开始获取私钥'); + showTitleEasyLoading('获取锁信息 2/3'); IoSenderManage.getPrivateKey( lockId: BlueManage().connectDeviceName, - keyID: "1", + keyID: '1', authUserID: await Storage.getUid(), nowTime: DateTime.now().millisecondsSinceEpoch ~/ 1000, publicKeyData: publicKey, @@ -127,7 +127,7 @@ class NearbyLockLogic extends BaseGetXController { break; default: // state.sureBtnState.value = 0; - AppLog.log("获取公钥失败"); + AppLog.log('获取公钥失败'); break; } } @@ -135,7 +135,7 @@ class NearbyLockLogic extends BaseGetXController { Future _replyGetPrivateKeyKey(Reply reply) async { switch (reply.status) { case 0x00: - AppLog.log("获取私钥成功"); + AppLog.log('获取私钥成功'); //成功 reply.data.removeAt(0); @@ -156,7 +156,7 @@ class NearbyLockLogic extends BaseGetXController { (0xff & timestamp[2]) << 8 | (0xFF & timestamp[3])); - showTitleEasyLoading("获取锁信息 3/3"); + showTitleEasyLoading('获取锁信息 3/3'); _getStarLockStatus(); break; default: @@ -171,83 +171,83 @@ class NearbyLockLogic extends BaseGetXController { switch (status) { case 0x00: //成功 - AppLog.log("获取锁状态成功"); + AppLog.log('获取锁状态成功'); // 厂商名称 var index = 3; var vendor = reply.data.sublist(index, index + 20); var vendorStr = utf8String(vendor); - state.lockInfo["vendor"] = vendorStr; + state.lockInfo['vendor'] = vendorStr; // state.lockInfo["vendor"] = "XL"; index = index + 20; - AppLog.log("厂商名称 vendorStr:$vendorStr"); + AppLog.log('厂商名称 vendorStr:$vendorStr'); // 锁设备类型 var product = reply.data[index]; - state.lockInfo["product"] = product; + state.lockInfo['product'] = product; index = index + 1; - AppLog.log("锁设备类型 product:$product"); + AppLog.log('锁设备类型 product:$product'); // 产品名称 var model = reply.data.sublist(index, index + 20); var modelStr = utf8String(model); - state.lockInfo["model"] = modelStr; + state.lockInfo['model'] = modelStr; // state.lockInfo["model"] = "JL-BLE-01"; index = index + 20; - AppLog.log("产品名称 mmodelStr:$modelStr"); + AppLog.log('产品名称 mmodelStr:$modelStr'); // 软件版本 var fwVersion = reply.data.sublist(index, index+20); var fwVersionStr = utf8String(fwVersion); - state.lockInfo["fwVersion"] = fwVersionStr; + state.lockInfo['fwVersion'] = fwVersionStr; index = index + 20; - AppLog.log("软件版本 fwVersionStr:$fwVersionStr"); + AppLog.log('软件版本 fwVersionStr:$fwVersionStr'); // 硬件版本 var hwVersion = reply.data.sublist(index, index+20); var hwVersionStr = utf8String(hwVersion); - state.lockInfo["hwVersion"] = hwVersionStr; + state.lockInfo['hwVersion'] = hwVersionStr; index = index + 20; - AppLog.log("硬件版本 hwVersionStr:$hwVersionStr"); + AppLog.log('硬件版本 hwVersionStr:$hwVersionStr'); // 厂商序列号 var serialNum0 = reply.data.sublist(index, index + 16); var serialNum0Str = utf8String(serialNum0); - state.lockInfo["serialNum0"] = serialNum0Str; + state.lockInfo['serialNum0'] = serialNum0Str; // state.lockInfo["serialNum0"] = "${DateTime.now().millisecondsSinceEpoch ~/ 10}"; index = index + 16; - AppLog.log("厂商序列号 serialNum0Str:${serialNum0Str.length}"); + AppLog.log('厂商序列号 serialNum0Str:${serialNum0Str.length}'); // 成品商序列号 var serialNum1 = reply.data.sublist(index, index + 16); var serialNum1Str = utf8String(serialNum1); - state.lockInfo["serialNum1"] = serialNum1Str; + state.lockInfo['serialNum1'] = serialNum1Str; index = index + 16; - AppLog.log("成品商序列号 serialNum1Str:$serialNum1Str"); + AppLog.log('成品商序列号 serialNum1Str:$serialNum1Str'); // 蓝牙名称 var btDeviceName = reply.data.sublist(index, index + 16); var btDeviceNameStr = utf8String(btDeviceName); - state.lockInfo["btDeviceName"] = btDeviceNameStr; + state.lockInfo['btDeviceName'] = btDeviceNameStr; index = index + 16; - AppLog.log("蓝牙名称 btDeviceNameStr:$btDeviceNameStr"); + AppLog.log('蓝牙名称 btDeviceNameStr:$btDeviceNameStr'); // 电池剩余电量 var battRemCap = reply.data[index]; - state.lockInfo["electricQuantity"] = battRemCap; + state.lockInfo['electricQuantity'] = battRemCap; index = index + 1; - AppLog.log("电池剩余电量 battRemCap:$battRemCap"); + AppLog.log('电池剩余电量 battRemCap:$battRemCap'); // 备用电池剩余电量 var battRemCapStandby = reply.data[index]; - state.lockInfo["electricQuantityStandby"] = battRemCapStandby; + state.lockInfo['electricQuantityStandby'] = battRemCapStandby; index = index + 1; - AppLog.log("电池剩余电量 battRemCap:$battRemCap"); + AppLog.log('电池剩余电量 battRemCap:$battRemCap'); // 重置次数 var restoreCounter = reply.data.sublist(index, index + 2); - state.lockInfo["restoreCount"] = restoreCounter[0] * 256 + restoreCounter[1]; + state.lockInfo['restoreCount'] = restoreCounter[0] * 256 + restoreCounter[1]; index = index + 2; - AppLog.log("重置次数 restoreCounter:${restoreCounter[0] * 256 + restoreCounter[1]}"); + AppLog.log('重置次数 restoreCounter:${restoreCounter[0] * 256 + restoreCounter[1]}'); // 重置时间 var restoreDate = reply.data.sublist(index, index + 4); @@ -256,16 +256,16 @@ class NearbyLockLogic extends BaseGetXController { (0xff & restoreDate[2]) << 8 | (0xFF & restoreDate[3])); // String restoreDateStr = DateTool().dateToYMDHNSString(restoreDateValue.toString()); - state.lockInfo["restoreDate"] = restoreDateValue * 1000; + state.lockInfo['restoreDate'] = restoreDateValue * 1000; index = index + 4; - AppLog.log("重置时间 restoreDateValue:$restoreDateValue"); + AppLog.log('重置时间 restoreDateValue:$restoreDateValue'); // 主控芯片型号 var icPartNo = reply.data.sublist(index, index + 10); var icPartNoStr = utf8String(icPartNo); - state.lockInfo["icPartNo"] = icPartNoStr; + state.lockInfo['icPartNo'] = icPartNoStr; index = index + 10; - AppLog.log("主控芯片型号 icPartNoStr:$icPartNoStr"); + AppLog.log('主控芯片型号 icPartNoStr:$icPartNoStr'); // 有效时间 var indate = reply.data.sublist(index, index + 4); @@ -274,27 +274,27 @@ class NearbyLockLogic extends BaseGetXController { (0xff & indate[2]) << 8 | (0xFF & indate[3])); // String indateStr = DateTool().dateToYMDHNSString("$indateValue"); - state.lockInfo["indate"] = indateValue * 1000; + state.lockInfo['indate'] = indateValue * 1000; index = index + 4; - AppLog.log("有效时间 indateValue:$indateValue"); + AppLog.log('有效时间 indateValue:$indateValue'); // mac地址 var macAddress = reply.data.sublist(index, index + 20); var macAddressStr = utf8String(macAddress); - state.lockInfo["mac"] = macAddressStr; + state.lockInfo['mac'] = macAddressStr; index = index + 20; - AppLog.log("mac地址 macAddressStr:$macAddressStr"); + AppLog.log('mac地址 macAddressStr:$macAddressStr'); // 锁特征值字符串长度 var featureValueLength = reply.data[index]; index = index + 1; - AppLog.log("锁特征值字符串长度 featureValueLength:$featureValueLength"); + AppLog.log('锁特征值字符串长度 featureValueLength:$featureValueLength'); // 锁特征值说明(本机能支持的功能) // 获取到锁给的字符数组 var featureNetxLength = index + featureValueLength; if (reply.data.length < featureNetxLength) { - showToast("锁数据异常,请重试"); + showToast('锁数据异常,请重试'); return; } var featureValue = reply.data.sublist(index, index + featureValueLength); @@ -303,17 +303,17 @@ class NearbyLockLogic extends BaseGetXController { // List allFeatureValueTwoList = charListChangeIntList(featureValue); // AppLog.log("featureValueLength:$featureValueLength featureValue:$featureValue \n featureValueStr:$featureValueStr"); index = index + featureValueLength; - AppLog.log("锁特征值字符串 featureValueStr:$featureValueStr"); + AppLog.log('锁特征值字符串 featureValueStr:$featureValueStr'); // 使能特征值字符串长度 var featureEnValLength = reply.data[index]; index = index + 1; - AppLog.log("使能特征值字符串长度 featureEnValLength:$featureEnValLength"); + AppLog.log('使能特征值字符串长度 featureEnValLength:$featureEnValLength'); // 使能锁特征值说明(本机启用的功能) var featureEnNextLength = index + featureEnValLength; if (reply.data.length < featureEnNextLength) { - showToast("锁数据异常,请重试"); + showToast('锁数据异常,请重试'); return; } var featureEnVal = reply.data.sublist(index, index + featureEnValLength); @@ -322,21 +322,21 @@ class NearbyLockLogic extends BaseGetXController { // List allFeatureEnValTwoList = charListChangeIntList(featureEnVal); // AppLog.log("featureEnValLength:$featureEnValLength featureEnVal:$featureEnVal \n featureEnValStr:$featureEnValStr"); index = index + featureEnValLength; - AppLog.log("使能锁特征值说明 featureEnValStr:$featureEnValStr"); + AppLog.log('使能锁特征值说明 featureEnValStr:$featureEnValStr'); // 支持的带参数特征值的总条目数 // var featureParaTotal = reply.data[index]; var featureParaTotalList = reply.data.sublist(index); state.featureSettingParams = featureParaTotalList; - AppLog.log("featureParaTotalList:$featureParaTotalList"); + AppLog.log('featureParaTotalList:$featureParaTotalList'); Get.toNamed(Routers.lockAddressGaoDePage, arguments: { - "pwdTimestamp": state.timestampValue * 1000, - "lockInfo": state.lockInfo, - "featureValue": state.featureValue, - "featureSettingValue": state.featureSettingValue, - "featureSettingParams": state.featureSettingParams, + 'pwdTimestamp': state.timestampValue * 1000, + 'lockInfo': state.lockInfo, + 'featureValue': state.featureValue, + 'featureSettingValue': state.featureSettingValue, + 'featureSettingParams': state.featureSettingParams, }); break; @@ -372,7 +372,7 @@ class NearbyLockLogic extends BaseGetXController { // if (state == BluetoothConnectionState.connected) { // dismissEasyLoading(); - AppLog.log("开始获取锁状态"); + AppLog.log('开始获取锁状态'); var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); @@ -397,9 +397,9 @@ class NearbyLockLogic extends BaseGetXController { ScanResult device = list[i]; if (((device.advertisementData.serviceUuids.isNotEmpty ? device.advertisementData.serviceUuids[0] - : "") + : '') .toString()[31] != - "1")) { + '1')) { state.devices.add(list[i]); } } @@ -413,17 +413,17 @@ class NearbyLockLogic extends BaseGetXController { // 点击连接设备,升级 ota 固件 void oTAUpgrade(String deviceName) { - showTitleEasyLoading("连接设备中..."); + showTitleEasyLoading('连接设备中...'); this.deviceName = deviceName; BlueManage().blueSendData(deviceName, (BluetoothConnectionState state) async { - AppLog.log("连接设备"); + AppLog.log('连接设备'); if (state == BluetoothConnectionState.connected) { - AppLog.log("连接成功"); + AppLog.log('连接成功'); dismissEasyLoading(); otaUpdate(); } else if (state == BluetoothConnectionState.disconnected) { - AppLog.log("连接失败"); + AppLog.log('连接失败'); dismissEasyLoading(); } }, isAddEquipment: true); From a914df7c1be57391bf90d6948256700db3cf4a2d Mon Sep 17 00:00:00 2001 From: anfe <448468458@qq.com> Date: Wed, 22 May 2024 17:38:42 +0800 Subject: [PATCH 43/44] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E9=A6=96=E6=AC=A1?= =?UTF-8?q?=E8=BF=9B=E5=85=A5=E5=88=97=E8=A1=A8=E4=B8=8D=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E9=94=81=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/main/lockMian/lockList/lockList_logic.dart | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/main/lockMian/lockList/lockList_logic.dart b/lib/main/lockMian/lockList/lockList_logic.dart index 49a87d25..14b08463 100755 --- a/lib/main/lockMian/lockList/lockList_logic.dart +++ b/lib/main/lockMian/lockList/lockList_logic.dart @@ -23,7 +23,8 @@ import '../entity/lockListInfo_entity.dart'; import 'lockList_state.dart'; class LockListLogic extends BaseGetXController { - LockListLogic(this.entity); + LockListLogic(this.entity){ + } LockListState state = LockListState(); List groupDataList = []; @@ -277,6 +278,12 @@ class LockListLogic extends BaseGetXController { _initReplySubscription(); } + @override + void onInit() { + super.onInit(); + setLockListInfoGroupEntity(entity!); + } + @override void onClose() { _replySubscription.cancel(); From dd8d56c012c6306caae133b2d066bdbb9f0784eb Mon Sep 17 00:00:00 2001 From: Daisy <> Date: Wed, 22 May 2024 17:49:34 +0800 Subject: [PATCH 44/44] =?UTF-8?q?1=EF=BC=8C=E6=88=91=E7=9A=84=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE--=E6=8E=88=E6=9D=83=E7=AE=A1=E7=90=86=E5=91=98?= =?UTF-8?q?=E5=85=B3=E8=81=94=E7=9A=84=E9=94=81=E6=8E=A5=E5=8F=A3=E5=AF=B9?= =?UTF-8?q?=E6=8E=A5=202=EF=BC=8C=E6=B2=A1=E6=9C=89=E9=94=81=E4=B9=9F?= =?UTF-8?q?=E5=8F=AF=E5=BC=80=E9=80=9A=E9=AB=98=E7=BA=A7=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E6=9D=83=E9=99=90=E6=94=BE=E5=BC=80=203=EF=BC=8C=E4=BF=AE?= =?UTF-8?q?=E5=A4=8DN=E5=A4=A9=E6=9C=AA=E5=BC=80=E9=97=A8=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=E9=A1=B5=E9=9D=A2=E9=BB=98=E8=AE=A4=E5=A4=A9=E6=95=B0?= =?UTF-8?q?=E6=8A=A5=E9=94=99=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../massSendLockGroupCell.dart | 23 +++-- .../massSendLockGroupList_logic.dart | 2 +- .../massSendLockGroupList_page.dart | 16 ++-- .../coerceFingerprintList_logic.dart | 13 +-- .../coerceFingerprintList_page.dart | 23 ++--- .../nDaysUnopened/nDaysUnopened_state.dart | 6 +- lib/mine/mine/starLockMine_page.dart | 14 +-- .../administratorAssociationLock_entity.dart | 85 +++++++++++++++++++ .../administratorAssociationLock_logic.dart | 8 +- .../administratorAssociationLock_page.dart | 51 ++++------- .../valueAddedServicesList_page.dart | 12 +-- lib/network/api_repository.dart | 5 +- 12 files changed, 168 insertions(+), 90 deletions(-) create mode 100644 lib/mine/mineSet/authorizedAdministrator/administratorAssociationLock/administratorAssociationLock_entity.dart diff --git a/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupCell.dart b/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupCell.dart index 5115cfa7..5bab6e32 100755 --- a/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupCell.dart +++ b/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupCell.dart @@ -6,27 +6,26 @@ import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/ma typedef _CallBack = void Function(int selectIndex, String selectLockId); class massSendLockGroupCell extends StatelessWidget { + massSendLockGroupCell(int index, + {required this.currentIndex, + required this.lockListByGroup, + required this.selectLockAction, + required this.isVip, + Key? key}) + : super(key: key); final int currentIndex; List lockListByGroup; final _CallBack selectLockAction; bool isVip; - massSendLockGroupCell(int index, - {Key? key, - required this.currentIndex, - required this.lockListByGroup, - required this.selectLockAction, - required this.isVip}) - : super(key: key); - @override Widget build(BuildContext context) { return ListView.separated( physics: const NeverScrollableScrollPhysics(), shrinkWrap: true, itemCount: lockListByGroup.length, - itemBuilder: (_, itemIndex) { - LockListItem itemData = lockListByGroup[itemIndex]; + itemBuilder: (_, int itemIndex) { + final LockListItem itemData = lockListByGroup[itemIndex]; return _itemBuilder(itemData, itemIndex); }, separatorBuilder: (BuildContext context, int index) { @@ -68,8 +67,8 @@ class massSendLockGroupCell extends StatelessWidget { )), Image.asset( itemData.isChecked - ? "images/icon_round_select.png" - : "images/icon_round_unSelect.png", + ? 'images/icon_round_select.png' + : 'images/icon_round_unSelect.png', width: 30.w, height: 30.w, color: !isVip ? Colors.grey : AppColors.mainColor, diff --git a/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupList_logic.dart b/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupList_logic.dart index 1f916225..ef401d4e 100755 --- a/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupList_logic.dart +++ b/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupList_logic.dart @@ -9,7 +9,7 @@ class MassSendLockGroupListLogic extends BaseGetXController { //分组列表请求 Future mockNetworkDataRequest() async { - MassSendLockGroupListEntity entity = + final MassSendLockGroupListEntity entity = await ApiRepository.to.lockGroupList(state.keyLimits); if (entity.errorCode!.codeIsSuccessful) { if (entity.data != null) { diff --git a/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupList_page.dart b/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupList_page.dart index 85040399..1dca45df 100755 --- a/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupList_page.dart +++ b/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupList_page.dart @@ -1,11 +1,11 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; -import 'package:star_lock/appRouters.dart'; import 'package:star_lock/app_settings/app_colors.dart'; import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupCell.dart'; import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupListEntity.dart'; import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupList_logic.dart'; +import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupList_state.dart'; import 'package:star_lock/tools/ExpandedListView.dart'; import 'package:star_lock/tools/showCupertinoAlertView.dart'; import 'package:star_lock/tools/submitBtn.dart'; @@ -21,8 +21,10 @@ class MassSendLockGroupListPage extends StatefulWidget { } class _MassSendLockGroupListPageState extends State { - final logic = Get.put(MassSendLockGroupListLogic()); - final state = Get.find().state; + final MassSendLockGroupListLogic logic = + Get.put(MassSendLockGroupListLogic()); + final MassSendLockGroupListState state = + Get.find().state; @override initState() { @@ -77,7 +79,7 @@ class _MassSendLockGroupListPageState extends State { child: SubmitBtn( btnName: '确定'.tr, onClick: () { - Map resultMap = {}; + final Map resultMap = {}; resultMap['selectLockIdList'] = state.selectLockIdList.value; Navigator.pop(context, resultMap); @@ -94,12 +96,12 @@ class _MassSendLockGroupListPageState extends State { Widget _buildListView(BuildContext context, List itemList) { return ListView.separated( itemCount: itemList.length, - itemBuilder: (context, index) { - GroupListItem itemData = itemList[index]; + itemBuilder: (BuildContext context, int index) { + final GroupListItem itemData = itemList[index]; return _buildLockExpandedList(context, index, itemData); }, shrinkWrap: true, - separatorBuilder: (context, index) { + separatorBuilder: (BuildContext context, index) { return const Divider( height: 1, color: AppColors.greyLineColor, diff --git a/lib/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceFingerprintList/coerceFingerprintList_logic.dart b/lib/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceFingerprintList/coerceFingerprintList_logic.dart index 4a17b077..6b8b90c6 100755 --- a/lib/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceFingerprintList/coerceFingerprintList_logic.dart +++ b/lib/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceFingerprintList/coerceFingerprintList_logic.dart @@ -9,8 +9,9 @@ class CoerceFingerprintListLogic extends BaseGetXController { final CoerceFingerprintListState state = CoerceFingerprintListState(); // 锁用户列表 - void getCoercedFingerprintList() async { - var entity = await ApiRepository.to.getCoercedFingerprintList( + Future getCoercedFingerprintList() async { + final CoerceFingerprintListEntity entity = + await ApiRepository.to.getCoercedFingerprintList( lockId: state.getLockId.value, pageNo: state.pageNum.value, pageSize: state.pageSize.value, @@ -24,15 +25,15 @@ class CoerceFingerprintListLogic extends BaseGetXController { //获取指纹有效期 String getfingerprintUseDateStr( CoerceFingerprintItemData fingerprintItemData) { - var keyDateTypeStr = ""; // 永久:1;限时2,单次3,循环:4 + var keyDateTypeStr = ''; // 永久:1;限时2,单次3,循环:4 if (fingerprintItemData.fingerprintType! == 1) { - keyDateTypeStr = "永久".tr; + keyDateTypeStr = '永久'.tr; } else if (fingerprintItemData.fingerprintType! == 2) { keyDateTypeStr = - "${DateTool().dateToYMDHNString(fingerprintItemData.startDate.toString())} - ${DateTool().dateToYMDHNString(fingerprintItemData.endDate.toString())} 限时"; + '${DateTool().dateToYMDHNString(fingerprintItemData.startDate.toString())} - ${DateTool().dateToYMDHNString(fingerprintItemData.endDate.toString())} 限时'; } else if (fingerprintItemData.fingerprintType! == 4) { keyDateTypeStr = - "${DateTool().dateToYMDString(fingerprintItemData.startDate.toString())}-${DateTool().dateToYMDString(fingerprintItemData.endDate.toString())} 循环"; + '${DateTool().dateToYMDString(fingerprintItemData.startDate.toString())}-${DateTool().dateToYMDString(fingerprintItemData.endDate.toString())} 循环'; } return keyDateTypeStr; } diff --git a/lib/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceFingerprintList/coerceFingerprintList_page.dart b/lib/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceFingerprintList/coerceFingerprintList_page.dart index dc1e5d52..a5d67930 100755 --- a/lib/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceFingerprintList/coerceFingerprintList_page.dart +++ b/lib/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceFingerprintList/coerceFingerprintList_page.dart @@ -3,6 +3,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceFingerprintList/coerceFingerprintList_entity.dart'; import 'package:star_lock/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceFingerprintList/coerceFingerprintList_logic.dart'; +import 'package:star_lock/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceFingerprintList/coerceFingerprintList_state.dart'; import 'package:star_lock/tools/keySearchWidget.dart'; import '../../../../../../app_settings/app_colors.dart'; @@ -18,8 +19,10 @@ class CoerceFingerprintListPage extends StatefulWidget { } class _CoerceFingerprintListPageState extends State { - final logic = Get.put(CoerceFingerprintListLogic()); - final state = Get.find().state; + final CoerceFingerprintListLogic logic = + Get.put(CoerceFingerprintListLogic()); + final CoerceFingerprintListState state = + Get.find().state; @override initState() { @@ -37,7 +40,7 @@ class _CoerceFingerprintListPageState extends State { backgroundColor: AppColors.mainColor, ), body: Column( - children: [ + children: [ KeySearchWidget( editingController: state.searchController, onSubmittedAction: () { @@ -48,7 +51,7 @@ class _CoerceFingerprintListPageState extends State { SizedBox( height: 20.h, ), - Expanded(child: Obx(() => _buildMainUI())), + Expanded(child: Obx(_buildMainUI)), SubmitBtn( btnName: '确定'.tr, onClick: () { @@ -68,7 +71,7 @@ class _CoerceFingerprintListPageState extends State { return ListView.separated( shrinkWrap: true, itemCount: state.fingerprintList.length, - itemBuilder: (c, index) { + itemBuilder: (BuildContext c, int index) { return _electronicKeyItem(state.fingerprintList[index], index); }, separatorBuilder: (BuildContext context, int index) { @@ -85,7 +88,7 @@ class _CoerceFingerprintListPageState extends State { return GestureDetector( onTap: () { for (int i = 0; i < state.fingerprintList.value.length; i++) { - CoerceFingerprintItemData item = state.fingerprintList.value[i]; + final CoerceFingerprintItemData item = state.fingerprintList.value[i]; if (selectIndex == i) { item.isCurrentSelect = true; } else { @@ -100,7 +103,7 @@ class _CoerceFingerprintListPageState extends State { color: Colors.white, height: 90.h, child: Row( - children: [ + children: [ SizedBox( width: 30.w, ), @@ -115,9 +118,9 @@ class _CoerceFingerprintListPageState extends State { Expanded( child: Column( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ Row( - children: [ + children: [ Text( itemData.fingerprintName ?? '', style: TextStyle( @@ -133,7 +136,7 @@ class _CoerceFingerprintListPageState extends State { SizedBox(height: 10.h), Row( mainAxisAlignment: MainAxisAlignment.start, - children: [ + children: [ Text( logic.getfingerprintUseDateStr(itemData), style: TextStyle( diff --git a/lib/main/lockDetail/messageWarn/msgNotification/nDaysUnopened/nDaysUnopened_state.dart b/lib/main/lockDetail/messageWarn/msgNotification/nDaysUnopened/nDaysUnopened_state.dart index 607280bf..be246bdf 100755 --- a/lib/main/lockDetail/messageWarn/msgNotification/nDaysUnopened/nDaysUnopened_state.dart +++ b/lib/main/lockDetail/messageWarn/msgNotification/nDaysUnopened/nDaysUnopened_state.dart @@ -22,7 +22,7 @@ class NDaysUnopenedState { ]; var isUnOpenNotice = false.obs; // 是否N天未开门提醒 - var unOpenDoorTime = 1.obs; // 未开门时间 + var unOpenDoorTime = 3.obs; // 未开门时间 var getLockId = 0.obs; var lockUserKeys = LockUserListKeys().obs; @@ -43,7 +43,9 @@ class NDaysUnopenedState { msgNoticeInfo.value = map['lockSetInfoData']; isUnOpenNotice.value = msgNoticeInfo.value.dayNotOpenDoorState == 1 ? true : false; - unOpenDoorTime.value = msgNoticeInfo.value.dayNotOpenDoorValue!; + if (msgNoticeInfo.value.dayNotOpenDoorValue != 0) { + unOpenDoorTime.value = msgNoticeInfo.value.dayNotOpenDoorValue!; + } } } } diff --git a/lib/mine/mine/starLockMine_page.dart b/lib/mine/mine/starLockMine_page.dart index 0b5240a6..f1fe3ad8 100755 --- a/lib/mine/mine/starLockMine_page.dart +++ b/lib/mine/mine/starLockMine_page.dart @@ -93,13 +93,13 @@ class StarLockMinePageState extends State with BaseWidget { Obx(() => GestureDetector( onTap: () { if (!state.isVip.value) { - if (CommonDataManage().currentKeyInfo.isLockOwner != - 1) { - logic.showToast('请先添加锁'); - } else { - Get.toNamed(Routers.advancedFeaturesWebPage, - arguments: {'isShop': true}); - } + // if (CommonDataManage().currentKeyInfo.isLockOwner != + // 1) { + // logic.showToast('请先添加锁'); + // } else { + Get.toNamed(Routers.advancedFeaturesWebPage, + arguments: {'isShop': true}); + // } } else { Get.toNamed( Routers.valueAddedServicesHighFunctionPage); diff --git a/lib/mine/mineSet/authorizedAdministrator/administratorAssociationLock/administratorAssociationLock_entity.dart b/lib/mine/mineSet/authorizedAdministrator/administratorAssociationLock/administratorAssociationLock_entity.dart new file mode 100644 index 00000000..1dacb9a4 --- /dev/null +++ b/lib/mine/mineSet/authorizedAdministrator/administratorAssociationLock/administratorAssociationLock_entity.dart @@ -0,0 +1,85 @@ +import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupListEntity.dart'; + +class AdministratorAssociationLockEntity { + AdministratorAssociationLockEntity( + {this.errorCode, this.description, this.errorMsg, this.data}); + + AdministratorAssociationLockEntity.fromJson(Map json) { + errorCode = json['errorCode']; + description = json['description']; + errorMsg = json['errorMsg']; + if (json['data'] != null) { + data = []; + json['data'].forEach((v) { + data!.add(GroupListItemData.fromJson(v)); + }); + } + } + int? errorCode; + String? description; + String? errorMsg; + List? data; + + Map toJson() { + final Map data = {}; + data['errorCode'] = errorCode; + data['description'] = description; + data['errorMsg'] = errorMsg; + if (this.data != null) { + data['data'] = + this.data!.map((GroupListItemData v) => v.toJson()).toList(); + } + return data; + } +} + +class GroupListItemData { + GroupListItemData( + {this.uid, this.groupName, this.groupType, this.groupId, this.lockList}); + GroupListItemData.fromJson(Map json) { + uid = json['uid']; + groupName = json['groupName']; + groupType = json['groupType']; + groupId = json['groupId']; + if (json['lockList'] != null) { + lockList = []; + json['lockList'].forEach((v) { + lockList!.add(LockListItem.fromJson(v)); + }); + } + } + int? uid; + String? groupName; + int? groupType; + int? groupId; + List? lockList; + + Map toJson() { + final Map data = {}; + data['uid'] = uid; + data['groupName'] = groupName; + data['groupType'] = groupType; + data['groupId'] = groupId; + if (lockList != null) { + data['lockList'] = lockList!.map((LockListItem v) => v.toJson()).toList(); + } + return data; + } +} + +// class LockListItemData { +// LockListItemData({this.lockId, this.lockAlias}); +// LockListItemData.fromJson(Map json) { +// lockId = json['lockId']; +// lockAlias = json['lockAlias']; +// } +// int? lockId; +// String? lockAlias; + +// Map toJson() { +// final Map data = {}; +// data['lockId'] = lockId; +// data['lockAlias'] = lockAlias; +// return data; +// } +// } diff --git a/lib/mine/mineSet/authorizedAdministrator/administratorAssociationLock/administratorAssociationLock_logic.dart b/lib/mine/mineSet/authorizedAdministrator/administratorAssociationLock/administratorAssociationLock_logic.dart index 09e42583..063af209 100644 --- a/lib/mine/mineSet/authorizedAdministrator/administratorAssociationLock/administratorAssociationLock_logic.dart +++ b/lib/mine/mineSet/authorizedAdministrator/administratorAssociationLock/administratorAssociationLock_logic.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; -import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:get/get.dart'; +import 'package:star_lock/mine/mineSet/authorizedAdministrator/administratorAssociationLock/administratorAssociationLock_entity.dart'; import 'package:star_lock/mine/mineSet/authorizedAdministrator/administratorAssociationLock/administratorAssociationLock_state.dart'; import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/tools/baseGetXController.dart'; @@ -11,11 +11,13 @@ class AdministratorAssociationLockLogic extends BaseGetXController { //获取授权管理员下锁列表 Future administratorOwnLockListRequest() async { - var entity = await ApiRepository.to.administratorOwnLockList( + final AdministratorAssociationLockEntity entity = + await ApiRepository.to.administratorOwnLockList( uid: state.itemData.value.uid ?? 0, ); if (entity.errorCode!.codeIsSuccessful) { - EasyLoading.showToast('修改成功', duration: 2000.milliseconds); + state.itemLockList.value = entity.data!; + state.itemLockList.refresh(); } } diff --git a/lib/mine/mineSet/authorizedAdministrator/administratorAssociationLock/administratorAssociationLock_page.dart b/lib/mine/mineSet/authorizedAdministrator/administratorAssociationLock/administratorAssociationLock_page.dart index 2e624d04..a507f6a1 100644 --- a/lib/mine/mineSet/authorizedAdministrator/administratorAssociationLock/administratorAssociationLock_page.dart +++ b/lib/mine/mineSet/authorizedAdministrator/administratorAssociationLock/administratorAssociationLock_page.dart @@ -3,6 +3,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupCell.dart'; import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupListEntity.dart'; +import 'package:star_lock/mine/mineSet/authorizedAdministrator/administratorAssociationLock/administratorAssociationLock_entity.dart'; import 'package:star_lock/mine/mineSet/authorizedAdministrator/administratorAssociationLock/administratorAssociationLock_logic.dart'; import 'package:star_lock/mine/mineSet/authorizedAdministrator/administratorAssociationLock/administratorAssociationLock_state.dart'; import 'package:star_lock/tools/ExpandedListView.dart'; @@ -44,17 +45,14 @@ class _AdministratorAssociationLockPageState ), ], ), - body: _buildListView(), + body: Obx(_buildListView), ); } Widget _buildListView() { return ListView.separated( itemCount: state.itemLockList.length, - itemBuilder: (BuildContext context, int index) { - final GroupListItem itemData = state.itemLockList[index]; - return _buildLockExpandedList(context, index, itemData); - }, + itemBuilder: _buildLockExpandedList, shrinkWrap: true, separatorBuilder: (BuildContext context, int index) { return const Divider( @@ -65,38 +63,23 @@ class _AdministratorAssociationLockPageState } //设备多层级列表 - Widget _buildLockExpandedList(context, index, GroupListItem itemData) { - List lockItemList = itemData.lockList ?? []; + Widget _buildLockExpandedList(context, index) { + final GroupListItemData itemData = state.itemLockList[index]; + final List lockItemList = itemData.lockList ?? []; + final GroupListItem getItemData = GroupListItem(); + getItemData.keyGroupId = itemData.groupId; + getItemData.keyGroupName = itemData.groupName; + getItemData.groupType = itemData.groupType; + return ExpandedListTile( - onTap: () { - //是否选中组 - if (itemData.isChecked) { - var selectList = itemData.lockList; - for (LockListItem lockListItem in selectList!) { - lockListItem.isChecked = true; - state.selectLockIdList.value.add(lockListItem.lockId); - } - } else { - var selectList = itemData.lockList; - for (LockListItem lockListItem in selectList!) { - lockListItem.isChecked = false; - state.selectLockIdList.value.remove(lockListItem.lockId); - } - } - setState(() {}); - }, + onTap: () {}, typeImgList: const [], - groupItem: itemData, + groupItem: getItemData, child: massSendLockGroupCell(index, - currentIndex: index, lockListByGroup: lockItemList, isVip: true, - selectLockAction: (int selectIndex, String selectLockId) { - final LockListItem lockItem = lockItemList[selectIndex]; - lockItem.isChecked = !lockItem.isChecked; - if (lockItem.isChecked) { - state.selectLockIdList.value.add(lockItem.lockId); - } - setState(() {}); - }), + currentIndex: index, + lockListByGroup: lockItemList, + isVip: true, + selectLockAction: (int selectIndex, String selectLockId) {}), ); } } diff --git a/lib/mine/valueAddedServices/valueAddedServicesList/valueAddedServicesList_page.dart b/lib/mine/valueAddedServices/valueAddedServicesList/valueAddedServicesList_page.dart index 6b599b24..a019ce22 100755 --- a/lib/mine/valueAddedServices/valueAddedServicesList/valueAddedServicesList_page.dart +++ b/lib/mine/valueAddedServices/valueAddedServicesList/valueAddedServicesList_page.dart @@ -66,12 +66,12 @@ class _ValueAddedServicesPageListState TranslationLoader.lanKeys!.advancedFunction!.tr, () async { var isVip = await Storage.getBool(saveIsVip); if (isVip == null || !isVip) { - if (CommonDataManage().currentKeyInfo.isLockOwner != 1) { - logic.showToast('请先添加锁'); - } else { - Get.toNamed(Routers.advancedFeaturesWebPage, - arguments: {'isShop': true}); - } + // if (CommonDataManage().currentKeyInfo.isLockOwner != 1) { + // logic.showToast('请先添加锁'); + // } else { + Get.toNamed(Routers.advancedFeaturesWebPage, + arguments: {'isShop': true}); + // } } else { Get.toNamed(Routers.valueAddedServicesHighFunctionPage); } diff --git a/lib/network/api_repository.dart b/lib/network/api_repository.dart index db2c6619..4cea9c43 100755 --- a/lib/network/api_repository.dart +++ b/lib/network/api_repository.dart @@ -20,6 +20,7 @@ import 'package:star_lock/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_ import 'package:star_lock/mine/minePersonInfo/minePersonInfoSetSafetyProblem/minePersonInfoSetSafetyProblem_entity.dart'; import 'package:star_lock/mine/minePersonInfo/minePersonInfoViewSafetyProblem/minePersonInfoViewSafetyProblem_entity.dart'; import 'package:star_lock/mine/mineSet/appUnlockNeedMobileNetworkingLock/selectLockListEntity.dart'; +import 'package:star_lock/mine/mineSet/authorizedAdministrator/administratorAssociationLock/administratorAssociationLock_entity.dart'; import 'package:star_lock/mine/mineSet/authorizedAdministrator/administratorDetails/administratorDetailEntity.dart'; import 'package:star_lock/mine/mineSet/authorizedAdministrator/authorizedAdministrator/authorizedAdminListEntity.dart'; import 'package:star_lock/mine/mineSet/lockUserManage/expireLockList/expireElectronicKey/expireLockList_entity.dart'; @@ -1014,10 +1015,10 @@ class ApiRepository { } //获取授权管理员下锁列表 - Future administratorOwnLockList( + Future administratorOwnLockList( {required int uid}) async { final res = await apiProvider.administratorOwnLockList(uid); - return AuthorizedAdminListEntity.fromJson(res.body); + return AdministratorAssociationLockEntity.fromJson(res.body); } //删除授权管理员