From 3bdd58d6207d49ee7568f825be3412cffec43654 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AD=8F=E5=B0=91=E9=98=B3?= <786612630@qq.com> Date: Thu, 1 Feb 2024 11:22:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=82=AE=E7=AE=B1=E6=B3=A8?= =?UTF-8?q?=E5=86=8C=E3=80=81=E9=82=AE=E7=AE=B1=E7=99=BB=E5=BD=95bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../XSConstantMacro/XSConstantMacro.dart | 36 +++ .../safetyVerification_page.dart | 10 +- .../starLock_forgetPassword_logic.dart | 17 +- .../starLock_forgetPassword_page.dart | 59 ++++- .../starLock_forgetPassword_state.dart | 8 +- .../register/starLock_register_logic.dart | 23 +- .../register/starLock_register_page.dart | 22 +- .../register/starLock_register_state.dart | 4 +- .../selectCountryRegion_page.dart | 72 ++++-- .../authorizedAdminManage_tabbar.dart | 10 + .../authorizedAdminList_logic.dart | 20 +- .../authorizedAdminList_page.dart | 233 ++++++++++-------- .../authorizedAdminList_state.dart | 3 +- .../electronicKeyDetail_logic.dart | 9 +- .../electronicKeyDetail_page.dart | 10 +- .../electronicKeyDetail_state.dart | 3 + .../electronicKeyList_logic.dart | 3 +- .../electronicKeyList_page.dart | 8 +- .../sendElectronicKey_logic.dart | 39 ++- .../sendElectronicKey_page.dart | 58 +++-- .../lockDetail/lockDetail_logic.dart | 56 +++-- .../lockDetail/lockDetail_page.dart | 42 ++-- .../lockDetail/lockDetail_state.dart | 2 +- .../uploadElectricQuantity_state.dart | 1 - .../passwordKeyList/passwordKeyList_page.dart | 4 +- .../lockMian/lockList/lockList_logic.dart | 15 ++ .../main/lockMian/lockList/lockList_page.dart | 26 +- .../lockMian/lockList/lockList_state.dart | 3 + star_lock/lib/mine/about/about_page.dart | 2 +- star_lock/lib/network/api.dart | 6 +- star_lock/lib/network/api_provider.dart | 30 +-- star_lock/lib/network/api_repository.dart | 39 +-- star_lock/lib/tools/keySearchWidget.dart | 8 +- star_lock/pubspec.yaml | 2 +- 34 files changed, 549 insertions(+), 334 deletions(-) diff --git a/star_lock/lib/common/XSConstantMacro/XSConstantMacro.dart b/star_lock/lib/common/XSConstantMacro/XSConstantMacro.dart index 3af67c78..b2cce474 100644 --- a/star_lock/lib/common/XSConstantMacro/XSConstantMacro.dart +++ b/star_lock/lib/common/XSConstantMacro/XSConstantMacro.dart @@ -18,4 +18,40 @@ class XSConstantMacro { static int keyTypeTime = 2; static int keyTypeOnce = 3; static int keyTypeLoop = 4; + + // "110401" 正常使用 + // "110402" 待接收 + // "110403" 待生效 + // "110405" 已冻结 + // "110412" 已过期 + // "110408" 已删除 + // "110410" 已重置 + static int keyStatusNormalUse = 110401; // 正常使用 + static int keyStatusWaitReceive = 110402; // 待接收 + static int keyStatusWaitIneffective = 110403; // 待生效 + static int keyStatusFrozen = 110405; // 已冻结 + static int keyStatusExpired = 110412; // 已过期 + static int keyStatusDeleted = 110408; // 已删除 + static int keyStatusReset = 110410; // 已重置 + + static String getKeyStatusStr(int keyStatus){ + switch(keyStatus){ + case 110401: + return "正常使用"; + case 110402: + return "待接收"; + case 110403: + return "未生效"; + case 110405: + return "已冻结"; + case 110408: + return "已删除"; + // case 110410: + // return "已重置"; + case 110412: + return "已过期"; + default: + return "未知"; + } + } } diff --git a/star_lock/lib/common/safetyVerification/safetyVerification_page.dart b/star_lock/lib/common/safetyVerification/safetyVerification_page.dart index 77650808..5d910149 100644 --- a/star_lock/lib/common/safetyVerification/safetyVerification_page.dart +++ b/star_lock/lib/common/safetyVerification/safetyVerification_page.dart @@ -50,7 +50,7 @@ class _SafetyVerificationPageState extends State with Ti sliderMoveFinish = false; checkResultAfterDrag = false; }); - print("countryCode:${state.getData["countryCode"]} getAccount:${state.getData["getAccount"]}"); + // print("countryCode:${state.getData["countryCode"]} getAccount:${state.getData["getAccount"]}"); var entity = await ApiRepository.to.getSliderVerifyImg(state.getData["countryCode"].toString(), state.getData["account"].toString()); if(entity.errorCode! == 0){ @@ -338,23 +338,23 @@ class _SafetyVerificationPageState extends State with Ti onPanStart: (startDetails) { ///开始 _checkMilliseconds = DateTime.now().millisecondsSinceEpoch; - print(startDetails.localPosition); + // print(startDetails.localPosition); sliderStartX = startDetails.localPosition.dx; }, onPanUpdate: (updateDetails) { ///更新 - print(updateDetails.localPosition); + // print(updateDetails.localPosition); double offset = updateDetails.localPosition.dx - sliderStartX; if(offset < 0){ offset = 0; } - print("offset ------ $offset"); + // print("offset ------ $offset"); setState(() { state.sliderXMoved.value = offset; }); }, onPanEnd: (endDetails) { //结束 - print("endDetails sliderXMoved:${state.sliderXMoved.value}"); + // print("endDetails sliderXMoved:${state.sliderXMoved.value}"); checkCaptcha(state.sliderXMoved.value); int nowTime = DateTime.now().millisecondsSinceEpoch; _checkMilliseconds = nowTime - _checkMilliseconds; diff --git a/star_lock/lib/login/forgetPassword/starLock_forgetPassword_logic.dart b/star_lock/lib/login/forgetPassword/starLock_forgetPassword_logic.dart index 93e78c4e..4a6e5723 100644 --- a/star_lock/lib/login/forgetPassword/starLock_forgetPassword_logic.dart +++ b/star_lock/lib/login/forgetPassword/starLock_forgetPassword_logic.dart @@ -47,13 +47,11 @@ class StarLockForgetPasswordLogic extends BaseGetXController { void sendValidationCode() async { var entity = await ApiRepository.to.sendValidationCode( // state.countryCode.value, - "+86", - state.phoneStr.value, - // state.isIphoneType.value ? "1" : "2", - '1', - state.codeType.value, - "B748F838-94EE-4BDB-A0E6-7B2D16849792", - state.xWidth.value.toString()); + countryCode:"+86", + account:state.phoneStr.value, + channel:state.codeType.value, + codeType:'2', + xWidth:state.xWidth.value.toString()); if (entity.errorCode!.codeIsSuccessful) { _startTimer(); } else {} @@ -66,6 +64,11 @@ class StarLockForgetPasswordLogic extends BaseGetXController { void changeInput(TextEditingController controller) { if (controller == state.phoneController) { state.phoneStr.value = controller.text; + if(state.phoneStr.value.contains("@")){ + state.codeType.value = "2"; + }else{ + state.codeType.value = "1"; + } state.phoneStrIsOK.value = state.phoneStr.value.isNotEmpty; } if (controller == state.pwdController) { diff --git a/star_lock/lib/login/forgetPassword/starLock_forgetPassword_page.dart b/star_lock/lib/login/forgetPassword/starLock_forgetPassword_page.dart index af0b1eb3..a017903b 100644 --- a/star_lock/lib/login/forgetPassword/starLock_forgetPassword_page.dart +++ b/star_lock/lib/login/forgetPassword/starLock_forgetPassword_page.dart @@ -39,27 +39,72 @@ class _StarLockForgetPasswordPageState body: ListView( padding: EdgeInsets.only(top: 40.h, left: 40.w, right: 40.w), children: [ + GestureDetector( + onTap: () async { + var result = await Navigator.pushNamed( + context, Routers.selectCountryRegionPage); + if (result != null) { + result as Map; + state.countryCode.value = result['code']; + state.countryName.value = result['countryName']; + } + // print("路由返回值: ${result}, countryCode:${logic.state.countryCode} ,countryId:${logic.state.countryId}"); + }, + child: SizedBox( + height: 70.h, + child: Row( + children: [ + SizedBox(width: 5.w), + Expanded( + child: Text(TranslationLoader.lanKeys!.countryAndRegion!.tr, + style: TextStyle( + fontSize: 26.sp, color: AppColors.blackColor))), + SizedBox(width: 20.w), + Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Obx(() => Text( + '${state.countryName} +${state.countryCode}', + // state.isIphoneType.value + // ? '${state.countryName} +${state.countryCode}' + // : "${state.countryName}", + textAlign: TextAlign.end, + style: TextStyle( + fontSize: 26.sp, color: AppColors.blackColor), + )) + ], + ), + SizedBox(width: 5.w), + Image.asset( + 'images/icon_right.png', + width: 50.w, + height: 50.w, + ), + ], + ), + ), + ), + Container( + height: 0.5.h, + color: Colors.grey, + ), LoginInput( controller: state.phoneController, onchangeAction: (v) { - print("3333333:${v}"); logic.checkNext(state.phoneController); }, leftWidget: Padding( - padding: EdgeInsets.only( - top: 30.w, bottom: 20.w, right: 20.w, left: 5.w), + padding: EdgeInsets.only(top: 30.w, bottom: 20.w, right: 20.w, left: 5.w), child: Image.asset( 'images/icon_login_account.png', width: 36.w, height: 36.w, ), ), - hintText: - TranslationLoader.lanKeys!.pleaseEnterNumberOrEmail!.tr, + hintText:TranslationLoader.lanKeys!.pleaseEnterNumberOrEmail!.tr, keyboardType: TextInputType.number, inputFormatters: [ - FilteringTextInputFormatter.allow(RegExp('[0-9]')), - LengthLimitingTextInputFormatter(20), + LengthLimitingTextInputFormatter(30), ]), SizedBox(height: 10.h), LoginInput( diff --git a/star_lock/lib/login/forgetPassword/starLock_forgetPassword_state.dart b/star_lock/lib/login/forgetPassword/starLock_forgetPassword_state.dart index 205206fb..97668b6c 100644 --- a/star_lock/lib/login/forgetPassword/starLock_forgetPassword_state.dart +++ b/star_lock/lib/login/forgetPassword/starLock_forgetPassword_state.dart @@ -14,9 +14,9 @@ class StarLockForgetPasswordState { return DateTime.now().millisecondsSinceEpoch; } - var countryCode = '+86'.obs; - var countryId = '9'.obs; - var codeType = '2'.obs; + var countryCode = "86".obs; + var countryName = '中国'.obs; + var codeType = '2'.obs; // 1:邮箱 2:手机 var pwd = ''.obs; var surePwd = ''.obs; var verificationCode = ''.obs; @@ -26,7 +26,7 @@ class StarLockForgetPasswordState { var phoneStrIsOK = false.obs; var date = currentTimeMillis().toString().obs; - bool get isIphone => RegexUtil.isMobileSimple(phoneStr.value); + // bool get isIphone => RegexUtil.isMobileSimple(phoneStr.value); bool get pwdIsOK => pwd.value.isNotEmpty && (pwd.value == surePwd.value); bool get codeIsOK => verificationCode.value.isNotEmpty; diff --git a/star_lock/lib/login/register/starLock_register_logic.dart b/star_lock/lib/login/register/starLock_register_logic.dart index 920658d4..a5073aab 100644 --- a/star_lock/lib/login/register/starLock_register_logic.dart +++ b/star_lock/lib/login/register/starLock_register_logic.dart @@ -30,12 +30,11 @@ class StarLockRegisterLogic extends BaseGetXController { void register() async { var entity = await ApiRepository.to.register( - state.countryCode.value, - state.countryId.value, - state.phoneOrEmailStr.value, - state.pwd.value, - "477E6814-289D-402A-9F49-F89A8BD05D63", - state.verificationCode.value); + receiverType:state.isIphoneType.value == true ? 1 : 2, + countryCode:state.countryCode.value, + account:state.phoneOrEmailStr.value, + password:state.pwd.value, + verificationCode:state.verificationCode.value); if (entity.errorCode!.codeIsSuccessful) { // await loginSuccess(loginEntity: entity); // Toast.show(msg: "注册成功"); @@ -47,12 +46,11 @@ class StarLockRegisterLogic extends BaseGetXController { void sendValidationCode() async { var entity = await ApiRepository.to.sendValidationCode( // state.countryCode.value, - "+86", - state.phoneOrEmailStr.value, - state.isIphoneType.value ? "1" : "2", - '1', - "B748F838-94EE-4BDB-A0E6-7B2D16849792", - state.xWidth.value.toString()); + 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 { @@ -85,6 +83,5 @@ class StarLockRegisterLogic extends BaseGetXController { state.canSub.value = state.pwdIsOK && state.codeIsOK && (state.isIphoneType.value ? state.isIphone : state.isEmail); - print("22222:${state.canSub.value}"); } } diff --git a/star_lock/lib/login/register/starLock_register_page.dart b/star_lock/lib/login/register/starLock_register_page.dart index 9fd86e30..24c6e7f5 100644 --- a/star_lock/lib/login/register/starLock_register_page.dart +++ b/star_lock/lib/login/register/starLock_register_page.dart @@ -1,5 +1,3 @@ -import 'dart:async'; -import 'dart:ffi'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; @@ -145,12 +143,10 @@ class _StarLockRegisterPageState extends State { context, Routers.selectCountryRegionPage); if (result != null) { result as Map; - logic.state.countryCode.value = result['code']; - logic.state.countryId.value = result["countryId"]; - logic.state.countryName.value = result['countryName']; + state.countryCode.value = result['code']; + state.countryName.value = result['countryName']; } - print( - "路由返回值: ${result}, countryCode:${logic.state.countryCode} ,countryId:${logic.state.countryId}"); + // print("路由返回值: ${result}, countryCode:${logic.state.countryCode} ,countryId:${logic.state.countryId}"); }, child: SizedBox( height: 70.h, @@ -167,8 +163,8 @@ class _StarLockRegisterPageState extends State { children: [ Obx(() => Text( state.isIphoneType.value - ? '${logic.state.countryName} +${logic.state.countryCode}' - : "${logic.state.countryName}", + ? '${state.countryName} +${state.countryCode}' + : "${state.countryName}", textAlign: TextAlign.end, style: TextStyle( fontSize: 26.sp, color: AppColors.blackColor), @@ -199,7 +195,6 @@ class _StarLockRegisterPageState extends State { LoginInput( controller: state.phoneOrEmailController, onchangeAction: (v) { - print("3333333:${v}"); logic.checkNext(state.phoneOrEmailController); }, leftWidget: @@ -299,8 +294,7 @@ class _StarLockRegisterPageState extends State { "countryCode": state.countryCode, "account": state.phoneOrEmailStr.value }); - logic.state.xWidth.value = - (result as Map)['xWidth']; + state.xWidth.value = (result as Map)['xWidth']; logic.sendValidationCode(); } : null, @@ -309,9 +303,7 @@ class _StarLockRegisterPageState extends State { height: 60.h, padding: EdgeInsets.all(5.h), decoration: BoxDecoration( - color: state.phoneOrEmailStrIsOK.value - ? AppColors.mainColor - : Colors.grey, + color: state.phoneOrEmailStrIsOK.value ? AppColors.mainColor : Colors.grey, borderRadius: BorderRadius.circular(5)), child: Center( child: Text(state.btnText.value, diff --git a/star_lock/lib/login/register/starLock_register_state.dart b/star_lock/lib/login/register/starLock_register_state.dart index e2e545f0..253aba4f 100644 --- a/star_lock/lib/login/register/starLock_register_state.dart +++ b/star_lock/lib/login/register/starLock_register_state.dart @@ -10,9 +10,9 @@ class StarLockRegisterState { final TextEditingController sureController = TextEditingController(); final TextEditingController codeController = TextEditingController(); - var countryCode = '86'.obs; - var countryId = '1'.obs; + var countryCode = 86.obs; var countryName = '中国'.obs; + var phoneOrEmailStr = ''.obs; var phoneOrEmailStrIsOK = false.obs; var pwd = ''.obs; diff --git a/star_lock/lib/login/selectCountryRegion/selectCountryRegion_page.dart b/star_lock/lib/login/selectCountryRegion/selectCountryRegion_page.dart index a93058b3..b61ba36d 100644 --- a/star_lock/lib/login/selectCountryRegion/selectCountryRegion_page.dart +++ b/star_lock/lib/login/selectCountryRegion/selectCountryRegion_page.dart @@ -1,12 +1,14 @@ import 'package:azlistview/azlistview.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/login/selectCountryRegion/common/countryRegionEntity.dart'; import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/tools/baseGetXController.dart'; import '../../app_settings/app_colors.dart'; +import '../../tools/keySearchWidget.dart'; import '../../tools/titleAppBar.dart'; import '../../translations/trans_lib.dart'; import 'common/index.dart'; @@ -20,6 +22,7 @@ class SelectCountryRegionPage extends StatefulWidget { class _SelectCountryRegionPageState extends State { List countriesList = []; + TextEditingController searchController = TextEditingController(); @override void initState() { @@ -60,9 +63,11 @@ class _SelectCountryRegionPageState extends State { // A-Z sort. SuspensionUtil.sortListBySuspensionTag(list); // show sus tag. - SuspensionUtil.setShowSuspensionStatus(countriesList); + SuspensionUtil.setShowSuspensionStatus(list); - setState(() {}); + setState(() { + Get.log('list.length:${list.length}'); + }); } @override @@ -76,26 +81,49 @@ class _SelectCountryRegionPageState extends State { haveBack: true, backgroundColor: AppColors.mainColor, ), - body: AzListView( - data: countriesList, - itemCount: countriesList.length, - itemBuilder: (BuildContext context, int index) { - CountryRegionModel model = countriesList[index]; - return Utils.getListItem(context, model, () { - Map resultMap = {}; - resultMap['code'] = model.code; - resultMap['countryId'] = model.countryId.toString(); - resultMap['countryName'] = model.name; - Navigator.pop(context, resultMap); - }); - }, - padding: EdgeInsets.zero, - susItemBuilder: (BuildContext context, int index) { - CountryRegionModel model = countriesList[index]; - String tag = model.getSuspensionTag(); - return Utils.getSusItem(context, tag); - }, - indexBarData: const ['★', ...kIndexBarData], + body: Column( + children: [ + KeySearchWidget( + editingController: searchController, + backgroundColor: AppColors.mainBackgroundColor, + onSubmittedAction: () { + var searchList = []; + for (int i = 0, length = countriesList.length; i < length; i++) { + CountryRegionModel countryModel = countriesList[i]; + if(countryModel.name!.contains(searchController.text) || countryModel.code!.contains(searchController.text)){ + searchList.add(countryModel); + Get.log('countryModel.name:${countryModel.name} countryModel.code:${countryModel.code}'); + } + } + Get.log('searchList.length:${searchList.length}'); + _handleList(searchList); + }, + ), + SizedBox(height:20.h), + Expanded( + child: AzListView( + data: countriesList, + itemCount: countriesList.length, + itemBuilder: (BuildContext context, int index) { + CountryRegionModel model = countriesList[index]; + return Utils.getListItem(context, model, () { + Map resultMap = {}; + resultMap['code'] = model.code; + resultMap['countryId'] = model.countryId.toString(); + resultMap['countryName'] = model.name; + Navigator.pop(context, resultMap); + }); + }, + padding: EdgeInsets.zero, + susItemBuilder: (BuildContext context, int index) { + CountryRegionModel model = countriesList[index]; + String tag = model.getSuspensionTag(); + return Utils.getSusItem(context, tag); + }, + indexBarData: const ['★', ...kIndexBarData], + ), + ), + ], ), ); } diff --git a/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdminManage/authorizedAdminManage_tabbar.dart b/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdminManage/authorizedAdminManage_tabbar.dart index dcbf7c45..ad81a669 100644 --- a/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdminManage/authorizedAdminManage_tabbar.dart +++ b/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdminManage/authorizedAdminManage_tabbar.dart @@ -37,6 +37,13 @@ class _AuthorizedAdminManageTabbarState vsync: this, length: _itemTabs.length, initialIndex: widget.initialIndex); + + _tabController.addListener(() { + // print("_tabController.animation!.value:${_tabController.animation!.value} _tabController.index:${_tabController.index}"); + if (_tabController.animation!.value==_tabController.index){ + FocusScope.of(context).requestFocus(FocusNode()); + } + }); } @override @@ -54,6 +61,9 @@ class _AuthorizedAdminManageTabbarState return TabBar( controller: _tabController, tabs: _itemTabs.map((ItemView item) => _tab(item)).toList(), + onTap: (index){ + FocusScope.of(context).requestFocus(FocusNode()); + }, isScrollable: true, indicatorColor: Colors.red, unselectedLabelColor: Colors.black, diff --git a/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_logic.dart b/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_logic.dart index 1bdbf550..79e6b3bb 100644 --- a/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_logic.dart +++ b/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_logic.dart @@ -7,27 +7,29 @@ class AuthorizedAdminListLogic extends BaseGetXController { final AuthorizedAdminListState state = AuthorizedAdminListState(); //请求电子钥匙列表 - Future> mockNetworkDataRequest() async { + Future mockNetworkDataRequest() async { ElectronicKeyListEntity entity = await ApiRepository.to.electronicKeyList( endDate: '0', keyId: state.keyInfo.value.keyId.toString(), keyStatus: '', + keyRight: '1', lockId: state.keyInfo.value.lockId.toString(), - operatorUid: '', pageNo: pageNo.toString(), pageSize: pageSize.toString(), startDate: '0', - keyRight: '0', searchStr:state.searchStr.value); - List dataList = []; if (entity.errorCode!.codeIsSuccessful) { - print("电子钥匙列表成功:${entity.data?.itemList}"); - if (entity.data != null) { - dataList = entity.data!.itemList; + if (pageNo == 1) { + state.itemDataList.value = entity.data!.itemList!; + pageNo++; + } else { + if (entity.data!.itemList!.isNotEmpty) { + state.itemDataList.value.addAll(entity.data!.itemList!); + pageNo++; + } } } - state.itemDataList.value = dataList; - return dataList; + return entity; } //删除电子钥匙名称请求 diff --git a/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_page.dart b/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_page.dart index 0cb5ffe3..ea04859c 100644 --- a/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_page.dart +++ b/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_page.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:flutter_slidable/flutter_slidable.dart'; import 'package:get/get.dart'; import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart'; import 'package:star_lock/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_logic.dart'; @@ -9,6 +10,7 @@ import 'package:star_lock/tools/storage.dart'; import '../../../../appRouters.dart'; import '../../../../app_settings/app_colors.dart'; +import '../../../../tools/EasyRefreshTool.dart'; import '../../../../tools/left_slide_actions.dart'; import '../../../../tools/showIosTipView.dart'; import '../../../../tools/submitBtn.dart'; @@ -38,7 +40,9 @@ class _AuthorizedAdminListPageState extends State { // 获取是否是演示模式 演示模式不获取接口 var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); if (isDemoMode == false) { - logic.mockNetworkDataRequest(); + logic.mockNetworkDataRequest().then((ElectronicKeyListEntity value){ + setState(() {}); + }); } } @@ -51,122 +55,137 @@ class _AuthorizedAdminListPageState extends State { haveBack: true, backgroundColor: AppColors.mainColor, ), - body: Column( - children: [ - Expanded( - child:_buildMainUI()), - SizedBox( - height: 20.h, - ), - AddBottomWhiteBtn( - btnName: TranslationLoader.lanKeys!.addAuthorizedAdmin!.tr, - onClick: () { - Navigator.pushNamed(context, Routers.authorizedAdminManagePage, - arguments: { - // "lockMainEntity": state.lockMainEntity.value, - "keyInfo": state.keyInfo.value - }).then((val) { - if (val != null) { - logic.mockNetworkDataRequest(); - setState(() {}); - } - }); - }, - ), - SizedBox( - height: 64.h, - ) - ], + body: EasyRefreshTool( + onRefresh: (){ + logic.pageNo = 1; + mockRequest(); + }, + onLoad: (){ + mockRequest(); + }, + child: Column( + children: [ + Expanded( + child:_buildMainUI()), + SizedBox( + height: 20.h, + ), + AddBottomWhiteBtn( + btnName: TranslationLoader.lanKeys!.addAuthorizedAdmin!.tr, + onClick: () { + Navigator.pushNamed(context, Routers.authorizedAdminManagePage, + arguments: { + // "lockMainEntity": state.lockMainEntity.value, + "keyInfo": state.keyInfo.value + }).then((val) { + if (val != null) { + logic.mockNetworkDataRequest(); + setState(() {}); + } + }); + }, + ), + SizedBox( + height: 44.h, + ) + ], + ), )); } Widget _buildMainUI() { - return state.itemDataList.value.isEmpty + return Obx(() => state.itemDataList.value.isEmpty ? NoData(noDataHeight: 1.sh - ScreenUtil().statusBarHeight - 90) - : ListView.separated( - itemCount: state.itemDataList.value.length, - itemBuilder: (c, index) { - ElectronicKeyListItem indexEntity = state.itemDataList.value[index]; - String useDateStr = ''; //使用期限 - String keyStatus = ''; //钥匙状态 + : SlidableAutoCloseBehavior( + child: ListView.separated( + itemCount: state.itemDataList.value.length, + itemBuilder: (c, index) { + ElectronicKeyListItem indexEntity = state.itemDataList.value[index]; + String useDateStr = ''; //使用期限 + String keyStatus = ''; //钥匙状态 - //使用期限 - useDateStr = getUseDateStr(indexEntity); + //使用期限 + useDateStr = getUseDateStr(indexEntity); - //钥匙状态 - keyStatus = getKeyStatus(indexEntity.keyStatus); + //钥匙状态 + keyStatus = getKeyStatus(indexEntity.keyStatus); - //是否为管理钥匙 - bool isAdminKey = false; - if (indexEntity.keyRight == 1) { - isAdminKey = true; - } else { - isAdminKey = false; - } + //是否为管理钥匙 + bool isAdminKey = false; + if (indexEntity.keyRight == 1) { + isAdminKey = true; + } else { + isAdminKey = false; + } - if (index < state.itemDataList.value.length) { - return LeftSlideActions( - // key: Key(indexEntity.lockId!.toString()), - actionsWidth: 60, - actions: [ - _buildDeleteBtn(indexEntity), - ], - decoration: const BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(1)), - ), - child: _electronicKeyItem( - 'images/controls_user.png', - indexEntity.keyName!, - useDateStr, - keyStatus, - isAdminKey, () { - Navigator.pushNamed( - context, Routers.electronicKeyDetailPage, - arguments: {'itemData': indexEntity}).then((val) { - if (val != null) { - logic.mockNetworkDataRequest(); - setState(() {}); - } - }); - }), - ); - } - return const SizedBox.shrink(); - }, - separatorBuilder: (BuildContext context, int index) { - return Divider( - height: 1.h, - color: AppColors.greyLineColor, - ); - }, + return Slidable( + key:ValueKey(indexEntity.keyId), + endActionPane: ActionPane( + extentRatio: 0.2, + motion: const ScrollMotion(), + children: [ + SlidableAction( + onPressed: (BuildContext context){ + showIosTipViewDialog(context, indexEntity.keyId!.toString()); + }, + backgroundColor: Colors.red, + foregroundColor: Colors.white, + label: '删除', + ), + ], + ), + child: _electronicKeyItem('images/controls_user.png', indexEntity.keyName!, useDateStr, keyStatus, isAdminKey, () { + Navigator.pushNamed(context, Routers.electronicKeyDetailPage, + arguments: {"itemData": indexEntity}).then((val) { + if (val != null) { + logic.mockNetworkDataRequest(); + setState(() {}); + } + }); + }), ); - } - Widget _buildDeleteBtn(ElectronicKeyListItem passwordKeyListItem) { - return GestureDetector( - onTap: () { - // 省略: 弹出是否删除的确认对话框。 - showIosTipViewDialog(context, passwordKeyListItem); - }, - child: Container( - width: 60, - color: const Color(0xFFF20101), - alignment: Alignment.center, - child: const Text( - '删除', - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.w500, - color: Colors.white, - height: 1, - ), - ), + // if (index < state.itemDataList.value.length) { + // return LeftSlideActions( + // // key: Key(indexEntity.lockId!.toString()), + // actionsWidth: 60, + // actions: [ + // _buildDeleteBtn(indexEntity), + // ], + // decoration: const BoxDecoration( + // borderRadius: BorderRadius.all(Radius.circular(1)), + // ), + // child: _electronicKeyItem( + // 'images/controls_user.png', + // indexEntity.keyName!, + // useDateStr, + // keyStatus, + // isAdminKey, () { + // Navigator.pushNamed( + // context, Routers.electronicKeyDetailPage, + // arguments: {'itemData': indexEntity}).then((val) { + // if (val != null) { + // logic.mockNetworkDataRequest(); + // setState(() {}); + // } + // }); + // }), + // ); + // } + return const SizedBox.shrink(); + }, + separatorBuilder: (BuildContext context, int index) { + return Divider( + height: 1.h, + color: AppColors.greyLineColor, + ); + }, ), - ); + )); } void showIosTipViewDialog( - BuildContext context, ElectronicKeyListItem passwordKeyListItem) { + BuildContext context, String keyId) { showDialog( context: context, builder: (BuildContext context) { @@ -175,7 +194,7 @@ class _AuthorizedAdminListPageState extends State { tipTitle: "确定要删除吗?", sureClick: () { Get.back(); - logic.deleteKeyRequest(passwordKeyListItem.keyId.toString()); + logic.deleteKeyRequest(keyId); }, cancelClick: () { Get.back(); @@ -281,10 +300,10 @@ class _AuthorizedAdminListPageState extends State { child: SizedBox( width: 20.w, )), - // Text( - // keyStatus, - // style: TextStyle(fontSize: 18.sp, color: Colors.red), - // ), + Text( + keyStatus, + style: TextStyle(fontSize: 18.sp, color: Colors.red), + ), ], ), SizedBox(height: 10.h), diff --git a/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_state.dart b/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_state.dart index cc1afb14..3eaf0a74 100644 --- a/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_state.dart +++ b/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_state.dart @@ -6,8 +6,7 @@ import '../../../lockMian/entity/lockListInfo_entity.dart'; class AuthorizedAdminListState { final keyInfo = LockListInfoItemEntity().obs; // final lockMainEntity = LockMainEntity().obs; - var pageNum = 1.obs; //请求页码 - final pageSize = 20.obs; //请求每页数据条数 + final itemDataList = [].obs; final searchStr = ''.obs; diff --git a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_logic.dart b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_logic.dart index 052e792a..264675c3 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_logic.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_logic.dart @@ -12,14 +12,19 @@ class ElectronicKeyDetailLogic extends BaseGetXController { //修改钥匙名称请求 Future modifyKeyNameRequest() async { + if (state.changeNameController.text.isEmpty) { + showToast("请输入钥匙名称"); + return; + } KeyOperationRecordEntity entity = await ApiRepository.to .modifyKeyNameForAdmin(state.itemData.value.keyId.toString(), state.changeNameController.text, ''); if (entity.errorCode!.codeIsSuccessful) { - print("修改要是名称成功啦啦啦啦啦"); + state.itemData.value.keyName = state.changeNameController.text; + state.keyName.value = state.itemData.value.keyName!; + Get.back(); showToast("修改成功", something: (){ eventBus.fire(ElectronicKeyListRefreshUI()); - Get.back(); }); } } diff --git a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_page.dart b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_page.dart index 2e702252..c563146d 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_page.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_page.dart @@ -58,17 +58,15 @@ class _ElectronicKeyDetailPageState extends State { backgroundColor: AppColors.mainColor), body: Column( children: [ - CommonItem( + Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.name!.tr, - rightTitle: state.changeNameController.text.isNotEmpty - ? state.changeNameController.text - : state.itemData.value.keyName, + rightTitle: state.keyName.value, isHaveDirection: true, isHaveLine: true, action: () { showCupertinoAlertDialog(context); - }), - getPeriodValidityWidget(), + })), + Obx(() => getPeriodValidityWidget()), Container(height: 10.h), CommonItem( leftTitel: TranslationLoader.lanKeys!.receiver!.tr, diff --git a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_state.dart b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_state.dart index 98c7d383..83085ae1 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_state.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_state.dart @@ -4,10 +4,13 @@ import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity class ElectronicKeyDetailState { final itemData = ElectronicKeyListItem().obs; + final keyName = "".obs; final TextEditingController changeNameController = TextEditingController(); ElectronicKeyDetailState() { Map map = Get.arguments; itemData.value = map["itemData"]; + changeNameController.text = itemData.value.keyName!; + keyName.value = itemData.value.keyName!; } } diff --git a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_logic.dart b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_logic.dart index 025005bb..89c25095 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_logic.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_logic.dart @@ -16,12 +16,11 @@ class ElectronicKeyListLogic extends BaseGetXController { endDate: '0', keyId: state.keyInfo.value.keyId.toString(), keyStatus: '', + keyRight: '0', lockId: state.keyInfo.value.lockId.toString(), - operatorUid: '', pageNo: pageNo.toString(), pageSize: pageSize.toString(), startDate: '0', - keyRight: '0', searchStr: state.searchController.text); if (entity.errorCode!.codeIsSuccessful) { if (pageNo == 1) { diff --git a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_page.dart b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_page.dart index 57469de0..97253cf4 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_page.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_page.dart @@ -94,6 +94,9 @@ class _ElectronicKeyListPageState extends State { ), Expanded( child: _buildMainUI()), + SizedBox( + height: 20.h, + ), AddBottomWhiteBtn( btnName: TranslationLoader.lanKeys!.sendKey!.tr, onClick: () { @@ -111,7 +114,7 @@ class _ElectronicKeyListPageState extends State { }, ), SizedBox( - height: 64.h, + height: 44.h, ) ], ), @@ -307,8 +310,7 @@ class _ElectronicKeyListPageState extends State { children: [ Text( receiveUser, - style: TextStyle( - fontSize: 24.sp, color: AppColors.blackColor), + style: TextStyle(fontSize: 24.sp, color: AppColors.blackColor), ), SizedBox(width: 10.w), isAdminKey diff --git a/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_logic.dart b/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_logic.dart index 0aefe1b4..fe161625 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_logic.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_logic.dart @@ -13,17 +13,40 @@ class SendElectronicKeyLogic extends BaseGetXController { final SendElectronicKeyState state = SendElectronicKeyState(); //发送钥匙请求 - Future sendElectronicKeyRequest(BuildContext widgetContext) async { + Future sendElectronicKeyRequest() async { + if(state.emailOrPhoneController.text.isEmpty){ + showToast("请输入接收者账号"); + return; + } + if(state.keyNameController.text.isEmpty){ + showToast("请输入接收者姓名"); + return; + } + + DateTime startDateTime = DateTime(state.effectiveDateTime.value.year, state.effectiveDateTime.value.month, state.effectiveDateTime.value.day, state.effectiveDateTime.value.hour, state.effectiveDateTime.value.minute); + DateTime endDateTime = DateTime(state.failureDateTime.value.year, state.failureDateTime.value.month, state.failureDateTime.value.day, state.failureDateTime.value.hour, state.failureDateTime.value.minute); + + //发送钥匙请求 + if (state.type.value == "0" || state.type.value == "3") { + if (!startDateTime.isBefore(endDateTime) || startDateTime.isAtSameMomentAs(endDateTime)) { + showToast("失效时间需大于生效时间"); + return; + } + + if (!startDateTime.isBefore(DateTime.now()) || startDateTime.isAtSameMomentAs(DateTime.now())) { + showToast("生效时间需大于当前时间"); + return; + } + } + String lockID = state.keyInfo.value.lockId.toString(); int typeValue = int.parse(state.type.value); switch (typeValue) { case 0: { typeValue = XSConstantMacro.keyTypeTime; - state.failureTimestamp.value = - state.failureDateTime.value.millisecondsSinceEpoch; - state.effectiveTimestamp.value = - state.effectiveDateTime.value.millisecondsSinceEpoch; + state.failureTimestamp.value = state.failureDateTime.value.millisecondsSinceEpoch; + state.effectiveTimestamp.value = state.effectiveDateTime.value.millisecondsSinceEpoch; } break; case 1: @@ -70,9 +93,9 @@ class SendElectronicKeyLogic extends BaseGetXController { if (entity.errorCode == 425) { //用户未注册 if (isPhoneNumber(state.emailOrPhoneController.text) == true) { - _showPhoneDialog(widgetContext, '${entity.errorMsg}'); + _showPhoneDialog(Get.context, '${entity.errorMsg}'); } else { - _showEmailDialog(widgetContext); + _showEmailDialog(Get.context); } } } @@ -158,7 +181,7 @@ class SendElectronicKeyLogic extends BaseGetXController { state.isCreateUser.value = true; Navigator.of(context).pop(); - sendElectronicKeyRequest(widgetContext); + sendElectronicKeyRequest(); }, ), ], diff --git a/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_page.dart b/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_page.dart index 405ddfe4..98ceb8d3 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_page.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_page.dart @@ -268,33 +268,34 @@ class _SendElectronicKeyPageState extends State { btnName: TranslationLoader.lanKeys!.send!.tr, onClick: () { if (isDemoMode == false) { - DateTime startDateTime = DateTime( - state.effectiveDateTime.value.year, - state.effectiveDateTime.value.month, - state.effectiveDateTime.value.day, - state.effectiveDateTime.value.hour, - state.effectiveDateTime.value.minute); - DateTime endDateTime = DateTime( - state.failureDateTime.value.year, - state.failureDateTime.value.month, - state.failureDateTime.value.day, - state.failureDateTime.value.hour, - state.failureDateTime.value.minute); - //发送钥匙请求 - if (state.emailOrPhoneController.text.isNotEmpty && state.keyNameController.text.isNotEmpty) { - if (int.parse(widget.type) == 0) { - if (!startDateTime.isBefore(endDateTime) || - startDateTime.isAtSameMomentAs(endDateTime)) { - logic.showToast("失效时间需大于生效时间"); - } else { - logic.sendElectronicKeyRequest(context); - } - } else { - logic.sendElectronicKeyRequest(context); - } - } else { - logic.showToast("请完善信息"); - } + // DateTime startDateTime = DateTime( + // state.effectiveDateTime.value.year, + // state.effectiveDateTime.value.month, + // state.effectiveDateTime.value.day, + // state.effectiveDateTime.value.hour, + // state.effectiveDateTime.value.minute); + // DateTime endDateTime = DateTime( + // state.failureDateTime.value.year, + // state.failureDateTime.value.month, + // state.failureDateTime.value.day, + // state.failureDateTime.value.hour, + // state.failureDateTime.value.minute); + // //发送钥匙请求 + // if (state.emailOrPhoneController.text.isNotEmpty && state.keyNameController.text.isNotEmpty) { + // if (int.parse(widget.type) == 0) { + // if (!startDateTime.isBefore(endDateTime) || + // startDateTime.isAtSameMomentAs(endDateTime)) { + // logic.showToast("失效时间需大于生效时间"); + // } else { + // logic.sendElectronicKeyRequest(); + // } + // } else { + // logic.sendElectronicKeyRequest(); + // } + // } else { + // logic.showToast("请完善信息"); + // } + logic.sendElectronicKeyRequest(); } else { //演示模式不获取接口 logic.showToast("演示模式"); @@ -495,6 +496,9 @@ class _SendElectronicKeyPageState extends State { .phoneNumbers![0] .replaceAll(RegExp(r"\s+\b|\b\s"), ""); } + if (currentContact.fullName!.isNotEmpty) { + state.keyNameController.text = currentContact.fullName!; + } }); }, ), diff --git a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart index 97aafcde..aa6cda64 100644 --- a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart +++ b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart @@ -157,6 +157,9 @@ class LockDetailLogic extends BaseGetXController { case 0x00: //成功 print("${reply.commandType}数据解析成功"); + dismissEasyLoading(); + cancelBlueConnetctToastTimer(); + // 厂商名称 var vendor = reply.data.sublist(3, 23); // print("vendor:$vendor"); @@ -192,7 +195,7 @@ class LockDetailLogic extends BaseGetXController { // 电池剩余电量 var battRemCap = reply.data[132]; // print("battRemCap:$battRemCap"); - + uploadElectricQuantityRequest(battRemCap.toString()); // 重置次数 var restoreCounter = reply.data.sublist(133, 135); // print("restoreCounter:$restoreCounter"); @@ -531,6 +534,32 @@ class LockDetailLogic extends BaseGetXController { // }, isShowLoading: false); // } + // 获取锁状态 更新电量 + Future getStarLockStatus() async { + showEasyLoading(); + showBlueConnetctToastTimer(action: (){ + dismissEasyLoading(); + }); + BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async { + if (deviceConnectionState == DeviceConnectionState.connected) { + dismissEasyLoading(); + var privateKey = await Storage.getStringList(saveBluePrivateKey); + List getPrivateKeyList = changeStringListToIntList(privateKey!); + IoSenderManage.senderGetStarLockStatuInfo( + lockID: BlueManage().connectDeviceName, + userID: await Storage.getUid(), + privateKey: getPrivateKeyList, + ); + } else if (deviceConnectionState == DeviceConnectionState.disconnected) { + dismissEasyLoading(); + cancelBlueConnetctToastTimer(); + if(state.ifCurrentScreen.value == true){ + showBlueConnetctToast(); + } + } + }); + } + // 查询事件记录(时间查询) Future senderReferEventRecordTime(int time) async { BlueManage().bludSendData(BlueManage().connectDeviceName, @@ -685,22 +714,15 @@ class LockDetailLogic extends BaseGetXController { } } - // connectBlueAndAnimationController(){ - // state.lockState.value = 1; - // state.animationController.forward(); - // BlueManage().bludSendData(state.keyInfos.value.bluetooth!.bluetoothDeviceName!, (DeviceConnectionState deviceConnectionState) async { - // if (deviceConnectionState == DeviceConnectionState.connected){ - // state.lockState.value = 2; - // }else if (deviceConnectionState == DeviceConnectionState.disconnected){ - // showBlueConnetctToast(); - // - // state.lockState.value = 4; - // state.animationController.reset(); - // state.animationController.forward(); - // } - // }); - // } - + //电量更新请求 + Future uploadElectricQuantityRequest(String electricQuantity) async { + KeyOperationRecordEntity entity = await ApiRepository.to.uploadElectricQuantity(electricQuantity, state.keyInfos.value.lockId.toString()); + if (entity.errorCode!.codeIsSuccessful) { + showToast("电量更新成功", something: (){ + eventBus.fire(RefreshLockListInfoDataEvent()); + }); + } + } /// 锁设置里面开启关闭考勤刷新锁详情 StreamSubscription? _lockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceEvent; diff --git a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart index 4e538b2b..712d7cf9 100644 --- a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart +++ b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart @@ -9,6 +9,7 @@ import '../../../app_settings/app_colors.dart'; import '../../../blue/blue_manage.dart'; import '../../../blue/io_tool/io_tool.dart'; import '../../../tools/appRouteObserver.dart'; +import '../../../tools/jh_pop_menus.dart'; import '../../../tools/storage.dart'; import '../../../translations/trans_lib.dart'; import '../../lockMian/entity/lockListInfo_entity.dart'; @@ -129,21 +130,32 @@ class _LockDetailPageState extends State ))) ), Positioned( - child: Obx(() => Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - Text("${state.electricQuantity.value}%", - style: TextStyle( - fontSize: 18.sp, - color: AppColors.darkGrayTextColor)), - SizedBox(width: 2.w), - Image.asset( - showElectricIcon(state.electricQuantity.value), - width: 30.w, - height: 24.w), - SizedBox(width: 30.w), - ], - ))) + child: Obx(() => GestureDetector( + onTap: (){ + logic.getStarLockStatus(); + }, + child: 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: 30.h), diff --git a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_state.dart b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_state.dart index b088909b..7dff3873 100644 --- a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_state.dart +++ b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_state.dart @@ -36,7 +36,7 @@ class LockDetailState { var iSOpenLock = true.obs; // 是开锁还是关锁 Timer? closedUnlockSuccessfulTimer; - var bottomBtnisUneable = false.obs; // 是否不可用 + var bottomBtnisUneable = false.obs; // 是否不可用 用于限制底部按钮是否可用 //过渡动画控制器 late AnimationController animationController; diff --git a/star_lock/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_state.dart b/star_lock/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_state.dart index ff88f1f5..1c0bf1f6 100644 --- a/star_lock/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_state.dart +++ b/star_lock/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_state.dart @@ -1,5 +1,4 @@ - import 'package:get/get.dart'; import '../../lockSet/lockSetInfo_entity.dart'; diff --git a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart index 36d5f08d..01de800c 100644 --- a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart +++ b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart @@ -105,7 +105,7 @@ class _PasswordKeyListPageState extends State { }); }), SizedBox( - height: 42.h, + height: 44.h, ) ], ), @@ -214,7 +214,7 @@ class _PasswordKeyListPageState extends State { // width: 20.w, // )), SizedBox(width: 10.w), - passwordKeyListItem.keyboardPwdStatus == 2 ? Text('已失效', style: TextStyle(color: Colors.red, fontSize: 20.sp),) : Container(), + passwordKeyListItem.keyboardPwdStatus == 2 ? Text('已过期', style: TextStyle(color: Colors.red, fontSize: 20.sp),) : Container(), SizedBox(width: 15.w) ], ), diff --git a/star_lock/lib/main/lockMian/lockList/lockList_logic.dart b/star_lock/lib/main/lockMian/lockList/lockList_logic.dart index af8a9457..3713b576 100644 --- a/star_lock/lib/main/lockMian/lockList/lockList_logic.dart +++ b/star_lock/lib/main/lockMian/lockList/lockList_logic.dart @@ -1,5 +1,7 @@ import 'package:star_lock/tools/baseGetXController.dart'; +import '../../../common/XSConstantMacro/XSConstantMacro.dart'; +import '../entity/lockListInfo_entity.dart'; import 'lockList_state.dart'; class LockListLogic extends BaseGetXController{ @@ -20,6 +22,19 @@ class LockListLogic extends BaseGetXController{ return 'images/main/icon_lockElectricLevel_5.png'; } + String getKeyEffective(LockListInfoItemEntity keyInfo){ + // 当是限时、循环的时候 + if(keyInfo.keyType == XSConstantMacro.keyTypeTime || keyInfo.keyType == XSConstantMacro.keyTypeLoop){ + // 当是正常使用跟待接收状态的时候 + if(keyInfo.keyStatus == XSConstantMacro.keyStatusNormalUse || keyInfo.keyStatus == XSConstantMacro.keyStatusWaitReceive) { + return "余${compareTimeGetDaysFromNow(keyInfo.endDate!)}天"; + } else { + return XSConstantMacro.getKeyStatusStr(keyInfo.keyStatus!); + } + } + return ""; + } + /// 获取是否超过现在的时间 bool compareTimeIsOvertime(int endTiem){ DateTime dateTime = DateTime.fromMillisecondsSinceEpoch(endTiem); // 将时间戳转换为 DateTime diff --git a/star_lock/lib/main/lockMian/lockList/lockList_page.dart b/star_lock/lib/main/lockMian/lockList/lockList_page.dart index 5f32c1ab..066140b7 100644 --- a/star_lock/lib/main/lockMian/lockList/lockList_page.dart +++ b/star_lock/lib/main/lockMian/lockList/lockList_page.dart @@ -149,17 +149,17 @@ class _LockListPageState extends State { ), ), SizedBox(width: 20.w), - Text( - "${keyInfo.electricQuantity!}%", - style: TextStyle( - fontSize: 18.sp, color: AppColors.darkGrayTextColor), - ), - SizedBox(width: 2.w), Image.asset( logic.showElectricIcon(keyInfo.electricQuantity!), width: 30.w, height: 24.w, ), + SizedBox(width: 2.w), + Text( + "${keyInfo.electricQuantity!}%", + style: TextStyle( + fontSize: 18.sp, color: AppColors.darkGrayTextColor), + ), SizedBox(width: 30.w), ], ), @@ -191,11 +191,9 @@ class _LockListPageState extends State { ), ], )), - SizedBox( - height: 20.h, - ), + SizedBox(height: 20.h), Visibility( - visible: keyInfo.keyType == XSConstantMacro.keyTypeTime ? true : false, + visible: (keyInfo.keyType == XSConstantMacro.keyTypeTime || keyInfo.keyType == XSConstantMacro.keyTypeLoop) ? true : false, // visible: true, child:Row( children: [ @@ -206,8 +204,8 @@ class _LockListPageState extends State { borderRadius: BorderRadius.circular(5.w), color: logic.compareTimeIsOvertime(keyInfo.endDate!) ? AppColors.listTimeYellowColor : AppColors.mainColor, ), - child: Text( - logic.compareTimeIsOvertime(keyInfo.endDate!) ? "已过期" : "余${logic.compareTimeGetDaysFromNow(keyInfo.endDate!)}天", style: TextStyle(fontSize: 18.sp, color: Colors.white) + child: Text(logic.getKeyEffective(keyInfo), style: TextStyle(fontSize: 18.sp, color: Colors.white) + // child: Text(logic.compareTimeIsOvertime(keyInfo.endDate!) ? "已过期" : "余${logic.compareTimeGetDaysFromNow(keyInfo.endDate!)}天", style: TextStyle(fontSize: 18.sp, color: Colors.white) ), ), ], @@ -223,9 +221,7 @@ class _LockListPageState extends State { ), ], ), - SizedBox( - height: 20.h, - ), + SizedBox(height: 20.h), ], ), ), diff --git a/star_lock/lib/main/lockMian/lockList/lockList_state.dart b/star_lock/lib/main/lockMian/lockList/lockList_state.dart index e91ad363..a927c01a 100644 --- a/star_lock/lib/main/lockMian/lockList/lockList_state.dart +++ b/star_lock/lib/main/lockMian/lockList/lockList_state.dart @@ -1,5 +1,8 @@ +import 'package:get/get.dart'; class LockListState{ + var itemStatusIsEable = false.obs; // 列表里面item是否能点击 + } \ No newline at end of file diff --git a/star_lock/lib/mine/about/about_page.dart b/star_lock/lib/mine/about/about_page.dart index a9d58280..3c50d465 100644 --- a/star_lock/lib/mine/about/about_page.dart +++ b/star_lock/lib/mine/about/about_page.dart @@ -39,7 +39,7 @@ class _AboutPageState extends State { ), SizedBox(height: 20.h), Text( - "${F.title} 1.0.0.09(preRelease-20240126-1)", + "${F.title} 1.0.0.10(preRelease-20240201)", style: TextStyle(fontSize: 24.sp, color: AppColors.blackColor), ), SizedBox(height: 20.h), diff --git a/star_lock/lib/network/api.dart b/star_lock/lib/network/api.dart index 2731df5b..4e2194db 100644 --- a/star_lock/lib/network/api.dart +++ b/star_lock/lib/network/api.dart @@ -11,12 +11,10 @@ abstract class Api { final String sendElectronicKeyURL = '/key/send'; //发送电子钥匙 final String resetElectronicKeyURL = '/key/reset'; //重置电子钥匙 final String keyOperationRecordURL = '/lockRecords/list'; //操作记录 - final String uploadElectricQuantityURL = - '/room/uploadElectricQuantity'; //锁电量更新 + final String uploadElectricQuantityURL = '/room/uploadElectricQuantity'; //锁电量更新 final String lockRecordUploadURL = '/lockRecords/fromLock'; //操作上传 - final String getLockRecordLastUploadDataTimeURL = - '/lockRecords/getLastRecordTime'; //查询锁记录最后时间 + final String getLockRecordLastUploadDataTimeURL = '/lockRecords/getLastRecordTime'; //查询锁记录最后时间 final String getLockNetTokenURL = '/lock/getLockNetToken'; //获取手机联网token final String updateLockUserNoURL = '/key/updateLockUserNo'; //更新锁用户NO diff --git a/star_lock/lib/network/api_provider.dart b/star_lock/lib/network/api_provider.dart index fcafedcc..88db87cc 100644 --- a/star_lock/lib/network/api_provider.dart +++ b/star_lock/lib/network/api_provider.dart @@ -5,7 +5,7 @@ import 'api_provider_base.dart'; class ApiProvider extends BaseProvider { Future getVerificationCode(String countryCode, String account, - String channel, String codeType, String uniqueid, String xWidth) => + String channel, String codeType, String xWidth) => post( getVerificationCodeUrl.toUrl, jsonEncode({ @@ -13,21 +13,24 @@ class ApiProvider extends BaseProvider { 'account': account, "channel": channel, 'codeType': codeType, - "uniqueid": uniqueid, 'xWidth': xWidth, })); - Future register(String countryCode, String countryId, String mobile, - String password, String uniqueid, String verificationCode) => - post(registerUrl.toUrl, null, query: { + Future register( + int receiverType, + int countryCode, + String account, + String password, + String verificationCode, + ) => + post(registerUrl.toUrl, jsonEncode({ + 'receiverType': receiverType, 'countryCode': countryCode, - 'countryId': countryId, - "mobile": mobile, + "account": account, 'password': password, - 'platId': "2", - "uniqueid": uniqueid, 'verificationCode': verificationCode, - }); + 'platId': "2", + })); // post( // registerUrl.toUrl, @@ -97,13 +100,13 @@ class ApiProvider extends BaseProvider { String endDate, String keyId, String keyStatus, + String keyRight, String lockId, - String operatorUid, String pageNo, String pageSize, String startDate, - String keyRight, - String searchStr) => + String searchStr, + ) => post( electronicKeyListURL.toUrl, jsonEncode({ @@ -111,7 +114,6 @@ class ApiProvider extends BaseProvider { 'keyId': keyId, "keyStatus": keyStatus, 'lockId': lockId, - "operatorUid": operatorUid, 'pageNo': pageNo, 'pageSize': pageSize, 'startDate': startDate, diff --git a/star_lock/lib/network/api_repository.dart b/star_lock/lib/network/api_repository.dart index 969571e4..f7ea11f5 100644 --- a/star_lock/lib/network/api_repository.dart +++ b/star_lock/lib/network/api_repository.dart @@ -57,27 +57,29 @@ class ApiRepository { // 发送验证码 1注册,2找回密码,3绑定手机号,4解绑(换绑),5删除账号 Future sendValidationCode( - String countryCode, - String account, - String channel, - String codeType, - String uniqueid, - String xWidth) async { + { + required String countryCode, + required String account, + required String channel, + required String codeType, + required String xWidth + }) async { final res = await apiProvider.getVerificationCode( - countryCode, account, channel, codeType, uniqueid, xWidth); + countryCode, account, channel, codeType, xWidth); return SendValidationCodeEntity.fromJson(res.body); } // 注册 Future register( - String countryCode, - String countryId, - String mobile, - String password, - String uniqueid, - String verificationCode) async { + { + required int receiverType, + required int countryCode, + required String account, + required String password, + required String verificationCode + }) async { final res = await apiProvider.register( - countryCode, countryId, mobile, password, uniqueid, verificationCode); + receiverType, countryCode, account, password, verificationCode); return LoginEntity.fromJson(res.body); } @@ -129,16 +131,15 @@ class ApiRepository { required String endDate, required String keyId, required String keyStatus, + required String keyRight, required String lockId, - required String operatorUid, required String pageNo, required String pageSize, required String startDate, - required String keyRight, - required String searchStr + required String searchStr, }) async { - final res = await apiProvider.electronicKeyList(endDate, keyId, keyStatus, - lockId, operatorUid, pageNo, pageSize, startDate, keyRight, searchStr); + final res = await apiProvider.electronicKeyList(endDate, keyId, keyStatus, keyRight, + lockId, pageNo, pageSize, startDate, searchStr); return ElectronicKeyListEntity.fromJson(res.body); } diff --git a/star_lock/lib/tools/keySearchWidget.dart b/star_lock/lib/tools/keySearchWidget.dart index 8c7a3ebf..eb30abce 100644 --- a/star_lock/lib/tools/keySearchWidget.dart +++ b/star_lock/lib/tools/keySearchWidget.dart @@ -11,21 +11,23 @@ import '../translations/trans_lib.dart'; class KeySearchWidget extends StatelessWidget { TextEditingController editingController; Function() onSubmittedAction; + Color? backgroundColor; KeySearchWidget( {Key? key, required this.editingController, - required this.onSubmittedAction}) + required this.onSubmittedAction, + this.backgroundColor}) : super(key: key); @override Widget build(BuildContext context) { return Container( height: 60.h, - margin: EdgeInsets.only(top: 20.w, left: 20.w, right: 10.w), + margin: EdgeInsets.only(top: 20.w, left: 20.w, right: 20.w), padding: EdgeInsets.only(top: 5.h,right: 10.w), decoration: BoxDecoration( - color: Colors.white, borderRadius: BorderRadius.circular(5)), + color: backgroundColor ?? Colors.white, borderRadius: BorderRadius.circular(5)), child: Row( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, diff --git a/star_lock/pubspec.yaml b/star_lock/pubspec.yaml index 6e4ad906..1975a452 100644 --- a/star_lock/pubspec.yaml +++ b/star_lock/pubspec.yaml @@ -17,7 +17,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. -version: 1.0.0+9 +version: 1.0.0+10 environment: sdk: '>=2.12.0 <3.0.0'