From fd4dab3e2e5d8848e019e23c3f90c062bc21b4e7 Mon Sep 17 00:00:00 2001 From: Daisy <> Date: Fri, 31 May 2024 14:11:16 +0800 Subject: [PATCH 01/10] =?UTF-8?q?1=EF=BC=8C=E6=96=B0=E5=A2=9E=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E8=AE=BE=E5=A4=87=E4=BF=A1=E6=81=AF=E7=9A=84=E5=85=AC?= =?UTF-8?q?=E7=94=A8=E6=96=B9=E6=B3=95=202=EF=BC=8C=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E7=99=BB=E5=BD=95=E6=96=B0=E5=A2=9E=E5=85=A5=E5=8F=82=EF=BC=9A?= =?UTF-8?q?=E8=AE=BE=E5=A4=87=E4=BF=A1=E6=81=AF=203=EF=BC=8C=E6=B3=A8?= =?UTF-8?q?=E5=86=8C=E6=8E=A5=E5=8F=A3=E6=96=B0=E5=A2=9E=E5=85=A5=E5=8F=82?= =?UTF-8?q?=EF=BC=9A=E8=AE=BE=E5=A4=87=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../XSConstantMacro/XSConstantMacro.dart | 25 +++++++ lib/login/login/starLock_login_logic.dart | 18 ++++- lib/login/login/starLock_login_state.dart | 1 + .../register/starLock_register_logic.dart | 57 ++++++++++----- .../register/starLock_register_page.dart | 73 ++++++++++--------- .../register/starLock_register_state.dart | 1 + .../register/starLock_register_xhj_page.dart | 17 +++-- lib/network/api_provider.dart | 7 +- lib/network/api_repository.dart | 17 +++-- 9 files changed, 142 insertions(+), 74 deletions(-) diff --git a/lib/common/XSConstantMacro/XSConstantMacro.dart b/lib/common/XSConstantMacro/XSConstantMacro.dart index bf692ec0..38485f83 100755 --- a/lib/common/XSConstantMacro/XSConstantMacro.dart +++ b/lib/common/XSConstantMacro/XSConstantMacro.dart @@ -1,3 +1,7 @@ +import 'dart:io'; + +import 'package:device_info_plus/device_info_plus.dart'; + import '../../flavors.dart'; class XSConstantMacro { @@ -85,4 +89,25 @@ class XSConstantMacro { static int webBuyTypeVip = 3; //VIP购买 static int webBuyTypeAuth = 4; //实名购买 static int webBuyTypeShop = 5; //商城购买 + + //设备类型信息 + Future> getDeviceInfoData() async { + final DeviceInfoPlugin deviceInfo = DeviceInfoPlugin(); + final Map deviceData = {}; + + if (Platform.isAndroid) { + final AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo; + deviceData['deviceBrand'] = androidInfo.brand; + deviceData['deviceModel'] = androidInfo.model; + deviceData['deviceVersion'] = androidInfo.version.release; + deviceData['deviceType'] = 10; + } else if (Platform.isIOS) { + final IosDeviceInfo iosInfo = await deviceInfo.iosInfo; + deviceData['deviceBrand'] = iosInfo.name; + deviceData['deviceModel'] = iosInfo.model; + deviceData['deviceVersion'] = iosInfo.systemVersion; + deviceData['deviceType'] = 20; + } + return deviceData; + } } diff --git a/lib/login/login/starLock_login_logic.dart b/lib/login/login/starLock_login_logic.dart index 9826cbce..8651fa1d 100755 --- a/lib/login/login/starLock_login_logic.dart +++ b/lib/login/login/starLock_login_logic.dart @@ -1,10 +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/app_settings/app_settings.dart'; import 'package:star_lock/blue/blue_manage.dart'; +import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.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'; @@ -44,7 +45,8 @@ class StarLockLoginLogic extends BaseGetXController { loginType: '1', password: state.pwd.value, countryCode: state.countryCode.value, - username: state.emailOrPhone.value); + username: state.emailOrPhone.value, + deviceInfo: state.deviceInfoMap.value); if (entity.errorCode!.codeIsSuccessful) { Storage.saveLoginData(entity.data); Storage.setBool(saveIsVip, entity.data!.isVip == 0 ? false : true); @@ -86,4 +88,16 @@ class StarLockLoginLogic extends BaseGetXController { state.onClose(); super.onClose(); } + + @override + void onReady() { + super.onReady(); + + XSConstantMacro().getDeviceInfoData().then((Map data) { + state.deviceInfoMap.value = data; + }).catchError((error) { + // 适当处理错误 + AppLog.log('获取设备信息时出错: $error'); + }); + } } diff --git a/lib/login/login/starLock_login_state.dart b/lib/login/login/starLock_login_state.dart index 1aeba9d8..9521398c 100755 --- a/lib/login/login/starLock_login_state.dart +++ b/lib/login/login/starLock_login_state.dart @@ -19,6 +19,7 @@ class StarLockLoginState { FocusNode emailOrPhoneFocusNode = FocusNode(); FocusNode pwdFocusNode = FocusNode(); + RxMap deviceInfoMap = {}.obs; StarLockLoginState() { // emailOrPhone.value = StoreService.to.getLastUserAccount() as String; diff --git a/lib/login/register/starLock_register_logic.dart b/lib/login/register/starLock_register_logic.dart index 39fd7561..ef1bcfd5 100755 --- a/lib/login/register/starLock_register_logic.dart +++ b/lib/login/register/starLock_register_logic.dart @@ -1,8 +1,10 @@ import 'dart:async'; - import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:star_lock/app_settings/app_settings.dart'; +import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart'; +import 'package:star_lock/login/login/entity/LoginEntity.dart'; +import 'package:star_lock/login/register/entity/SendValidationCodeEntity.dart'; import '../../network/api_repository.dart'; import '../../tools/baseGetXController.dart'; @@ -13,7 +15,7 @@ class StarLockRegisterLogic extends BaseGetXController { late Timer _timer; void _startTimer() { - _timer = Timer.periodic(1.seconds, (timer) { + _timer = Timer.periodic(1.seconds, (Timer timer) { if (state.currentSecond > 1) { state.currentSecond--; } else { @@ -29,35 +31,38 @@ class StarLockRegisterLogic extends BaseGetXController { // _timer = null; } - void register() async { - AppLog.log("state.pwd.value:${state.pwd.value} state.surePwd.value:${state.surePwd.value}"); - if(state.pwd.value != state.surePwd.value){ - showToast("密码不一致哦".tr); + Future register() async { + AppLog.log( + 'state.pwd.value:${state.pwd.value} state.surePwd.value:${state.surePwd.value}'); + if (state.pwd.value != state.surePwd.value) { + showToast('密码不一致哦'.tr); return; } - var entity = await ApiRepository.to.register( + final LoginEntity entity = await ApiRepository.to.register( receiverType: state.isIphoneType.value == true ? 1 : 2, countryCode: int.parse(state.countryCode.value), account: state.phoneOrEmailStr.value, password: state.pwd.value, - verificationCode: state.verificationCode.value); + verificationCode: state.verificationCode.value, + deviceInfo: state.deviceInfoMap.value); if (entity.errorCode!.codeIsSuccessful) { - showToast("注册成功".tr); - Get.back(result:{ - "phoneOrEmailStr":state.phoneOrEmailStr.value, - "pwd":state.pwd.value + showToast('注册成功'.tr); + Get.back(result: { + 'phoneOrEmailStr': state.phoneOrEmailStr.value, + 'pwd': state.pwd.value }); } } - void sendValidationCode() async { - var entity = await ApiRepository.to.sendValidationCodeUnLogin( - // state.countryCode.value, - countryCode: state.countryCode.value.toString(), - account: state.phoneOrEmailStr.value, - channel: state.isIphoneType.value ? "1" : "2", - codeType: '1', - xWidth: state.xWidth.value.toString()); + Future sendValidationCode() async { + final SendValidationCodeEntity entity = + await ApiRepository.to.sendValidationCodeUnLogin( + // state.countryCode.value, + countryCode: state.countryCode.value.toString(), + account: state.phoneOrEmailStr.value, + channel: state.isIphoneType.value ? '1' : '2', + codeType: '1', + xWidth: state.xWidth.value.toString()); if (entity.errorCode!.codeIsSuccessful) { _startTimer(); } else {} @@ -93,4 +98,16 @@ class StarLockRegisterLogic extends BaseGetXController { state.codeIsOK && (state.isIphoneType.value ? state.isIphone : state.isEmail); } + + @override + void onReady() { + super.onReady(); + + XSConstantMacro().getDeviceInfoData().then((Map data) { + state.deviceInfoMap.value = data; + }).catchError((error) { + // 适当处理错误 + AppLog.log('获取设备信息时出错: $error'); + }); + } } diff --git a/lib/login/register/starLock_register_page.dart b/lib/login/register/starLock_register_page.dart index ea90d00e..c87d092c 100755 --- a/lib/login/register/starLock_register_page.dart +++ b/lib/login/register/starLock_register_page.dart @@ -3,6 +3,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_settings.dart'; +import 'package:star_lock/login/register/starLock_register_state.dart'; import '../../appRouters.dart'; import '../../app_settings/app_colors.dart'; @@ -21,8 +22,8 @@ class StarLockRegisterPage extends StatefulWidget { } class _StarLockRegisterPageState extends State { - final logic = Get.put(StarLockRegisterLogic()); - final state = Get.find().state; + final StarLockRegisterLogic logic = Get.put(StarLockRegisterLogic()); + final StarLockRegisterState state = Get.find().state; @override Widget build(BuildContext context) { @@ -35,7 +36,7 @@ class _StarLockRegisterPageState extends State { backgroundColor: AppColors.mainColor), body: ListView( padding: EdgeInsets.only(top: 40.h, left: 40.w, right: 40.w), - children: [ + children: [ topSelectCountryAndRegionWidget(), middleTFWidget(), Obx(() { @@ -67,11 +68,11 @@ class _StarLockRegisterPageState extends State { Widget topSelectCountryAndRegionWidget() { return Column( - children: [ + children: [ SizedBox(height: 50.h), Row( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ Container( width: 340.w, height: 60.h, @@ -81,7 +82,7 @@ class _StarLockRegisterPageState extends State { border: Border.all(width: 1.0, color: AppColors.greyLineColor)), child: Row( - children: [ + children: [ GestureDetector( onTap: () { state.isIphoneType.value = true; @@ -141,19 +142,19 @@ class _StarLockRegisterPageState extends State { SizedBox(height: 60.h), GestureDetector( onTap: () async { - var result = await Get.toNamed(Routers.selectCountryRegionPage); + final result = await Get.toNamed(Routers.selectCountryRegionPage); if (result != null) { result as Map; state.countryCode.value = result['code']; state.countryName.value = result['countryName']; } AppLog.log( - "路由返回值: $result, countryCode:${logic.state.countryCode}"); + '路由返回值: $result, countryCode:${logic.state.countryCode}'); }, child: Obx(() => SizedBox( height: 70.h, child: Row( - children: [ + children: [ SizedBox(width: 5.w), Expanded( child: Text( @@ -163,7 +164,7 @@ class _StarLockRegisterPageState extends State { SizedBox(width: 20.w), Row( mainAxisAlignment: MainAxisAlignment.end, - children: [ + children: [ Text( state.isIphoneType.value ? '${state.countryName.value} +${state.countryCode.value}' @@ -194,7 +195,7 @@ class _StarLockRegisterPageState extends State { Widget middleTFWidget() { return Column( - children: [ + children: [ Obx(() => LoginInput( controller: state.phoneOrEmailController, onchangeAction: (v) { @@ -207,7 +208,7 @@ class _StarLockRegisterPageState extends State { child: Image.asset( state.isIphoneType.value ? 'images/icon_login_account.png' - : "images/icon_login_email.png", + : 'images/icon_login_email.png', width: 30.w, height: 30.w, ), @@ -215,7 +216,7 @@ class _StarLockRegisterPageState extends State { hintText: "${TranslationLoader.lanKeys!.pleaseEnter!.tr}${state.isIphoneType.value ? "手机号".tr : TranslationLoader.lanKeys!.email!.tr}", keyboardType: TextInputType.number, - inputFormatters: [ + inputFormatters: [ // FilteringTextInputFormatter.allow(RegExp('[0-9]')), LengthLimitingTextInputFormatter(30), ])), @@ -236,8 +237,8 @@ class _StarLockRegisterPageState extends State { ), ), hintText: - "${TranslationLoader.lanKeys!.pleaseEnter!.tr}${TranslationLoader.lanKeys!.password!.tr}", - inputFormatters: [ + '${TranslationLoader.lanKeys!.pleaseEnter!.tr}${TranslationLoader.lanKeys!.password!.tr}', + inputFormatters: [ LengthLimitingTextInputFormatter(20), ]), SizedBox(height: 15.w), @@ -263,13 +264,13 @@ class _StarLockRegisterPageState extends State { ), ), hintText: - "${TranslationLoader.lanKeys!.sure!.tr}${TranslationLoader.lanKeys!.password!.tr}", - inputFormatters: [ + '${TranslationLoader.lanKeys!.sure!.tr}${TranslationLoader.lanKeys!.password!.tr}', + inputFormatters: [ LengthLimitingTextInputFormatter(20), ]), SizedBox(height: 10.w), Row( - children: [ + children: [ Expanded( child: LoginInput( controller: state.codeController, @@ -284,8 +285,8 @@ class _StarLockRegisterPageState extends State { ), ), hintText: - "${TranslationLoader.lanKeys!.pleaseEnter!.tr}${TranslationLoader.lanKeys!.verificationCode!.tr}", - inputFormatters: [ + '${TranslationLoader.lanKeys!.pleaseEnter!.tr}${TranslationLoader.lanKeys!.verificationCode!.tr}', + inputFormatters: [ LengthLimitingTextInputFormatter(20), ]), ), @@ -297,14 +298,14 @@ class _StarLockRegisterPageState extends State { state.phoneOrEmailStrIsOK.value && state.canResend.value ? () async { // Navigator.pushNamed(context, Routers.safetyVerificationPage, arguments: {"countryCode":"+86", "account":state.phoneOrEmailStr.value}); - var result = await Navigator.pushNamed( + final Object? result = await Navigator.pushNamed( context, Routers.safetyVerificationPage, - arguments: { - "countryCode": state.countryCode, - "account": state.phoneOrEmailStr.value + arguments: { + 'countryCode': state.countryCode, + 'account': state.phoneOrEmailStr.value }); state.xWidth.value = - (result as Map)['xWidth']; + (result! as Map)['xWidth']; logic.sendValidationCode(); } : null, @@ -337,7 +338,7 @@ class _StarLockRegisterPageState extends State { Widget _buildBottomAgreement() { return Row( mainAxisAlignment: MainAxisAlignment.start, - children: [ + children: [ Obx(() => GestureDetector( onTap: () { state.agree.value = !state.agree.value; @@ -358,7 +359,7 @@ class _StarLockRegisterPageState extends State { text: TextSpan( text: TranslationLoader.lanKeys!.readAndAgree!.tr, style: TextStyle(color: const Color(0xff333333), fontSize: 20.sp), - children: [ + children: [ WidgetSpan( alignment: PlaceholderAlignment.middle, child: GestureDetector( @@ -367,10 +368,11 @@ class _StarLockRegisterPageState extends State { style: TextStyle( color: AppColors.mainColor, fontSize: 20.sp)), onTap: () { - Get.toNamed(Routers.webviewShowPage, arguments: { - "url": XSConstantMacro.userAgreementURL, - "title": '用户协议'.tr - }); + Get.toNamed(Routers.webviewShowPage, + arguments: { + 'url': XSConstantMacro.userAgreementURL, + 'title': '用户协议'.tr + }); }, )), WidgetSpan( @@ -381,10 +383,11 @@ class _StarLockRegisterPageState extends State { style: TextStyle( color: AppColors.mainColor, fontSize: 20.sp)), onTap: () { - Get.toNamed(Routers.webviewShowPage, arguments: { - "url": XSConstantMacro.privacyPolicyURL, - "title": '隐私政策'.tr - }); + Get.toNamed(Routers.webviewShowPage, + arguments: { + 'url': XSConstantMacro.privacyPolicyURL, + 'title': '隐私政策'.tr + }); }, )), ], diff --git a/lib/login/register/starLock_register_state.dart b/lib/login/register/starLock_register_state.dart index 41625bac..2c1d55ad 100755 --- a/lib/login/register/starLock_register_state.dart +++ b/lib/login/register/starLock_register_state.dart @@ -32,6 +32,7 @@ class StarLockRegisterState { var btnText = ''.obs; var totalSeconds = 120; var currentSecond = 120; + RxMap deviceInfoMap = {}.obs; StarLockRegisterState() { resetResend(); diff --git a/lib/login/register/starLock_register_xhj_page.dart b/lib/login/register/starLock_register_xhj_page.dart index 6e8955df..ddace6a7 100755 --- a/lib/login/register/starLock_register_xhj_page.dart +++ b/lib/login/register/starLock_register_xhj_page.dart @@ -193,18 +193,21 @@ class _StarLockRegisterPageState extends State { ), Obx(() => GestureDetector( onTap: - state.phoneOrEmailStrIsOK.value && state.canResend.value ? () async { + state.phoneOrEmailStrIsOK.value && state.canResend.value + ? () async { // Navigator.pushNamed(context, Routers.safetyVerificationPage, arguments: {"countryCode":"+86", "account":state.phoneOrEmailStr.value}); - if(state.pwd.value != state.surePwd.value){ - logic.showToast("密码不一致哦".tr); - return; - } - var result = await Get.toNamed(Routers.safetyVerificationPage, + if (state.pwd.value != state.surePwd.value) { + logic.showToast("密码不一致哦".tr); + return; + } + var result = await Get.toNamed( + Routers.safetyVerificationPage, arguments: { "countryCode": state.countryCode, "account": state.phoneOrEmailStr.value }); - state.xWidth.value = (result as Map)['xWidth']; + state.xWidth.value = + (result as Map)['xWidth']; logic.sendValidationCode(); } : null, diff --git a/lib/network/api_provider.dart b/lib/network/api_provider.dart index 0c290898..0045081a 100755 --- a/lib/network/api_provider.dart +++ b/lib/network/api_provider.dart @@ -22,6 +22,7 @@ class ApiProvider extends BaseProvider { String account, String password, String verificationCode, + Map deviceInfo, ) => post( registerUrl.toUrl, @@ -32,6 +33,7 @@ class ApiProvider extends BaseProvider { 'password': password, 'verificationCode': verificationCode, 'platId': '2', + 'deviceInfo': deviceInfo, })); // post( @@ -65,7 +67,7 @@ class ApiProvider extends BaseProvider { })); Future login(String loginType, String password, String countryCode, - String username) => + String username, Map deviceInfo) => post( loginUrl.toUrl, jsonEncode({ @@ -74,7 +76,8 @@ class ApiProvider extends BaseProvider { 'platId': '2', 'uniqueid': '477E6814-289D-402A-9F49-F89A8BD05D63', 'countryCode': countryCode, - 'username': username + 'username': username, + 'deviceInfo': deviceInfo, })); Future resetPassword( diff --git a/lib/network/api_repository.dart b/lib/network/api_repository.dart index 5c6eef04..3a97c0fd 100755 --- a/lib/network/api_repository.dart +++ b/lib/network/api_repository.dart @@ -98,9 +98,10 @@ class ApiRepository { required int countryCode, required String account, required String password, - required String verificationCode}) async { - final res = await apiProvider.register( - receiverType, countryCode, account, password, verificationCode); + required String verificationCode, + required Map deviceInfo}) async { + final res = await apiProvider.register(receiverType, countryCode, account, + password, verificationCode, deviceInfo); return LoginEntity.fromJson(res.body); } @@ -124,9 +125,10 @@ class ApiRepository { {required String loginType, required String password, required String countryCode, - required String username}) async { - final res = - await apiProvider.login(loginType, password, countryCode, username); + required String username, + required Map deviceInfo}) async { + final res = await apiProvider.login( + loginType, password, countryCode, username, deviceInfo); return LoginEntity.fromJson(res.body); } @@ -2154,8 +2156,7 @@ class ApiRepository { // 电子钥匙获取短信模板 Future getAppInfo() async { - final Response res = - await apiProvider.getAppInfo(); + final Response res = await apiProvider.getAppInfo(); return GetAppInfo.fromJson(res.body); } } From 1be9cfab22af80b1d70c5e896152ed36bf9fd09a Mon Sep 17 00:00:00 2001 From: anfe <448468458@qq.com> Date: Fri, 31 May 2024 14:28:52 +0800 Subject: [PATCH 02/10] =?UTF-8?q?feat:=E5=AE=8C=E6=88=90=E4=BA=91=20OTA=20?= =?UTF-8?q?=E5=8D=87=E7=BA=A7?= 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 | 3 +- .../lockEscalation/lockEscalation_logic.dart | 70 +++++++++++++------ .../lockEscalation/lockEscalation_page.dart | 42 +++++++---- .../lockEscalation/lockEscalation_state.dart | 7 +- .../lockEscalation/version_entity.dart | 48 +++++++++++++ lib/network/api.dart | 1 + lib/network/api_provider.dart | 11 +++ lib/network/api_repository.dart | 12 +++- 10 files changed, 160 insertions(+), 40 deletions(-) create mode 100644 lib/main/lockDetail/lockSet/lockEscalation/version_entity.dart diff --git a/images/lan/lan_en.json b/images/lan/lan_en.json index d2f6f144..1e08ee34 100755 --- a/images/lan/lan_en.json +++ b/images/lan/lan_en.json @@ -856,5 +856,6 @@ "视频事件":"Video event", "请开启蓝牙":"Please turn on Bluetooth", "请选择有效日":"Please select the effective day", - "公司名字长度不能小于 6 ": "The length of the company name cannot be less than 6" + "公司名字长度不能小于 6 ": "The length of the company name cannot be less than 6", + "已是最新版本": "It is the latest version" } diff --git a/images/lan/lan_keys.json b/images/lan/lan_keys.json index d293e3b9..67174980 100755 --- a/images/lan/lan_keys.json +++ b/images/lan/lan_keys.json @@ -885,5 +885,6 @@ "视频事件":"视频事件", "请开启蓝牙":"请开启蓝牙", "请选择有效日":"请选择有效日", - "公司名字长度不能小于 6 ": "公司名字长度不能小于 6 " + "公司名字长度不能小于 6 ": "公司名字长度不能小于 6 ", + "已是最新版本": "已是最新版本" } diff --git a/images/lan/lan_zh.json b/images/lan/lan_zh.json index 5e3192e1..bd48b813 100755 --- a/images/lan/lan_zh.json +++ b/images/lan/lan_zh.json @@ -855,5 +855,6 @@ "视频事件": "视频事件", "请开启蓝牙": "请开启蓝牙", "请选择有效日": "请选择有效日", - "公司名字长度不能小于 6 ": "公司名字长度不能小于 6 " + "公司名字长度不能小于 6 ": "公司名字长度不能小于 6 ", + "已是最新版本": "已是最新版本" } diff --git a/lib/main/lockDetail/lockSet/lockEscalation/lockEscalation_logic.dart b/lib/main/lockDetail/lockSet/lockEscalation/lockEscalation_logic.dart index e1850e7a..4a34e67a 100755 --- a/lib/main/lockDetail/lockSet/lockEscalation/lockEscalation_logic.dart +++ b/lib/main/lockDetail/lockSet/lockEscalation/lockEscalation_logic.dart @@ -8,15 +8,15 @@ import 'package:file_picker/file_picker.dart'; import 'package:flutter_blue_plus/flutter_blue_plus.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:get/get.dart'; -import 'package:permission_handler/permission_handler.dart'; +import 'package:http/http.dart' as http; import 'package:star_lock/blue/blue_manage.dart'; import 'package:star_lock/blue/io_protocol/io_otaUpgrade.dart'; import 'package:star_lock/blue/io_protocol/io_processOtaUpgrade.dart'; import 'package:star_lock/blue/io_reply.dart'; import 'package:star_lock/blue/io_tool/io_tool.dart'; import 'package:star_lock/blue/io_tool/manager_event_bus.dart'; -import 'package:star_lock/blue/sender_manage.dart'; -import 'package:star_lock/main/lockDetail/lockSet/lockSet/lockSet_logic.dart'; +import 'package:star_lock/main/lockDetail/lockSet/lockEscalation/version_entity.dart'; +import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/tools/baseGetXController.dart'; import 'package:star_lock/tools/commonDataManage.dart'; import 'package:star_lock/tools/showTipView.dart'; @@ -34,17 +34,8 @@ class LockEscalationLogic extends BaseGetXController { int otaIndex = 0; Uint8List? otaBin; int startSecond = 0; - Map? headJson = null; - - // 锁升级 - Future setLockSetGeneralSetting() async { - // var entity = await ApiRepository.to.getLockVersionInfoData( - // lockId: state.getKeyInfosData.value.lockId.toString(), - // ); - // if(entity.errorCode!.codeIsSuccessful){ - // - // } - } + Map? headJson; + FwVersionEntity? entity; //手动升级 Future otaUpdate() async { @@ -58,6 +49,10 @@ class LockEscalationLogic extends BaseGetXController { } final File file = File(result.files.single.path!); final Uint8List data = await file.readAsBytes(); + stateUpData(data); + } + + Future stateUpData(Uint8List data) async { headJson = await getHeadFile(data); if (headJson is! Map) { return; @@ -69,10 +64,10 @@ class LockEscalationLogic extends BaseGetXController { final String md5Str = md5.convert(otaBin!).toString(); headJson!['fwMd5'] = md5Str; ShowTipView().showIosTipWithContentDialog('未避免异常情况,请在门打开时升级'.tr, () async { - blueOTAUpgrade(headJson!, [0, 0, 0, 0]); + blueOTAUpgrade(headJson!, [0, 0, 0, 0]); EasyLoading.show( status: '设备连接中...'.tr, maskType: EasyLoadingMaskType.black); - Future.delayed(const Duration(seconds: 4), EasyLoading.dismiss); + Future.delayed(const Duration(seconds: 4), EasyLoading.dismiss); }); } @@ -81,9 +76,12 @@ class LockEscalationLogic extends BaseGetXController { BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { if (deviceConnectionState == BluetoothConnectionState.connected) { - final privateKey = await Storage.getStringList(saveBluePrivateKey); - final List getPrivateKeyList = changeStringListToIntList(privateKey!); - final signKey = await Storage.getStringList(saveBlueSignKey); + final List? privateKey = + await Storage.getStringList(saveBluePrivateKey); + final List getPrivateKeyList = + changeStringListToIntList(privateKey!); + final List? signKey = + await Storage.getStringList(saveBlueSignKey); final List signKeyDataList = changeStringListToIntList(signKey!); final String uid = await Storage.getUid() ?? ''; BlueManage().writeCharacteristicWithResponse(OTAUpgradeCommand( @@ -236,17 +234,47 @@ class LockEscalationLogic extends BaseGetXController { return bin; } + //检查最新版本 + Future checkUpData() async { + final String model = CommonDataManage().currentKeyInfo.model ?? ''; + String currentVersion = CommonDataManage().currentKeyInfo.fwVersion ?? ''; + if (currentVersion.split('.').length >= 3) { + currentVersion = currentVersion.split('.')[0] + + '.' + + currentVersion.split('.')[1] + + '.' + + currentVersion.split('.')[2]; + } + state.showVersion.value = currentVersion; + entity = await ApiRepository.to + .getFwVersion(model: model, currentVersion: currentVersion); + state.isShowUpDataBtn.value = entity?.data?.isUpdate == 1; + state.showNewVersion.value = entity?.data?.version??''; + } + + //下载升级 + Future downloadTheFile() async { + if (entity?.data?.downloadUrl == null) { + return; + } + final String url = entity!.data!.downloadUrl!; + final http.Response response = await http.get(Uri.parse(url)); + if (response.statusCode == 200) { + stateUpData(response.bodyBytes); + } + } + @override void onReady() { super.onReady(); - setLockSetGeneralSetting(); + checkUpData(); } @override void onInit() { super.onInit(); _replySubscription = - EventBusManager().eventBus!.on().listen((reply) { + EventBusManager().eventBus!.on().listen((Reply reply) { if (reply is OTAUpgradeReply) { if (reply.status == 0x00) { //验证通过,开始发送数据包 diff --git a/lib/main/lockDetail/lockSet/lockEscalation/lockEscalation_page.dart b/lib/main/lockDetail/lockSet/lockEscalation/lockEscalation_page.dart index e2dc59d7..949a7e3d 100755 --- a/lib/main/lockDetail/lockSet/lockEscalation/lockEscalation_page.dart +++ b/lib/main/lockDetail/lockSet/lockEscalation/lockEscalation_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/tools/commonDataManage.dart'; import '../../../../app_settings/app_colors.dart'; import '../../../../tools/submitBtn.dart'; @@ -63,29 +64,46 @@ class _LockEscalationPageState extends State { SizedBox( width: 10.w, ), - Text( - // TranslationLoader.lanKeys!.haveNewVersion!.tr, - "未发现新版本", - style: TextStyle(fontSize: 24.sp, fontWeight: FontWeight.w600), - ) + Obx(() { + if (logic.state.isShowUpDataBtn.value) { + return Text( + TranslationLoader.lanKeys!.haveNewVersion!.tr + logic.state.showNewVersion.value, + style: + TextStyle(fontSize: 24.sp, fontWeight: FontWeight.w600), + ); + } else { + return Text( + '已是最新版本'.tr, + style: + TextStyle(fontSize: 24.sp, fontWeight: FontWeight.w600), + ); + } + }) ], ), SizedBox( height: 30.h, ), - Text( - "${TranslationLoader.lanKeys!.currentVersion!.tr}:1.0.0", - style: TextStyle(fontSize: 18.sp, color: AppColors.darkGrayTextColor), - ), + Obx(() { + return Text( + '${TranslationLoader.lanKeys!.currentVersion!.tr}:${logic.state.showVersion.value}', + style: + TextStyle(fontSize: 18.sp, color: AppColors.darkGrayTextColor), + ); + }), SizedBox( height: 40.h, ), Obx(() { - return !logic.state.otaUpdateIng.value + final bool show = !logic.state.otaUpdateIng.value && + logic.state.isShowUpDataBtn.value; + return show ? SubmitBtn( btnName: TranslationLoader.lanKeys!.upgrade!.tr, - onClick: () {}) - : SizedBox(); + onClick: () { + logic.downloadTheFile(); + }) + : const SizedBox(); }), SizedBox( height: 10.h, diff --git a/lib/main/lockDetail/lockSet/lockEscalation/lockEscalation_state.dart b/lib/main/lockDetail/lockSet/lockEscalation/lockEscalation_state.dart index a53bd383..a182c23a 100755 --- a/lib/main/lockDetail/lockSet/lockEscalation/lockEscalation_state.dart +++ b/lib/main/lockDetail/lockSet/lockEscalation/lockEscalation_state.dart @@ -1,6 +1,9 @@ import 'package:get/get.dart'; class LockEscalationState { - var otaUpdateIng = false.obs; - var otaProgress = 0.00.obs; + RxBool otaUpdateIng = false.obs; + RxDouble otaProgress = 0.00.obs; + RxBool isShowUpDataBtn = false.obs; + RxString showVersion = '1.0.0'.obs; + RxString showNewVersion = '1.0.0'.obs; } diff --git a/lib/main/lockDetail/lockSet/lockEscalation/version_entity.dart b/lib/main/lockDetail/lockSet/lockEscalation/version_entity.dart new file mode 100644 index 00000000..74e6d8e0 --- /dev/null +++ b/lib/main/lockDetail/lockSet/lockEscalation/version_entity.dart @@ -0,0 +1,48 @@ +class FwVersionEntity { + FwVersionEntity({this.errorCode, this.description, this.errorMsg, this.data}); + + FwVersionEntity.fromJson(Map json) { + errorCode = json['errorCode']; + description = json['description']; + errorMsg = json['errorMsg']; + if (json['data'] is Map) { + data = Data.fromJson(json['data']); + } + } + + int? errorCode; + String? description; + String? errorMsg; + Data? data; + + Map toJson() { + final Map data = {}; + data['errorCode'] = errorCode; + data['description'] = description; + data['errorMsg'] = errorMsg; + data['data'] = this.data; + return data; + } +} + +class Data { + Data.fromJson(Map json) { + isUpdate = json['isUpdate']; + downloadUrl = json['downloadUrl']; + description = json['description']; + } + + int? isUpdate; + String? downloadUrl; + String? description; + String? version; + + Map toJson() { + final Map data = {}; + data['isUpdate'] = isUpdate; + data['downloadUrl'] = downloadUrl; + data['description'] = description; + data['version'] = version; + return data; + } +} diff --git a/lib/network/api.dart b/lib/network/api.dart index 7901353e..af2786e3 100755 --- a/lib/network/api.dart +++ b/lib/network/api.dart @@ -240,4 +240,5 @@ abstract class Api { final String lockDataUploadUrl = '/lockRecords/lockDataUpload'; // 锁数据上传 final String getNoticeTemplateURL = '/key/getNoticeTemplate'; //获取短信或者邮箱模板 final String appGetAppInfoURL = '/app/getAppInfo'; //获取APP基本信息 + final String appGetFwVersionURL = '/app/getFwVersion'; //获取固件信息 } diff --git a/lib/network/api_provider.dart b/lib/network/api_provider.dart index 21bd6b91..0b6d352d 100755 --- a/lib/network/api_provider.dart +++ b/lib/network/api_provider.dart @@ -2127,6 +2127,17 @@ class ApiProvider extends BaseProvider { Future> getAppInfo() => post(appGetAppInfoURL.toUrl, jsonEncode({}), isShowErrMsg: false); + + // 获取App固件信息 + Future> getFwVersion(String model, String currentVersion) => + post( + appGetFwVersionURL.toUrl, + jsonEncode({ + 'model': model, + 'currentVersion': currentVersion, + }), + isUnShowLoading: true, + ); } extension ExtensionString on String { diff --git a/lib/network/api_repository.dart b/lib/network/api_repository.dart index 20f5f7ca..46b6202b 100755 --- a/lib/network/api_repository.dart +++ b/lib/network/api_repository.dart @@ -9,6 +9,7 @@ import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/ma import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupListEntity.dart'; import 'package:star_lock/main/lockDetail/face/addFace/addFace_entity.dart'; import 'package:star_lock/main/lockDetail/lockSet/basicInformation/basicInformation/KeyDetailEntity.dart'; +import 'package:star_lock/main/lockDetail/lockSet/lockEscalation/version_entity.dart'; import 'package:star_lock/main/lockDetail/messageWarn/lockUser/lockUser_entity.dart'; import 'package:star_lock/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceFingerprintList/coerceFingerprintList_entity.dart'; import 'package:star_lock/main/lockDetail/messageWarn/msgNotification/msgNotification/msgNotification_entity.dart'; @@ -2154,8 +2155,15 @@ class ApiRepository { // 电子钥匙获取短信模板 Future getAppInfo() async { - final Response res = - await apiProvider.getAppInfo(); + final Response res = await apiProvider.getAppInfo(); return GetAppInfo.fromJson(res.body); } + + // 获取最新固件 + Future getFwVersion( + {required String model, required String currentVersion}) async { + final Response res = + await apiProvider.getFwVersion(model, currentVersion); + return FwVersionEntity.fromJson(res.body); + } } From ba0b9c0fab23262d91662f98399aab13e7b0fc43 Mon Sep 17 00:00:00 2001 From: Daisy <> Date: Fri, 31 May 2024 15:10:57 +0800 Subject: [PATCH 03/10] =?UTF-8?q?1=EF=BC=8C=E9=94=81=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E6=96=B0=E5=A2=9E=E6=89=8B=E6=9C=BA=E9=9C=80?= =?UTF-8?q?=E8=81=94=E7=BD=91=E5=AD=97=E6=AE=B5=E5=8F=8A=E6=A0=87=E8=AF=86?= =?UTF-8?q?=202=EF=BC=8Cxhj=E9=94=81=E8=AF=A6=E6=83=85=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E9=83=A8=E5=88=86=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- images/main/icon_lockDetail_needNetwork.png | Bin 0 -> 4199 bytes .../lockDetail/lockDetail_page.dart | 160 ++++++++++-------- .../lockMian/entity/lockListInfo_entity.dart | 4 + 3 files changed, 94 insertions(+), 70 deletions(-) create mode 100644 images/main/icon_lockDetail_needNetwork.png diff --git a/images/main/icon_lockDetail_needNetwork.png b/images/main/icon_lockDetail_needNetwork.png new file mode 100644 index 0000000000000000000000000000000000000000..32a741f0440e72383497451bb287be5eb622517a GIT binary patch literal 4199 zcmV-t5SZ_YP)0e>JRf|d=*He628 zamvgh%m%4SQ7dX8dP8lfP3UqJwJ|r=Ch{U$SyicUV`gD#L&k{^mjzoANKqgOVn6_c z-w=cO_HMf*TrWaOsquZ_+=T)9+h8l&Z!lCe31%L!aU!36<=AOM8G z^E`0Q;kqueVhfQVEhW>5iEL;3dRI37;b3p_g+%g&k^Aol&V@#mpS<^A{(QM!g>JQ= zX$qqL04Q7}0uls~!*VTH+(kGh#B_8rN6ll$Gn znG34obu$=`BI@Oq<(b2VO`u#39o_*YfJh z`Ie%iTrR^jO&sVAARVF8BPV*^I62rexgX#5z2@wVXkz_Q`{G*JMWfL`Djh*cwvdZz z?{>zWo8LJW|M1VF2>`bJ>;6JHr&`7kW!~6&O@(7xSgR70n{+sRFf>jpP>-iDy;tA% z9Jz(%8ml&2qyPJ-xsO*jOo*X0WLd_@so{5{A>94JLA<{cJNI?uOdZMjMeWU&qMyHi z{{d>X8V(*zAr>ITAHI6@)KEIIr$=m;*ha&vQY7Z;bBkfcszvst|K($TlGDc|)Y-J}Qr4;HE!MNy93ohx3cY4&K% z5I3`>=Yk0yJ`4K_(U5QI#PHBthx<~cV}0oYkS-`j^m4OJhkrkHd%W3fqF5~clIXH^ z@MzzAyY*4n3$f2vF;=Y5k+r%3Pg2m;<5T-O9(^#}O$u9M)*9^WY&Csjy4Eo|vk}Hx z6D}SgC5CQ4|HDDB{qeLleE3^tHnol(xovc58a<&Yk8j7uRj@P#m#X3|$=q2r@rx z!$hmqLZ!BWwY4>Trmz3{QA9k`-~Ziz+PePbqlu|c3;hLFmh;QY%aArOHrc73866t< z@T9nyHnW2uTFV0KxHm?5X!q%MJ`{Z37)K1D$ab1F6Q7 z#I`Ze+5S~;hkls`On_<7T%312|8{i35w#ExsjqX-ga;R^)xhbM#)0w4Ih=V=MrJ2I ze{JOEi)*Z9io=D)%EfBS9V^w;oMAYqH=1x92mSpAkd8;5Sp$QEgYRa#dM`!dvCEWF z_2nMn8Dao%yeB>Fi=g^Fbd1(&wbB0G=uZ;?Z(ETZN+(Me=eMHKC{$I);^HF8tEIDZ zGwRt`m{q5{yFUsC#Oc5NcJAt~$vtd^E;_dOi{i#3R4Nr1h5{_m=pFzDLI}FLx)72B zNG1XZO7!haHucf*o}Ejh#+SE7HBHL}BH@A%kV?@5ho5ogtMJ*pI#yGKQKjV@)=c|c zxw3&qqXEUJ!FE&}h{ccy`U)pb481jaB=OXf^i1UDE6F#@mDcb|J&bm{jYO2ABkDsc z;oj_snK!yR10Mw$T|AiCg<`m~G8~&-yb#k{=a2{jA@(i~9DZvjmwsy?Gyz~@rdZB2 z6!)6X(BGtH>x|Q`L+2KjDt^=qn(t_lpM1JtnXmM-n_JgzNA8o)m(P|}oWA*|xeEdf zB9=-c91i1fK6N!6!9*;CsYCH+L;u$>|J&dFg0EJ`-G@^-$2CC$A`DqXa^&wWvyRlw z%*gPrl>b}>A;UptWxYPGn)=Y~JEe1qq973h!jg->89Vjr$^Q5x@I>SuX!KIEE{y7J z2G=$4%J9m~v_JImkB_C^*)5@MeDUe&?BXYvoVhu8rFGc04U-Fy;~j|6i7Ob)k0MRq zK<~~TQ2-cBK?P74?ux&2X92^ja${VuMOG~P!5BlnZH`Bp#`M9cUlo7;^Pl63)!C7W zKNhdlt2$!QH2VAd@ybZ*pT9pm@b7!&wS42orTUk*->b|&U{<*dpJ_o9MQ|d*bb*#@ zV@1=399fbzORt5}nU&qn(HWP^+@HD|igva(8t#auX^`c{C~r6DP*2xQ0RYe%C{@It008~N?FVN!G~a2P4I z4jnB%e}-rA>Y?cM&*%E8k|ZT9tBs8fb+}MyC289Uld!-!lB-1sZ4=2{`U?E4hC@ep zUD^OZGToZg+c>jPCeRT^iwk+`I8MlM07~g*y|qWw?%p2pKUzDxzP=s`HkoGY$U=(-M5G%^C`oRP=9MAvm; z+je-@%mCQ79kMJ7j4@D3AxRPffxvd;p2Su}8QWApvMhr!22m722s!6C&aTTF%d(PN z$DDHj0Og!B+qS_uha^dR;ROItM8RqV{jlOO2!0VB;gB2y!Bz_{Zvz4cAq1LFgzHeW z{T)zc0j}(V3xI$iD2qV#1W2y9>-hyiun6%$>E^53ahxzEgjid5(zb1wrkMeD-w^HY z?!LzSffC}0)3Dk}IA$1z8Zu^PptT)1+=SDMfCPw zMm)ajHD_5?!Z2KH1&R=2QQ76C7F^ht3+@_Fjln#y`(7b??c3J@Y%6>9;oZDcug|KD z2HaH>&|Bb~LlHg5ECdYXV03pw7&$x?>>n;X$MlY%+2Ne78W6YwKNS(C;aMRbk55LU zQ2>DFc`ytkb9ZGuzu(DZSuXly`3JHrZ>^>6IXurpAP_(_8hx8m`a<>vDwWC)DwPTt zV~9qhV2ss-t|UI}h~}ITJ7D41sfl(ZrTP&@+?Elu{D@c* zWD{@$GPG#quCxnX`E{7xK(bN}z#Z$z3j4 z;rmfr%U?|eBOed;NA|onL{WtBc->J-0Z-W4quY~M27uXxrAy7aab;m)5r!5(M@JVT zkqA0F<+s9N-}F=D{$V8Y)2X5|I(xVHiRSq5$!!;s#K+d*j-}IdvP^L`9>mm<1a>8C z1y>4-jtI}PzyNr*0f7-vQ-TfF+AXQi7BSY)F>?E!ccofYQ7;?db_J(i4j`L!-aFlY z_}#6sPqi6hvB=bk6DK}YZ8|hFSITqFQK?j*D9UKF?E6hva;N5^;zW>Ig`ngXIp>Tp zzvVy-Iq<@wD4O3tI`qL)!@A?;Y@3HfQM5eI zgXePQaS@tn=5@=LDOFo%Roj;-Hw|#kk;!Bb^b-sY4!)g^_$HpT_Y}E-D6D}W9{l_J z^G1%;N;m3lH@~<%58Wat5&?__MxwFUh$IC-sRYhBWXT8a*$}A*COPo6>$P->ethsi zSOox0QY^=>z$YrOsSS7{2oc~B?Wu_T*Qcu&OEvqNDiFaAd$=tSE=Cs5XY;sm!>dIr)}uz;OT~ z2=F`suDdCOEz5%Anh-<|)3RaP_HS+5%L1DXB+fbex;?-r|5sHtuW8!pcH4rhWqHYobo)6ZK)E^^Wfo$W6#@u z74-J@eh^8KyImGJrgMLe6Do1e8Ka~sftLb4uNV|bF&1W1Oh9cXe(!iAm=`WWNaO`K3Bk4D2!JU_5GaG-bGEbP$f5KkfPHQ7|0VWbdhZZ^zrQ3& z(srFkDTUAH+xpOE-_q-O_{P2<+JYX9PxGDwV;cfn^GEL={|9Q-#d%!v< crossAxisAlignment: CrossAxisAlignment.center, children: [ const Spacer(), + Positioned( + child: GestureDetector( + onTap: () { + ShowTipView().showSureAlertDialog( + "${"锁电量更新时间:".tr}${DateTool().dateToYMDHNString(state.keyInfos.value.electricQuantityDate!.toString())}"); + }, + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Image.asset(showElectricIcon(state.electricQuantity.value), + width: 30.w, height: 24.w), + SizedBox(width: 2.w), + Text('${state.electricQuantity.value}%', + style: TextStyle( + fontSize: 18.sp, + color: AppColors.darkGrayTextColor)), + SizedBox(width: 2.w), + Icon( + Icons.info, // 使用内置的 warning 图标,它是一个叹号 + color: AppColors.mainColor, // 设置图标颜色为红色 + size: 25.w, // 设置图标大小为 30 + ), + SizedBox(width: 20.w), + ], + ), + SizedBox( + height: 15.h, + ), + Visibility( + visible: state + .keyInfos.value.lockFeature!.isSupportBackupBattery == + 1, + child: Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + FlavorsImg( + child: Image.asset( + showElectricIcon( + state.electricQuantityStandby.value), + width: 30.w, + height: 24.w), + ), + SizedBox(width: 2.w), + Text('${state.electricQuantityStandby.value}%', + style: TextStyle( + fontSize: 18.sp, + color: AppColors.darkGrayTextColor)), + SizedBox(width: 2.w), + FlavorsImg( + child: Icon( + Icons.info, // 使用内置的 warning 图标,它是一个叹号 + color: AppColors.mainColor, // 设置图标颜色为红色 + size: 25.w, // 设置图标大小为 30 + ), + ), + SizedBox(width: 20.w), + ], + ), + ) + ], + ), + )), GestureDetector( onTap: () { if (state.openDoorBtnisUneable.value == true) { @@ -282,7 +348,7 @@ class _LockDetailPageState extends State spreadRadius: 0, ), ]), - margin: EdgeInsets.only(top: 20.h), + margin: EdgeInsets.only(top: 0.h), child: Stack( alignment: AlignmentDirectional.center, children: [ @@ -326,10 +392,10 @@ class _LockDetailPageState extends State Padding( padding: EdgeInsets.only(left: 15.w, right: 00.w, bottom: 15.h), child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisAlignment: MainAxisAlignment.center, children: [ Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.center, children: [ Text( TranslationLoader @@ -339,76 +405,12 @@ class _LockDetailPageState extends State fontSize: 20.sp, ), ), + SizedBox( + height: 16.h, + ), adminInfoView(center: false, max: false), ], ), - GestureDetector( - onTap: () { - ShowTipView().showSureAlertDialog( - "${"锁电量更新时间:".tr}${DateTool().dateToYMDHNString(state.keyInfos.value.electricQuantityDate!.toString())}"); - }, - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - Image.asset( - showElectricIcon(state.electricQuantity.value), - width: 30.w, - height: 24.w), - SizedBox(width: 2.w), - Text('${state.electricQuantity.value}%', - style: TextStyle( - fontSize: 18.sp, - color: AppColors.darkGrayTextColor)), - SizedBox(width: 2.w), - Icon( - Icons.info, // 使用内置的 warning 图标,它是一个叹号 - color: AppColors.mainColor, // 设置图标颜色为红色 - size: 25.w, // 设置图标大小为 30 - ), - SizedBox(width: 20.w), - ], - ), - SizedBox( - height: 15.h, - ), - Visibility( - visible: state.keyInfos.value.lockFeature! - .isSupportBackupBattery == - 1, - child: Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - FlavorsImg( - child: Image.asset( - showElectricIcon( - state.electricQuantityStandby.value), - width: 30.w, - height: 24.w), - ), - SizedBox(width: 2.w), - Text('${state.electricQuantityStandby.value}%', - style: TextStyle( - fontSize: 18.sp, - color: AppColors.darkGrayTextColor)), - SizedBox(width: 2.w), - FlavorsImg( - child: Icon( - Icons.info, // 使用内置的 warning 图标,它是一个叹号 - color: AppColors.mainColor, // 设置图标颜色为红色 - size: 25.w, // 设置图标大小为 30 - ), - ), - SizedBox(width: 20.w), - ], - ), - ) - ], - ), - ) ], ), ) @@ -760,6 +762,24 @@ class _LockDetailPageState extends State ? AppColors.mainColor : AppColors.btnDisableColor), ), + if (add) SizedBox(width: 20.w) else SizedBox(width: 40.w), + FlavorsImg( + child: Image.asset('images/main/icon_lockDetail_needNetwork.png', + width: 24.w, + height: 20.w, + color: state.keyInfos.value.appUnlockOnline == 1 + ? AppColors.mainColor + : AppColors.btnDisableColor), + ), + SizedBox(width: 6.w), + Text( + '手机需联网', + style: TextStyle( + fontSize: 20.sp, + color: state.keyInfos.value.appUnlockOnline == 1 + ? AppColors.mainColor + : AppColors.btnDisableColor), + ), if (add) ...[ const Spacer(), GestureDetector( diff --git a/lib/main/lockMian/entity/lockListInfo_entity.dart b/lib/main/lockMian/entity/lockListInfo_entity.dart index c3a63756..b3c62d17 100755 --- a/lib/main/lockMian/entity/lockListInfo_entity.dart +++ b/lib/main/lockMian/entity/lockListInfo_entity.dart @@ -133,6 +133,7 @@ class LockListInfoItemEntity { LockFeature? lockFeature; LockSetting? lockSetting; int? hasGateway; + int? appUnlockOnline; String? mac; LockListInfoItemEntity({ @@ -169,6 +170,7 @@ class LockListInfoItemEntity { this.model, this.vendor, this.hasGateway, + this.appUnlockOnline, this.mac, }); @@ -212,6 +214,7 @@ class LockListInfoItemEntity { ? LockSetting.fromJson(json['lockSetting']) : null; hasGateway = json['hasGateway']; + appUnlockOnline = json['appUnlockOnline']; mac = json['mac']; } @@ -256,6 +259,7 @@ class LockListInfoItemEntity { data['lockSetting'] = lockSetting!.toJson(); } data['hasGateway'] = hasGateway; + data['appUnlockOnline'] = appUnlockOnline; data['mac'] = mac; return data; } From 443ea7731bf4f5fdb42b8dadf2ce59174d54d091 Mon Sep 17 00:00:00 2001 From: anfe <448468458@qq.com> Date: Sat, 1 Jun 2024 13:35:03 +0800 Subject: [PATCH 04/10] =?UTF-8?q?fix:=20=E5=B0=86=E6=9E=81=E5=85=89?= =?UTF-8?q?=E6=8E=A8=E9=80=81=E5=88=86=E5=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/flavors.dart | 1 + lib/login/login/starLock_login_logic.dart | 2 +- lib/main.dart | 3 ++ lib/tools/xs_jPhush.dart | 37 ++++++++++++++--------- 4 files changed, 27 insertions(+), 16 deletions(-) diff --git a/lib/flavors.dart b/lib/flavors.dart index fcfb501e..723078df 100755 --- a/lib/flavors.dart +++ b/lib/flavors.dart @@ -29,6 +29,7 @@ class F { static String get name => appFlavor?.name ?? ''; static bool get isXHJ => appFlavor == Flavor.xhj; + static bool get isSKY => appFlavor == Flavor.sky; //便捷判断并返回值 static dynamic sw( diff --git a/lib/login/login/starLock_login_logic.dart b/lib/login/login/starLock_login_logic.dart index 8651fa1d..848cd6f8 100755 --- a/lib/login/login/starLock_login_logic.dart +++ b/lib/login/login/starLock_login_logic.dart @@ -51,7 +51,7 @@ class StarLockLoginLogic extends BaseGetXController { Storage.saveLoginData(entity.data); Storage.setBool(saveIsVip, entity.data!.isVip == 0 ? false : true); eventBus.fire(MineInfoChangeRefreshUI()); - XSJPushProvider().initJPushService(); + XSJPushProvider().bindDeviceID(); XSJPushProvider().initLocalNotification(isCancelLocalPush: false); Get.offNamedUntil(Routers.starLockMain, (Route route) => false); BlueManage().scanDevices.clear(); //清除设备缓存 diff --git a/lib/main.dart b/lib/main.dart index 65a67850..db02409e 100755 --- a/lib/main.dart +++ b/lib/main.dart @@ -9,6 +9,7 @@ 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/tools/xs_jPhush.dart'; import 'package:star_lock/translations/trans_lib.dart'; import 'app.dart'; @@ -27,6 +28,8 @@ FutureOr main() async { // bugly错误日志监控 await BuglyTool.init(); + await XSJPushProvider().initJPushService(); + runApp(const MyApp()); if (AppPlatform.isAndroid) { diff --git a/lib/tools/xs_jPhush.dart b/lib/tools/xs_jPhush.dart index 986243e7..5d08d9bb 100755 --- a/lib/tools/xs_jPhush.dart +++ b/lib/tools/xs_jPhush.dart @@ -3,6 +3,7 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_local_notifications/flutter_local_notifications.dart'; import 'package:jpush_flutter/jpush_flutter.dart'; +import 'package:star_lock/flavors.dart'; import 'package:star_lock/mine/minePersonInfo/minePersonInfoEditAccount/minePersonInfoEditAccount/mineUnbindPhoneOrEmail_entity.dart'; import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/tools/baseGetXController.dart'; @@ -22,8 +23,15 @@ class XSJPushProvider { return; } + String appKey; + if (F.isSKY) { + appKey = '7ff37d174c1a568a89e98dad'; + } else { + appKey = '251fc8074820d122b6de58d2'; + } + jpush.setup( - appKey: '251fc8074820d122b6de58d2', + appKey: appKey, channel: 'flutter_channel', production: false, debug: true, @@ -34,25 +42,24 @@ class XSJPushProvider { ); addJPushEventHandler(); - bindDeviceID(); } //极光推送事件处理方法 void addJPushEventHandler() { jpush.addEventHandler( - onReceiveNotification: (Map message) async { - AppLog.log('onReceiveNotification: $message'); - }, - onOpenNotification: (Map message) async { - AppLog.log('onOpenNotification: $message'); - }, - onReceiveMessage: (Map message) async { - AppLog.log('onReceiveMessage: $message'); - }, - onReceiveNotificationAuthorization: (Map message) async { - AppLog.log('onReceiveNotificationAuthorization: $message'); - }, - ); + onReceiveNotification: (Map message) async { + AppLog.log('onReceiveNotification: $message'); + }, onOpenNotification: (Map message) async { + AppLog.log('onOpenNotification: $message'); + }, onReceiveMessage: (Map message) async { + AppLog.log('onReceiveMessage: $message'); + //这里接收自定义消息 + }, onReceiveNotificationAuthorization: + (Map message) async { + AppLog.log('onReceiveNotificationAuthorization: $message'); + }, onInAppMessageShow: (Map message) async { + AppLog.log('onInAppMessageShow: $message'); + }); } //绑定设备ID From af155c80c59e019e5522d760ebddefd586c07984 Mon Sep 17 00:00:00 2001 From: Daisy <> Date: Sat, 1 Jun 2024 14:10:01 +0800 Subject: [PATCH 05/10] =?UTF-8?q?fix=E6=8F=90=E6=B5=8B=E9=97=AE=E9=A2=98?= =?UTF-8?q?=EF=BC=9A=E9=94=81=E8=AE=BE=E7=BD=AE-=E5=BC=80=E9=94=81?= =?UTF-8?q?=E6=8F=90=E9=86=92=E6=97=A0=E6=B3=95=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lockSet/lockSet/lockSet_logic.dart | 86 +++++++++++-------- .../lockSet/lockSet/lockSet_page.dart | 12 +-- .../lockSet/lockSet/lockSet_state.dart | 15 ++-- 3 files changed, 59 insertions(+), 54 deletions(-) diff --git a/lib/main/lockDetail/lockSet/lockSet/lockSet_logic.dart b/lib/main/lockDetail/lockSet/lockSet/lockSet_logic.dart index 39fb92f8..2729d160 100755 --- a/lib/main/lockDetail/lockSet/lockSet/lockSet_logic.dart +++ b/lib/main/lockDetail/lockSet/lockSet/lockSet_logic.dart @@ -1,4 +1,3 @@ - import 'dart:async'; import 'package:flutter/scheduler.dart'; @@ -64,7 +63,8 @@ class LockSetLogic extends BaseGetXController { // } // 上传数据获取锁设置 - if (reply is UpdataLockSetReply && (state.ifCurrentScreen.value == true)) { + if (reply is UpdataLockSetReply && + (state.ifCurrentScreen.value == true)) { _replyUpdataLockSetReply(reply); } }); @@ -128,11 +128,13 @@ class LockSetLogic extends BaseGetXController { //无权限 final List? privateKey = await Storage.getStringList(saveBluePrivateKey); - final List getPrivateKeyList = changeStringListToIntList(privateKey!); + final List getPrivateKeyList = + changeStringListToIntList(privateKey!); final List? publicKey = await Storage.getStringList(saveBluePublicKey); - final List publicKeyDataList = changeStringListToIntList(publicKey!); + final List publicKeyDataList = + changeStringListToIntList(publicKey!); final List? token = await Storage.getStringList(saveBlueToken); final List getTokenList = changeStringListToIntList(token!); @@ -217,16 +219,19 @@ class LockSetLogic extends BaseGetXController { // 上传数据获取锁设置解析 Future _replyUpdataLockSetReply(Reply reply) async { final int status = reply.data[2]; - switch(status){ + switch (status) { case 0x00: - //成功 + //成功 dismissEasyLoading(); cancelBlueConnetctToastTimer(); - _lockDataUpload(uploadType:1, recordType:0, records:reply.data.sublist(7, reply.data.length)); + _lockDataUpload( + uploadType: 1, + recordType: 0, + records: reply.data.sublist(7, reply.data.length)); break; case 0x06: - //无权限 + //无权限 final List token = reply.data.sublist(3, 7); final List saveStrList = changeIntListToStringList(token); Storage.setStringList(saveBlueToken, saveStrList); @@ -294,11 +299,13 @@ class LockSetLogic extends BaseGetXController { if (connectionState == BluetoothConnectionState.connected) { final List? privateKey = await Storage.getStringList(saveBluePrivateKey); - final List getPrivateKeyList = changeStringListToIntList(privateKey!); + final List getPrivateKeyList = + changeStringListToIntList(privateKey!); final List? publicKey = await Storage.getStringList(saveBluePublicKey); - final List publicKeyDataList = changeStringListToIntList(publicKey!); + final List publicKeyDataList = + changeStringListToIntList(publicKey!); final List? token = await Storage.getStringList(saveBlueToken); final List getTokenList = changeStringListToIntList(token!); @@ -358,14 +365,16 @@ class LockSetLogic extends BaseGetXController { if (connectionState == BluetoothConnectionState.connected) { final List? privateKey = await Storage.getStringList(saveBluePrivateKey); - final List getPrivateKeyList = changeStringListToIntList(privateKey!); + final List getPrivateKeyList = + changeStringListToIntList(privateKey!); final List? token = await Storage.getStringList(saveBlueToken); final List getTokenList = changeStringListToIntList(token!); final List? publicKey = await Storage.getStringList(saveBluePublicKey); - final List getPublicKeyList = changeStringListToIntList(publicKey!); + final List getPublicKeyList = + changeStringListToIntList(publicKey!); state.settingUpSupportFeatures = type; @@ -404,7 +413,8 @@ class LockSetLogic extends BaseGetXController { // 获取锁设置信息 Future getLockSettingInfoData() async { - final LockSetInfoEntity entity = await ApiRepository.to.getLockSettingInfoData( + final LockSetInfoEntity entity = + await ApiRepository.to.getLockSettingInfoData( lockId: state.lockId.toString(), ); if (entity.errorCode!.codeIsSuccessful) { @@ -425,6 +435,8 @@ class LockSetLogic extends BaseGetXController { state.lockSettingInfo.value.bluetoothBroadcast!; state.isOpenExceptionWarnings.value = state.lockSettingInfo.value.bluetoothBroadcast!; + state.isUnlockReminder.value = + state.lockSettingInfo.value.unlockReminder!; } return entity; } @@ -432,7 +444,8 @@ class LockSetLogic extends BaseGetXController { // 开启考勤获取是否有公司 Future openCheckingInData( BlockSetCheckInCallback blockSetCheckInCallback) async { - final CheckingInInfoDataEntity entity = await ApiRepository.to.openCheckingInData( + final CheckingInInfoDataEntity entity = + await ApiRepository.to.openCheckingInData( lockId: state.lockSetInfoData.value.lockId.toString(), ); if (entity.errorCode!.codeIsSuccessful) { @@ -459,15 +472,15 @@ class LockSetLogic extends BaseGetXController { // 设置是否打开开锁提醒 Future setLockPickingReminder() async { - final LoginEntity entity = await ApiRepository.to.setLockPickingReminderData( + final LoginEntity entity = + await ApiRepository.to.setLockPickingReminderData( lockId: state.lockSetInfoData.value.lockId!, - unlockReminder: state.isLockPickingReminder.value == 1 ? 0 : 1, + unlockReminder: state.isUnlockReminder.value == 1 ? 0 : 1, ); if (entity.errorCode!.codeIsSuccessful) { - state.isLockPickingReminder.value = - (state.isLockPickingReminder.value == 1 ? 0 : 1); - state.lockSettingInfo.value.unlockReminderPush = - state.isLockPickingReminder.value; + state.isUnlockReminder.value = + (state.isUnlockReminder.value == 1 ? 0 : 1); + state.lockSettingInfo.value.unlockReminder = state.isUnlockReminder.value; showToast('设置成功'.tr, something: () { eventBus.fire(RefreshLockListInfoDataEvent()); }); @@ -519,7 +532,8 @@ class LockSetLogic extends BaseGetXController { ShowTipView().showIosTipWithContentDialog('删除锁后,所有信息都会一起删除,确定删除锁吗?'.tr, () { // 删除锁 - ShowTipView().showTFViewAlertDialog(state.passwordTF, '请输入登录密码'.tr, '请输入登录密码'.tr, checkLoginPassword); + ShowTipView().showTFViewAlertDialog( + state.passwordTF, '请输入登录密码'.tr, '请输入登录密码'.tr, checkLoginPassword); }); } else if (state.lockBasicInfo.value.keyRight == 1) { // 授权管理员弹框提示 @@ -597,7 +611,8 @@ class LockSetLogic extends BaseGetXController { Future getUpdataLockSet() async { // showBlueConnetctToastTimer(action: (){ // }); - BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async { + BlueManage().blueSendData(BlueManage().connectDeviceName, + (BluetoothConnectionState connectionState) async { if (connectionState == BluetoothConnectionState.connected) { final List? token = await Storage.getStringList(saveBlueToken); final List getTokenList = changeStringListToIntList(token!); @@ -614,7 +629,8 @@ class LockSetLogic extends BaseGetXController { // 公共的上传锁设置 Future updataLockSet(List token) async { - final List? privateKey = await Storage.getStringList(saveBluePrivateKey); + final List? privateKey = + await Storage.getStringList(saveBluePrivateKey); final List getPrivateKeyList = changeStringListToIntList(privateKey!); final List? signKey = await Storage.getStringList(saveBlueSignKey); @@ -626,26 +642,21 @@ class LockSetLogic extends BaseGetXController { token: token, needAuthor: 1, signKey: signKeyDataList, - privateKey: getPrivateKeyList - ); + privateKey: getPrivateKeyList); } // 锁数据上传服务器 - Future _lockDataUpload({ - required int uploadType, - required int recordType, - required List records - }) async{ + Future _lockDataUpload( + {required int uploadType, + required int recordType, + required List records}) async { final LoginEntity entity = await ApiRepository.to.lockDataUpload( lockId: CommonDataManage().currentKeyInfo.lockId!, - uploadType:uploadType, + uploadType: uploadType, recordType: recordType, - records:records, - isUnShowLoading: true - ); - if(entity.errorCode!.codeIsSuccessful){ - - } + records: records, + isUnShowLoading: true); + if (entity.errorCode!.codeIsSuccessful) {} } @override @@ -659,7 +670,6 @@ class LockSetLogic extends BaseGetXController { @override void onClose() { - _replySubscription.cancel(); _passCurrentLockInformationEvent!.cancel(); // _scanListDiscoveredDeviceSubscription.cancel(); diff --git a/lib/main/lockDetail/lockSet/lockSet/lockSet_page.dart b/lib/main/lockDetail/lockSet/lockSet/lockSet_page.dart index 1734eaef..d98c86e1 100755 --- a/lib/main/lockDetail/lockSet/lockSet/lockSet_page.dart +++ b/lib/main/lockDetail/lockSet/lockSet/lockSet_page.dart @@ -490,9 +490,7 @@ class _LockSetPageState extends State with RouteAware { Obx( () => Visibility( visible: state.lockBasicInfo.value.isLockOwner == 1 && - state.lockFeature.value.unlockReminder == 1 - ? true - : false, + state.lockFeature.value.unlockReminder == 1, child: CommonItem( leftTitel: TranslationLoader.lanKeys!.unlockReminder!.tr, rightTitle: "", @@ -661,11 +659,9 @@ class _LockSetPageState extends State with RouteAware { activeColor: CupertinoColors.activeBlue, trackColor: CupertinoColors.systemGrey5, thumbColor: CupertinoColors.white, - value: state.isLockPickingReminder.value == 1 ? true : false, - onChanged: (value) { - setState(() { - logic.setLockPickingReminder(); - }); + value: state.isUnlockReminder.value == 1, + onChanged: (bool value) { + logic.setLockPickingReminder(); }, ); } diff --git a/lib/main/lockDetail/lockSet/lockSet/lockSet_state.dart b/lib/main/lockDetail/lockSet/lockSet/lockSet_state.dart index 0040129b..e791f008 100755 --- a/lib/main/lockDetail/lockSet/lockSet/lockSet_state.dart +++ b/lib/main/lockDetail/lockSet/lockSet/lockSet_state.dart @@ -1,4 +1,3 @@ - import 'dart:async'; import 'package:flutter/material.dart'; @@ -15,13 +14,13 @@ class LockSetState { final lockId = 0.obs; var isOnlyOneData = false.obs; - var isAttendance = 0.obs;// 是否开启考勤 - var isOpenLockNeedOnline = 0.obs;// APP开锁时是否需联网 + var isAttendance = 0.obs; // 是否开启考勤 + var isOpenLockNeedOnline = 0.obs; // APP开锁时是否需联网 - var isLockPickingReminder = 0.obs;// 是否开启开锁提醒 - var isOpenBlueBroadcast = 0.obs;// 是否开启蓝牙广播 - var isOpenExceptionWarnings = 0.obs;// 是否开启异常警告 - var isOpenStayWarn = 0.obs;// 是否开启逗留警告 + var isUnlockReminder = 0.obs; // 是否开启开锁提醒 + var isOpenBlueBroadcast = 0.obs; // 是否开启蓝牙广播 + var isOpenExceptionWarnings = 0.obs; // 是否开启异常警告 + var isOpenStayWarn = 0.obs; // 是否开启逗留警告 var passwordTF = TextEditingController(); @@ -34,4 +33,4 @@ class LockSetState { lockId.value = map["lockId"]; isOnlyOneData.value = map["isOnlyOneData"]; } -} \ No newline at end of file +} From 87d6655849fd3a2b436325460ba36cd5347bee02 Mon Sep 17 00:00:00 2001 From: Daisy <> Date: Sat, 1 Jun 2024 16:33:24 +0800 Subject: [PATCH 06/10] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dxhj=E7=9A=84release?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=E4=B8=8B=E4=B8=8D=E8=83=BD=E8=BF=9B=E5=85=A5?= =?UTF-8?q?=E8=AE=BE=E5=A4=87=E8=AF=A6=E6=83=85=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/main/lockDetail/lockDetail/lockDetail_page.dart | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/main/lockDetail/lockDetail/lockDetail_page.dart b/lib/main/lockDetail/lockDetail/lockDetail_page.dart index f4193511..f97a8481 100755 --- a/lib/main/lockDetail/lockDetail/lockDetail_page.dart +++ b/lib/main/lockDetail/lockDetail/lockDetail_page.dart @@ -253,8 +253,7 @@ class _LockDetailPageState extends State crossAxisAlignment: CrossAxisAlignment.center, children: [ const Spacer(), - Positioned( - child: GestureDetector( + GestureDetector( onTap: () { ShowTipView().showSureAlertDialog( "${"锁电量更新时间:".tr}${DateTool().dateToYMDHNString(state.keyInfos.value.electricQuantityDate!.toString())}"); @@ -318,7 +317,7 @@ class _LockDetailPageState extends State ) ], ), - )), + ), GestureDetector( onTap: () { if (state.openDoorBtnisUneable.value == true) { From d5db2db6728af54e548e3345bb691d6a7d61e50d Mon Sep 17 00:00:00 2001 From: anfe <448468458@qq.com> Date: Sat, 1 Jun 2024 17:25:55 +0800 Subject: [PATCH 07/10] =?UTF-8?q?feat:=E5=AE=8C=E6=88=90=E5=BE=AA=E7=8E=AF?= =?UTF-8?q?=E6=97=A5=E6=9C=9F=E5=A4=A7=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- images/lan/lan_en.json | 102 ++++++----- images/lan/lan_keys.json | 9 +- images/lan/lan_zh.json | 9 +- .../card/addCardType/addCardType_logic.dart | 5 + .../card/addCardType/addCardType_page.dart | 2 +- .../card/cardDetail/cardDetail_logic.dart | 171 ++++++++++-------- .../card/cardDetail/cardDetail_page.dart | 2 +- .../electronicKeyDetail_logic.dart | 5 + .../electronicKeyDetail_page.dart | 2 +- .../massSendElectronicKey_logic.dart | 5 + .../massSendElectronicKey_page.dart | 16 +- .../view/sendElectronicKeyView_logic.dart | 9 +- .../view/sendElectronicKeyView_page.dart | 2 +- .../face/addFaceType/addFaceType_logic.dart | 5 + .../face/addFaceType/addFaceType_page.dart | 2 +- .../face/faceDetail/faceDetail_logic.dart | 7 +- .../face/faceDetail/faceDetail_page.dart | 4 +- .../addFingerprintType_logic.dart | 5 + .../addFingerprintType_page.dart | 2 +- .../fingerprintDetail_logic.dart | 5 + .../fingerprintDetail_page.dart | 4 +- .../iris/addIrisType/addIrisType_logic.dart | 5 + .../iris/addIrisType/addIrisType_page.dart | 26 +-- .../iris/irisDetail/irisDetail_logic.dart | 5 + .../iris/irisDetail/irisDetail_page.dart | 2 +- .../basicInformation_logic.dart | 22 ++- .../basicInformation_page.dart | 2 +- .../palm/addPalmType/addPalmType_logic.dart | 5 + .../palm/addPalmType/addPalmType_page.dart | 28 +-- .../palm/palmDetail/palmDetail_logic.dart | 7 +- .../palm/palmDetail/palmDetail_page.dart | 72 ++++---- .../passwordKey_perpetual_page.dart | 2 +- .../addRemoteControl_logic.dart | 5 + .../addRemoteControl_page.dart | 38 ++-- lib/tools/pickers/time_picker/time_utils.dart | 37 +++- 35 files changed, 381 insertions(+), 248 deletions(-) diff --git a/images/lan/lan_en.json b/images/lan/lan_en.json index 0b123252..5c9cf9f3 100755 --- a/images/lan/lan_en.json +++ b/images/lan/lan_en.json @@ -337,7 +337,6 @@ "customSMSTemplate": "Custom SMS Template", "customMailTemplate": "Custom Mail Template", "record": "Record", - "forTheFirstTime": "For the first time", "onceDay": "once a day", "weekOnce": "once a week", @@ -789,53 +788,51 @@ "文件校验失败 0x02": "File verification failed 0x02", "文件校验失败 0x03": "File verification failed 0x03", "固件升级完成": "Firmware upgrade completed", - "记录":"Record", - "开通高级功能后才可以对锁进行管理":"You can manage locks only after the advanced function is enabled", - "去开通":"Go and Activate", - "实名认证":"Real-name authentication", - "当前剩余数量":"Current surplus quantity", - "购买":"Buy", - "实名认证为付费功能,请购买后再使用":"Real-name authentication is a paid function, please use it after purchase", - "密码不一致哦":"The passwords are inconsistent", - - "退出添加":"Quit adding", - "管理员已满":"Admin full", + "记录": "Record", + "开通高级功能后才可以对锁进行管理": "You can manage locks only after the advanced function is enabled", + "去开通": "Go and Activate", + "实名认证": "Real-name authentication", + "当前剩余数量": "Current surplus quantity", + "购买": "Buy", + "实名认证为付费功能,请购买后再使用": "Real-name authentication is a paid function, please use it after purchase", + "密码不一致哦": "The passwords are inconsistent", + "退出添加": "Quit adding", + "管理员已满": "Admin full", "用户已满": "The user is full", "锁上面添加指纹已满": "Add fingerprint on lock is full", "指纹已存在": "The fingerprint already exists.", "锁上面添加人脸已满": "Lock above add face is full", "人脸已存在": "The face already exists", - "锁上面添加卡已满":"Lock above add card is full", + "锁上面添加卡已满": "Lock above add card is full", "卡已存在": "Card already exists", "锁上面添加密码已满": "Lock above add password is full", "密码已存在": "Password already exists", "请输入密码": "Please enter password", "暂无密码,无需重置": "No password, no need to reset", - - "真实姓名":"Real name", - "身份证号":"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", - "请先获取固件文件到手机本地,再选择升级":"Please obtain the firmware file to the local phone first, and then select Upgrade", - "固件升级中":"The firmware is being upgraded", - "取消升级":"Cancel the upgrade", - "固件传输中":"Firmware in transit", - "关闭":"Shut down", - "传输中'":"In transit", - "操作记录":"Operation record", - "修改姓名":"Modify name", - "传输中":"In transit", - "发送人":"Sender", - "发送时间":"Send time", - "钥匙详情":"Key details", - "姓名":"Name", - "发送":"Send", - "请确认姓名全名和身份证号码是否正确":"Please confirm that the full name and ID number are correct", - "传输期间请勿离开当前页面":"Do not leave the current page during transfer", + "真实姓名": "Real name", + "身份证号": "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", + "请先获取固件文件到手机本地,再选择升级": "Please obtain the firmware file to the local phone first, and then select Upgrade", + "固件升级中": "The firmware is being upgraded", + "取消升级": "Cancel the upgrade", + "固件传输中": "Firmware in transit", + "关闭": "Shut down", + "传输中'": "In transit", + "操作记录": "Operation record", + "修改姓名": "Modify name", + "传输中": "In transit", + "发送人": "Sender", + "发送时间": "Send time", + "钥匙详情": "Key details", + "姓名": "Name", + "发送": "Send", + "请确认姓名全名和身份证号码是否正确": "Please confirm that the full name and ID number are correct", + "传输期间请勿离开当前页面": "Do not leave the current page during transfer", "机型": "models", "硬件版本": "Hardware version", "固件版本": "Firmware version", @@ -846,16 +843,23 @@ "操作失败,请确认锁是否在附近,或重启手机蓝牙后再试。": "The operation failed. Please confirm whether the lock is nearby, or restart your phone's Bluetooth and try again.", "如果是全自动锁,请使屏幕变亮": "If it is a fully automatic lock, please make the screen brighter", "正在尝试闭锁……": "Attempting to lock...", - "清空记录":"Clear record", - "是否要删除操作记录?":"Do you want to delete the operation record?", - "被删除的记录不能恢复":"The deleted record cannot be restored", - "全部事件":"All events", - "开锁事件":"Unlock event", - "异常事件":"Abnormal event", - "门铃事件":"Doorbell event", - "视频事件":"Video event", - "请开启蓝牙":"Please turn on Bluetooth", - "请选择有效日":"Please select the effective day", + "清空记录": "Clear record", + "是否要删除操作记录?": "Do you want to delete the operation record?", + "被删除的记录不能恢复": "The deleted record cannot be restored", + "全部事件": "All events", + "开锁事件": "Unlock event", + "异常事件": "Abnormal event", + "门铃事件": "Doorbell event", + "视频事件": "Video event", + "请开启蓝牙": "Please turn on Bluetooth", + "请选择有效日": "Please select the effective day", "公司名字长度不能小于 6 ": "The length of the company name cannot be less than 6", - "已是最新版本": "It is the latest version" + "已是最新版本": "It is the latest version", + "一": "Mon", + "二": "Tue", + "三": "Wed", + "四": "Thu", + "五": "Fri", + "六": "Sat", + "日": "Sun" } diff --git a/images/lan/lan_keys.json b/images/lan/lan_keys.json index d05012dd..2f33cfae 100755 --- a/images/lan/lan_keys.json +++ b/images/lan/lan_keys.json @@ -886,5 +886,12 @@ "请开启蓝牙":"请开启蓝牙", "请选择有效日":"请选择有效日", "公司名字长度不能小于 6 ": "公司名字长度不能小于 6 ", - "已是最新版本": "已是最新版本" + "已是最新版本": "已是最新版本", + "一":"一", + "二":"二", + "三":"三", + "四":"四", + "五":"五", + "六":"六", + "日":"日" } diff --git a/images/lan/lan_zh.json b/images/lan/lan_zh.json index 43e12af2..d0a4460d 100755 --- a/images/lan/lan_zh.json +++ b/images/lan/lan_zh.json @@ -856,5 +856,12 @@ "请开启蓝牙": "请开启蓝牙", "请选择有效日": "请选择有效日", "公司名字长度不能小于 6 ": "公司名字长度不能小于 6 ", - "已是最新版本": "已是最新版本" + "已是最新版本": "已是最新版本", + "一": "一", + "二": "二", + "三": "三", + "四": "四", + "五": "五", + "六": "六", + "日": "日" } diff --git a/lib/main/lockDetail/card/addCardType/addCardType_logic.dart b/lib/main/lockDetail/card/addCardType/addCardType_logic.dart index a0068189..af92363d 100755 --- a/lib/main/lockDetail/card/addCardType/addCardType_logic.dart +++ b/lib/main/lockDetail/card/addCardType/addCardType_logic.dart @@ -2,6 +2,7 @@ import 'package:get/get.dart'; import 'package:star_lock/login/login/entity/LoginEntity.dart'; import 'package:star_lock/tools/baseGetXController.dart'; +import 'package:star_lock/tools/pickers/time_picker/time_utils.dart'; import '../../../../appRouters.dart'; import '../../../../network/api_repository.dart'; @@ -11,6 +12,10 @@ import 'addCardType_state.dart'; class AddCardTypeLogic extends BaseGetXController{ AddCardTypeState state = AddCardTypeState(); + List get weekDayStr { + return state.weekdaysList.map((e) => TimeUtils.translateWeekday(e)).toList(); + } + // 添加卡数据 Future addCardData() async { int carType = 0; // 永久:1;限时2,单次3,循环:4 diff --git a/lib/main/lockDetail/card/addCardType/addCardType_page.dart b/lib/main/lockDetail/card/addCardType/addCardType_page.dart index 6ef366d4..a7d8c8cc 100755 --- a/lib/main/lockDetail/card/addCardType/addCardType_page.dart +++ b/lib/main/lockDetail/card/addCardType/addCardType_page.dart @@ -210,7 +210,7 @@ class _AddCardPageState extends State visible: state.weekdaysList.isNotEmpty, child: CommonItem( leftTitel: '有效日'.tr, - rightTitle: state.weekdaysList.value.join(',').toString(), + rightTitle: logic.weekDayStr.join(',').toString(), isHaveDirection: true, isHaveLine: true, action: () async { diff --git a/lib/main/lockDetail/card/cardDetail/cardDetail_logic.dart b/lib/main/lockDetail/card/cardDetail/cardDetail_logic.dart index 9f6a85c7..012ca8b6 100755 --- a/lib/main/lockDetail/card/cardDetail/cardDetail_logic.dart +++ b/lib/main/lockDetail/card/cardDetail/cardDetail_logic.dart @@ -1,4 +1,3 @@ - import 'dart:async'; import 'package:flutter_blue_plus/flutter_blue_plus.dart'; @@ -7,6 +6,7 @@ import 'package:star_lock/blue/io_type.dart'; import 'package:star_lock/login/login/entity/LoginEntity.dart'; import 'package:star_lock/tools/baseGetXController.dart'; import 'package:star_lock/tools/eventBusEventManage.dart'; +import 'package:star_lock/tools/pickers/time_picker/time_utils.dart'; import '../../../../blue/blue_manage.dart'; import '../../../../blue/io_protocol/io_addICCardWithTimeCycleCoercion.dart'; @@ -19,15 +19,22 @@ import '../../../../tools/dateTool.dart'; import '../../../../tools/storage.dart'; import 'cardDetail_state.dart'; -class CardDetailLogic extends BaseGetXController{ +class CardDetailLogic extends BaseGetXController { CardDetailState state = CardDetailState(); + List get weekDayStr { + return state.weekDay.map((e) => TimeUtils.translateWeekday(e)).toList(); + } + // 监听设备返回的数据 late StreamSubscription _replySubscription; + void _initReplySubscription() { - _replySubscription = EventBusManager().eventBus!.on().listen((Reply reply) async { + _replySubscription = + EventBusManager().eventBus!.on().listen((Reply reply) async { // 添加卡片开始(重置锁里面所有卡) - if((reply is SenderAddICCardWithTimeCycleCoercionReply) && (state.ifCurrentScreen.value == true)) { + if ((reply is SenderAddICCardWithTimeCycleCoercionReply) && + (state.ifCurrentScreen.value == true)) { _replyAddICCardBegin(reply); } }); @@ -37,23 +44,26 @@ class CardDetailLogic extends BaseGetXController{ Future _replyAddICCardBegin(Reply reply) async { final int status = reply.data[2]; - switch(status){ + switch (status) { case 0x00: //成功 cancelBlueConnetctToastTimer(); dismissEasyLoading(); - if(state.isDeletCard.value == true){ + if (state.isDeletCard.value == true) { deletICCardData(); - }else{ + } else { editICCardData(); } break; case 0x06: //无权限 - final List? privateKey = await Storage.getStringList(saveBluePrivateKey); - final List getPrivateKeyList = changeStringListToIntList(privateKey!); + final List? privateKey = + await Storage.getStringList(saveBluePrivateKey); + final List getPrivateKeyList = + changeStringListToIntList(privateKey!); - final List? signKey = await Storage.getStringList(saveBlueSignKey); + final List? signKey = + await Storage.getStringList(saveBlueSignKey); final List signKeyDataList = changeStringListToIntList(signKey!); final List token = reply.data.sublist(5, 9); @@ -61,25 +71,29 @@ class CardDetailLogic extends BaseGetXController{ Storage.setStringList(saveBlueToken, saveStrList); IoSenderManage.senderAddCardWithTimeCycleCoercionCommand( - keyID:state.keyId.value.toString(), - userID:await Storage.getUid(), - cardNo:int.parse(state.typeNumber.value), - useCountLimit:0xffff, - operate:state.isDeletCard.value ? 2 : 1, // 0:注册 1:修改 2:删除 3:删除全部 - isAdmin:state.isAdministrator.value == true ? 1 : 0, - isForce:state.isStressCard.value == true ? 1 : 0, // 是否是胁迫 - isRound:state.keyType.value == 4 ? 1: 0, // 是否是循环 - weekRound:DateTool().accordingTheCycleIntoTheCorrespondingNumber(state.weekDay.value), // 周循环 - startDate: int.parse(state.startDate.value)~/1000, - endDate: int.parse(state.endDate.value)~/1000, - startTime:DateTool().dateToHNString(state.starTime.value), - endTime:DateTool().dateToHNString(state.endTime.value), - needAuthor:1, - signKey:signKeyDataList, - privateKey:getPrivateKeyList, - token: token, - isBeforeAddUser: false - ); + keyID: state.keyId.value.toString(), + userID: await Storage.getUid(), + cardNo: int.parse(state.typeNumber.value), + useCountLimit: 0xffff, + operate: state.isDeletCard.value ? 2 : 1, + // 0:注册 1:修改 2:删除 3:删除全部 + isAdmin: state.isAdministrator.value == true ? 1 : 0, + isForce: state.isStressCard.value == true ? 1 : 0, + // 是否是胁迫 + isRound: state.keyType.value == 4 ? 1 : 0, + // 是否是循环 + weekRound: DateTool().accordingTheCycleIntoTheCorrespondingNumber( + state.weekDay.value), + // 周循环 + startDate: int.parse(state.startDate.value) ~/ 1000, + endDate: int.parse(state.endDate.value) ~/ 1000, + startTime: DateTool().dateToHNString(state.starTime.value), + endTime: DateTool().dateToHNString(state.endTime.value), + needAuthor: 1, + signKey: signKeyDataList, + privateKey: getPrivateKeyList, + token: token, + isBeforeAddUser: false); break; default: //失败 @@ -89,52 +103,61 @@ class CardDetailLogic extends BaseGetXController{ // 添加卡片 Future senderAddICCard() 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 deviceConnectionState) async { - if (deviceConnectionState == BluetoothConnectionState.connected){ - final List? signKey = await Storage.getStringList(saveBlueSignKey); + BlueManage().blueSendData(BlueManage().connectDeviceName, + (BluetoothConnectionState deviceConnectionState) async { + if (deviceConnectionState == BluetoothConnectionState.connected) { + final List? signKey = + await Storage.getStringList(saveBlueSignKey); final List signKeyDataList = changeStringListToIntList(signKey!); - final List? privateKey = await Storage.getStringList(saveBluePrivateKey); - final List getPrivateKeyList = changeStringListToIntList(privateKey!); + final List? privateKey = + await Storage.getStringList(saveBluePrivateKey); + final List getPrivateKeyList = + changeStringListToIntList(privateKey!); final List? token = await Storage.getStringList(saveBlueToken); final List getTokenList = changeStringListToIntList(token!); IoSenderManage.senderAddCardWithTimeCycleCoercionCommand( - keyID:state.keyId.value.toString(), - userID:await Storage.getUid(), - cardNo:int.parse(state.typeNumber.value), - useCountLimit:0xffff, - operate:state.isDeletCard.value ? 2 : 1, // 0:注册 1:修改 2:删除 3:删除全部 - isAdmin:state.isAdministrator.value == true ? 1 : 0, - isForce:state.isStressCard.value == true ? 1 : 0, // 是否是胁迫 - isRound:state.keyType.value == 4 ? 1: 0, // 是否是循环 - weekRound:DateTool().accordingTheCycleIntoTheCorrespondingNumber(state.weekDay.value), // 周循环 - startDate: int.parse(state.startDate.value)~/1000, - endDate: int.parse(state.endDate.value)~/1000, - startTime:DateTool().dateToHNString(state.starTime.value), - endTime:DateTool().dateToHNString(state.endTime.value), - needAuthor:1, - signKey:signKeyDataList, - privateKey:getPrivateKeyList, - token: getTokenList, - isBeforeAddUser: false - ); - } else if (deviceConnectionState == BluetoothConnectionState.disconnected) { + keyID: state.keyId.value.toString(), + userID: await Storage.getUid(), + cardNo: int.parse(state.typeNumber.value), + useCountLimit: 0xffff, + operate: state.isDeletCard.value ? 2 : 1, + // 0:注册 1:修改 2:删除 3:删除全部 + isAdmin: state.isAdministrator.value == true ? 1 : 0, + isForce: state.isStressCard.value == true ? 1 : 0, + // 是否是胁迫 + isRound: state.keyType.value == 4 ? 1 : 0, + // 是否是循环 + weekRound: DateTool().accordingTheCycleIntoTheCorrespondingNumber( + state.weekDay.value), + // 周循环 + startDate: int.parse(state.startDate.value) ~/ 1000, + endDate: int.parse(state.endDate.value) ~/ 1000, + startTime: DateTool().dateToHNString(state.starTime.value), + endTime: DateTool().dateToHNString(state.endTime.value), + needAuthor: 1, + signKey: signKeyDataList, + privateKey: getPrivateKeyList, + token: getTokenList, + isBeforeAddUser: false); + } else if (deviceConnectionState == + BluetoothConnectionState.disconnected) { dismissEasyLoading(); cancelBlueConnetctToastTimer(); state.sureBtnState.value = 0; - if(state.ifCurrentScreen.value == true){ + if (state.ifCurrentScreen.value == true) { showBlueConnetctToast(); } } @@ -142,7 +165,7 @@ class CardDetailLogic extends BaseGetXController{ } // 编辑iC卡 - Future editICCardData() async{ + Future editICCardData() async { final LoginEntity entity = await ApiRepository.to.editICCardData( cardId: state.keyId.value.toString(), lockId: state.fingerprintItemData.value.lockId.toString(), @@ -154,39 +177,40 @@ class CardDetailLogic extends BaseGetXController{ changeType: '1', startTime: int.parse(state.starTime.value), endTime: int.parse(state.endTime.value), - cardType:state.keyType.value, + cardType: state.keyType.value, cardRight: state.isAdministrator.value ? 1 : 0, ); - if(entity.errorCode!.codeIsSuccessful){ - showToast('修改成功'.tr, something: (){ + if (entity.errorCode!.codeIsSuccessful) { + showToast('修改成功'.tr, something: () { eventBus.fire(OtherTypeRefreshListEvent()); }); } } // 删除IC卡 - Future deletICCardData() async{ + Future deletICCardData() async { final LoginEntity entity = await ApiRepository.to.deletIcCardData( cardId: state.fingerprintItemData.value.cardId.toString(), lockId: state.fingerprintItemData.value.lockId.toString(), type: '0', - deleteType:'1' - ); - if(entity.errorCode!.codeIsSuccessful){ - showToast('删除成功'.tr, something: (){ + deleteType: '1'); + if (entity.errorCode!.codeIsSuccessful) { + showToast('删除成功'.tr, something: () { Get.back(result: 'addScuess'); }); } } - String getKeyTypeShowDateTime(){ + String getKeyTypeShowDateTime() { String useDateStr = ''; - if(state.keyType.value == 1){ + if (state.keyType.value == 1) { useDateStr = '永久'.tr; - }else if(state.keyType.value == 2){ - useDateStr = '${DateTool().dateToYMDHNString(state.startDate.value)}\n${DateTool().dateToYMDHNString(state.endDate.value)}'; - } else if(state.keyType.value == 4){ - useDateStr = '${DateTool().dateToYMDString(state.startDate.value)}\n${DateTool().dateToYMDString(state.endDate.value)}'; + } else if (state.keyType.value == 2) { + useDateStr = + '${DateTool().dateToYMDHNString(state.startDate.value)}\n${DateTool().dateToYMDHNString(state.endDate.value)}'; + } else if (state.keyType.value == 4) { + useDateStr = + '${DateTool().dateToYMDString(state.startDate.value)}\n${DateTool().dateToYMDString(state.endDate.value)}'; } return useDateStr; } @@ -204,5 +228,4 @@ class CardDetailLogic extends BaseGetXController{ _replySubscription.cancel(); } - -} \ No newline at end of file +} diff --git a/lib/main/lockDetail/card/cardDetail/cardDetail_page.dart b/lib/main/lockDetail/card/cardDetail/cardDetail_page.dart index 96166bd2..316a1bde 100755 --- a/lib/main/lockDetail/card/cardDetail/cardDetail_page.dart +++ b/lib/main/lockDetail/card/cardDetail/cardDetail_page.dart @@ -110,7 +110,7 @@ class _CardDetailPageState extends State with RouteAware { visible: state.keyType.value == 4, child: Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.effectiveDay!.tr, - rightTitle: state.weekDay.value.join(','), + rightTitle: logic.weekDayStr.join(','), isHaveDirection: true, isHaveLine: true, action: () async { diff --git a/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_logic.dart b/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_logic.dart index 1bc06968..4436d5f8 100755 --- a/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_logic.dart +++ b/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_logic.dart @@ -14,6 +14,7 @@ import '../../../../../tools/commonDataManage.dart'; import '../../../../../tools/custom_bottom_sheet.dart'; import '../../../../../tools/dateTool.dart'; import '../../../../../tools/eventBusEventManage.dart'; +import '../../../../../tools/pickers/time_picker/time_utils.dart'; import '../../../../../tools/showTipView.dart'; import '../../../lockOperatingRecord/keyOperationRecord_entity.dart'; @@ -22,6 +23,10 @@ typedef BlockIsHaveAllDataCallback = void Function(bool isAllData); class ElectronicKeyDetailLogic extends BaseGetXController { final ElectronicKeyDetailState state = ElectronicKeyDetailState(); + List get weekDayStr { + return state.weekDay.map((e) => TimeUtils.translateWeekday(e)).toList(); + } + //修改钥匙名称请求 Future modifyKeyNameRequest() async { if (state.changeNameController.text.isEmpty) { diff --git a/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_page.dart b/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_page.dart index 0df58a34..1da7b39a 100755 --- a/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_page.dart +++ b/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_page.dart @@ -147,7 +147,7 @@ class _ElectronicKeyDetailPageState extends State { visible: state.keyType.value == 4 ? true : false, child: Obx(() => CommonItem( leftTitel: '有效日'.tr, - rightTitle: state.weekDay.value.join(','), + rightTitle: logic.weekDayStr.join(','), isHaveDirection: true, isHaveLine: true, action: () async { diff --git a/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendElectronicKey/massSendElectronicKey_logic.dart b/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendElectronicKey/massSendElectronicKey_logic.dart index ebf47281..10679722 100755 --- a/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendElectronicKey/massSendElectronicKey_logic.dart +++ b/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendElectronicKey/massSendElectronicKey_logic.dart @@ -1,5 +1,6 @@ import 'package:get/get.dart'; import 'package:star_lock/tools/baseGetXController.dart'; +import 'package:star_lock/tools/pickers/time_picker/time_utils.dart'; import '../../../../../common/XSConstantMacro/XSConstantMacro.dart'; import '../../../../../network/api_repository.dart'; import '../../../../../tools/dateTool.dart'; @@ -9,6 +10,10 @@ import 'massSendElectronicKey_state.dart'; class MassSendElectronicKeyLogic extends BaseGetXController { MassSendElectronicKeyState state = MassSendElectronicKeyState(); + List get weekDayStr { + return state.weekdaysList.map((e) => TimeUtils.translateWeekday(e)).toList(); + } + //群发钥匙检查 Future massKeyChecksRequest() async { String getFailureDateTime = '0'; diff --git a/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendElectronicKey/massSendElectronicKey_page.dart b/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendElectronicKey/massSendElectronicKey_page.dart index 2495cec2..43a09b90 100755 --- a/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendElectronicKey/massSendElectronicKey_page.dart +++ b/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendElectronicKey/massSendElectronicKey_page.dart @@ -176,7 +176,7 @@ class _MassSendElectronicKeyPageState extends State { ), CommonItem( leftTitel: TranslationLoader.lanKeys!.countryAndRegion!.tr, - rightTitle: "", + rightTitle: '', isHaveLine: true, isHaveRightWidget: true, isHaveDirection: true, @@ -261,7 +261,7 @@ class _MassSendElectronicKeyPageState extends State { children: [ CommonItem( leftTitel: TranslationLoader.lanKeys!.remoteUnlockingAllowed!.tr, - rightTitle: "", + rightTitle: '', isHaveRightWidget: true, rightWidget: SizedBox(width: 60.w, height: 50.h, child: _switch()), action: () {}), @@ -276,7 +276,7 @@ class _MassSendElectronicKeyPageState extends State { children: [ Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr, - rightTitle: "${state.beginTime.value}\n${state.endTime.value}", + rightTitle: '${state.beginTime.value}\n${state.endTime.value}', isHaveDirection: true, isHaveLine: true, action: () async { @@ -297,10 +297,10 @@ class _MassSendElectronicKeyPageState extends State { } })), Obx(() => Visibility( - visible: state.weekdaysList.isNotEmpty ? true : false, + visible: state.weekdaysList.isNotEmpty, child: CommonItem( - leftTitel: "有效日".tr, - rightTitle: state.weekdaysList.value.join(",").toString(), + leftTitel: '有效日'.tr, + rightTitle: logic.weekDayStr.join(',').toString(), isHaveDirection: true, isHaveLine: true, action: () async { @@ -323,9 +323,9 @@ class _MassSendElectronicKeyPageState extends State { Obx(() => Visibility( visible: state.effectiveDateTime.value.isNotEmpty, child: CommonItem( - leftTitel: "有效时间".tr, + leftTitel: '有效时间'.tr, rightTitle: - "${state.effectiveDateTime.value}-${state.failureDateTime.value}", + '${state.effectiveDateTime.value}-${state.failureDateTime.value}', isHaveDirection: true, action: () async { var result = await Get.toNamed( 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 d5974e16..5d49209f 100755 --- a/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_logic.dart +++ b/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_logic.dart @@ -6,12 +6,13 @@ import 'package:star_lock/main/lockDetail/authorizedAdmin/authorizedAdmin/author 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'; import 'package:star_lock/tools/dateTool.dart'; import 'package:star_lock/tools/eventBusEventManage.dart'; +import 'package:star_lock/tools/pickers/time_picker/time_utils.dart'; +import 'package:star_lock/tools/regularExpression.dart'; +import 'package:star_lock/tools/showCupertinoAlertView.dart'; import 'package:star_lock/tools/showTipView.dart'; import 'package:star_lock/tools/storage.dart'; @@ -20,6 +21,10 @@ class SendElectronicKeyViewLogic extends BaseGetXController { String type; final SendElectronicKeyViewState state = SendElectronicKeyViewState(); + List get weekDayStr { + return state.weekdaysList.map((e) => TimeUtils.translateWeekday(e)).toList(); + } + @override void onInit() { super.onInit(); diff --git a/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_page.dart b/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_page.dart index 40473e16..654cc2df 100755 --- a/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_page.dart +++ b/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_page.dart @@ -257,7 +257,7 @@ class _SendElectronicKeyViewState extends State visible: logic.state.weekdaysList.isNotEmpty, child: CommonItem( leftTitel: '有效日'.tr, - rightTitle: logic.state.weekdaysList.join(',').toString(), + rightTitle: logic.weekDayStr.join(',').toString(), isHaveDirection: true, isHaveLine: true, action: () async { diff --git a/lib/main/lockDetail/face/addFaceType/addFaceType_logic.dart b/lib/main/lockDetail/face/addFaceType/addFaceType_logic.dart index 6cac090b..1191ac29 100755 --- a/lib/main/lockDetail/face/addFaceType/addFaceType_logic.dart +++ b/lib/main/lockDetail/face/addFaceType/addFaceType_logic.dart @@ -3,12 +3,17 @@ import 'package:star_lock/login/login/entity/LoginEntity.dart'; import 'package:star_lock/main/lockDetail/face/addFaceType/addFaceType_state.dart'; import 'package:star_lock/tools/baseGetXController.dart'; import 'package:star_lock/tools/dateTool.dart'; +import 'package:star_lock/tools/pickers/time_picker/time_utils.dart'; import '../../../../appRouters.dart'; import '../../../../network/api_repository.dart'; class AddFaceTypeLogic extends BaseGetXController { AddFaceTypeState state = AddFaceTypeState(); + List get weekDayStr { + return state.weekdaysList.map((e) => TimeUtils.translateWeekday(e)).toList(); + } + // 添加指纹 Future addFaceData() async { int faceType = 0; // 永久:1;限时2,单次3,循环:4 diff --git a/lib/main/lockDetail/face/addFaceType/addFaceType_page.dart b/lib/main/lockDetail/face/addFaceType/addFaceType_page.dart index b89f68fe..5d57651f 100755 --- a/lib/main/lockDetail/face/addFaceType/addFaceType_page.dart +++ b/lib/main/lockDetail/face/addFaceType/addFaceType_page.dart @@ -209,7 +209,7 @@ class _AddFaceTypePageState extends State with SingleTickerProv visible: state.weekdaysList.isNotEmpty, child: CommonItem( leftTitel: '有效日'.tr, - rightTitle: state.weekdaysList.value.join(',').toString(), + rightTitle: logic.weekDayStr.join(',').toString(), isHaveDirection: true, isHaveLine: true, action: () async { diff --git a/lib/main/lockDetail/face/faceDetail/faceDetail_logic.dart b/lib/main/lockDetail/face/faceDetail/faceDetail_logic.dart index 774e722f..8e34d8e9 100755 --- a/lib/main/lockDetail/face/faceDetail/faceDetail_logic.dart +++ b/lib/main/lockDetail/face/faceDetail/faceDetail_logic.dart @@ -2,12 +2,11 @@ import 'dart:async'; import 'package:flutter_blue_plus/flutter_blue_plus.dart'; import 'package:get/get.dart'; -import 'package:star_lock/app_settings/app_settings.dart'; import 'package:star_lock/blue/io_protocol/io_addFace.dart'; -import 'package:star_lock/blue/io_type.dart'; import 'package:star_lock/main/lockDetail/face/faceDetail/faceDetail_state.dart'; import 'package:star_lock/tools/baseGetXController.dart'; import 'package:star_lock/tools/dateTool.dart'; +import 'package:star_lock/tools/pickers/time_picker/time_utils.dart'; import '../../../../blue/blue_manage.dart'; import '../../../../blue/io_reply.dart'; import '../../../../blue/io_tool/io_tool.dart'; @@ -19,6 +18,10 @@ import '../../../../tools/storage.dart'; class FaceDetailLogic extends BaseGetXController { FaceDetailState state = FaceDetailState(); + List get weekDayStr { + return state.weekDay.map((e) => TimeUtils.translateWeekday(e)).toList(); + } + // 获取解析后的数据 late StreamSubscription _replySubscription; void _initReplySubscription() { diff --git a/lib/main/lockDetail/face/faceDetail/faceDetail_page.dart b/lib/main/lockDetail/face/faceDetail/faceDetail_page.dart index 577361ba..1e596979 100755 --- a/lib/main/lockDetail/face/faceDetail/faceDetail_page.dart +++ b/lib/main/lockDetail/face/faceDetail/faceDetail_page.dart @@ -111,10 +111,10 @@ class _FaceDetailPageState extends State with RouteAware { } }))), Obx(() => Visibility( - visible: state.keyType.value == 4 ? true : false, + visible: state.keyType.value == 4, child: Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.effectiveDay!.tr, - rightTitle: state.weekDay.value.join(','), + rightTitle: logic.weekDayStr.join(','), isHaveDirection: true, isHaveLine: true, action: () async { diff --git a/lib/main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintType_logic.dart b/lib/main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintType_logic.dart index 7676df86..caff99d5 100755 --- a/lib/main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintType_logic.dart +++ b/lib/main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintType_logic.dart @@ -2,6 +2,7 @@ import 'package:get/get.dart'; import 'package:star_lock/login/login/entity/LoginEntity.dart'; import 'package:star_lock/tools/baseGetXController.dart'; +import 'package:star_lock/tools/pickers/time_picker/time_utils.dart'; import '../../../../appRouters.dart'; import '../../../../network/api_repository.dart'; import '../../../../tools/dateTool.dart'; @@ -10,6 +11,10 @@ import 'addFingerprintType_state.dart'; class AddFingerprintTypeLogic extends BaseGetXController{ AddFingerprintState state = AddFingerprintState(); + List get weekDayStr { + return state.weekdaysList.map((e) => TimeUtils.translateWeekday(e)).toList(); + } + // 添加指纹 Future addFingerprintsData() async { int fingerprintType = 0; // 永久:1;限时2,单次3,循环:4 diff --git a/lib/main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintType_page.dart b/lib/main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintType_page.dart index 3f771e6f..b2d10259 100755 --- a/lib/main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintType_page.dart +++ b/lib/main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintType_page.dart @@ -202,7 +202,7 @@ class _AddFingerprintTypePageState extends State with Si visible: state.weekdaysList.isNotEmpty, child: CommonItem( leftTitel: '有效日'.tr, - rightTitle: state.weekdaysList.value.join(',').toString(), + rightTitle: logic.weekDayStr.join(',').toString(), isHaveDirection: true, isHaveLine: true, action: () async { diff --git a/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_logic.dart b/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_logic.dart index a27dde10..7d70c18c 100755 --- a/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_logic.dart +++ b/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_logic.dart @@ -5,6 +5,7 @@ import 'package:flutter_blue_plus/flutter_blue_plus.dart'; import 'package:get/get.dart'; import 'package:star_lock/login/login/entity/LoginEntity.dart'; import 'package:star_lock/tools/baseGetXController.dart'; +import 'package:star_lock/tools/pickers/time_picker/time_utils.dart'; import '../../../../blue/blue_manage.dart'; import '../../../../blue/io_protocol/io_addFingerprintWithTimeCycleCoercion.dart'; import '../../../../blue/io_reply.dart'; @@ -20,6 +21,10 @@ import 'fingerprintDetail_state.dart'; class FingerprintDetailLogic extends BaseGetXController{ FingerprintDetailState state = FingerprintDetailState(); + List get weekDayStr { + return state.weekDay.map((e) => TimeUtils.translateWeekday(e)).toList(); + } + // 获取解析后的数据 late StreamSubscription _replySubscription; void _initReplySubscription() { diff --git a/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_page.dart b/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_page.dart index f6d80e57..28914bf4 100755 --- a/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_page.dart +++ b/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_page.dart @@ -115,10 +115,10 @@ class _FingerprintDetailPageState extends State } }))), Obx(() => Visibility( - visible: state.keyType.value == 4 ? true : false, + visible: state.keyType.value == 4, child: Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.effectiveDay!.tr, - rightTitle: state.weekDay.value.join(','), + rightTitle: logic.weekDayStr.join(','), isHaveDirection: true, isHaveLine: true, action: () async { diff --git a/lib/main/lockDetail/iris/addIrisType/addIrisType_logic.dart b/lib/main/lockDetail/iris/addIrisType/addIrisType_logic.dart index dd52ec5c..2efdbdb7 100755 --- a/lib/main/lockDetail/iris/addIrisType/addIrisType_logic.dart +++ b/lib/main/lockDetail/iris/addIrisType/addIrisType_logic.dart @@ -2,12 +2,17 @@ import 'package:get/get.dart'; import 'package:star_lock/main/lockDetail/iris/addIrisType/addIrisType_state.dart'; import 'package:star_lock/tools/baseGetXController.dart'; import 'package:star_lock/tools/dateTool.dart'; +import 'package:star_lock/tools/pickers/time_picker/time_utils.dart'; import '../../../../appRouters.dart'; import '../../../../network/api_repository.dart'; class AddIrisTypeLogic extends BaseGetXController { AddIrisTypeState state = AddIrisTypeState(); + List get weekDayStr { + return state.weekdaysList.map((e) => TimeUtils.translateWeekday(e)).toList(); + } + // 添加虹膜 void addIrisData() async { var irisType = 0; // 永久:1;限时2,单次3,循环:4 diff --git a/lib/main/lockDetail/iris/addIrisType/addIrisType_page.dart b/lib/main/lockDetail/iris/addIrisType/addIrisType_page.dart index 582b126a..42011cb3 100755 --- a/lib/main/lockDetail/iris/addIrisType/addIrisType_page.dart +++ b/lib/main/lockDetail/iris/addIrisType/addIrisType_page.dart @@ -57,14 +57,14 @@ class _AddIrisTypePageState extends State { super.initState(); WidgetsBinding.instance.addPostFrameCallback((_) { - if (state.selectType.value == "1") { + if (state.selectType.value == '1') { state.beginTime.value = DateTool().dateToYMDHNString( DateTime.now().millisecondsSinceEpoch.toString()); //默认为当前时间 state.endTime.value = DateTool().dateToYMDHNString( DateTime.now().millisecondsSinceEpoch.toString()); //默认为当前时间 } else { - state.beginTime.value = ""; //默认为当前时间 - state.endTime.value = ""; //默认为当前时间 + state.beginTime.value = ''; //默认为当前时间 + state.endTime.value = ''; //默认为当前时间 } }); } @@ -126,7 +126,7 @@ class _AddIrisTypePageState extends State { Container(height: 10.h), CommonItem( leftTitel: titleStr, - rightTitle: "", + rightTitle: '', isHaveRightWidget: true, rightWidget: getTFWidget(rightTitle)), Container(height: 10.h), @@ -174,7 +174,7 @@ class _AddIrisTypePageState extends State { children: [ Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr, - rightTitle: "${state.beginTime.value}\n${state.endTime.value}", + rightTitle: '${state.beginTime.value}\n${state.endTime.value}', isHaveDirection: true, isHaveLine: true, action: () async { @@ -197,8 +197,8 @@ class _AddIrisTypePageState extends State { Obx(() => Visibility( visible: state.weekdaysList.isNotEmpty ? true : false, child: CommonItem( - leftTitel: "有效日", - rightTitle: state.weekdaysList.value.join(",").toString(), + leftTitel: '有效日'.tr, + rightTitle: logic.weekDayStr.join(',').toString(), isHaveDirection: true, isHaveLine: true, action: () async { @@ -221,9 +221,9 @@ class _AddIrisTypePageState extends State { Obx(() => Visibility( visible: state.effectiveDateTime.value.isNotEmpty, child: CommonItem( - leftTitel: "有效时间".tr, + leftTitel: '有效时间'.tr, rightTitle: - "${state.effectiveDateTime.value}-${state.failureDateTime.value}", + '${state.effectiveDateTime.value}-${state.failureDateTime.value}', isHaveDirection: true, action: () async { var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, @@ -255,8 +255,8 @@ class _AddIrisTypePageState extends State { ? true : false, child: CommonItem( - leftTitel: "是否为管理员".tr, - rightTitle: "", + leftTitel: '是否为管理员'.tr, + rightTitle: '', isTipsImg: false, isHaveRightWidget: true, rightWidget: SizedBox( @@ -268,13 +268,13 @@ class _AddIrisTypePageState extends State { var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); if (isDemoMode == false) { if (state.nameController.text.isEmpty) { - logic.showToast("请输入姓名"); + logic.showToast('请输入姓名'); return; } logic.checkIrisNameDuplicated(state.nameController.text); } else { // Get.toNamed(Routers.selectLockTypePage); - logic.showToast("演示模式"); + logic.showToast('演示模式'); } }), ], diff --git a/lib/main/lockDetail/iris/irisDetail/irisDetail_logic.dart b/lib/main/lockDetail/iris/irisDetail/irisDetail_logic.dart index e5309102..2a31cd67 100755 --- a/lib/main/lockDetail/iris/irisDetail/irisDetail_logic.dart +++ b/lib/main/lockDetail/iris/irisDetail/irisDetail_logic.dart @@ -6,6 +6,7 @@ import 'package:star_lock/blue/io_type.dart'; import 'package:star_lock/main/lockDetail/iris/irisDetail/irisDetail_state.dart'; import 'package:star_lock/tools/baseGetXController.dart'; import 'package:star_lock/tools/eventBusEventManage.dart'; +import 'package:star_lock/tools/pickers/time_picker/time_utils.dart'; import '../../../../blue/blue_manage.dart'; // import '../../../../blue/io_protocol/io_addICCard.dart'; @@ -20,6 +21,10 @@ import '../../../../tools/storage.dart'; class IrisDetailLogic extends BaseGetXController { IrisDetailState state = IrisDetailState(); + List get weekDayStr { + return state.weekDay.map((e) => TimeUtils.translateWeekday(e)).toList(); + } + // 监听设备返回的数据 late StreamSubscription _replySubscription; void _initReplySubscription() { diff --git a/lib/main/lockDetail/iris/irisDetail/irisDetail_page.dart b/lib/main/lockDetail/iris/irisDetail/irisDetail_page.dart index efe540ba..05bd6edf 100755 --- a/lib/main/lockDetail/iris/irisDetail/irisDetail_page.dart +++ b/lib/main/lockDetail/iris/irisDetail/irisDetail_page.dart @@ -108,7 +108,7 @@ class _CardDetailPageState extends State with RouteAware { visible: state.keyType.value == 4 ? true : false, child: Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.effectiveDay!.tr, - rightTitle: state.weekDay.value.join(','), + rightTitle: logic.weekDayStr.join(','), isHaveDirection: true, isHaveLine: true, action: () async { diff --git a/lib/main/lockDetail/lockSet/basicInformation/basicInformation/basicInformation_logic.dart b/lib/main/lockDetail/lockSet/basicInformation/basicInformation/basicInformation_logic.dart index e7c68916..27b818b7 100755 --- a/lib/main/lockDetail/lockSet/basicInformation/basicInformation/basicInformation_logic.dart +++ b/lib/main/lockDetail/lockSet/basicInformation/basicInformation/basicInformation_logic.dart @@ -1,21 +1,31 @@ - import 'dart:async'; import 'package:star_lock/app_settings/app_settings.dart'; +import 'package:star_lock/tools/pickers/time_picker/time_utils.dart'; import '../../../../../tools/baseGetXController.dart'; import '../../../../../tools/eventBusEventManage.dart'; import '../../lockSet/lockSet_logic.dart'; import 'basicInformation_state.dart'; -class BasicInformationLogic extends BaseGetXController{ +class BasicInformationLogic extends BaseGetXController { final BasicInformationState state = BasicInformationState(); + List get weekDayStr { + return state.lockBasicInfo.value.weekDays + ?.map((e) => TimeUtils.translateWeekday(e)) + .toList() ?? + []; + } + // 下级界面修改成功后传递数据 StreamSubscription? _passCurrentLockInformationEvent; + void initLoadDataAction(BlockSetStateCallback blockSetStateCallback) { // 蓝牙协议通知传输跟蓝牙之外的数据传输类不一样 eventBus - _passCurrentLockInformationEvent = eventBus.on().listen((PassCurrentLockInformationEvent event) { + _passCurrentLockInformationEvent = eventBus + .on() + .listen((PassCurrentLockInformationEvent event) { state.lockSetInfoData.value = event.lockSetInfoData; blockSetStateCallback(); }); @@ -25,7 +35,8 @@ class BasicInformationLogic extends BaseGetXController{ void onReady() { super.onReady(); - AppLog.log('厂商 vendor:${state.lockBasicInfo.value.vendor} 型号 model:${state.lockBasicInfo.value.model}'); + AppLog.log( + '厂商 vendor:${state.lockBasicInfo.value.vendor} 型号 model:${state.lockBasicInfo.value.model}'); } @override @@ -33,5 +44,4 @@ class BasicInformationLogic extends BaseGetXController{ super.onClose(); _passCurrentLockInformationEvent?.cancel(); } - -} \ No newline at end of file +} diff --git a/lib/main/lockDetail/lockSet/basicInformation/basicInformation/basicInformation_page.dart b/lib/main/lockDetail/lockSet/basicInformation/basicInformation/basicInformation_page.dart index df445e77..1950a415 100755 --- a/lib/main/lockDetail/lockSet/basicInformation/basicInformation/basicInformation_page.dart +++ b/lib/main/lockDetail/lockSet/basicInformation/basicInformation/basicInformation_page.dart @@ -89,7 +89,7 @@ class _BasicInformationPageState extends State { visible: (state.lockBasicInfo.value.keyType ?? 0) == 4, child: CommonItem( leftTitel: '有效日'.tr, - rightTitle: (state.lockBasicInfo.value.weekDays ?? []).join(',').toString(), + rightTitle: logic.weekDayStr.join(',').toString(), allHeight: 70.h, isHaveLine: true), )), diff --git a/lib/main/lockDetail/palm/addPalmType/addPalmType_logic.dart b/lib/main/lockDetail/palm/addPalmType/addPalmType_logic.dart index e8d658b8..3df980d6 100755 --- a/lib/main/lockDetail/palm/addPalmType/addPalmType_logic.dart +++ b/lib/main/lockDetail/palm/addPalmType/addPalmType_logic.dart @@ -2,12 +2,17 @@ import 'package:get/get.dart'; import 'package:star_lock/main/lockDetail/palm/addPalmType/addPalmType_state.dart'; import 'package:star_lock/tools/baseGetXController.dart'; import 'package:star_lock/tools/dateTool.dart'; +import 'package:star_lock/tools/pickers/time_picker/time_utils.dart'; import '../../../../appRouters.dart'; import '../../../../network/api_repository.dart'; class AddPalmTypeLogic extends BaseGetXController { AddPalmTypeState state = AddPalmTypeState(); + List get weekDayStr { + return state.weekdaysList.map((e) => TimeUtils.translateWeekday(e)).toList(); + } + // 添加指纹 void addPalmData() async { var palmType = 0; // 永久:1;限时2,单次3,循环:4 diff --git a/lib/main/lockDetail/palm/addPalmType/addPalmType_page.dart b/lib/main/lockDetail/palm/addPalmType/addPalmType_page.dart index 9fa34e10..7941ee1d 100755 --- a/lib/main/lockDetail/palm/addPalmType/addPalmType_page.dart +++ b/lib/main/lockDetail/palm/addPalmType/addPalmType_page.dart @@ -57,14 +57,14 @@ class _AddPalmTypePageState extends State { super.initState(); WidgetsBinding.instance.addPostFrameCallback((_) { - if (state.selectType.value == "1") { + if (state.selectType.value == '1') { state.beginTime.value = DateTool().dateToYMDHNString( DateTime.now().millisecondsSinceEpoch.toString()); //默认为当前时间 state.endTime.value = DateTool().dateToYMDHNString( DateTime.now().millisecondsSinceEpoch.toString()); //默认为当前时间 } else { - state.beginTime.value = ""; //默认为当前时间 - state.endTime.value = ""; //默认为当前时间 + state.beginTime.value = ''; //默认为当前时间 + state.endTime.value = ''; //默认为当前时间 } }); } @@ -126,7 +126,7 @@ class _AddPalmTypePageState extends State { Container(height: 10.h), CommonItem( leftTitel: titleStr, - rightTitle: "", + rightTitle: '', isHaveRightWidget: true, rightWidget: getTFWidget(rightTitle)), Container(height: 10.h), @@ -174,7 +174,7 @@ class _AddPalmTypePageState extends State { children: [ Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr, - rightTitle: "${state.beginTime.value}\n${state.endTime.value}", + rightTitle: '${state.beginTime.value}\n${state.endTime.value}', isHaveDirection: true, isHaveLine: true, action: () async { @@ -195,10 +195,10 @@ class _AddPalmTypePageState extends State { } })), Obx(() => Visibility( - visible: state.weekdaysList.isNotEmpty ? true : false, + visible: state.weekdaysList.isNotEmpty, child: CommonItem( - leftTitel: "有效日", - rightTitle: state.weekdaysList.value.join(",").toString(), + leftTitel: '有效日'.tr, + rightTitle: logic.weekDayStr.join(',').toString(), isHaveDirection: true, isHaveLine: true, action: () async { @@ -221,9 +221,9 @@ class _AddPalmTypePageState extends State { Obx(() => Visibility( visible: state.effectiveDateTime.value.isNotEmpty, child: CommonItem( - leftTitel: "有效时间".tr, + leftTitel: '有效时间'.tr, rightTitle: - "${state.effectiveDateTime.value}-${state.failureDateTime.value}", + '${state.effectiveDateTime.value}-${state.failureDateTime.value}', isHaveDirection: true, action: () async { var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, @@ -255,8 +255,8 @@ class _AddPalmTypePageState extends State { ? true : false, child: CommonItem( - leftTitel: "是否为管理员".tr, - rightTitle: "", + leftTitel: '是否为管理员'.tr, + rightTitle: '', isTipsImg: false, isHaveRightWidget: true, rightWidget: SizedBox( @@ -268,13 +268,13 @@ class _AddPalmTypePageState extends State { var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); if (isDemoMode == false) { if (state.nameController.text.isEmpty) { - logic.showToast("请输入姓名"); + logic.showToast('请输入姓名'); return; } logic.checkPalmNameDuplicated(state.nameController.text); } else { // Get.toNamed(Routers.selectLockTypePage); - logic.showToast("演示模式"); + logic.showToast('演示模式'); } }), ], diff --git a/lib/main/lockDetail/palm/palmDetail/palmDetail_logic.dart b/lib/main/lockDetail/palm/palmDetail/palmDetail_logic.dart index c92a3a67..771f6f55 100755 --- a/lib/main/lockDetail/palm/palmDetail/palmDetail_logic.dart +++ b/lib/main/lockDetail/palm/palmDetail/palmDetail_logic.dart @@ -6,13 +6,12 @@ import 'package:star_lock/blue/io_type.dart'; import 'package:star_lock/main/lockDetail/palm/palmDetail/palmDetail_state.dart'; import 'package:star_lock/tools/baseGetXController.dart'; import 'package:star_lock/tools/eventBusEventManage.dart'; +import 'package:star_lock/tools/pickers/time_picker/time_utils.dart'; import '../../../../blue/blue_manage.dart'; -// import '../../../../blue/io_protocol/io_addICCard.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'; import '../../../../network/api_repository.dart'; import '../../../../tools/dateTool.dart'; import '../../../../tools/storage.dart'; @@ -20,6 +19,10 @@ import '../../../../tools/storage.dart'; class PalmDetailLogic extends BaseGetXController { PalmDetailState state = PalmDetailState(); + List get weekDayStr { + return state.weekDay.map((e) => TimeUtils.translateWeekday(e)).toList(); + } + // 监听设备返回的数据 late StreamSubscription _replySubscription; void _initReplySubscription() { diff --git a/lib/main/lockDetail/palm/palmDetail/palmDetail_page.dart b/lib/main/lockDetail/palm/palmDetail/palmDetail_page.dart index 2bcc2ac0..b7865dfc 100755 --- a/lib/main/lockDetail/palm/palmDetail/palmDetail_page.dart +++ b/lib/main/lockDetail/palm/palmDetail/palmDetail_page.dart @@ -34,14 +34,14 @@ class _PalmDetailPageState extends State with RouteAware { return Scaffold( backgroundColor: AppColors.mainBackgroundColor, appBar: TitleAppBar( - barTitle: "手掌详情", + barTitle: '手掌详情', haveBack: true, backgroundColor: AppColors.mainColor, ), body: ListView( children: [ Obx(() => CommonItem( - leftTitel: "手掌号", + leftTitel: '手掌号', rightTitle: state.typeNumber.value, isHaveDirection: false, isHaveLine: true)), @@ -72,14 +72,14 @@ class _PalmDetailPageState extends State with RouteAware { var data = await Get.toNamed( Routers.otherTypeKeyChangeDatePage, arguments: { - "pushType": 0, - "fingerprintItemData": + 'pushType': 0, + 'fingerprintItemData': state.fingerprintItemData.value, }); if (data != null) { setState(() { - state.starDate.value = data["beginTimeTimestamp"]; - state.endDate.value = data["endTimeTimestamp"]; + state.starDate.value = data['beginTimeTimestamp']; + state.endDate.value = data['endTimeTimestamp']; state.keyType.value = 2; }); } @@ -88,68 +88,68 @@ class _PalmDetailPageState extends State with RouteAware { var data = await Get.toNamed( Routers.otherTypeKeyChangeValidityDatePage, arguments: { - "pushType": 0, - "fingerprintItemData": + 'pushType': 0, + 'fingerprintItemData': state.fingerprintItemData.value, }); if (data != null) { setState(() { - state.starDate.value = data["starDate"]; - state.endDate.value = data["endDate"]; - state.starTime.value = data["starTime"]; - state.endTime.value = data["endTime"]; - state.weekDay.value = data["weekDay"]; + state.starDate.value = data['starDate']; + state.endDate.value = data['endDate']; + state.starTime.value = data['starTime']; + state.endTime.value = data['endTime']; + state.weekDay.value = data['weekDay']; }); } } }))), Obx(() => Visibility( - visible: state.keyType.value == 4 ? true : false, + visible: state.keyType.value == 4 , child: Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.effectiveDay!.tr, - rightTitle: state.weekDay.value.join(','), + rightTitle: logic.weekDayStr.join(','), isHaveDirection: true, isHaveLine: true, action: () async { var data = await Get.toNamed( Routers.otherTypeKeyChangeValidityDatePage, arguments: { - "pushType": 0, - "fingerprintItemData": + 'pushType': 0, + 'fingerprintItemData': state.fingerprintItemData.value, }); if (data != null) { setState(() { - state.starDate.value = data["starDate"]; - state.endDate.value = data["endDate"]; - state.starTime.value = data["starTime"]; - state.endTime.value = data["endTime"]; - state.weekDay.value = data["weekDay"]; + state.starDate.value = data['starDate']; + state.endDate.value = data['endDate']; + state.starTime.value = data['starTime']; + state.endTime.value = data['endTime']; + state.weekDay.value = data['weekDay']; }); } })))), Obx(() => Visibility( visible: state.keyType.value == 4 ? true : false, child: Obx(() => CommonItem( - leftTitel: "有效时间", + leftTitel: '有效时间', rightTitle: - "${DateTool().dateToHNString(state.starTime.value)}-${DateTool().dateToHNString(state.endTime.value)}", + '${DateTool().dateToHNString(state.starTime.value)}-${DateTool().dateToHNString(state.endTime.value)}', isHaveDirection: true, action: () async { var data = await Get.toNamed( Routers.otherTypeKeyChangeValidityDatePage, arguments: { - "pushType": 0, - "fingerprintItemData": + 'pushType': 0, + 'fingerprintItemData': state.fingerprintItemData.value, }); if (data != null) { setState(() { - state.starDate.value = data["starDate"]; - state.endDate.value = data["endDate"]; - state.starTime.value = data["starTime"]; - state.endTime.value = data["endTime"]; - state.weekDay.value = data["validityValue"]; + state.starDate.value = data['starDate']; + state.endDate.value = data['endDate']; + state.starTime.value = data['starTime']; + state.endTime.value = data['endTime']; + state.weekDay.value = data['validityValue']; }); } })))), @@ -166,7 +166,7 @@ class _PalmDetailPageState extends State with RouteAware { SizedBox(height: 10.h), CommonItem( leftTitel: TranslationLoader.lanKeys!.operatingRecord!.tr, - rightTitle: "", + rightTitle: '', isHaveDirection: true, action: () { // Get.toNamed(Routers.keyOperationRecordPage, arguments: { @@ -199,11 +199,11 @@ class _PalmDetailPageState extends State with RouteAware { return ShowTFView( title: "${TranslationLoader.lanKeys!.amend!.tr}${TranslationLoader.lanKeys!.name!.tr}", - tipTitle: "", + tipTitle: '', controller: state.changeNameController, sureClick: () { if (state.changeNameController.text.isEmpty) { - logic.showToast("请输入姓名"); + logic.showToast('请输入姓名'); return; } Get.back(); @@ -222,8 +222,8 @@ class _PalmDetailPageState extends State with RouteAware { context: context, builder: (BuildContext context) { return ShowIosTipView( - title: "提示", - tipTitle: "确定要删除吗?", + title: '提示', + tipTitle: '确定要删除吗?', sureClick: () async { Get.back(); String? idStr = await Storage.getUid(); diff --git a/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart b/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart index bfc15647..e6fb21da 100755 --- a/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart +++ b/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart @@ -355,7 +355,7 @@ class _PasswordKeyPerpetualPageState extends State return Column( children: [ CommonItem( - leftTitel: '有效日', + leftTitel: '有效日'.tr, rightTitle: state.loopModeStr.value, isHaveLine: true, isHaveDirection: true, diff --git a/lib/main/lockDetail/remoteControl/addRemoteControl/addRemoteControl_logic.dart b/lib/main/lockDetail/remoteControl/addRemoteControl/addRemoteControl_logic.dart index 0ee20ef7..07161d66 100755 --- a/lib/main/lockDetail/remoteControl/addRemoteControl/addRemoteControl_logic.dart +++ b/lib/main/lockDetail/remoteControl/addRemoteControl/addRemoteControl_logic.dart @@ -1,11 +1,16 @@ import 'package:star_lock/tools/baseGetXController.dart'; +import 'package:star_lock/tools/pickers/time_picker/time_utils.dart'; import 'addRemoteControl_state.dart'; class AddRemoteControlLoigc extends BaseGetXController{ AddRemoteControlState state = AddRemoteControlState(); + List get weekDayStr { + return state.weekdaysList.map((e) => TimeUtils.translateWeekday(e)).toList(); + } + @override void onInit() { diff --git a/lib/main/lockDetail/remoteControl/addRemoteControl/addRemoteControl_page.dart b/lib/main/lockDetail/remoteControl/addRemoteControl/addRemoteControl_page.dart index 9ea0ffc5..5145000f 100755 --- a/lib/main/lockDetail/remoteControl/addRemoteControl/addRemoteControl_page.dart +++ b/lib/main/lockDetail/remoteControl/addRemoteControl/addRemoteControl_page.dart @@ -130,7 +130,7 @@ class _AddRemoteControlPageState extends State children: [ CommonItem( leftTitel: titleStr, - rightTitle: "", + rightTitle: '', isHaveRightWidget: true, rightWidget: getTFWidget(rightTitle)), Container(height: 10.h), @@ -161,8 +161,8 @@ class _AddRemoteControlPageState extends State rightTitle: state.timeLimitEndTime.value, isHaveDirection: true, action: () { - PDuration selectDate = - PDuration.parse(DateTime.tryParse(state.timeLimitEndTime.value)); + PDuration selectDate = PDuration.parse( + DateTime.tryParse(state.timeLimitEndTime.value)); Pickers.showDatePicker(context, selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) { state.timeLimitEndTime.value = @@ -181,7 +181,7 @@ class _AddRemoteControlPageState extends State Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr, rightTitle: - "${state.cycleBeginTime.value}\n${state.cycleEndTime.value}", + '${state.cycleBeginTime.value}\n${state.cycleEndTime.value}', isHaveDirection: true, isHaveLine: true, action: () async { @@ -202,10 +202,10 @@ class _AddRemoteControlPageState extends State } })), Obx(() => Visibility( - visible: state.weekdaysList.isNotEmpty ? true : false, + visible: state.weekdaysList.isNotEmpty, child: CommonItem( - leftTitel: "有效日".tr, - rightTitle: state.weekdaysList.value.join(",").toString(), + leftTitel: '有效日'.tr, + rightTitle: logic.weekDayStr.join(',').toString(), isHaveDirection: true, isHaveLine: true, action: () async { @@ -228,9 +228,9 @@ class _AddRemoteControlPageState extends State Obx(() => Visibility( visible: state.effectiveDateTime.value.isNotEmpty, child: CommonItem( - leftTitel: "有效时间".tr, + leftTitel: '有效时间'.tr, rightTitle: - "${state.effectiveDateTime.value}-${state.failureDateTime.value}", + '${state.effectiveDateTime.value}-${state.failureDateTime.value}', isHaveDirection: true, action: () async { var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, @@ -270,14 +270,14 @@ class _AddRemoteControlPageState extends State var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); if (isDemoMode == false) { if (state.nameController.text.isEmpty) { - logic.showToast("请输入姓名"); + logic.showToast('请输入姓名'); return; } - logic.showToast("请确保在设备附近"); + logic.showToast('请确保在设备附近'); // logic.addFingerprintsData(); } else { // Get.toNamed(Routers.selectLockTypePage); - logic.showToast("演示模式"); + logic.showToast('演示模式'); } }), ], @@ -307,7 +307,7 @@ class _AddRemoteControlPageState extends State height: 20.h, ), Text( - "操作成功,密码为", + '操作成功,密码为', style: TextStyle( fontSize: 32.sp, color: Colors.black, @@ -317,7 +317,7 @@ class _AddRemoteControlPageState extends State height: 10.h, ), Text( - "62689876", + '62689876', style: TextStyle( fontSize: 60.sp, color: Colors.black, @@ -423,15 +423,15 @@ class _AddRemoteControlPageState extends State } final List _itemTabs = [ - ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, selectType: "0"), - ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, selectType: "1"), + ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, selectType: '0'), + ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, selectType: '1'), ItemView( - title: TranslationLoader.lanKeys!.circulation!.tr, selectType: "2"), + title: TranslationLoader.lanKeys!.circulation!.tr, selectType: '2'), ]; final List _fromCheckInTypeItemTabs = [ - ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, selectType: "0"), - ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, selectType: "1"), + ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, selectType: '0'), + ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, selectType: '1'), ]; TabBar _tabBar() { diff --git a/lib/tools/pickers/time_picker/time_utils.dart b/lib/tools/pickers/time_picker/time_utils.dart index bcb183e7..bbe70a56 100755 --- a/lib/tools/pickers/time_picker/time_utils.dart +++ b/lib/tools/pickers/time_picker/time_utils.dart @@ -1,3 +1,5 @@ +import 'package:get/get_utils/get_utils.dart'; + class TimeUtils { /// 年 static List calcYears({int begin = 1900, int end = 2100}) => @@ -14,7 +16,7 @@ class TimeUtils { static List calcDay(int year, int month, {int begin = 1, int end = 31}) { begin = begin < 1 ? 1 : begin; - int days = _calcDateCount(year, month); + final int days = _calcDateCount(year, month); if (end > days) { end = days; } @@ -36,11 +38,15 @@ class TimeUtils { } static List _calcCount(begin, end) { - int length = end - begin + 1; - if (length == 0) return [begin]; - if (length < 0) return []; + final int length = end - begin + 1; + if (length == 0) { + return [begin]; + } + if (length < 0) { + return []; + } - return List.generate(length, (index) => begin + index); + return List.generate(length, (int index) => begin + index); } // 计算月份所对应天数 @@ -67,7 +73,22 @@ class TimeUtils { return (v < 10) ? "0$v" : "$v"; } - // String _checkStr(String v) { - // return v == null ? "" : v; - // } + + static String translateWeekday(int number,[int index=1]) { + final List weekDays = [ + '一'.tr, + '二'.tr, + '三'.tr, + '四'.tr, + '五'.tr, + '六'.tr, + '日'.tr + ]; + final String days = weekDays[number- index]; + return days; // + } + +// String _checkStr(String v) { +// return v == null ? "" : v; +// } } From 778fcffe1d7e4e4ee5b6a4d1bcaa80ca4c533410 Mon Sep 17 00:00:00 2001 From: Daisy <> Date: Sat, 1 Jun 2024 17:29:41 +0800 Subject: [PATCH 08/10] =?UTF-8?q?fix=E6=8F=90=E6=B5=8B=E9=97=AE=E9=A2=98?= =?UTF-8?q?=EF=BC=9A=20=E5=8D=A1/=E5=AF=86=E7=A0=81/=E6=8C=87=E7=BA=B9=20?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E8=B6=85=E8=BF=87=2020=20=E6=9D=A1=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E5=8D=95=E6=9D=A1=E5=90=8E=E4=B8=8B=E6=8B=89=E5=8D=A1?= =?UTF-8?q?=E9=A1=BF=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../card/cardList/cardList_logic.dart | 213 ++++++++------- .../card/cardList/cardList_page.dart | 161 +++++------ .../fingerprintList_logic.dart | 251 +++++++++++------- .../fingerprintList/fingerprintList_page.dart | 173 ++++++------ .../passwordKeyList_logic.dart | 68 ++--- 5 files changed, 473 insertions(+), 393 deletions(-) diff --git a/lib/main/lockDetail/card/cardList/cardList_logic.dart b/lib/main/lockDetail/card/cardList/cardList_logic.dart index 0fa9ccfc..92fed5e3 100755 --- a/lib/main/lockDetail/card/cardList/cardList_logic.dart +++ b/lib/main/lockDetail/card/cardList/cardList_logic.dart @@ -1,4 +1,3 @@ - import 'dart:async'; import 'package:flutter_blue_plus/flutter_blue_plus.dart'; @@ -27,10 +26,11 @@ class CardListLogic extends BaseGetXController { // 获取解析后的数据 late StreamSubscription _replySubscription; void _initReplySubscription() { - _replySubscription = EventBusManager().eventBus!.on().listen((Reply reply) { - + _replySubscription = + EventBusManager().eventBus!.on().listen((Reply reply) { // 添加卡片开始(重置锁里面所有卡) - if((reply is SenderAddICCardWithTimeCycleCoercionReply) && (state.ifCurrentScreen.value == true)) { + if ((reply is SenderAddICCardWithTimeCycleCoercionReply) && + (state.ifCurrentScreen.value == true)) { _replyAddICCardBegin(reply); } }); @@ -40,7 +40,7 @@ class CardListLogic extends BaseGetXController { Future _replyAddICCardBegin(Reply reply) async { final int status = reply.data[2]; - switch(status){ + switch (status) { case 0x00: //成功 cancelBlueConnetctToastTimer(); @@ -48,10 +48,13 @@ class CardListLogic extends BaseGetXController { break; case 0x06: //无权限 - final List? privateKey = await Storage.getStringList(saveBluePrivateKey); - final List getPrivateKeyList = changeStringListToIntList(privateKey!); + final List? privateKey = + await Storage.getStringList(saveBluePrivateKey); + final List getPrivateKeyList = + changeStringListToIntList(privateKey!); - final List? signKey = await Storage.getStringList(saveBlueSignKey); + final List? signKey = + await Storage.getStringList(saveBlueSignKey); final List signKeyDataList = changeStringListToIntList(signKey!); final List token = reply.data.sublist(5, 9); @@ -59,25 +62,24 @@ class CardListLogic extends BaseGetXController { Storage.setStringList(saveBlueToken, saveStrList); IoSenderManage.senderAddCardWithTimeCycleCoercionCommand( - keyID:state.deletKeyID, - userID:(await Storage.getUid())!, - cardNo:state.deletCardNo, - useCountLimit:0xffff, - operate: state.isDeletAll == true ? 3 : 2, // 0:注册 1:修改 2:删除 3:删除全部 - isAdmin:0, - isForce:0, // 是否是胁迫 - isRound:0, // 是否是循环 - weekRound:0, // 周循环 - startDate: 0x11223344, - endDate: 0x11223344, - startTime:'0', - endTime:'0', - needAuthor:1, - signKey:signKeyDataList, - privateKey:getPrivateKeyList, - token: token, - isBeforeAddUser: false - ); + keyID: state.deletKeyID, + userID: (await Storage.getUid())!, + cardNo: state.deletCardNo, + useCountLimit: 0xffff, + operate: state.isDeletAll == true ? 3 : 2, // 0:注册 1:修改 2:删除 3:删除全部 + isAdmin: 0, + isForce: 0, // 是否是胁迫 + isRound: 0, // 是否是循环 + weekRound: 0, // 周循环 + startDate: 0x11223344, + endDate: 0x11223344, + startTime: '0', + endTime: '0', + needAuthor: 1, + signKey: signKeyDataList, + privateKey: getPrivateKeyList, + token: token, + isBeforeAddUser: false); break; default: //失败 @@ -88,44 +90,48 @@ class CardListLogic extends BaseGetXController { // 删除卡片 Future senderAddICCard() async { showEasyLoading(); - showBlueConnetctToastTimer(action: (){ + showBlueConnetctToastTimer(action: () { dismissEasyLoading(); }); - BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { - if (deviceConnectionState == BluetoothConnectionState.connected){ - final List? signKey = await Storage.getStringList(saveBlueSignKey); + BlueManage().blueSendData(BlueManage().connectDeviceName, + (BluetoothConnectionState deviceConnectionState) async { + if (deviceConnectionState == BluetoothConnectionState.connected) { + final List? signKey = + await Storage.getStringList(saveBlueSignKey); final List signKeyDataList = changeStringListToIntList(signKey!); - final List? privateKey = await Storage.getStringList(saveBluePrivateKey); - final List getPrivateKeyList = changeStringListToIntList(privateKey!); + final List? privateKey = + await Storage.getStringList(saveBluePrivateKey); + final List getPrivateKeyList = + changeStringListToIntList(privateKey!); final List? token = await Storage.getStringList(saveBlueToken); final List getTokenList = changeStringListToIntList(token!); IoSenderManage.senderAddCardWithTimeCycleCoercionCommand( - keyID:state.deletKeyID, - userID:(await Storage.getUid())!, - cardNo:state.deletCardNo, - useCountLimit:0xffff, - operate: state.isDeletAll == true ? 3 : 2, // 0:注册 1:修改 2:删除 3:删除全部 - isAdmin:0, - isForce:0, // 是否是胁迫 - isRound:0, // 是否是循环 - weekRound:0, // 周循环 - startDate: 0x11223344, - endDate: 0x11223344, - startTime:'0', - endTime:'0', - needAuthor:1, - signKey:signKeyDataList, - privateKey:getPrivateKeyList, - token: getTokenList, - isBeforeAddUser: false - ); - } else if (deviceConnectionState == BluetoothConnectionState.disconnected) { + keyID: state.deletKeyID, + userID: (await Storage.getUid())!, + cardNo: state.deletCardNo, + useCountLimit: 0xffff, + operate: state.isDeletAll == true ? 3 : 2, // 0:注册 1:修改 2:删除 3:删除全部 + isAdmin: 0, + isForce: 0, // 是否是胁迫 + isRound: 0, // 是否是循环 + weekRound: 0, // 周循环 + startDate: 0x11223344, + endDate: 0x11223344, + startTime: '0', + endTime: '0', + needAuthor: 1, + signKey: signKeyDataList, + privateKey: getPrivateKeyList, + token: getTokenList, + isBeforeAddUser: false); + } else if (deviceConnectionState == + BluetoothConnectionState.disconnected) { dismissEasyLoading(); cancelBlueConnetctToastTimer(); - if(state.ifCurrentScreen.value == true){ + if (state.ifCurrentScreen.value == true) { showBlueConnetctToast(); } } @@ -133,32 +139,34 @@ class CardListLogic extends BaseGetXController { } // 获取IC卡列表 - Future getICCardListData() async{ - final FingerprintListDataEntity entity = await ApiRepository.to.getICCardListData( + Future getICCardListData( + {required bool isRefresh}) async { + // 如果是下拉刷新,清空已有数据 + if (isRefresh) { + state.fingerprintItemListData.clear(); + pageNo = 1; + } + final FingerprintListDataEntity entity = + await ApiRepository.to.getICCardListData( lockId: state.lockId.value.toString(), pageNo: pageNo.toString(), pageSize: pageSize, searchStr: state.searchController.text, ); - if(entity.errorCode!.codeIsSuccessful){ - if (pageNo == 1) { - state.fingerprintItemListData.value = entity.data!.list!; - pageNo++; - } else { - if (entity.data!.list!.isNotEmpty) { - state.fingerprintItemListData.value.addAll(entity.data!.list!); - pageNo++; - } - } + if (entity.errorCode!.codeIsSuccessful) { + // 更新数据列表 + state.fingerprintItemListData.addAll(entity.data!.list!); + // 更新页码 + pageNo++; } return entity; } // 删除所有IC卡 - Future deletICCardData() async{ + Future deletICCardData() async { String cardId = ''; String type = '1'; - if(state.isDeletAll == false){ + if (state.isDeletAll == false) { cardId = state.deletKeyID; type = '0'; } @@ -166,18 +174,15 @@ class CardListLogic extends BaseGetXController { cardId: cardId, lockId: state.lockId.value.toString(), type: type, - deleteType:'1' - ); - if(entity.errorCode!.codeIsSuccessful){ - if(state.isDeletAll == false){ - showToast('删除成功'.tr, something: (){ - pageNo = 1; - getICCardListData(); + deleteType: '1'); + if (entity.errorCode!.codeIsSuccessful) { + if (state.isDeletAll == false) { + showToast('删除成功'.tr, something: () { + getICCardListData(isRefresh: true); }); - }else{ - showToast('重置成功'.tr, something: (){ - pageNo = 1; - getICCardListData(); + } else { + showToast('重置成功'.tr, something: () { + getICCardListData(isRefresh: true); }); } } @@ -186,44 +191,48 @@ class CardListLogic extends BaseGetXController { // 监听修改完详情之后刷新列表 late StreamSubscription _teamEvent; void _initRefreshAction() { - _teamEvent = eventBus.on().listen((OtherTypeRefreshListEvent event) { - pageNo = 1; - getICCardListData(); + _teamEvent = eventBus + .on() + .listen((OtherTypeRefreshListEvent event) { + getICCardListData(isRefresh: true); }); } - String getKeyType(FingerprintItemData fingerprintItemData){ - String keyTypeStr = '';// - if(fingerprintItemData.cardStatus == 1){ - if(fingerprintItemData.startDate! > DateTime.now().millisecondsSinceEpoch){ + String getKeyType(FingerprintItemData fingerprintItemData) { + String keyTypeStr = ''; // + if (fingerprintItemData.cardStatus == 1) { + if (fingerprintItemData.startDate! > + DateTime.now().millisecondsSinceEpoch) { keyTypeStr = '未生效'.tr; } - - }else if(fingerprintItemData.cardStatus == 2){ + } else if (fingerprintItemData.cardStatus == 2) { keyTypeStr = '已失效'.tr; } return keyTypeStr; } - String getKeyDateType(FingerprintItemData fingerprintItemData){ - String keyDateTypeStr = '';// 永久:1;限时2,单次3,循环:4 - if(fingerprintItemData.cardType! == 1){ - keyDateTypeStr = '${DateTool().dateToYMDHNString(fingerprintItemData.createDate.toString())} 永久'; - }else if(fingerprintItemData.cardType! == 2){ - keyDateTypeStr = '${DateTool().dateToYMDHNString(fingerprintItemData.startDate.toString())} - ${DateTool().dateToYMDHNString(fingerprintItemData.endDate.toString())} 限时'; - }else if(fingerprintItemData.cardType! == 4){ - keyDateTypeStr = '${DateTool().dateToYMDString(fingerprintItemData.startDate.toString())}-${DateTool().dateToYMDString(fingerprintItemData.endDate.toString())} 循环'; + String getKeyDateType(FingerprintItemData fingerprintItemData) { + String keyDateTypeStr = ''; // 永久:1;限时2,单次3,循环:4 + if (fingerprintItemData.cardType! == 1) { + keyDateTypeStr = + '${DateTool().dateToYMDHNString(fingerprintItemData.createDate.toString())} 永久'; + } else if (fingerprintItemData.cardType! == 2) { + keyDateTypeStr = + '${DateTool().dateToYMDHNString(fingerprintItemData.startDate.toString())} - ${DateTool().dateToYMDHNString(fingerprintItemData.endDate.toString())} 限时'; + } else if (fingerprintItemData.cardType! == 4) { + keyDateTypeStr = + '${DateTool().dateToYMDString(fingerprintItemData.startDate.toString())}-${DateTool().dateToYMDString(fingerprintItemData.endDate.toString())} 循环'; } return keyDateTypeStr; } - + @override Future onReady() async { super.onReady(); // 获取是否是演示模式 演示模式不获取接口 - final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); - if(isDemoMode == false){ + final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); + if (isDemoMode == false) { _initReplySubscription(); _initRefreshAction(); @@ -239,10 +248,10 @@ class CardListLogic extends BaseGetXController { Future onClose() async { super.onClose(); - final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); - if(isDemoMode == false) { + final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); + if (isDemoMode == false) { _replySubscription.cancel(); _teamEvent.cancel(); } } -} \ No newline at end of file +} diff --git a/lib/main/lockDetail/card/cardList/cardList_page.dart b/lib/main/lockDetail/card/cardList/cardList_page.dart index f9d195b2..088d571b 100755 --- a/lib/main/lockDetail/card/cardList/cardList_page.dart +++ b/lib/main/lockDetail/card/cardList/cardList_page.dart @@ -1,4 +1,3 @@ - import 'package:flutter/material.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; @@ -31,11 +30,13 @@ class _CardListPageState extends State with RouteAware { final CardListLogic logic = Get.put(CardListLogic()); final CardListState state = Get.find().state; - Future getHttpData() async { + Future getHttpData({required bool isRefresh}) async { final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); if (isDemoMode == false) { - logic.getICCardListData().then((FingerprintListDataEntity value){ - if(mounted) { + logic + .getICCardListData(isRefresh: isRefresh) + .then((FingerprintListDataEntity value) { + if (mounted) { setState(() {}); } }); @@ -46,12 +47,11 @@ class _CardListPageState extends State with RouteAware { void initState() { super.initState(); - getHttpData(); + getHttpData(isRefresh: true); } @override Widget build(BuildContext context) { - return Scaffold( backgroundColor: AppColors.mainBackgroundColor, appBar: TitleAppBar( @@ -67,7 +67,8 @@ class _CardListPageState extends State with RouteAware { onPressed: () async { final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); if (isDemoMode == false) { - ShowTipView().showIosTipWithContentDialog('重置后,该锁的卡都将被删除哦,确认要重置吗?'.tr, () async { + ShowTipView().showIosTipWithContentDialog( + '重置后,该锁的卡都将被删除哦,确认要重置吗?'.tr, () async { state.isDeletAll = true; state.deletKeyID = '0'; state.deletCardNo = 0; @@ -82,34 +83,33 @@ class _CardListPageState extends State with RouteAware { ], ), body: EasyRefreshTool( - onRefresh: (){ - logic.pageNo = 1; - getHttpData(); + onRefresh: () { + getHttpData(isRefresh: true); }, - onLoad: (){ - getHttpData(); + onLoad: () { + getHttpData(isRefresh: false); }, child: Column( children: [ KeySearchWidget( editingController: state.searchController, onSubmittedAction: () { - logic.pageNo = 1; - getHttpData(); + getHttpData(isRefresh: true); }, ), SizedBox(height: 20.h), Expanded(child: _buildMainUI()), AddBottomWhiteBtn( - btnName: '${TranslationLoader.lanKeys!.add!.tr}${TranslationLoader.lanKeys!.card!.tr}', + btnName: + '${TranslationLoader.lanKeys!.add!.tr}${TranslationLoader.lanKeys!.card!.tr}', onClick: () async { - final data = await Get.toNamed(Routers.addCardPage, arguments: { - 'lockId': state.lockId.value, - 'fromType': 1 // 1从添加钥匙列表进入 2从考勤添加员工入口进入 - }); + final data = await Get.toNamed(Routers.addCardPage, + arguments: { + 'lockId': state.lockId.value, + 'fromType': 1 // 1从添加钥匙列表进入 2从考勤添加员工入口进入 + }); if (data != null) { - logic.pageNo = 1; - getHttpData(); + getHttpData(isRefresh: true); } }, ), @@ -125,59 +125,69 @@ class _CardListPageState extends State with RouteAware { Widget _buildMainUI() { return Obx(() => state.fingerprintItemListData.value.isNotEmpty ? SlidableAutoCloseBehavior( - child: ListView.separated( - itemCount: state.fingerprintItemListData.value.length, - itemBuilder: (BuildContext c, int index) { - final FingerprintItemData fingerprintItemData = state.fingerprintItemListData.value[index]; - return Slidable( - key:ValueKey(fingerprintItemData.fingerprintId), - endActionPane: ActionPane( - extentRatio: 0.2, - motion: const ScrollMotion(), - children: [ - SlidableAction( - onPressed: (BuildContext context){ - ShowTipView().showIosTipWithContentDialog('确定要删除吗?'.tr, () async { - state.isDeletAll = false; - state.deletKeyID = fingerprintItemData.cardId.toString(); - state.deletCardNo = int.parse(fingerprintItemData.cardNumber!); - logic.senderAddICCard(); - }); - }, - backgroundColor: Colors.red, - foregroundColor: Colors.white, - label: '删除'.tr, - padding: EdgeInsets.only(left: 5.w, right: 5.w), - ), - ], + child: ListView.separated( + itemCount: state.fingerprintItemListData.value.length, + itemBuilder: (BuildContext c, int index) { + final FingerprintItemData fingerprintItemData = + state.fingerprintItemListData.value[index]; + return Slidable( + key: ValueKey(fingerprintItemData.fingerprintId), + endActionPane: ActionPane( + extentRatio: 0.2, + motion: const ScrollMotion(), + children: [ + SlidableAction( + onPressed: (BuildContext context) { + ShowTipView().showIosTipWithContentDialog( + '确定要删除吗?'.tr, () async { + state.isDeletAll = false; + state.deletKeyID = + fingerprintItemData.cardId.toString(); + state.deletCardNo = + int.parse(fingerprintItemData.cardNumber!); + logic.senderAddICCard(); + }); + }, + backgroundColor: Colors.red, + foregroundColor: Colors.white, + label: '删除'.tr, + padding: EdgeInsets.only(left: 5.w, right: 5.w), + ), + ], + ), + child: _keyItem( + 'images/icon_card.png', + fingerprintItemData.cardName!, + logic.getKeyType(fingerprintItemData), + logic.getKeyDateType(fingerprintItemData), () async { + final data = await Get.toNamed(Routers.cardDetailPage, + arguments: { + 'fingerprintItemData': fingerprintItemData, + }); + if (data != null) { + getHttpData(isRefresh: true); + } + }), + ); + }, + separatorBuilder: (BuildContext context, int index) { + return const Divider( + height: 1, + color: AppColors.greyLineColor, + ); + }, ), - child: _keyItem( - 'images/icon_card.png', - fingerprintItemData.cardName!, - logic.getKeyType(fingerprintItemData), - logic.getKeyDateType(fingerprintItemData), () async { - final data = await Get.toNamed( - Routers.cardDetailPage, arguments: { - 'fingerprintItemData': fingerprintItemData, - }); - if (data != null) { - logic.pageNo = 1; - getHttpData(); - } - }), - ); - }, - separatorBuilder: (BuildContext context, int index) { - return const Divider( - height: 1, - color: AppColors.greyLineColor, - ); - }, - ), - ) : NoData(noDataHeight: 1.sh - ScreenUtil().statusBarHeight - ScreenUtil().bottomBarHeight - 190.h - 64.h)); + ) + : NoData( + noDataHeight: 1.sh - + ScreenUtil().statusBarHeight - + ScreenUtil().bottomBarHeight - + 190.h - + 64.h)); } - Widget _keyItem(String lockTypeIcon, String lockTypeTitle, String ifInvalidation, String showTime, Function() action) { + Widget _keyItem(String lockTypeIcon, String lockTypeTitle, + String ifInvalidation, String showTime, Function() action) { return GestureDetector( onTap: action, child: Container( @@ -201,14 +211,13 @@ class _CardListPageState extends State with RouteAware { child: Row( children: [ Flexible( - child: Text( - lockTypeTitle, + child: Text(lockTypeTitle, maxLines: 1, overflow: TextOverflow.ellipsis, - style: TextStyle(fontSize: 24.sp, color: AppColors.blackColor) - ), + style: TextStyle( + fontSize: 24.sp, + color: AppColors.blackColor)), ), - ], ), ), diff --git a/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_logic.dart b/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_logic.dart index 22925060..f7f2d2b7 100755 --- a/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_logic.dart +++ b/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_logic.dart @@ -1,4 +1,3 @@ - import 'dart:async'; import 'package:flutter_blue_plus/flutter_blue_plus.dart'; @@ -18,15 +17,17 @@ import '../../../../tools/storage.dart'; import 'fingerprintListData_entity.dart'; import 'fingerprintList_state.dart'; -class FingerprintListLogic extends BaseGetXController{ +class FingerprintListLogic extends BaseGetXController { FingerprintListState state = FingerprintListState(); // 获取解析后的数据 late StreamSubscription _replySubscription; void _initReplySubscription() { - _replySubscription = EventBusManager().eventBus!.on().listen((Reply reply) { + _replySubscription = + EventBusManager().eventBus!.on().listen((Reply reply) { // 添加指纹开始(此处用作删除指纹) - if((reply is SenderAddFingerprintWithTimeCycleCoercionReply) && (state.ifCurrentScreen.value == true)) { + if ((reply is SenderAddFingerprintWithTimeCycleCoercionReply) && + (state.ifCurrentScreen.value == true)) { _replyAddFingerprintBegin(reply); } @@ -45,7 +46,7 @@ class FingerprintListLogic extends BaseGetXController{ Future _replyAddFingerprintBegin(Reply reply) async { final int status = reply.data[2]; - switch(status){ + switch (status) { case 0x00: //成功 cancelBlueConnetctToastTimer(); @@ -54,10 +55,13 @@ class FingerprintListLogic extends BaseGetXController{ break; case 0x06: //无权限 - final List? privateKey = await Storage.getStringList(saveBluePrivateKey); - final List getPrivateKeyList = changeStringListToIntList(privateKey!); + final List? privateKey = + await Storage.getStringList(saveBluePrivateKey); + final List getPrivateKeyList = + changeStringListToIntList(privateKey!); - final List? signKey = await Storage.getStringList(saveBlueSignKey); + final List? signKey = + await Storage.getStringList(saveBlueSignKey); final List signKeyDataList = changeStringListToIntList(signKey!); final List token = reply.data.sublist(5, 9); @@ -65,25 +69,24 @@ class FingerprintListLogic extends BaseGetXController{ Storage.setStringList(saveBlueToken, saveStrList); IoSenderManage.senderAddFingerprintWithTimeCycleCoercionCommand( - keyID:state.deletKeyID, - userID:(await Storage.getUid())!, - fingerNo:state.deletFingerNo, - useCountLimit:0xffff, - operate: state.isDeletAll == true ? 3 : 2, // 0:注册 1:修改 2:删除 3:删除全部 - isAdmin:0, - isForce:0, // 是否是胁迫 - isRound:0, // 是否是循环 - weekRound:0, // 周循环 - startDate: 0x11223344, - endDate: 0x11223344, - startTime:'0', - endTime:'0', - needAuthor:1, - signKey:signKeyDataList, - privateKey:getPrivateKeyList, - token: token, - isBeforeAddUser: false - ); + keyID: state.deletKeyID, + userID: (await Storage.getUid())!, + fingerNo: state.deletFingerNo, + useCountLimit: 0xffff, + operate: state.isDeletAll == true ? 3 : 2, // 0:注册 1:修改 2:删除 3:删除全部 + isAdmin: 0, + isForce: 0, // 是否是胁迫 + isRound: 0, // 是否是循环 + weekRound: 0, // 周循环 + startDate: 0x11223344, + endDate: 0x11223344, + startTime: '0', + endTime: '0', + needAuthor: 1, + signKey: signKeyDataList, + privateKey: getPrivateKeyList, + token: token, + isBeforeAddUser: false); break; default: //失败 @@ -245,81 +248,124 @@ class FingerprintListLogic extends BaseGetXController{ // 删除指纹 Future senderAddFingerprint() async { showEasyLoading(); - showBlueConnetctToastTimer(action: (){ + showBlueConnetctToastTimer(action: () { dismissEasyLoading(); }); - BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { - if (deviceConnectionState == BluetoothConnectionState.connected){ + BlueManage().blueSendData(BlueManage().connectDeviceName, + (BluetoothConnectionState deviceConnectionState) async { + if (deviceConnectionState == BluetoothConnectionState.connected) { // var publicKey = await Storage.getStringList(saveBluePublicKey); // List publicKeyDataList = changeStringListToIntList(publicKey!); - final List? signKey = await Storage.getStringList(saveBlueSignKey); + final List? signKey = + await Storage.getStringList(saveBlueSignKey); final List signKeyDataList = changeStringListToIntList(signKey!); - final List? privateKey = await Storage.getStringList(saveBluePrivateKey); - final List getPrivateKeyList = changeStringListToIntList(privateKey!); + final List? privateKey = + await Storage.getStringList(saveBluePrivateKey); + final List getPrivateKeyList = + changeStringListToIntList(privateKey!); final List? token = await Storage.getStringList(saveBlueToken); final List getTokenList = changeStringListToIntList(token!); IoSenderManage.senderAddFingerprintWithTimeCycleCoercionCommand( - keyID:state.deletKeyID, - userID:(await Storage.getUid())!, - fingerNo:state.deletFingerNo, - useCountLimit:0xffff, - operate: state.isDeletAll == true ? 3 : 2, // 0:注册 1:修改 2:删除 3:删除全部 - isAdmin:0, - isForce:0, // 是否是胁迫 - isRound:0, // 是否是循环 - weekRound:0, // 周循环 - startDate: 0x11223344, - endDate: 0x11223344, - startTime:'0', - endTime:'0', - needAuthor:1, - signKey:signKeyDataList, - privateKey:getPrivateKeyList, - token: getTokenList, - isBeforeAddUser: false - ); - } else if (deviceConnectionState == BluetoothConnectionState.disconnected) { + keyID: state.deletKeyID, + userID: (await Storage.getUid())!, + fingerNo: state.deletFingerNo, + useCountLimit: 0xffff, + operate: state.isDeletAll == true ? 3 : 2, // 0:注册 1:修改 2:删除 3:删除全部 + isAdmin: 0, + isForce: 0, // 是否是胁迫 + isRound: 0, // 是否是循环 + weekRound: 0, // 周循环 + startDate: 0x11223344, + endDate: 0x11223344, + startTime: '0', + endTime: '0', + needAuthor: 1, + signKey: signKeyDataList, + privateKey: getPrivateKeyList, + token: getTokenList, + isBeforeAddUser: false); + } else if (deviceConnectionState == + BluetoothConnectionState.disconnected) { dismissEasyLoading(); cancelBlueConnetctToastTimer(); - if(state.ifCurrentScreen.value == true){ + if (state.ifCurrentScreen.value == true) { showBlueConnetctToast(); } } }); } + /** + * //请求密码钥匙列表 + Future mockNetworkDataRequest( + {required bool isRefresh}) async { + // 如果是下拉刷新,清空已有数据 + if (isRefresh) { + state.itemDataList.clear(); + pageNo = 1; + } + + final PasswordKeyListEntity entity = await ApiRepository.to.passwordKeyList( + state.keyInfo.value.keyStatus.toString(), + state.keyInfo.value.lockId.toString(), + pageNo.toString(), + pageSize.toString(), + state.searchController.text); + if (entity.errorCode!.codeIsSuccessful) { + // 更新数据列表 + state.itemDataList.addAll(entity.data!.itemList!); + // 更新页码 + pageNo++; + } + return entity; + } + + */ // 获取指纹列表 - Future getFingerprintsListData() async{ - // state.fingerprintItemListData.value.clear(); - final FingerprintListDataEntity entity = await ApiRepository.to.getFingerprintsListData( + Future getFingerprintsListData( + {required bool isRefresh}) async { + // 如果是下拉刷新,清空已有数据 + if (isRefresh) { + state.fingerprintItemListData.clear(); + pageNo = 1; + } + final FingerprintListDataEntity entity = + await ApiRepository.to.getFingerprintsListData( lockId: state.lockId.value.toString(), pageNo: pageNo.toString(), pageSize: pageSize.toString(), searchStr: state.searchController.text, ); - if(entity.errorCode!.codeIsSuccessful){ - if (pageNo == 1) { - state.fingerprintItemListData.value = entity.data!.list!; - pageNo++; - } else { - if (entity.data!.list!.isNotEmpty) { - state.fingerprintItemListData.value.addAll(entity.data!.list!); - pageNo++; - } - } + // if (entity.errorCode!.codeIsSuccessful) { + // if (pageNo == 1) { + // state.fingerprintItemListData.value = entity.data!.list!; + // pageNo++; + // } else { + // if (entity.data!.list!.isNotEmpty) { + // state.fingerprintItemListData.value.addAll(entity.data!.list!); + // pageNo++; + // } + // } + // } + if (entity.errorCode!.codeIsSuccessful) { + // 更新数据列表 + state.fingerprintItemListData.addAll(entity.data!.list!); + // 更新页码 + pageNo++; } + return entity; } // 重置所有的指纹 - Future deletAllFingerprintsData() async{ + Future deletAllFingerprintsData() async { String fingerprintId = ''; String type = '1'; - if(state.isDeletAll == false){ + if (state.isDeletAll == false) { fingerprintId = state.deletKeyID; type = '0'; } @@ -327,18 +373,15 @@ class FingerprintListLogic extends BaseGetXController{ fingerprintId: fingerprintId, lockId: state.lockId.value.toString(), type: type, - deleteType:'1' - ); - if(entity.errorCode!.codeIsSuccessful){ - if(state.isDeletAll == false){ - showToast('删除成功'.tr, something:(){ - pageNo = 1; - getFingerprintsListData(); + deleteType: '1'); + if (entity.errorCode!.codeIsSuccessful) { + if (state.isDeletAll == false) { + showToast('删除成功'.tr, something: () { + getFingerprintsListData(isRefresh: true); }); - }else{ - showToast('重置成功'.tr, something:(){ - pageNo = 1; - getFingerprintsListData(); + } else { + showToast('重置成功'.tr, something: () { + getFingerprintsListData(isRefresh: true); }); } } @@ -347,35 +390,39 @@ class FingerprintListLogic extends BaseGetXController{ // 监听修改完详情之后刷新列表 late StreamSubscription _teamEvent; void _initRefreshAction() { - _teamEvent = eventBus.on().listen((OtherTypeRefreshListEvent event) { - pageNo = 1; - getFingerprintsListData(); + _teamEvent = eventBus + .on() + .listen((OtherTypeRefreshListEvent event) { + getFingerprintsListData(isRefresh: true); }); } - String getKeyType(FingerprintItemData fingerprintItemData){ + String getKeyType(FingerprintItemData fingerprintItemData) { // fingerprintStatus 1:正常 2:失效 - String keyTypeStr = '';// + String keyTypeStr = ''; // // (fingerprintItemData.fingerprintType! != 1) ? (fingerprintItemData.endDate! < DateTime.now().millisecondsSinceEpoch ? "已失效" : "") : "" - if(fingerprintItemData.fingerprintStatus == 1){ - if(fingerprintItemData.startDate! > DateTime.now().millisecondsSinceEpoch){ + if (fingerprintItemData.fingerprintStatus == 1) { + if (fingerprintItemData.startDate! > + DateTime.now().millisecondsSinceEpoch) { keyTypeStr = '未生效'.tr; } - - }else if(fingerprintItemData.fingerprintStatus == 2){ + } else if (fingerprintItemData.fingerprintStatus == 2) { keyTypeStr = '已失效'.tr; } return keyTypeStr; } - String getKeyDateType(FingerprintItemData fingerprintItemData){ - String keyDateTypeStr = '';// 永久:1;限时2,单次3,循环:4 - if(fingerprintItemData.fingerprintType! == 1){ - keyDateTypeStr = "${DateTool().dateToYMDHNString(fingerprintItemData.createDate.toString())} ${"永久".tr}"; - }else if(fingerprintItemData.fingerprintType! == 2){ - keyDateTypeStr = '${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())} 循环'; + String getKeyDateType(FingerprintItemData fingerprintItemData) { + String keyDateTypeStr = ''; // 永久:1;限时2,单次3,循环:4 + if (fingerprintItemData.fingerprintType! == 1) { + keyDateTypeStr = + "${DateTool().dateToYMDHNString(fingerprintItemData.createDate.toString())} ${"永久".tr}"; + } else if (fingerprintItemData.fingerprintType! == 2) { + keyDateTypeStr = + '${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())} 循环'; } return keyDateTypeStr; } @@ -385,8 +432,8 @@ class FingerprintListLogic extends BaseGetXController{ super.onReady(); // 获取是否是演示模式 演示模式不获取接口 - final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); - if(isDemoMode == false){ + final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); + if (isDemoMode == false) { _initReplySubscription(); _initRefreshAction(); @@ -402,10 +449,10 @@ class FingerprintListLogic extends BaseGetXController{ Future onClose() async { super.onClose(); - final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); - if(isDemoMode == false) { + final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); + if (isDemoMode == false) { _replySubscription.cancel(); _teamEvent.cancel(); } } -} \ No newline at end of file +} diff --git a/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_page.dart b/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_page.dart index 0ce9a349..d18ee3bc 100755 --- a/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_page.dart +++ b/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_page.dart @@ -1,4 +1,3 @@ - import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; @@ -29,14 +28,17 @@ class FingerprintListPage extends StatefulWidget { State createState() => _FingerprintListPageState(); } -class _FingerprintListPageState extends State with RouteAware { +class _FingerprintListPageState extends State + with RouteAware { final logic = Get.put(FingerprintListLogic()); final state = Get.find().state; - Future getHttpData() async { + Future getHttpData({required bool isRefresh}) async { var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); if (isDemoMode == false) { - logic.getFingerprintsListData().then((FingerprintListDataEntity value){ + logic + .getFingerprintsListData(isRefresh: isRefresh) + .then((FingerprintListDataEntity value) { if (mounted) { setState(() {}); } @@ -48,7 +50,7 @@ class _FingerprintListPageState extends State with RouteAwa void initState() { super.initState(); - getHttpData(); + getHttpData(isRefresh: true); } @override @@ -68,7 +70,8 @@ class _FingerprintListPageState extends State with RouteAwa onPressed: () async { var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); if (isDemoMode == false) { - ShowTipView().showIosTipWithContentDialog("重置后,该锁的指纹都将被删除哦,确认要重置吗?".tr, () async { + ShowTipView().showIosTipWithContentDialog( + "重置后,该锁的指纹都将被删除哦,确认要重置吗?".tr, () async { state.isDeletAll = true; state.deletKeyID = "1"; state.deletFingerNo = 0; @@ -82,20 +85,18 @@ class _FingerprintListPageState extends State with RouteAwa ], ), body: EasyRefreshTool( - onRefresh: (){ - logic.pageNo = 1; - getHttpData(); + onRefresh: () { + getHttpData(isRefresh: true); }, - onLoad: (){ - getHttpData(); + onLoad: () { + getHttpData(isRefresh: false); }, child: Column( children: [ KeySearchWidget( editingController: state.searchController, onSubmittedAction: () { - logic.pageNo = 1; - getHttpData(); + getHttpData(isRefresh: true); }, ), SizedBox( @@ -103,16 +104,16 @@ class _FingerprintListPageState extends State with RouteAwa ), Expanded(child: _buildMainUI()), AddBottomWhiteBtn( - btnName: '${TranslationLoader.lanKeys!.add!.tr}${TranslationLoader.lanKeys!.fingerprint!.tr}', + btnName: + '${TranslationLoader.lanKeys!.add!.tr}${TranslationLoader.lanKeys!.fingerprint!.tr}', onClick: () async { - var data = - await Get.toNamed(Routers.addFingerprintTypePage, arguments: { - "lockId": state.lockId.value, - "fromType": 1 // 1从添加钥匙列表进入 2从考勤添加员工入口进入 - }); + var data = await Get.toNamed(Routers.addFingerprintTypePage, + arguments: { + "lockId": state.lockId.value, + "fromType": 1 // 1从添加钥匙列表进入 2从考勤添加员工入口进入 + }); if (data != null) { - logic.pageNo = 1; - getHttpData(); + getHttpData(isRefresh: true); } }, ), @@ -126,61 +127,70 @@ class _FingerprintListPageState extends State with RouteAwa Widget _buildMainUI() { return Obx(() => state.fingerprintItemListData.value.isNotEmpty ? SlidableAutoCloseBehavior( - child: ListView.separated( - itemCount: state.fingerprintItemListData.value.length, - itemBuilder: (c, index) { - FingerprintItemData fingerprintItemData = state.fingerprintItemListData.value[index]; - // 指纹 - return Slidable( - key:ValueKey(fingerprintItemData.fingerprintId), - endActionPane: ActionPane( - extentRatio: 0.2, - motion: const ScrollMotion(), - children: [ - SlidableAction( - onPressed: (BuildContext context){ - ShowTipView().showIosTipWithContentDialog("确定要删除吗?".tr, () async { - state.isDeletAll = false; - state.deletKeyID = fingerprintItemData.fingerprintId.toString(); - state.deletFingerNo = int.parse(fingerprintItemData.fingerprintNumber!); - logic.senderAddFingerprint(); - }); - }, - backgroundColor: Colors.red, - // foregroundColor: Colors.white, - label: '删除'.tr, - padding: EdgeInsets.only(left: 5.w, right: 5.w), - ), - ], + child: ListView.separated( + itemCount: state.fingerprintItemListData.value.length, + itemBuilder: (c, index) { + FingerprintItemData fingerprintItemData = + state.fingerprintItemListData.value[index]; + // 指纹 + return Slidable( + key: ValueKey(fingerprintItemData.fingerprintId), + endActionPane: ActionPane( + extentRatio: 0.2, + motion: const ScrollMotion(), + children: [ + SlidableAction( + onPressed: (BuildContext context) { + ShowTipView().showIosTipWithContentDialog( + "确定要删除吗?".tr, () async { + state.isDeletAll = false; + state.deletKeyID = + fingerprintItemData.fingerprintId.toString(); + state.deletFingerNo = int.parse( + fingerprintItemData.fingerprintNumber!); + logic.senderAddFingerprint(); + }); + }, + backgroundColor: Colors.red, + // foregroundColor: Colors.white, + label: '删除'.tr, + padding: EdgeInsets.only(left: 5.w, right: 5.w), + ), + ], + ), + child: _keyItem( + 'images/icon_fingerprint.png', + fingerprintItemData.fingerprintName!, + logic.getKeyType(fingerprintItemData), + logic.getKeyDateType(fingerprintItemData), () async { + var data = await Get.toNamed(Routers.fingerprintDetailPage, + arguments: { + "fingerprintItemData": fingerprintItemData, + }); + if (data != null) { + getHttpData(isRefresh: true); + } + }), + ); + }, + separatorBuilder: (BuildContext context, int index) { + return const Divider( + height: 1, + color: AppColors.greyLineColor, + ); + }, ), - child: _keyItem( - 'images/icon_fingerprint.png', - fingerprintItemData.fingerprintName!, - logic.getKeyType(fingerprintItemData), - logic.getKeyDateType(fingerprintItemData), () async { - var data = await Get.toNamed( - Routers.fingerprintDetailPage, - arguments: { - "fingerprintItemData": fingerprintItemData, - }); - if (data != null) { - logic.pageNo = 1; - getHttpData(); - } - }), - ); - }, - separatorBuilder: (BuildContext context, int index) { - return const Divider( - height: 1, - color: AppColors.greyLineColor, - ); - }, - ), - ) : NoData(noDataHeight: 1.sh - ScreenUtil().statusBarHeight - ScreenUtil().bottomBarHeight - 190.h - 64.h)); + ) + : NoData( + noDataHeight: 1.sh - + ScreenUtil().statusBarHeight - + ScreenUtil().bottomBarHeight - + 190.h - + 64.h)); } - Widget _keyItem(String lockTypeIcon, String lockTypeTitle, String ifInvalidation, String showTime, Function() action) { + Widget _keyItem(String lockTypeIcon, String lockTypeTitle, + String ifInvalidation, String showTime, Function() action) { return GestureDetector( onTap: action, child: Container( @@ -204,24 +214,24 @@ class _FingerprintListPageState extends State with RouteAwa // mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ SizedBox( - width: ifInvalidation.isNotEmpty ? 1.sw - 110.w - 100.w : 1.sw - 110.w - 50.w, + width: ifInvalidation.isNotEmpty + ? 1.sw - 110.w - 100.w + : 1.sw - 110.w - 50.w, child: Row( children: [ Flexible( - child: Text( - lockTypeTitle, + child: Text(lockTypeTitle, maxLines: 1, overflow: TextOverflow.ellipsis, - style: TextStyle(fontSize: 24.sp, color: AppColors.blackColor) - ), + style: TextStyle( + fontSize: 24.sp, + color: AppColors.blackColor)), ), - ], ), ), Text(ifInvalidation, - style: TextStyle( - fontSize: 22.sp, color: Colors.red)), + style: TextStyle(fontSize: 22.sp, color: Colors.red)), SizedBox(width: 10.w), ], ), @@ -298,5 +308,4 @@ class _FingerprintListPageState extends State with RouteAwa if (EasyLoading.isShow) EasyLoading.dismiss(animation: true); state.ifCurrentScreen.value = false; } - } diff --git a/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_logic.dart b/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_logic.dart index 3e3f7e85..529dcfdb 100755 --- a/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_logic.dart +++ b/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_logic.dart @@ -25,13 +25,16 @@ class PasswordKeyListLogic extends BaseGetXController { // 获取解析后的数据 late StreamSubscription _replySubscription; void _initReplySubscription() { - _replySubscription = EventBusManager().eventBus!.on().listen((Reply reply) { + _replySubscription = + EventBusManager().eventBus!.on().listen((Reply reply) { // 添加卡片开始(重置锁里面所有卡) - if ((reply is SenderCustomPasswordsReply) && (state.ifCurrentScreen.value == true)) { + if ((reply is SenderCustomPasswordsReply) && + (state.ifCurrentScreen.value == true)) { _replyAddPassword(reply); } - if ((reply is SenderResetPasswordsReply) && (state.ifCurrentScreen.value == true)) { + if ((reply is SenderResetPasswordsReply) && + (state.ifCurrentScreen.value == true)) { _replyResetPassword(reply); } }); @@ -49,10 +52,13 @@ class PasswordKeyListLogic extends BaseGetXController { break; case 0x06: //无权限 - final List? privateKey = await Storage.getStringList(saveBluePrivateKey); - final List getPrivateKeyList = changeStringListToIntList(privateKey!); + final List? privateKey = + await Storage.getStringList(saveBluePrivateKey); + final List getPrivateKeyList = + changeStringListToIntList(privateKey!); - final List? signKey = await Storage.getStringList(saveBlueSignKey); + final List? signKey = + await Storage.getStringList(saveBlueSignKey); final List signKeyDataList = changeStringListToIntList(signKey!); final List token = reply.data.sublist(5, 9); @@ -95,10 +101,13 @@ class PasswordKeyListLogic extends BaseGetXController { break; case 0x06: //无权限 - final List? privateKey = await Storage.getStringList(saveBluePrivateKey); - final List getPrivateKeyList = changeStringListToIntList(privateKey!); + final List? privateKey = + await Storage.getStringList(saveBluePrivateKey); + final List getPrivateKeyList = + changeStringListToIntList(privateKey!); - final List? signKey = await Storage.getStringList(saveBlueSignKey); + final List? signKey = + await Storage.getStringList(saveBlueSignKey); final List signKeyDataList = changeStringListToIntList(signKey!); final List token = reply.data.sublist(5, 9); @@ -131,11 +140,14 @@ class PasswordKeyListLogic extends BaseGetXController { BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { if (deviceConnectionState == BluetoothConnectionState.connected) { - final List? signKey = await Storage.getStringList(saveBlueSignKey); + final List? signKey = + await Storage.getStringList(saveBlueSignKey); final List signKeyDataList = changeStringListToIntList(signKey!); - final List? privateKey = await Storage.getStringList(saveBluePrivateKey); - final List getPrivateKeyList = changeStringListToIntList(privateKey!); + final List? privateKey = + await Storage.getStringList(saveBluePrivateKey); + final List getPrivateKeyList = + changeStringListToIntList(privateKey!); final List? token = await Storage.getStringList(saveBlueToken); final List getTokenList = changeStringListToIntList(token!); @@ -182,11 +194,14 @@ class PasswordKeyListLogic extends BaseGetXController { BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { if (deviceConnectionState == BluetoothConnectionState.connected) { - final List? signKey = await Storage.getStringList(saveBlueSignKey); + final List? signKey = + await Storage.getStringList(saveBlueSignKey); final List signKeyDataList = changeStringListToIntList(signKey!); - final List? privateKey = await Storage.getStringList(saveBluePrivateKey); - final List getPrivateKeyList = changeStringListToIntList(privateKey!); + final List? privateKey = + await Storage.getStringList(saveBluePrivateKey); + final List getPrivateKeyList = + changeStringListToIntList(privateKey!); final List? token = await Storage.getStringList(saveBlueToken); final List getTokenList = changeStringListToIntList(token!); @@ -255,26 +270,16 @@ class PasswordKeyListLogic extends BaseGetXController { state.itemDataList.addAll(entity.data!.itemList!); // 更新页码 pageNo++; - - // if (pageNo == 1) { - // state.itemDataList.value.clear(); - // state.itemDataList.value = entity.data!.itemList!; - // pageNo++; - // } else { - // if (entity.data!.itemList!.isNotEmpty) { - // state.itemDataList.value.addAll(entity.data!.itemList!); - // pageNo++; - // } - // } } return entity; } //密码钥匙重置请求 Future resetPasswordKeyListRequest() async { - final PasswordKeyListEntity entity = await ApiRepository.to.keyboardPwdReset( - lockId: state.keyInfo.value.lockId.toString(), - passwordKey: state.encrpyKey); + final PasswordKeyListEntity entity = await ApiRepository.to + .keyboardPwdReset( + lockId: state.keyInfo.value.lockId.toString(), + passwordKey: state.encrpyKey); if (entity.errorCode!.codeIsSuccessful) { showToast('重置成功'.tr, something: () { pageNo = 1; @@ -390,8 +395,9 @@ class PasswordKeyListLogic extends BaseGetXController { StreamSubscription? _getPasswordListRefreshUIEvent; void _getPasswordListRefreshUIAction() { // 蓝牙协议通知传输跟蓝牙之外的数据传输类不一样 eventBus - _getPasswordListRefreshUIEvent = - eventBus.on().listen((GetPasswordListRefreshUI event) { + _getPasswordListRefreshUIEvent = eventBus + .on() + .listen((GetPasswordListRefreshUI event) { mockNetworkDataRequest(isRefresh: true); }); } From 29e87937291b6edbeb4bf53e8e624c9b66321484 Mon Sep 17 00:00:00 2001 From: anfe <448468458@qq.com> Date: Sat, 1 Jun 2024 17:45:14 +0800 Subject: [PATCH 09/10] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E9=A6=96=E9=A1=B5?= =?UTF-8?q?=E8=AE=BE=E5=A4=87=E5=88=97=E8=A1=A8=E6=97=A0=E7=BD=91=E7=BB=9C?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E4=B8=8B=E8=BF=9B=E5=85=A5=E6=B2=A1=E6=9C=89?= =?UTF-8?q?=E5=87=BA=E7=8E=B0=E7=BC=93=E5=AD=98=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/main/lockMian/lockMain/lockMain_page.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main/lockMian/lockMain/lockMain_page.dart b/lib/main/lockMian/lockMain/lockMain_page.dart index dea9f5db..83b0163e 100755 --- a/lib/main/lockMian/lockMain/lockMain_page.dart +++ b/lib/main/lockMian/lockMain/lockMain_page.dart @@ -58,12 +58,12 @@ class _StarLockMainPageState extends State with BaseWidget { @override void initState() { super.initState(); - WidgetsBinding.instance.addPostFrameCallback((_) { + WidgetsBinding.instance.addPostFrameCallback((_) async { logic.pageNo = 1; getHttpData(); + _initLoadDataAction(); + setState(() {}); }); - - _initLoadDataAction(); } @override From 61140449910af1c00cc7f5bbe4999bcc98f0f367 Mon Sep 17 00:00:00 2001 From: Daisy <> Date: Mon, 3 Jun 2024 11:34:04 +0800 Subject: [PATCH 10/10] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dxhj=E5=B8=83=E5=B1=80?= =?UTF-8?q?=E4=B8=8B=E5=A2=9E=E5=80=BC=E6=9C=8D=E5=8A=A1=E8=B4=AD=E4=B9=B0?= =?UTF-8?q?=E5=90=8E=E7=8A=B6=E6=80=81=E6=9C=AA=E5=88=B7=E6=96=B0=E4=B8=8D?= =?UTF-8?q?=E8=83=BD=E4=BD=BF=E7=94=A8=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 | 2 +- lib/mine/mine/starLockMine_logic.dart | 2 +- .../advancedFeaturesWeb_logic.dart | 2 +- .../valueAddedServicesList_logic.dart | 16 ++++++++++++++++ .../valueAddedServicesList_page.dart | 13 +++++++++---- 5 files changed, 28 insertions(+), 7 deletions(-) diff --git a/lib/login/login/starLock_login_logic.dart b/lib/login/login/starLock_login_logic.dart index 848cd6f8..94412022 100755 --- a/lib/login/login/starLock_login_logic.dart +++ b/lib/login/login/starLock_login_logic.dart @@ -49,7 +49,7 @@ class StarLockLoginLogic extends BaseGetXController { deviceInfo: state.deviceInfoMap.value); if (entity.errorCode!.codeIsSuccessful) { Storage.saveLoginData(entity.data); - Storage.setBool(saveIsVip, entity.data!.isVip == 0 ? false : true); + Storage.setBool(saveIsVip, entity.data!.isVip == 1); eventBus.fire(MineInfoChangeRefreshUI()); XSJPushProvider().bindDeviceID(); XSJPushProvider().initLocalNotification(isCancelLocalPush: false); diff --git a/lib/mine/mine/starLockMine_logic.dart b/lib/mine/mine/starLockMine_logic.dart index b126f569..106bcf08 100755 --- a/lib/mine/mine/starLockMine_logic.dart +++ b/lib/mine/mine/starLockMine_logic.dart @@ -17,7 +17,7 @@ class StarLockMineLogic extends BaseGetXController { 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; + state.isVip.value = state.mineInfoData.value.isVip! == 1; Storage.setBool(saveIsVip, state.isVip.value); } } diff --git a/lib/mine/valueAddedServices/advancedFeaturesWeb/advancedFeaturesWeb_logic.dart b/lib/mine/valueAddedServices/advancedFeaturesWeb/advancedFeaturesWeb_logic.dart index eba7f1b3..b9f550a4 100755 --- a/lib/mine/valueAddedServices/advancedFeaturesWeb/advancedFeaturesWeb_logic.dart +++ b/lib/mine/valueAddedServices/advancedFeaturesWeb/advancedFeaturesWeb_logic.dart @@ -115,7 +115,7 @@ class AdvancedFeaturesWebLogic extends BaseGetXController { if (canGoBack) { await state.webBuyView.goBack(); } else if (state.allowReturn) { - Get.back(); + Get.back(result: true); } else { if (_lastPressedAt == null || DateTime.now().difference(_lastPressedAt!) > diff --git a/lib/mine/valueAddedServices/valueAddedServicesList/valueAddedServicesList_logic.dart b/lib/mine/valueAddedServices/valueAddedServicesList/valueAddedServicesList_logic.dart index 416130bb..7e4c4298 100755 --- a/lib/mine/valueAddedServices/valueAddedServicesList/valueAddedServicesList_logic.dart +++ b/lib/mine/valueAddedServices/valueAddedServicesList/valueAddedServicesList_logic.dart @@ -1,5 +1,7 @@ import 'dart:async'; +import 'package:star_lock/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_entity.dart'; import 'package:star_lock/mine/valueAddedServices/valueAddedServicesList/valueAddedServicesList_state.dart'; +import 'package:star_lock/tools/storage.dart'; import '../../../../network/api_repository.dart'; import '../../../../tools/baseGetXController.dart'; @@ -12,4 +14,18 @@ class ValueAddedServicesListLogic extends BaseGetXController { var entity = await ApiRepository.to.getServicePackageBuyUrl(); if (entity.errorCode!.codeIsSuccessful) {} } + + //用户信息 + Future getUserInfoRequest() async { + final MinePersonInfoEntity entity = await ApiRepository.to.getUserInfo(); + if (entity.errorCode!.codeIsSuccessful) { + Storage.setBool(saveIsVip, entity.data!.isVip! == 1); + } + } + + @override + Future onReady() async { + super.onReady(); + getUserInfoRequest(); + } } diff --git a/lib/mine/valueAddedServices/valueAddedServicesList/valueAddedServicesList_page.dart b/lib/mine/valueAddedServices/valueAddedServicesList/valueAddedServicesList_page.dart index 4a6af190..98d2cc47 100755 --- a/lib/mine/valueAddedServices/valueAddedServicesList/valueAddedServicesList_page.dart +++ b/lib/mine/valueAddedServices/valueAddedServicesList/valueAddedServicesList_page.dart @@ -66,14 +66,19 @@ class _ValueAddedServicesPageListState _valueAddedServicesItem( Image.asset('images/mine/icon_mine_valueAddedServices_vip.png'), TranslationLoader.lanKeys!.advancedFunction!.tr, () async { - bool? isVip = await Storage.getBool(saveIsVip); + final bool? isVip = await Storage.getBool(saveIsVip); if (isVip == null || !isVip) { // if (CommonDataManage().currentKeyInfo.isLockOwner != 1) { // logic.showToast('请先添加锁'); // } else { - Get.toNamed(Routers.advancedFeaturesWebPage, arguments: { - 'webBuyType': XSConstantMacro.webBuyTypeVip, - }); + //刷新购买状态 + final result = await Get.toNamed(Routers.advancedFeaturesWebPage, + arguments: { + 'webBuyType': XSConstantMacro.webBuyTypeVip, + }); + if (result != null && result.isNotEmpty) { + logic.getUserInfoRequest(); + } // } } else { Get.toNamed(Routers.valueAddedServicesHighFunctionPage);