From f49f7712b711d0d451897c20fff77e20d65a4e1b Mon Sep 17 00:00:00 2001 From: anfe <448468458@qq.com> Date: Fri, 3 May 2024 09:21:08 +0800 Subject: [PATCH 1/3] =?UTF-8?q?feat:=E6=96=B0=E5=A2=9E=E9=91=AB=E6=B3=93?= =?UTF-8?q?=E4=BD=B3=E9=A6=96=E9=A1=B5=E4=BA=8C=E6=AC=A1=E9=80=80=E5=87=BA?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- star_lock/ios/Podfile.lock | 2 +- star_lock/lib/flavors.dart | 2 ++ .../lockMain/xhj/lockMain_xhj_logic.dart | 2 ++ .../lockMain/xhj/lockMain_xhj_page.dart | 1 + star_lock/lib/mine/mall/lockMall_logic.dart | 30 +++++++++++++++---- 5 files changed, 31 insertions(+), 6 deletions(-) diff --git a/star_lock/ios/Podfile.lock b/star_lock/ios/Podfile.lock index e962a17c..c1b43709 100644 --- a/star_lock/ios/Podfile.lock +++ b/star_lock/ios/Podfile.lock @@ -316,7 +316,7 @@ SPEC CHECKSUMS: flutter_native_contact_picker: bd430ba0fbf82768bb50c2c52a69a65759a8f907 flutter_pcm_sound: de0572ca4f99091cc2abfcc31601b8a4ddd33c0e flutter_voice_processor: 2b89b93d69b02227ae3fd58589ee0bcfa3ca2a82 - fluttertoast: 9f2f8e81bb5ce18facb9748d7855bf5a756fe3db + fluttertoast: 31b00dabfa7fb7bacd9e7dbee580d7a2ff4bf265 fluwx: daa284756ce53442b3d0417ceeda66e981906811 google_maps_flutter_ios: d1318b4ff711612cab16862d7a87e31a7403d458 GoogleMaps: 20d7b12be49a14287f797e88e0e31bc4156aaeb4 diff --git a/star_lock/lib/flavors.dart b/star_lock/lib/flavors.dart index 3f1e4d38..9d350755 100644 --- a/star_lock/lib/flavors.dart +++ b/star_lock/lib/flavors.dart @@ -28,6 +28,8 @@ class F { static String get name => appFlavor?.name ?? ''; + static bool get isXHJ => appFlavor == Flavor.xhj; + //便捷判断并返回值 static dynamic sw( {required fCallFunction defaultCall, fCallFunction? xhjCall}) { diff --git a/star_lock/lib/main/lockMian/lockMain/xhj/lockMain_xhj_logic.dart b/star_lock/lib/main/lockMian/lockMain/xhj/lockMain_xhj_logic.dart index 3d01639f..0e28f379 100644 --- a/star_lock/lib/main/lockMian/lockMain/xhj/lockMain_xhj_logic.dart +++ b/star_lock/lib/main/lockMian/lockMain/xhj/lockMain_xhj_logic.dart @@ -15,6 +15,8 @@ class LockMainXHJLogic extends BaseGetXController { update(); } + bool get isMall => state.index ==1; + //打开设备弹窗 void openEquipment() { showModalBottomSheet( diff --git a/star_lock/lib/main/lockMian/lockMain/xhj/lockMain_xhj_page.dart b/star_lock/lib/main/lockMian/lockMain/xhj/lockMain_xhj_page.dart index 8f604e46..4cf3cd43 100644 --- a/star_lock/lib/main/lockMian/lockMain/xhj/lockMain_xhj_page.dart +++ b/star_lock/lib/main/lockMian/lockMain/xhj/lockMain_xhj_page.dart @@ -25,6 +25,7 @@ class StarLockMainXHJPage extends StatefulWidget { class _StarLockMainXHJPageState extends State with BaseWidget { + @override void initState() { super.initState(); diff --git a/star_lock/lib/mine/mall/lockMall_logic.dart b/star_lock/lib/mine/mall/lockMall_logic.dart index 1532c65e..5f7741e3 100644 --- a/star_lock/lib/mine/mall/lockMall_logic.dart +++ b/star_lock/lib/mine/mall/lockMall_logic.dart @@ -1,8 +1,12 @@ import 'dart:convert'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:fluttertoast/fluttertoast.dart'; import 'package:fluwx/fluwx.dart'; import 'package:get/get.dart'; +import 'package:star_lock/flavors.dart'; +import 'package:star_lock/main/lockMian/lockMain/xhj/lockMain_xhj_logic.dart'; import 'package:star_lock/mine/mall/lockMall_entity.dart'; import 'package:star_lock/mine/mall/lockMall_state.dart'; import 'package:star_lock/network/api_repository.dart'; @@ -16,8 +20,10 @@ import '../../tools/baseGetXController.dart'; class LockMallLogic extends BaseGetXController { late LockMallState state; + DateTime? _lastPressedAt; // 记录上一次按下返回键的时间 + LockMallLogic({required bool allowReturn}) - : state = LockMallState(allowReturn: allowReturn ); + : state = LockMallState(allowReturn: allowReturn); //获取商城跳转地址 Future getMallURLRequest() async { @@ -98,19 +104,33 @@ class LockMallLogic extends BaseGetXController { //判断webview 是否可以有路由可以回退,无则退出当前页面 Future canGoBack(bool didPop) async { bool canGoBack = await state.mallWebView.canGoBack(); - if (canGoBack) { + bool isMall = true; + if (Get.isRegistered() && F.isXHJ) { + isMall = Get.find().isMall; + } + if (canGoBack && isMall) { await state.mallWebView.goBack(); - } else if (state.allowReturn) { + } else if (state.allowReturn && isMall) { Get.back(); + } else { + if (_lastPressedAt == null || + DateTime.now().difference(_lastPressedAt!) > Duration(seconds: 2)) { + // 如果两次返回键时间间隔大于 2 秒,则提示再次按下返回键退出 + _lastPressedAt = DateTime.now(); + showToast('再返回一次退出${F.title}'); + return false; // 阻止返回操作 + } + SystemNavigator.pop(); + return true; } refreshGoBack(); return false; } //刷新当前路由状态 - void refreshGoBack(){ + void refreshGoBack() { //如果属于一直返回按钮,则根据是否有路由可以回退刷新 - if(state.allowReturn){ + if (state.allowReturn) { return; } state.mallWebView.canGoBack().then((value) { From ac9024e499c35870f156448652a1f32f6d3c5acf Mon Sep 17 00:00:00 2001 From: anfe <448468458@qq.com> Date: Fri, 3 May 2024 09:22:36 +0800 Subject: [PATCH 2/3] =?UTF-8?q?feat:=E6=89=93=E5=8C=85=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- star_lock/pubspec.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/star_lock/pubspec.yaml b/star_lock/pubspec.yaml index 8616ddd8..71d1dd87 100644 --- a/star_lock/pubspec.yaml +++ b/star_lock/pubspec.yaml @@ -38,8 +38,9 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # 1.0.28+2024042601 打包鑫锁提审华为 # 1.0.29+2024042901 打包给欧阳测试 # 1.0.30+2024043001 打包鑫锁提审ios +# 1.0.31+2024050301 打包鑫锁提审华为 -version: 1.0.30+2024043001 +version: 1.0.31+2024050301 environment: sdk: '>=2.12.0 <3.0.0' From 21ce56ff0f0d09d24d15c373eda2e2e67f91b7ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AD=8F=E5=B0=91=E9=98=B3?= <786612630@qq.com> Date: Fri, 3 May 2024 10:13:28 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E5=8D=87=E7=BA=A7=E7=95=8C=E9=9D=A2=EF=BC=8C=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E5=AF=86=E7=A0=81=E6=97=A5=E6=9C=9F=E8=B7=9F?= =?UTF-8?q?=E7=A6=BB=E7=BA=BF=E5=AF=86=E7=A0=81=E6=97=A5=E6=9C=9F=E5=88=86?= =?UTF-8?q?=E7=A6=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lockEscalation/lockEscalation_page.dart | 149 +++++++++--------- .../passwordKey_perpetual_logic.dart | 28 ++-- .../passwordKey_perpetual_page.dart | 56 +++++-- .../passwordKey_perpetual_state.dart | 3 + star_lock/lib/network/api_repository.dart | 17 +- 5 files changed, 142 insertions(+), 111 deletions(-) diff --git a/star_lock/lib/main/lockDetail/lockSet/lockEscalation/lockEscalation_page.dart b/star_lock/lib/main/lockDetail/lockSet/lockEscalation/lockEscalation_page.dart index 3ed29ee8..65a81e09 100644 --- a/star_lock/lib/main/lockDetail/lockSet/lockEscalation/lockEscalation_page.dart +++ b/star_lock/lib/main/lockDetail/lockSet/lockEscalation/lockEscalation_page.dart @@ -61,7 +61,8 @@ class _LockEscalationPageState extends State { width: 10.w, ), Text( - TranslationLoader.lanKeys!.haveNewVersion!.tr, + // TranslationLoader.lanKeys!.haveNewVersion!.tr, + "未发现新版本", style: TextStyle( fontSize: 24.sp, fontWeight: FontWeight.w600), ) @@ -75,80 +76,6 @@ class _LockEscalationPageState extends State { style: TextStyle( fontSize: 18.sp, color: AppColors.darkGrayTextColor), ), - SizedBox( - height: 10.h, - ), - Obx(() { - return !logic.state.otaUpdateIng.value - ? Stack( - children: [ - Container( - margin: EdgeInsets.only(top: 8, bottom: 8), - width: Get.width, - child: Center( - child: Text( - // "${TranslationLoader.lanKeys!.newVersion!.tr}:1.0.1", - "未发现新版本", - style: TextStyle( - color: AppColors.mainColor, - fontSize: 18.sp), - ), - ), - ), - Positioned( - right: 80.w, - child: GestureDetector( - onTap: () { - logic.otaUpdate(); - }, - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Text( - '手动升级', - style: TextStyle( - color: AppColors.mainColor, - fontSize: 18.sp, - fontWeight: FontWeight.w400), - ), - ), - ), - ) - ], - ) - : Padding( - padding: EdgeInsets.symmetric( - horizontal: 50.w, vertical: 15.h), - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - Text( - '固件传输中', - style: TextStyle( - color: AppColors.mainColor, - fontSize: 18.sp, - fontWeight: FontWeight.w400), - ), - SizedBox( - width: 10.w, - ), - Expanded( - child: ClipRRect( - borderRadius: BorderRadius.all( - Radius.circular(10.r)), - child: LinearProgressIndicator( - value: logic - .state.otaProgress.value, // 50% 进度 - backgroundColor: Colors.grey[200], - valueColor: - AlwaysStoppedAnimation( - AppColors.mainColor), - ), - ), - ), - ], - ), - ); - }), SizedBox( height: 40.h, ), @@ -159,6 +86,78 @@ class _LockEscalationPageState extends State { onClick: () {}) : SizedBox(); }), + SizedBox( + height: 10.h, + ), + Obx(() { + return !logic.state.otaUpdateIng.value + ? Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + // Container( + // margin: EdgeInsets.only(top: 8, bottom: 8), + // width: Get.width, + // child: Center( + // child: Text( + // // "${TranslationLoader.lanKeys!.newVersion!.tr}:1.0.1", + // "未发现新版本", + // style: TextStyle( + // color: AppColors.mainColor, + // fontSize: 18.sp), + // ), + // ), + // ), + GestureDetector( + onTap: () { + logic.otaUpdate(); + }, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Text( + '手动升级', + style: TextStyle( + color: AppColors.mainColor, + fontSize: 18.sp, + fontWeight: FontWeight.w400), + ), + ), + ) + ], + ) + : Padding( + padding: EdgeInsets.symmetric( + horizontal: 50.w, vertical: 15.h), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Text( + '固件传输中', + style: TextStyle( + color: AppColors.mainColor, + fontSize: 18.sp, + fontWeight: FontWeight.w400), + ), + SizedBox( + width: 10.w, + ), + Expanded( + child: ClipRRect( + borderRadius: BorderRadius.all( + Radius.circular(10.r)), + child: LinearProgressIndicator( + value: logic + .state.otaProgress.value, // 50% 进度 + backgroundColor: Colors.grey[200], + valueColor: + AlwaysStoppedAnimation( + AppColors.mainColor), + ), + ), + ), + ], + ), + ); + }), ], ), )); diff --git a/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_logic.dart b/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_logic.dart index b732cc68..4e82c36a 100644 --- a/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_logic.dart +++ b/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_logic.dart @@ -143,17 +143,17 @@ class PasswordKeyPerpetualLogic extends BaseGetXController { //是否为永久 if (state.isPermanent.value == false) { getKeyType = '3'; - getEffectiveDateTime = DateTool().dateToTimestamp(state.beginTime.value, 1).toString(); - getFailureDateTime = DateTool().dateToTimestamp(state.endTime.value, 1).toString(); + getEffectiveDateTime = DateTool().dateToTimestamp(state.customBeginTime.value, 1).toString(); + getFailureDateTime = DateTool().dateToTimestamp(state.customEndTime.value, 1).toString(); } var entity = await ApiRepository.to.addPasswordKey( - lockId, - state.nameController.text, - state.pwdController.text, - getKeyType, - getEffectiveDateTime, - getFailureDateTime, - '1'); + lockId:lockId, + keyboardPwdName:state.nameController.text, + keyboardPwd:state.pwdController.text, + keyboardPwdType:getKeyType, + startDate:getEffectiveDateTime, + endDate:getFailureDateTime, + addType:'1'); if (entity.errorCode!.codeIsSuccessful) { state.isSendSuccess.value = true; state.sendSucceedType.value = state.widgetType.value; @@ -234,8 +234,8 @@ class PasswordKeyPerpetualLogic extends BaseGetXController { pwdNo: state.isAdministrator.value == true ? 254 : 0, pwd:state.pwdController.text, useCountLimit: 0xff, - startTime: DateTool().dateToTimestamp(state.beginTime.value, 1)~/1000, - endTime: DateTool().dateToTimestamp(state.endTime.value, 1)~/1000, + startTime: DateTool().dateToTimestamp(state.customBeginTime.value, 1)~/1000, + endTime: DateTool().dateToTimestamp(state.customEndTime.value, 1)~/1000, needAuthor: 1, isBeforeAddUser: false, signKey: signKeyDataList, @@ -265,8 +265,8 @@ class PasswordKeyPerpetualLogic extends BaseGetXController { // 设置自定义密码 Future senderCustomPasswords() async { - var startDate = DateTool().dateToTimestamp(state.beginTime.value, 1); - var endDate = DateTool().dateToTimestamp(state.endTime.value, 1); + var startDate = DateTool().dateToTimestamp(state.customBeginTime.value, 1); + var endDate = DateTool().dateToTimestamp(state.customEndTime.value, 1); //非永久 须有时限 if (state.isPermanent.value == false) { if (startDate < DateTool().dateToTimestamp(DateTool().getNowDateWithType(3), 1)) { @@ -359,7 +359,7 @@ class PasswordKeyPerpetualLogic extends BaseGetXController { case 3: //自定义 if (state.isPermanent.value == false) { - '类型:自定义-限时\n有效期:${state.beginTime.value} -- ${state.endTime.value}'; + '类型:自定义-限时\n有效期:${state.customBeginTime.value} -- ${state.customEndTime.value}'; } else { useDateStr = '类型:自定义-永久'; } diff --git a/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart b/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart index 894276a8..6a49f621 100644 --- a/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart +++ b/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart @@ -139,7 +139,7 @@ class _PasswordKeyPerpetualPageState extends State wit children: [ keyIfPerpetualWidget(), state.isPermanent.value == false - ? keyTimeLimitWidget() + ? keyCustomTimeLimitWidget() : Container(), perpetualKeyWidget( false, @@ -228,14 +228,9 @@ class _PasswordKeyPerpetualPageState extends State wit context, maxDate: PDuration(year: DateTime.now().year + 3, month: DateTime.now().month, day: DateTime.now().day, hour: 24), // minDate: PDuration.now(), - mode: state.widgetType.value == 3 ? DateMode.YMDHM:DateMode.YMDH, + mode: DateMode.YMDHM, onConfirm: (p) { - if (state.widgetType.value == 3) { - // 自定义 - state.beginTime.value = DateTool().getYMDHNDateString(p, 1); - } else { - state.beginTime.value = DateTool().getYMDHNDateString(p, 4); - } + state.beginTime.value = DateTool().getYMDHNDateString(p, 4); }); }), ), @@ -251,12 +246,7 @@ class _PasswordKeyPerpetualPageState extends State wit minDate: PDuration(year: DateTime.now().year, month: DateTime.now().month, day: DateTime.now().day), mode: DateMode.YMDH, onConfirm: (p) { - if (state.widgetType.value == 3) { - // 自定义 - state.endTime.value = DateTool().getYMDHNDateString(p, 1); - } else { - state.endTime.value = DateTool().getYMDHNDateString(p, 4); - } + state.endTime.value = DateTool().getYMDHNDateString(p, 4); }); }), Container(height: 10.h), @@ -264,6 +254,44 @@ class _PasswordKeyPerpetualPageState extends State wit ); } + // 自定义限时顶部选择日期 + Widget keyCustomTimeLimitWidget() { + return Column( + children: [ + CommonItem( + leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr, + rightTitle: state.customBeginTime.value, + isHaveLine: true, + isHaveDirection: true, + action: () { + Pickers.showDatePicker( + context, + // maxDate: PDuration(year: DateTime.now().year + 3, month: DateTime.now().month, day: DateTime.now().day, hour: 24), + // minDate: PDuration.now(), + mode: DateMode.YMDHM, + onConfirm: (p) { + state.customBeginTime.value = DateTool().getYMDHNDateString(p, 1); + }); + }), + CommonItem( + leftTitel: TranslationLoader.lanKeys!.failureTime!.tr, + rightTitle: state.customEndTime.value, + isHaveDirection: true, + action: () { + Pickers.showDatePicker(context, + // maxDate传入三年以后得今天的时间 + // maxDate: PDuration(year: DateTime.now().year + 3, month: DateTime.now().month, day: DateTime.now().day), + // minDate: PDuration(year: DateTime.now().year, month: DateTime.now().month, day: DateTime.now().day), + mode: DateMode.YMDHM, + onConfirm: (p) { + state.customEndTime.value = DateTool().getYMDHNDateString(p, 1); + }); + }), + Container(height: 10.h), + ], + ); + } + // 自定义是否永久 Widget keyIfPerpetualWidget() { return Column( diff --git a/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_state.dart b/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_state.dart index ea1dab13..e9867c2e 100644 --- a/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_state.dart +++ b/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_state.dart @@ -25,6 +25,9 @@ class PasswordKeyPerpetualState { var loopEndHours = DateTime.now().hour.obs; var loopModeStr = '周末'.obs; //循环模式 + var customBeginTime = DateTool().getNowDateWithType(2).obs; //默认为当前时间 开始时间 + var customEndTime = DateTool().getNowDateWithType(2).obs;//默认为当前时间 结束时间 + final widgetType = 0.obs; final sendSucceedType = 0.obs; final keyInfo = LockListInfoItemEntity().obs; diff --git a/star_lock/lib/network/api_repository.dart b/star_lock/lib/network/api_repository.dart index 91121755..79fe0661 100644 --- a/star_lock/lib/network/api_repository.dart +++ b/star_lock/lib/network/api_repository.dart @@ -466,14 +466,15 @@ class ApiRepository { //自定义密码 Future addPasswordKey( - String lockId, - String keyboardPwdName, - String keyboardPwd, - String keyboardPwdType, - String startDate, - String endDate, - String addType, - ) async { + { + required String lockId, + required String keyboardPwdName, + required String keyboardPwd, + required String keyboardPwdType, + required String startDate, + required String endDate, + required String addType, + }) async { final res = await apiProvider.addKeyboardPwd(lockId, keyboardPwdName, keyboardPwd, keyboardPwdType, startDate, endDate, addType); return PasswordKeyEntity.fromJson(res.body);