diff --git a/star_lock/images/lan/lan_en.json b/star_lock/images/lan/lan_en.json index ca230699..b00628fc 100644 --- a/star_lock/images/lan/lan_en.json +++ b/star_lock/images/lan/lan_en.json @@ -415,5 +415,7 @@ "seletFingerprint":"Selet Fingerprint", "getKey":"Get Key", "getCard":"Get Card", - "getFingerprint":"Get Fingerprint" + "getFingerprint":"Get Fingerprint", + "safeVerify":"Security verification", + "deleteAccountTips": "After deleting the account, all your information and related records will be completely deleted from the platform, and can not be recovered, delete or not" } diff --git a/star_lock/images/lan/lan_keys.json b/star_lock/images/lan/lan_keys.json index 2e1e6224..1d4fc313 100644 --- a/star_lock/images/lan/lan_keys.json +++ b/star_lock/images/lan/lan_keys.json @@ -415,5 +415,7 @@ "seletFingerprint":"seletFingerprint", "getKey":"getKey", "getCard":"getCard", - "getFingerprint":"getFingerprint" + "getFingerprint":"getFingerprint", + "safeVerify":"safeVerify", + "deleteAccountTips":"deleteAccountTips" } \ No newline at end of file diff --git a/star_lock/images/lan/lan_zh.json b/star_lock/images/lan/lan_zh.json index 06b3ace3..b4692a38 100644 --- a/star_lock/images/lan/lan_zh.json +++ b/star_lock/images/lan/lan_zh.json @@ -418,5 +418,7 @@ "seletFingerprint":"选择指纹", "getKey":"获取钥匙", "getCard":"获取卡", - "getFingerprint":"获取指纹" + "getFingerprint":"获取指纹", + "safeVerify":"安全验证", + "deleteAccountTips":"删除账号后,你的所有信息及相关记录都会从平台彻底删除,且不可恢复,是否删除?" } \ No newline at end of file diff --git a/star_lock/lib/appRouters.dart b/star_lock/lib/appRouters.dart index 244097f6..ff7f42b9 100644 --- a/star_lock/lib/appRouters.dart +++ b/star_lock/lib/appRouters.dart @@ -8,6 +8,7 @@ import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/ma import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupList_page.dart'; import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendReceiver/massSendReceiver_page.dart'; import 'package:star_lock/main/lockDetail/lockDetail/lockDetail_main_page.dart'; +import 'package:star_lock/mine/mine/safeVerify/safeVerify_page.dart'; import 'package:star_lock/mine/minePersonInfo/minePersonInfoEmail/minePersonInfoEmail_page.dart'; import 'package:star_lock/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator_page.dart'; import 'package:star_lock/mine/mineSet/authorizedAdministrator/administratorDetails/adminDetailChangeDate_page.dart'; @@ -323,6 +324,7 @@ abstract class Routers { static const adminLockListPage = '/adminLockListPage'; //管理员详情的锁列表 static const expireLockChangeDatePage = '/expireLockChangeDatePage'; //即将到期列表有效期修改 + static const safeVerifyPage = '/safeVerifyPage'; //删除账号安全验证 } abstract class AppRouters { @@ -807,6 +809,7 @@ abstract class AppRouters { page: () => const AdminDetailChangeDatePage()), GetPage( name: Routers.expireLockChangeDatePage, - page: () => const ExpireLockChangeDatePage()) + page: () => const ExpireLockChangeDatePage()), + GetPage(name: Routers.safeVerifyPage, page: () => const SafeVerifyPage()) ]; } diff --git a/star_lock/lib/login/login/starLock_login_logic.dart b/star_lock/lib/login/login/starLock_login_logic.dart index 35a33cdf..78ad93e7 100644 --- a/star_lock/lib/login/login/starLock_login_logic.dart +++ b/star_lock/lib/login/login/starLock_login_logic.dart @@ -1,4 +1,3 @@ - import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:star_lock/appRouters.dart'; @@ -9,18 +8,14 @@ import '../../network/api_repository.dart'; import '../../tools/store_service.dart'; import 'starLock_login_state.dart'; -class StarLockLoginLogic extends BaseGetXController{ +class StarLockLoginLogic extends BaseGetXController { final StarLockLoginState state = StarLockLoginState(); final stateMyLogic = Get.put(StarLockMineLogic()).state; - void login() async{ - var entity = await ApiRepository.to.login( - "1", - state.pwd.value, - "+86", - state.emailOrPhone.value - ); - if(entity.errorCode!.codeIsSuccessful){ + void login() async { + var entity = await ApiRepository.to + .login("1", state.pwd.value, "+86", state.emailOrPhone.value); + if (entity.errorCode!.codeIsSuccessful) { // await StoreService.to.saveLogInInfo(entity); stateMyLogic.saveLoginData(entity.data); // Get.back(); @@ -32,24 +27,26 @@ class StarLockLoginLogic extends BaseGetXController{ _resetCanNext(); } - void exchangeFistShow() => state.passwordShow.value = !state.passwordShow.value; + void exchangeFistShow() => + state.passwordShow.value = !state.passwordShow.value; void checkNext(TextEditingController controller) { changeInput(controller); } void changeInput(TextEditingController controller) { - if(controller == state.emailOrPhoneController){ + if (controller == state.emailOrPhoneController) { state.emailOrPhone.value = controller.text; } - if(controller == state.pwdController) { + if (controller == state.pwdController) { state.pwd.value = controller.text; } _resetCanNext(); } - void _resetCanNext(){ - state.canNext.value = state.pwdIsOK && state.isEmailOrPhone && state.agree.value; + void _resetCanNext() { + state.canNext.value = + state.pwdIsOK && state.isEmailOrPhone && state.agree.value; } @override @@ -57,5 +54,4 @@ class StarLockLoginLogic extends BaseGetXController{ state.onClose(); super.onClose(); } - -} \ No newline at end of file +} diff --git a/star_lock/lib/login/register/starLock_register_page.dart b/star_lock/lib/login/register/starLock_register_page.dart index c365c554..47783eb3 100644 --- a/star_lock/lib/login/register/starLock_register_page.dart +++ b/star_lock/lib/login/register/starLock_register_page.dart @@ -142,10 +142,12 @@ class _StarLockRegisterPageState extends State { onTap: () async { var result = await Navigator.pushNamed( context, Routers.seletCountryRegionPage); - result as Map; - logic.state.countryCode.value = result['code']; - logic.state.countryId.value = result["countryId"]; - logic.state.countryName.value = result['countryName']; + if (result != null) { + result as Map; + logic.state.countryCode.value = result['code']; + logic.state.countryId.value = result["countryId"]; + logic.state.countryName.value = result['countryName']; + } print( "路由返回值: ${result}, countryCode:${logic.state.countryCode} ,countryId:${logic.state.countryId}"); }, diff --git a/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_entity.dart b/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_entity.dart index 76798e79..9079f6f9 100644 --- a/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_entity.dart +++ b/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_entity.dart @@ -27,7 +27,7 @@ class AuthorizedAdminSendEntity { } class Data { - int? receiverUid; + String? receiverUid; ReceiverUser? receiverUser; int? keyId; @@ -64,13 +64,13 @@ class ReceiverUser { ReceiverUser( {this.email, - this.name, - this.updatedAt, - this.createdAt, - this.id, - this.profilePhotoUrl, - this.phone, - this.cloud}); + this.name, + this.updatedAt, + this.createdAt, + this.id, + this.profilePhotoUrl, + this.phone, + this.cloud}); ReceiverUser.fromJson(Map json) { email = json['email']; @@ -113,13 +113,13 @@ class Phone { Phone( {this.userId, - this.phoneNumberHash, - this.phoneNumberEncrypt, - this.countryCode, - this.phoneNumberVerifiedAt, - this.updatedAt, - this.createdAt, - this.id}); + this.phoneNumberHash, + this.phoneNumberEncrypt, + this.countryCode, + this.phoneNumberVerifiedAt, + this.updatedAt, + this.createdAt, + this.id}); Phone.fromJson(Map json) { userId = json['user_id']; @@ -149,7 +149,7 @@ class Phone { class Cloud { String? username; String? password; - int? cloudUid; + String? cloudUid; int? userId; String? updatedAt; String? createdAt; @@ -157,12 +157,12 @@ class Cloud { Cloud( {this.username, - this.password, - this.cloudUid, - this.userId, - this.updatedAt, - this.createdAt, - this.id}); + this.password, + this.cloudUid, + this.userId, + this.updatedAt, + this.createdAt, + this.id}); Cloud.fromJson(Map json) { username = json['username']; diff --git a/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_page.dart b/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_page.dart index 3005c297..85e53505 100644 --- a/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_page.dart +++ b/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_page.dart @@ -1,4 +1,3 @@ -import 'package:date_format/date_format.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_native_contact_picker/flutter_native_contact_picker.dart'; @@ -6,7 +5,6 @@ import 'package:flutter_pickers/pickers.dart'; import 'package:flutter_pickers/time_picker/model/date_mode.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; -import 'package:star_lock/main/lockMian/entity/lockInfoEntity.dart'; import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/tools/baseGetXController.dart'; import 'package:star_lock/tools/toast.dart'; @@ -30,48 +28,13 @@ class _AuthorizedAdminPageState extends State { final logic = Get.put(AuthorizedAdminLogic()); final state = Get.find().state; - // final FlutterContactPicker _contactPicker = FlutterContactPicker(); - // late Contact _contact; - // late KeyInfos keyInfo; - // late LockMainEntity lockMainEntity; - // bool _isAuthentication = false; //是否可以实名认证 - // var _selectEffectiveDate = ''; //生效时间 - // var _selectFailureDate = ''; //失效时间 - // late DateTime _effectiveDateTime; - // late DateTime _failureDateTime; - // final TextEditingController _emailOrPhoneController = - // TextEditingController(); //邮箱/手机号输入框 - // final TextEditingController _keyNameController = - // TextEditingController(); //钥匙名输入框 - // late bool _isSendSuccess; - // String countryName = '中国'; - // String countryCode = '86'; - // List weekdaysList = []; - @override void initState() { super.initState(); - - // DateTime dateTime = DateTime.now(); - // _effectiveDateTime = dateTime; - // _failureDateTime = dateTime; - // _selectEffectiveDate = - // '${dateTime.year}-${dateTime.month}-${dateTime.day} ${dateTime.hour}:${dateTime.minute}'; //默认为当前时间 - // _selectFailureDate = - // '${dateTime.year}-${dateTime.month}-${dateTime.day} ${dateTime.hour}:${dateTime.minute}'; //默认为当前时间 - // _isSendSuccess = false; } @override Widget build(BuildContext context) { - // dynamic obj = ModalRoute.of(context)?.settings.arguments; - // if (obj != null && (obj["lockMainEntity"] != null)) { - // lockMainEntity = obj["lockMainEntity"]; - // } - // if (obj != null && (obj["keyInfo"] != null)) { - // keyInfo = obj["keyInfo"]; - // } - state.type.value = widget.type; return SingleChildScrollView( @@ -137,10 +100,12 @@ class _AuthorizedAdminPageState extends State { action: () async { var result = await Navigator.pushNamed( context, Routers.seletCountryRegionPage); - result as Map; - state.countryCode.value = result['code']; - state.countryName.value = result['countryName']; - setState(() {}); + if (result != null) { + result as Map; + state.countryCode.value = result['code']; + state.countryName.value = result['countryName']; + setState(() {}); + } }, ), CommonItem( @@ -169,7 +134,8 @@ class _AuthorizedAdminPageState extends State { setState(() { state.selectEffectiveDate.value = '${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}'; - state.effectiveDateTime.value = DateTime.parse(state.selectEffectiveDate.value); + state.effectiveDateTime.value = + DateTime.parse(state.selectEffectiveDate.value); }); }); }), @@ -183,7 +149,8 @@ class _AuthorizedAdminPageState extends State { setState(() { state.selectFailureDate.value = '${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}'; - state.failureDateTime.value = DateTime.parse(state.selectFailureDate.value); + state.failureDateTime.value = + DateTime.parse(state.selectFailureDate.value); }); }); }), @@ -232,7 +199,8 @@ class _AuthorizedAdminPageState extends State { btnName: TranslationLoader.lanKeys!.send!.tr, onClick: () { //发送钥匙请求 - if (state.emailOrPhoneController.text.isNotEmpty && state.keyNameController.value.text.isNotEmpty) { + if (state.emailOrPhoneController.text.isNotEmpty && + state.keyNameController.value.text.isNotEmpty) { // logic.addUserConnectBlue(); logic.sendElectronicKeyRequest(); } @@ -358,8 +326,9 @@ class _AuthorizedAdminPageState extends State { child: TextField( //输入框一行 maxLines: 1, - controller: - lineIndex == 1 ? state.emailOrPhoneController : state.keyNameController, + controller: lineIndex == 1 + ? state.emailOrPhoneController + : state.keyNameController, autofocus: false, textAlign: TextAlign.end, decoration: InputDecoration( @@ -389,7 +358,8 @@ class _AuthorizedAdminPageState extends State { alignment: Alignment.center, child: InkWell( onTap: () async { - Contact? contact = await state.contactPicker.selectContact(); + Contact? contact = + await state.contactPicker.selectContact(); setState(() { state.contact = contact!; // print("object111111111111 ${_contact.fullName} ${_contact.phoneNumbers}"); @@ -403,48 +373,6 @@ class _AuthorizedAdminPageState extends State { ); } - //发送授权管理员列表请求 - // Future sendElectronicKeyRequest() async { - // String getFailureDateTime = '0'; - // String getEffectiveDateTime = '0'; - // String lockID = state.keyInfo.value.lockId.toString(); - // String getKeyType = (int.parse(widget.type) + 1).toString(); - // if (widget.type == '0') { - // getFailureDateTime = state.failureDateTime.value.millisecondsSinceEpoch.toString(); - // getEffectiveDateTime = - // state.effectiveDateTime.value.millisecondsSinceEpoch.toString(); - // } - // var entity = await ApiRepository.to.sendElectronicKey( - // state.isCreateUser.value ? "1" : "0", - // state.countryCode.value, - // '1', - // getFailureDateTime, - // state.isAuthentication.value == true ? '1' : '2', - // '2', - // '2', - // state.keyNameController.text, - // '1', - // getKeyType, - // lockID, - // '', - // state.emailOrPhoneController.text, - // '', - // getEffectiveDateTime, - // state.weekdaysList); - // if (entity.errorCode!.codeIsSuccessful) { - // print('发送电子钥匙成功'); - // state.isSendSuccess.value = true; - // setState(() {}); - // } else { - // Toast.show(msg: '${entity.errorMsg}'); - // if (entity.errorCode == 425) { - // //用户未注册 - // state.isCreateUser.value = true; - // sendElectronicKeyRequest(); - // } - // } - // } - //实名认证 CupertinoSwitch _switch() { return CupertinoSwitch( diff --git a/star_lock/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_page.dart b/star_lock/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_page.dart index fd60c3f8..049f00dc 100644 --- a/star_lock/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_page.dart +++ b/star_lock/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_page.dart @@ -134,10 +134,12 @@ class _VolumeAuthorizationLockPageState action: () async { var result = await Navigator.pushNamed( context, Routers.seletCountryRegionPage); - result as Map; - countryCode = result['code']; - countryName = result['countryName']; - setState(() {}); + if (result != null) { + result as Map; + countryCode = result['code']; + countryName = result['countryName']; + setState(() {}); + } }, ), CommonItem( diff --git a/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_page.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_page.dart index aa261d99..59be558e 100644 --- a/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_page.dart +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_page.dart @@ -39,8 +39,9 @@ class _CheckingInAddStaffPageState extends State { rightTitle: "", isHaveLine: true, isHaveRightWidget: true, - rightWidget: - getTFWidget(TranslationLoader.lanKeys!.pleaseEnter!.tr, state.staffNameController)), + rightWidget: getTFWidget( + TranslationLoader.lanKeys!.pleaseEnter!.tr, + state.staffNameController)), Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.punchingMode!.tr, rightTitle: state.seletPrintingMethodStr.value, @@ -50,22 +51,28 @@ class _CheckingInAddStaffPageState extends State { var list = ["APP", "密码", "卡", "指纹"]; _showSeletClockInType(list, "1"); })), - SizedBox(height: 10.h,), + SizedBox( + height: 10.h, + ), //员工是否有App、卡、钥匙、指纹必须显示 Obx(() => CommonItem( - leftTitel:addStaffGetIfHaveKey(), + leftTitel: addStaffGetIfHaveKey(), rightTitle: "", isHaveLine: true, isHaveRightWidget: true, rightWidget: Row( children: [ - whetherTheEmployeeHasAKeyWidget("无", state.appUnHaveAccount.value, () { + whetherTheEmployeeHasAKeyWidget( + "无", state.appUnHaveAccount.value, () { setState(() { state.appUnHaveAccount.value = true; }); }), - SizedBox(width: 30.w,), - whetherTheEmployeeHasAKeyWidget("有", !state.appUnHaveAccount.value, () { + SizedBox( + width: 30.w, + ), + whetherTheEmployeeHasAKeyWidget( + "有", !state.appUnHaveAccount.value, () { setState(() { state.appUnHaveAccount.value = false; }); @@ -74,125 +81,149 @@ class _CheckingInAddStaffPageState extends State { ))), // 当选择App时显示 其他隐藏 Obx(() => Visibility( - visible: (state.appUnHaveAccount.value && state.seletPrintingMethodType.value == "1") ? true : false, - child: Column( - children: [ - CommonItem( - leftTitel: TranslationLoader.lanKeys!.accountNumber!.tr, - rightTitle: "", - isHaveLine: true, - isHaveRightWidget: true, - rightWidget: - getTFWidget(TranslationLoader.lanKeys!.pleaseEnter!.tr, state.staffAccountController)), - CommonItem( - leftTitel: TranslationLoader.lanKeys!.countryAndRegion!.tr, - rightTitle: "", - isHaveLine: true, - isHaveRightWidget: true, - isHaveDirection: true, - rightWidget: Text( - '${state.countryName.value} +${state.countryCode.value}', - textAlign: TextAlign.end, - style: - TextStyle(fontSize: 22.sp, color: AppColors.darkGrayTextColor), - ), - action: () async { - var result = await Navigator.pushNamed( - context, Routers.seletCountryRegionPage); - result as Map; - state.countryCode.value = result['code']; - state.countryName.value = result['countryName']; - setState(() {}); - }, - ), - ], - ), - )), - // 当选择密码、卡、指纹时显示 - Obx(() => Visibility( - visible: (state.seletPrintingMethodType.value != "1" && state.appUnHaveAccount.value) ? true : false, - child: CommonItem( - leftTitel: addStaffGetKeyType(), - isHaveLine: false, - isHaveRightWidget: true, - rightWidget: Row( + visible: (state.appUnHaveAccount.value && + state.seletPrintingMethodType.value == "1") + ? true + : false, + child: Column( children: [ - Obx(() => Text(state.getDataPassword.value, style: TextStyle(fontSize: 24.sp))), - SizedBox(width: 30.w,), - SizedBox( - width: 130.w, - height: 40.h, - child: ElevatedButton( - style: ElevatedButton.styleFrom(backgroundColor: AppColors.mainColor,), - child: Text(addStaffSeletKeyType(), style: TextStyle(color: Colors.white, fontSize: 22.sp)), - onPressed: () async { - switch(int.parse(state.seletPrintingMethodType.value)){ - case 2: - // 获取密码 - logic.getKeyboardPwdRequest(); - break; - case 3: - // 卡 - if(state.staffNameController.text.isEmpty){ - Toast.show(msg: "请输入姓名"); - return; - } - - var data = await Get.toNamed(Routers.otherTypeKeyManagePage, arguments: { - "lockId": state.getKeyInfosData.value.lockId, - "keyType": 0, - "fromType": 2, // 1从添加钥匙列表进入 2从考勤添加员工入口进入 - "fromTypeTwoStaffName" :state.staffNameController.text - }); - if(data != null) { - - } - break; - case 4: - // 指纹 - if(state.staffNameController.text.isEmpty){ - Toast.show(msg: "请输入姓名"); - return; - } - - var data = await Get.toNamed(Routers.otherTypeKeyManagePage, arguments: { - "lockId": state.getKeyInfosData.value.lockId, - "keyType": 1, - "fromType": 2, // 1从添加钥匙列表进入 2从考勤添加员工入口进入 - "fromTypeTwoStaffName" :state.staffNameController.text - }); - if(data != null) { - - } - break; - break; - } - - } + CommonItem( + leftTitel: TranslationLoader.lanKeys!.accountNumber!.tr, + rightTitle: "", + isHaveLine: true, + isHaveRightWidget: true, + rightWidget: getTFWidget( + TranslationLoader.lanKeys!.pleaseEnter!.tr, + state.staffAccountController)), + CommonItem( + leftTitel: + TranslationLoader.lanKeys!.countryAndRegion!.tr, + rightTitle: "", + isHaveLine: true, + isHaveRightWidget: true, + isHaveDirection: true, + rightWidget: Text( + '${state.countryName.value} +${state.countryCode.value}', + textAlign: TextAlign.end, + style: TextStyle( + fontSize: 22.sp, + color: AppColors.darkGrayTextColor), ), + action: () async { + var result = await Navigator.pushNamed( + context, Routers.seletCountryRegionPage); + if (result != null) { + result as Map; + state.countryCode.value = result['code']; + state.countryName.value = result['countryName']; + setState(() {}); + } + }, ), ], - )), - )), + ), + )), + // 当选择密码、卡、指纹时显示 + Obx(() => Visibility( + visible: (state.seletPrintingMethodType.value != "1" && + state.appUnHaveAccount.value) + ? true + : false, + child: CommonItem( + leftTitel: addStaffGetKeyType(), + isHaveLine: false, + isHaveRightWidget: true, + rightWidget: Row( + children: [ + Obx(() => Text(state.getDataPassword.value, + style: TextStyle(fontSize: 24.sp))), + SizedBox( + width: 30.w, + ), + SizedBox( + width: 130.w, + height: 40.h, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: AppColors.mainColor, + ), + child: Text(addStaffSeletKeyType(), + style: TextStyle( + color: Colors.white, fontSize: 22.sp)), + onPressed: () async { + switch (int.parse( + state.seletPrintingMethodType.value)) { + case 2: + // 获取密码 + logic.getKeyboardPwdRequest(); + break; + case 3: + // 卡 + if (state + .staffNameController.text.isEmpty) { + Toast.show(msg: "请输入姓名"); + return; + } + + var data = await Get.toNamed( + Routers.otherTypeKeyManagePage, + arguments: { + "lockId": state + .getKeyInfosData.value.lockId, + "keyType": 0, + "fromType": + 2, // 1从添加钥匙列表进入 2从考勤添加员工入口进入 + "fromTypeTwoStaffName": + state.staffNameController.text + }); + if (data != null) {} + break; + case 4: + // 指纹 + if (state + .staffNameController.text.isEmpty) { + Toast.show(msg: "请输入姓名"); + return; + } + + var data = await Get.toNamed( + Routers.otherTypeKeyManagePage, + arguments: { + "lockId": state + .getKeyInfosData.value.lockId, + "keyType": 1, + "fromType": + 2, // 1从添加钥匙列表进入 2从考勤添加员工入口进入 + "fromTypeTwoStaffName": + state.staffNameController.text + }); + if (data != null) {} + break; + break; + } + }), + ), + ], + )), + )), // 当选择钥匙类型为有时 必显示 Obx(() => Visibility( - visible: !state.appUnHaveAccount.value, - child: CommonItem( - leftTitel: addStaffGetKeyType(), - rightTitle: state.seletKey.value, - isHaveLine: false, - isHaveDirection: true, - action: () { - logic.addStaffSeletKey((v){ - var list = []; - for (var element in v) { - list.add(element.attendanceWay); - } - _showSeletClockInType(list, "2"); - }); - - }), - )), + visible: !state.appUnHaveAccount.value, + child: CommonItem( + leftTitel: addStaffGetKeyType(), + rightTitle: state.seletKey.value, + isHaveLine: false, + isHaveDirection: true, + action: () { + logic.addStaffSeletKey((v) { + var list = []; + for (var element in v) { + list.add(element.attendanceWay); + } + _showSeletClockInType(list, "2"); + }); + }), + )), SizedBox(height: 50.w), SubmitBtn( btnName: TranslationLoader.lanKeys!.sure!.tr, @@ -200,14 +231,14 @@ class _CheckingInAddStaffPageState extends State { margin: EdgeInsets.only(left: 30.w, right: 30.w, top: 30.w), padding: EdgeInsets.only(top: 25.w, bottom: 25.w), onClick: () { - if(state.staffNameController.text.isEmpty){ + if (state.staffNameController.text.isEmpty) { Toast.show(msg: "请输入姓名"); return; } - if(state.isAdd.value == "2"){ + if (state.isAdd.value == "2") { logic.editStaffLoadData(); - }else{ + } else { logic.addStaffLoadData(); } }), @@ -261,26 +292,30 @@ class _CheckingInAddStaffPageState extends State { data: list, //选择事件的回调 clickCallBack: (int index, var str) { - setState(() { - if(type == "1"){ - state.seletPrintingMethodType.value = (index+1).toString(); - state.seletPrintingMethodStr.value = str.toString(); - state.getDataPassword.value = ""; - }else{ - state.seletKey.value = str.toString(); - } - print("object:$index str:$str type:$type state.seletPrintingMethodType.value:${state.seletPrintingMethodType.value}"); - }); - }); + setState(() { + if (type == "1") { + state.seletPrintingMethodType.value = (index + 1).toString(); + state.seletPrintingMethodStr.value = str.toString(); + state.getDataPassword.value = ""; + } else { + state.seletKey.value = str.toString(); + } + print( + "object:$index str:$str type:$type state.seletPrintingMethodType.value:${state.seletPrintingMethodType.value}"); + }); + }); } - Widget whetherTheEmployeeHasAKeyWidget(String title, bool appUnHaveAccount, Function() action) { + Widget whetherTheEmployeeHasAKeyWidget( + String title, bool appUnHaveAccount, Function() action) { return GestureDetector( onTap: action, child: Row( children: [ Image.asset( - appUnHaveAccount ? 'images/icon_round_selet.png' : 'images/icon_round_unSelet.png', + appUnHaveAccount + ? 'images/icon_round_selet.png' + : 'images/icon_round_unSelet.png', width: 26.w, height: 26.w, ), @@ -298,9 +333,9 @@ class _CheckingInAddStaffPageState extends State { ); } - String addStaffGetIfHaveKey(){ + String addStaffGetIfHaveKey() { String title = ""; - switch(int.parse(state.seletPrintingMethodType.value)){ + switch (int.parse(state.seletPrintingMethodType.value)) { case 1: title = TranslationLoader.lanKeys!.whetherTheEmployeeHasAKey!.tr; break; @@ -317,9 +352,9 @@ class _CheckingInAddStaffPageState extends State { return title; } - String addStaffGetKeyType(){ + String addStaffGetKeyType() { String title = ""; - switch(int.parse(state.seletPrintingMethodType.value)){ + switch (int.parse(state.seletPrintingMethodType.value)) { case 1: title = TranslationLoader.lanKeys!.accountNumber!.tr; break; @@ -336,9 +371,9 @@ class _CheckingInAddStaffPageState extends State { return title; } - String addStaffSeletKeyType(){ + String addStaffSeletKeyType() { String title = ""; - switch(int.parse(state.seletPrintingMethodType.value)){ + switch (int.parse(state.seletPrintingMethodType.value)) { case 1: title = TranslationLoader.lanKeys!.getKey!.tr; break; @@ -354,5 +389,4 @@ class _CheckingInAddStaffPageState extends State { } return title; } - } 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 23b7357d..3cf63cb9 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 @@ -7,6 +7,7 @@ import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/tools/baseGetXController.dart'; import 'package:star_lock/tools/jh_pop_menus.dart'; +import 'package:star_lock/tools/showCupertinoAlert.dart'; import 'package:star_lock/tools/toast.dart'; import '../../../../../appRouters.dart'; @@ -271,7 +272,7 @@ class _ElectronicKeyDetailPageState extends State { print("删除电子钥匙成功"); Toast.show(msg: "删除成功"); setState(() { - Navigator.pop(context); + Navigator.pop(context, true); }); } } diff --git a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_binding.dart b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_binding.dart deleted file mode 100644 index 0c3517e1..00000000 --- a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_binding.dart +++ /dev/null @@ -1,9 +0,0 @@ -import 'package:get/get.dart'; -import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_logic.dart'; - -class ElectronicKeyListBinding extends Bindings { - @override - void dependencies() { - Get.lazyPut(() => ElectronicKeyListLogic()); - } -} 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 59a94de1..84d2d74e 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_logic.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_logic.dart @@ -1,16 +1,60 @@ -import 'package:get/get.dart'; +import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_state.dart'; import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart'; import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/tools/baseGetXController.dart'; +import 'package:star_lock/tools/toast.dart'; -class ElectronicKeyListLogic { - late ElectronicKeyListEntity dataEntity = ElectronicKeyListEntity(); - void electronicKeyList() async { - var entity = await ApiRepository.to - .electronicKeyList('0', '63', '0', '28', '1', '1', '20', '0', '0'); +class ElectronicKeyListLogic extends BaseGetXController { + final ElectronicKeyListState state = ElectronicKeyListState(); + + //请求电子钥匙列表 + Future> mockNetworkDataRequest() async { + ElectronicKeyListEntity entity = await ApiRepository.to.electronicKeyList( + '0', + state.keyInfo.value.keyId.toString(), + '', + state.keyInfo.value.lockId.toString(), + '', + state.pageNum.toString(), + state.pageSize.toString(), + '0', + '0'); if (entity.errorCode!.codeIsSuccessful) { print("电子钥匙列表成功:${entity.data?.itemList}"); - dataEntity = entity; + } + if (entity.data != null) { + return entity.data!.itemList; + } else { + List dataList = []; + return dataList; } } + + //电子钥匙重置请求 + Future resetElectronicKeyListRequest() async { + ElectronicKeyListEntity entity = await ApiRepository.to + .resetElectronicKey(state.keyInfo.value.lockId.toString(), '0'); + if (entity.errorCode!.codeIsSuccessful) { + print("重置电子钥匙成功啦啦啦啦啦"); + Toast.show(msg: "重置成功"); + mockNetworkDataRequest(); + } + } + + @override + void onReady() { + // TODO: implement onReady + super.onReady(); + } + + @override + void onInit() { + // TODO: implement onInit + super.onInit(); + } + + @override + void onClose() { + // TODO: implement onClose + } } 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 68c3cfa3..3cc76c8f 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_page.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_page.dart @@ -1,13 +1,10 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; +import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_logic.dart'; import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart'; -import 'package:star_lock/main/lockMian/entity/lockInfoEntity.dart'; -import 'package:star_lock/network/api_repository.dart'; -import 'package:star_lock/tools/baseGetXController.dart'; -import 'package:star_lock/tools/toast.dart'; - +import 'package:star_lock/tools/noData.dart'; import '../../../../appRouters.dart'; import '../../../../app_settings/app_colors.dart'; import '../../../../tools/submitBtn.dart'; @@ -23,19 +20,18 @@ class ElectronicKeyListPage extends StatefulWidget { class _ElectronicKeyListPageState extends State { final logic = Get.put(ElectronicKeyListLogic()); - late KeyInfos keyInfo; - late LockMainEntity lockMainEntity; + final state = Get.find().state; + late RefreshController _refreshController; + late List itemDataList = []; + + @override + void initState() { + super.initState(); + _refreshController = RefreshController(initialRefresh: true); + } @override Widget build(BuildContext context) { - dynamic obj = ModalRoute.of(context)?.settings.arguments; - if (obj != null && (obj["lockMainEntity"] != null)) { - lockMainEntity = obj["lockMainEntity"]; - } - if (obj != null && (obj["keyInfo"] != null)) { - keyInfo = obj["keyInfo"]; - } - return Scaffold( backgroundColor: AppColors.mainBackgroundColor, appBar: TitleAppBar( @@ -49,13 +45,14 @@ class _ElectronicKeyListPageState extends State { style: TextStyle(color: Colors.white, fontSize: 24.sp), ), onPressed: () { - resetElectronicKeyListRequest(); + logic.resetElectronicKeyListRequest(); + setState(() {}); }, ), ], ), body: FutureBuilder>( - future: mockNetworkDataRequest(), + future: logic.mockNetworkDataRequest(), builder: (BuildContext context, AsyncSnapshot> snapshot) { //请求结束 @@ -65,7 +62,7 @@ class _ElectronicKeyListPageState extends State { return const Text('请求失败'); } else { //请求成功 - final List itemData = snapshot.data!; + itemDataList = snapshot.data!; return Column( children: [ @@ -73,18 +70,34 @@ class _ElectronicKeyListPageState extends State { SizedBox( height: 20.h, ), - Expanded(child: _buildMainUI(itemData)), + Expanded( + child: itemDataList.isEmpty + ? const NoData() + : SmartRefresher( + controller: _refreshController, + onRefresh: _refresh, + onLoading: _loadMore, + header: ClassicHeader( + height: 45.h, + releaseText: '松开手刷新', + refreshingText: '刷新中', + completeText: '刷新完成', + failedText: '刷新失败', + idleText: '下拉刷新', + ), + child: _buildMainUI(itemDataList), + )), AddBottomWhiteBtn( btnName: TranslationLoader.lanKeys!.sendKey!.tr, onClick: () { Navigator.pushNamed( context, Routers.sendElectronicKeyManagePage, arguments: { - "lockMainEntity": lockMainEntity, - "keyInfo": keyInfo + "lockMainEntity": state.lockMainEntity.value, + "keyInfo": state.keyInfo.value }).then((val) { if (val != null) { - mockNetworkDataRequest(); + logic.mockNetworkDataRequest(); setState(() {}); } }); @@ -104,6 +117,30 @@ class _ElectronicKeyListPageState extends State { ); } + ///加载更多函数 + Future _loadMore() async { + if (state.pageNum.value == 1) { + if (itemDataList.length < 10) { + _refreshController.loadComplete(); + } else { + state.pageNum.value++; + await logic.mockNetworkDataRequest(); + _refreshController.loadComplete(); + } + } else { + state.pageNum.value++; + await logic.mockNetworkDataRequest(); + _refreshController.loadComplete(); + } + } + + ///刷新函数 + Future _refresh() async { + state.pageNum.value = 1; + await logic.mockNetworkDataRequest(); + _refreshController.refreshCompleted(); + } + Widget _searchWidget() { return Container( height: 60.h, @@ -142,6 +179,7 @@ class _ElectronicKeyListPageState extends State { Widget _buildMainUI(itemData) { List getItemData = itemData; return ListView.separated( + shrinkWrap: true, itemCount: getItemData.length, itemBuilder: (c, index) { ElectronicKeyListItem indexEntity = getItemData[index]; @@ -164,7 +202,13 @@ class _ElectronicKeyListPageState extends State { return _electronicKeyItem('images/controls_user.png', indexEntity.keyName!, useDateStr, keyStatus, isAdminKey, () { Navigator.pushNamed(context, Routers.electronicKeyDetailPage, - arguments: {"itemData": indexEntity}); + arguments: {"itemData": indexEntity}).then((val) { + if (val != null) { + logic.mockNetworkDataRequest(); + setState(() {}); + } + }); + ; }); }, separatorBuilder: (BuildContext context, int index) { @@ -176,41 +220,6 @@ class _ElectronicKeyListPageState extends State { ); } - //请求电子钥匙列表 - Future> mockNetworkDataRequest() async { - ElectronicKeyListEntity entity = await ApiRepository.to.electronicKeyList( - '0', - keyInfo.keyId.toString(), - '', - keyInfo.lockId.toString(), - '', - '1', - '20', - '0', - '0'); - if (entity.errorCode!.codeIsSuccessful) { - print("电子钥匙列表成功:${entity.data?.itemList}"); - } - if (entity.data != null) { - return entity.data!.itemList; - } else { - List dataList = []; - return dataList; - } - } - - //电子钥匙重置请求 - Future resetElectronicKeyListRequest() async { - ElectronicKeyListEntity entity = await ApiRepository.to - .resetElectronicKey(keyInfo.lockId.toString(), '0'); - if (entity.errorCode!.codeIsSuccessful) { - print("重置电子钥匙成功啦啦啦啦啦"); - Toast.show(msg: "重置成功"); - mockNetworkDataRequest(); - setState(() {}); - } - } - //使用期限 String getUseDateStr(ElectronicKeyListItem indexEntity) { String useDateStr = ''; diff --git a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_state.dart b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_state.dart new file mode 100644 index 00000000..cd7b7a00 --- /dev/null +++ b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_state.dart @@ -0,0 +1,16 @@ +import 'package:get/get.dart'; +import 'package:star_lock/main/lockMian/entity/lockInfoEntity.dart'; +import 'package:star_lock/mine/mineSet/mineSet/userSettingInfoEntity.dart'; + +class ElectronicKeyListState { + final keyInfo = KeyInfos().obs; + final lockMainEntity = LockMainEntity().obs; + var pageNum = 1.obs; //请求页码 + final pageSize = 20.obs; //请求每页数据条数 + + ElectronicKeyListState() { + Map map = Get.arguments; + lockMainEntity.value = map["lockMainEntity"]; + keyInfo.value = map["keyInfo"]; + } +} diff --git a/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendElectronicKey_page.dart b/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendElectronicKey_page.dart index 8b7668a8..25746a17 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendElectronicKey_page.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendElectronicKey_page.dart @@ -249,10 +249,12 @@ class _MassSendElectronicKeyPageState extends State { action: () async { var result = await Navigator.pushNamed( context, Routers.seletCountryRegionPage); - result as Map; - countryCode = result['code']; - countryName = result['countryName']; - setState(() {}); + if (result != null) { + result as Map; + countryCode = result['code']; + countryName = result['countryName']; + setState(() {}); + } }, ), CommonItem( diff --git a/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendReceiver/massSendReceiver_page.dart b/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendReceiver/massSendReceiver_page.dart index d581d3da..b9bd561f 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendReceiver/massSendReceiver_page.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendReceiver/massSendReceiver_page.dart @@ -81,10 +81,12 @@ class _MassSendReceiverPageState extends State { action: () async { var result = await Navigator.pushNamed( context, Routers.seletCountryRegionPage); - result as Map; - countryCode = result['code']; - countryName = result['countryName']; - setState(() {}); + if (result != null) { + result as Map; + countryCode = result['code']; + countryName = result['countryName']; + setState(() {}); + } }, ), Row( diff --git a/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_binding.dart b/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_binding.dart deleted file mode 100644 index 96f17ded..00000000 --- a/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_binding.dart +++ /dev/null @@ -1,9 +0,0 @@ -import 'package:get/get.dart'; -import 'package:star_lock/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_logic.dart'; - -class SendElectronicKeyBinding extends Bindings { - @override - void dependencies() { - Get.lazyPut(() => SendElectronicKeyLogic()); - } -} 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 77c1ee36..c5f0ade9 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 @@ -1,90 +1,50 @@ -import 'package:flutter/cupertino.dart'; -import 'package:get/get.dart'; import 'package:star_lock/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_state.dart'; import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/tools/baseGetXController.dart'; +import 'package:star_lock/tools/toast.dart'; class SendElectronicKeyLogic extends BaseGetXController { final SendElectronicKeyState state = SendElectronicKeyState(); - final stateMyLogic = Get.put(SendElectronicKeyLogic()).state; - void sendElectronicKey() async { - // String getFailureDateTime = '0'; - // String getEffectiveDateTime = '0'; - // String getKeyType = (int.parse(state.keyType) + 1).toString(); - - // if (state.keyType == '1') { - // getFailureDateTime = DateTime.fromMillisecondsSinceEpoch( - // int.parse(state.failureDate.value) * 1000) - // .toString() - // .substring(0, 19); - // getEffectiveDateTime = DateTime.fromMillisecondsSinceEpoch( - // int.parse(state.effectiveDate.value) * 1000) - // .toString() - // .substring(0, 19); - // } - // var entity = await ApiRepository.to.sendElectronicKey( - // '0', - // '0', - // '1', - // getFailureDateTime, - // state.isRealName == true ? '1' : '2', - // '2', - // state.isRemoteUnlock == true ? '1' : '2', - // state.keyNameController.text, - // '1', - // getKeyType, - // '28', - // '小吴副号', - // emailOrPhoneController.text, - // '0', - // getEffectiveDateTime, []); - // if (entity.errorCode!.codeIsSuccessful) { - // // print('发送电子钥匙成功'); - // } - // var entity = await ApiRepository.to.sendElectronicKey( - // '0', - // '0', - // '1', - // state.failureDate, - // state.isRealName == true ? '1' : '2', - // '2', - // state.isRemoteUnlock == true ? '1' : '2', - // state.emailOrPhoneController.text, - // '1', - // '0', - // '28', - // '小吴副号', - // '18682150237', - // '0', - // '0', []); - // if (entity.errorCode!.codeIsSuccessful) { - // print('发送电子钥匙成功'); - // Get.back(); - // } + //发送钥匙请求 + Future sendElectronicKeyRequest() async { + String getFailureDateTime = '0'; + String getEffectiveDateTime = '0'; + String lockID = state.keyInfo.value.lockId.toString(); + String getKeyType = (int.parse(state.type.value) + 1).toString(); + if (state.type.value == '0') { + getFailureDateTime = + state.failureDateTime.value.millisecondsSinceEpoch.toString(); + getEffectiveDateTime = + state.effectiveDateTime.value.millisecondsSinceEpoch.toString(); + } + var entity = await ApiRepository.to.sendElectronicKey( + state.isCreateUser.value ? "1" : "0", + state.countryCode.value, + '1', + getFailureDateTime, + state.isAuthentication.value == true ? '1' : '2', + '2', + state.isRemoteUnlock.value == true ? '1' : '2', + state.keyNameController.text, + '0', + getKeyType, + lockID, + '', + state.emailOrPhoneController.text, + '', + getEffectiveDateTime, + state.weekdaysList); + if (entity.errorCode!.codeIsSuccessful) { + print('发送电子钥匙成功'); + state.isSendSuccess.value = true; + } else { + Toast.show(msg: '${entity.errorMsg}'); + if (entity.errorCode == 425) { + //用户未注册 + state.isCreateUser.value = true; + sendElectronicKeyRequest(); + } + } } - - // void checkNext(TextEditingController controller) { - // changeInput(controller); - // } - - // void changeInput(TextEditingController controller) { - // if (controller == state.emailOrPhoneController) { - // state.emailOrPhone.value = controller.text; - // } - // if (controller == state.keyNameController) { - // state.keyName.value = controller.text; - // } - // _resetCanNext(); - // } - - // void _resetCanNext() { - // state.canNext.value = state.isEmailOrPhoneOK && state.isKeyNameOK; - // } - - // @override - // void onClose() { - // state.onClose(); - // super.onClose(); - // } } 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 592b41d2..abfdff73 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 @@ -1,4 +1,3 @@ -import 'package:date_format/date_format.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_pickers/pickers.dart'; @@ -7,7 +6,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/app_settings/app_colors.dart'; import 'package:flutter_native_contact_picker/flutter_native_contact_picker.dart'; -import 'package:star_lock/main/lockMian/entity/lockInfoEntity.dart'; +import 'package:star_lock/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_logic.dart'; import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/tools/baseGetXController.dart'; import 'package:star_lock/tools/toast.dart'; @@ -27,60 +26,25 @@ class SendElectronicKeyPage extends StatefulWidget { } class _SendElectronicKeyPageState extends State { - final FlutterContactPicker _contactPicker = FlutterContactPicker(); - late Contact _contact; - late KeyInfos keyInfo; - late LockMainEntity lockMainEntity; - - // final logic = Get.put(SendElectronicKeyLogic()); - // final state = Get.find().state; - - bool _isRemoteUnlock = false; //是否允许远程开锁 - bool _isAuthentication = false; //是否可以实名认证 - String _selectEffectiveDate = ''; //生效时间 - String _selectFailureDate = ''; //失效时间 - late DateTime _effectiveDateTime; - late DateTime _failureDateTime; - TextEditingController emailOrPhoneController = - TextEditingController(); //邮箱/手机号输入框 - TextEditingController keyNameController = TextEditingController(); //钥匙名输入框 - late bool _isSendSuccess; - String countryName = '中国'; - String countryCode = '86'; - List weekdaysList = []; - bool _isCreateUser = false; //用户未注册时传1 已注册传0 + final logic = Get.put(SendElectronicKeyLogic()); + final state = Get.find().state; @override void initState() { super.initState(); - - DateTime dateTime = DateTime.now(); - _effectiveDateTime = dateTime; - _failureDateTime = dateTime; - _selectEffectiveDate = formatDate( - dateTime, [yyyy, '-', mm, '-', dd, ' ', HH, ':', nn]); //默认为当前时间 - _selectFailureDate = formatDate( - dateTime, [yyyy, '-', mm, '-', dd, ' ', HH, ':', nn]); //默认为当前时间 - _isSendSuccess = false; } @override Widget build(BuildContext context) { - dynamic obj = ModalRoute.of(context)?.settings.arguments; - if (obj != null && (obj["lockMainEntity"] != null)) { - lockMainEntity = obj["lockMainEntity"]; - } - if (obj != null && (obj["keyInfo"] != null)) { - keyInfo = obj["keyInfo"]; - } + state.type.value = widget.type; return SingleChildScrollView( - child: indexChangeWidget(), + child: Obx(() => indexChangeWidget()), ); } Widget indexChangeWidget() { - if (_isSendSuccess) { + if (state.isSendSuccess.value == true) { return sendElectronicKeySucceed(); } else { switch (int.parse(widget.type)) { @@ -159,7 +123,7 @@ class _SendElectronicKeyPageState extends State { isHaveRightWidget: true, isHaveDirection: true, rightWidget: Text( - '$countryName +$countryCode', + '${state.countryName.value} +${state.countryCode.value}', textAlign: TextAlign.end, style: TextStyle(fontSize: 22.sp, color: AppColors.darkGrayTextColor), @@ -167,10 +131,12 @@ class _SendElectronicKeyPageState extends State { action: () async { var result = await Navigator.pushNamed( context, Routers.seletCountryRegionPage); - result as Map; - countryCode = result['code']; - countryName = result['countryName']; - setState(() {}); + if (result != null) { + result as Map; + state.countryCode.value = result['code']; + state.countryName.value = result['countryName']; + setState(() {}); + } }, ), CommonItem( @@ -190,30 +156,32 @@ class _SendElectronicKeyPageState extends State { children: [ CommonItem( leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr, - rightTitle: _selectEffectiveDate, + rightTitle: state.selectEffectiveDate.value, isHaveLine: true, isHaveDirection: true, action: () { Pickers.showDatePicker(context, mode: DateMode.YMDHM, onConfirm: (p) { setState(() { - _selectEffectiveDate = + state.selectEffectiveDate.value = '${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}'; - _effectiveDateTime = DateTime.parse(_selectEffectiveDate); + state.effectiveDateTime.value = + DateTime.parse(state.selectEffectiveDate.value); }); }); }), CommonItem( leftTitel: TranslationLoader.lanKeys!.failureTime!.tr, - rightTitle: _selectFailureDate, + rightTitle: state.selectFailureDate.value, isHaveDirection: true, action: () { Pickers.showDatePicker(context, mode: DateMode.YMDHM, onConfirm: (p) { setState(() { - _selectFailureDate = + state.selectFailureDate.value = '${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}'; - _failureDateTime = DateTime.parse(_selectFailureDate); + state.failureDateTime.value = + DateTime.parse(state.selectFailureDate.value); }); }); }), @@ -249,12 +217,12 @@ class _SendElectronicKeyPageState extends State { action: () async { var result = await Navigator.pushNamed( context, Routers.electronicKeyPeriodValidityPage); - result as Map; - weekdaysList = result['validityValue']; - _effectiveDateTime = result['starDate']; - _failureDateTime = result['endDate']; - print( - '得到的有效期数据:$weekdaysList $_effectiveDateTime $_failureDateTime'); + if (result != null) { + result as Map; + state.weekdaysList.value = result['validityValue']; + state.effectiveDateTime.value = result['starDate']; + state.failureDateTime.value = result['endDate']; + } }), SizedBox( height: 10.h, @@ -285,17 +253,19 @@ class _SendElectronicKeyPageState extends State { btnName: TranslationLoader.lanKeys!.send!.tr, onClick: () { //发送钥匙请求 - if (emailOrPhoneController.text.isNotEmpty && - keyNameController.text.isNotEmpty) { + if (state.emailOrPhoneController.text.isNotEmpty && + state.keyNameController.text.isNotEmpty) { if (int.parse(widget.type) == 0) { //失效时间大于生效时间 - if (_failureDateTime.compareTo(_effectiveDateTime) == 1) { - sendElectronicKeyRequest(); + if (state.failureDateTime.value + .compareTo(state.effectiveDateTime.value) == + 1) { + logic.sendElectronicKeyRequest(); } else { Toast.show(msg: '失效时间需大于生效时间'); } } else { - sendElectronicKeyRequest(); + logic.sendElectronicKeyRequest(); } } else { Toast.show(msg: '请完善信息'); @@ -324,48 +294,6 @@ class _SendElectronicKeyPageState extends State { ); } -//发送钥匙请求 - Future sendElectronicKeyRequest() async { - String getFailureDateTime = '0'; - String getEffectiveDateTime = '0'; - String lockID = keyInfo.lockId.toString(); - String getKeyType = (int.parse(widget.type) + 1).toString(); - if (widget.type == '0') { - getFailureDateTime = _failureDateTime.millisecondsSinceEpoch.toString(); - getEffectiveDateTime = - _effectiveDateTime.millisecondsSinceEpoch.toString(); - } - var entity = await ApiRepository.to.sendElectronicKey( - _isCreateUser ? "1" : "0", - countryCode, - '1', - getFailureDateTime, - _isAuthentication == true ? '1' : '2', - '2', - _isRemoteUnlock == true ? '1' : '2', - keyNameController.text, - '0', - getKeyType, - lockID, - '', - emailOrPhoneController.text, - '', - getEffectiveDateTime, - weekdaysList); - if (entity.errorCode!.codeIsSuccessful) { - print('发送电子钥匙成功'); - _isSendSuccess = true; - setState(() {}); - } else { - Toast.show(msg: '${entity.errorMsg}'); - if (entity.errorCode == 425) { - //用户未注册 - _isCreateUser = true; - sendElectronicKeyRequest(); - } - } - } - // 发送电子钥匙成功 Widget sendElectronicKeySucceed() { return Column( @@ -408,7 +336,7 @@ class _SendElectronicKeyPageState extends State { SubmitBtn( btnName: '完成', onClick: () { - _isSendSuccess = false; + state.isSendSuccess.value = false; Navigator.pop(context, true); }), SizedBox( @@ -443,7 +371,7 @@ class _SendElectronicKeyPageState extends State { //标记房间为已入住 isOn:已入住: 1 空闲:2 Future updateRoomCheckIn() async { var entity = await ApiRepository.to - .updateSetting(keyInfo.lockId.toString(), '1', '13'); + .updateSetting(state.keyInfo.value.lockId.toString(), '1', '13'); if (entity.errorCode!.codeIsSuccessful) { print("标记为已入住成功啦啦啦啦啦"); Toast.show(msg: "标记成功"); @@ -462,8 +390,9 @@ class _SendElectronicKeyPageState extends State { children: [ Expanded( child: TextField( - controller: - lineIndex == 1 ? emailOrPhoneController : keyNameController, + controller: lineIndex == 1 + ? state.emailOrPhoneController + : state.keyNameController, //输入框一行 maxLines: 1, // controller: _controller, @@ -496,9 +425,9 @@ class _SendElectronicKeyPageState extends State { child: InkWell( onTap: () async { Contact? currentContact = - await _contactPicker.selectContact(); + await state.contactPicker.selectContact(); setState(() { - _contact = currentContact!; + state.contact = currentContact!; // print("object111111111111 ${_contact.fullName} ${_contact.phoneNumbers}"); }); }, @@ -532,13 +461,14 @@ class _SendElectronicKeyPageState extends State { activeColor: CupertinoColors.activeBlue, trackColor: CupertinoColors.systemGrey5, thumbColor: CupertinoColors.white, - value: isRemote ? _isRemoteUnlock : _isAuthentication, + value: + isRemote ? state.isRemoteUnlock.value : state.isAuthentication.value, onChanged: (value) { setState(() { if (isRemote) { - _isRemoteUnlock = value; + state.isRemoteUnlock.value = !state.isRemoteUnlock.value; } else { - _isAuthentication = value; + state.isAuthentication.value = !state.isAuthentication.value; } }); }, diff --git a/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_state.dart b/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_state.dart index 2a4ff167..7c721187 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_state.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_state.dart @@ -1,29 +1,41 @@ import 'package:flutter/material.dart'; +import 'package:flutter_native_contact_picker/flutter_native_contact_picker.dart'; import 'package:get/get.dart'; +import 'package:star_lock/main/lockMian/entity/lockInfoEntity.dart'; class SendElectronicKeyState { - // var emailOrPhone = ''.obs; - // var keyName = ''.obs; - // var effectiveDate = ''.obs; //生效时间 - // var failureDate = ''.obs; //失效时间 - // var isRemoteUnlock = false; //远程开锁 - // var isRealName = false; //实名认证 - // var keyType = '1'; //钥匙类型 限期1,永久2,单次3,循环4 - // var canNext = false.obs; + TextEditingController emailOrPhoneController = + TextEditingController(); //邮箱/手机号输入框 + TextEditingController keyNameController = TextEditingController(); //钥匙名输入框 - // bool get isEmailOrPhoneOK => emailOrPhone.value.isNotEmpty; - // bool get isKeyNameOK => keyName.value.isNotEmpty; + final FlutterContactPicker contactPicker = FlutterContactPicker(); + late Contact contact; + final keyInfo = KeyInfos().obs; + final lockMainEntity = LockMainEntity().obs; - // TextEditingController emailOrPhoneController = - // TextEditingController(); //邮箱/手机号输入框 - // TextEditingController keyNameController = TextEditingController(); //钥匙名输入框 - // SendElectronicKeyState() { - // emailOrPhoneController.text = emailOrPhone.value; - // keyNameController.text = keyName.value; - // } + final isRemoteUnlock = false.obs; //是否允许远程开锁 + final isAuthentication = false.obs; //是否可以实名认证 + DateTime dateTime = DateTime.now(); + final effectiveDateTime = DateTime.now().obs; + final failureDateTime = DateTime.now().obs; - // void onClose() { - // emailOrPhoneController.dispose(); - // keyNameController.dispose(); - // } + var selectEffectiveDate = + '${DateTime.now().year}-${DateTime.now().month}-${DateTime.now().day} ${DateTime.now().hour}:${DateTime.now().minute}' + .obs; //默认为当前时间 + var selectFailureDate = + '${DateTime.now().year}-${DateTime.now().month}-${DateTime.now().day} ${DateTime.now().hour}:${DateTime.now().minute}' + .obs; //默认为当前时间 + + var type = ''.obs; + var isSendSuccess = false.obs; + var countryName = '中国'.obs; + var countryCode = '86'.obs; + var weekdaysList = [].obs; + var isCreateUser = false.obs; //用户未注册时传1 已注册传0 + + SendElectronicKeyState() { + Map map = Get.arguments; + lockMainEntity.value = map["lockMainEntity"]; + keyInfo.value = map["keyInfo"]; + } } diff --git a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_page.dart b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_page.dart index 0886b8c9..e63cf37f 100644 --- a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_page.dart +++ b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_page.dart @@ -199,6 +199,7 @@ class _PasswordKeyDetailPageState extends State { padding: EdgeInsets.only(top: 25.w, bottom: 25.w), onClick: () { deletePwdRequest(); + Navigator.pop(context, true); }), ], ), @@ -280,13 +281,9 @@ class _PasswordKeyDetailPageState extends State { //删除密码请求 deleteType:1-蓝牙 2-网关 Future deletePwdRequest() async { PasswordKeyEntity entity = await ApiRepository.to.deleteKeyboardPwd( - itemData.lockId.toString(), itemData.keyboardPwdId.toString(), '1'); + itemData.lockId.toString(), itemData.keyboardPwdId.toString(), 1); if (entity.errorCode!.codeIsSuccessful) { - print("删除密码成功"); Toast.show(msg: "删除成功"); - setState(() { - Navigator.pop(context); - }); } } @@ -314,8 +311,9 @@ class _PasswordKeyDetailPageState extends State { context: context, builder: (BuildContext context) { return ShowTFView( - title: - "${TranslationLoader.lanKeys!.amend!.tr}${TranslationLoader.lanKeys!.name!.tr}", + title: inputController == _inputNameController + ? "${TranslationLoader.lanKeys!.amend!.tr}${TranslationLoader.lanKeys!.name!.tr}" + : "${TranslationLoader.lanKeys!.amend!.tr}${TranslationLoader.lanKeys!.password!.tr}", tipTitle: "请输入", controller: inputController, sureClick: () { @@ -331,81 +329,4 @@ class _PasswordKeyDetailPageState extends State { }, ); } - -/* - void showCupertinoAlertDialog( - BuildContext context, TextEditingController inputController) { - showDialog( - context: context, - builder: (BuildContext context) { - return Card( - color: const Color(0x00FFFFFF), - child: CupertinoAlertDialog( - title: Text( - "${TranslationLoader.lanKeys!.amend!.tr} ${TranslationLoader.lanKeys!.password!.tr}"), - content: Column( - children: [ - const SizedBox( - height: 10, - ), - Container( - height: 80.h, - // color: Colors.white, - margin: EdgeInsets.all(10.w), - child: TextField( - controller: inputController, - //输入框一行 - maxLines: 1, - // controller: _controller, - autofocus: false, - decoration: InputDecoration( - //输入里面输入文字内边距设置 - // contentPadding: const EdgeInsets.only( - // top: 12.0, left: -19.0, right: -15.0, bottom: 8.0), - hintText: TranslationLoader.lanKeys!.pleaseEnter!.tr, - //不需要输入框下划线 - border: InputBorder.none, - //左边图标设置 - // icon: Padding( - // padding: EdgeInsets.only(top:30.w, bottom: 20.w, right: 20.w, left: 20.w), - // child: Image.asset('images/main/icon_main_search.png', width: 40.w, height: 40.w,), - // ), - // //右边图标设置 - // suffixIcon: GestureDetector( - // onTap: () { - // //addPostFrameCallback是 StatefulWidge 渲染结束的回调,只会被调用一次 - // // SchedulerBinding.instance.addPostFrameCallback((_) { - // // _controller.text = ""; - // // }); - // }, - // child: Padding( - // padding: EdgeInsets.all(8), - // child: Image.asset('images/main/icon_main_cell.png', width: 50.w, height: 50.w,), - // ), - // ) - ), - ), - ) - ], - ), - actions: [ - CupertinoDialogAction( - child: Text(TranslationLoader.lanKeys!.cancel!.tr), - onPressed: () { - Navigator.pop(context); - }, - ), - CupertinoDialogAction( - child: Text(TranslationLoader.lanKeys!.sure!.tr), - onPressed: () { - updatePwdRequest(); - Navigator.pop(context); - }, - ), - ], - ), - ); - }); - } - */ } diff --git a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_logic.dart b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_logic.dart new file mode 100644 index 00000000..cde1378f --- /dev/null +++ b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_logic.dart @@ -0,0 +1,56 @@ +import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyListEntity.dart'; +import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_state.dart'; +import 'package:star_lock/network/api_repository.dart'; +import 'package:star_lock/tools/baseGetXController.dart'; +import 'package:star_lock/tools/toast.dart'; + +class PasswordKeyListLogic extends BaseGetXController { + final PasswordKeyListState state = PasswordKeyListState(); + + //请求密码钥匙列表 + Future> mockNetworkDataRequest() async { + PasswordKeyListEntity entity = await ApiRepository.to.passwordKeyList( + '0', + state.keyInfo.value.lockId.toString(), + '0', + state.pageNum.toString(), + state.pageSize.toString()); + if (entity.errorCode!.codeIsSuccessful) { + print("密码钥匙列表成功:${entity.data?.itemList}"); + } + if (entity.data != null) { + return entity.data!.itemList!; + } else { + List dataList = []; + return dataList; + } + } + + //密码钥匙重置请求 + Future resetPasswordKeyListRequest() async { + PasswordKeyListEntity entity = await ApiRepository.to + .keyboardPwdReset(state.keyInfo.value.lockId.toString()); + if (entity.errorCode!.codeIsSuccessful) { + print("重置电子钥匙成功啦啦啦啦啦"); + Toast.show(msg: "重置成功"); + mockNetworkDataRequest(); + } + } + + @override + void onReady() { + // TODO: implement onReady + super.onReady(); + } + + @override + void onInit() { + // TODO: implement onInit + super.onInit(); + } + + @override + void onClose() { + // TODO: implement onClose + } +} 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 cf0eb3ee..c312808c 100644 --- a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart +++ b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart @@ -1,12 +1,11 @@ +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; +import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyListEntity.dart'; -import 'package:star_lock/main/lockMian/entity/lockInfoEntity.dart'; -import 'package:star_lock/network/api_repository.dart'; -import 'package:star_lock/tools/baseGetXController.dart'; -import 'package:star_lock/tools/toast.dart'; - +import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_logic.dart'; +import 'package:star_lock/tools/noData.dart'; import '../../../../appRouters.dart'; import '../../../../app_settings/app_colors.dart'; import '../../../../tools/submitBtn.dart'; @@ -21,18 +20,20 @@ class PasswordKeyListPage extends StatefulWidget { } class _PasswordKeyListPageState extends State { - late KeyInfos keyInfo; - late LockMainEntity lockMainEntity; + final logic = Get.put(PasswordKeyListLogic()); + final state = Get.find().state; + late List _itemDataList = []; + + late RefreshController _refreshController; + + @override + void initState() { + super.initState(); + _refreshController = RefreshController(initialRefresh: true); + } @override Widget build(BuildContext context) { - dynamic obj = ModalRoute.of(context)?.settings.arguments; - if (obj != null && (obj["lockMainEntity"] != null)) { - lockMainEntity = obj["lockMainEntity"]; - } - if (obj != null && (obj["keyInfo"] != null)) { - keyInfo = obj["keyInfo"]; - } return Scaffold( backgroundColor: AppColors.mainBackgroundColor, appBar: TitleAppBar( @@ -46,13 +47,13 @@ class _PasswordKeyListPageState extends State { style: TextStyle(color: Colors.white, fontSize: 24.sp), ), onPressed: () { - resetPasswordKeyListRequest(); + showCupertinoDialogStyle(); }, ), ], ), body: FutureBuilder>( - future: mockNetworkDataRequest(), + future: logic.mockNetworkDataRequest(), builder: (BuildContext context, AsyncSnapshot> snapshot) { //请求结束 @@ -62,7 +63,7 @@ class _PasswordKeyListPageState extends State { return const Text('请求失败'); } else { //请求成功 - final List itemData = snapshot.data!; + _itemDataList = snapshot.data!; return Column( children: [ @@ -70,7 +71,25 @@ class _PasswordKeyListPageState extends State { SizedBox( height: 20.h, ), - Expanded(child: _buildMainUI(itemData)), + Expanded( + child: _itemDataList.isEmpty + ? const NoData() + : SmartRefresher( + controller: _refreshController, + onRefresh: _refresh, + onLoading: _loadMore, + enablePullUp: true, + enablePullDown: true, + header: ClassicHeader( + height: 45.h, + releaseText: '松开手刷新', + refreshingText: '刷新中', + completeText: '刷新完成', + failedText: '刷新失败', + idleText: '下拉刷新', + ), + child: _buildMainUI(_itemDataList), + )), SizedBox( height: 20.h, ), @@ -80,11 +99,11 @@ class _PasswordKeyListPageState extends State { Navigator.pushNamed( context, Routers.passwordKeyManagePage, arguments: { - "lockMainEntity": lockMainEntity, - "keyInfo": keyInfo + "lockMainEntity": state.lockMainEntity.value, + "keyInfo": state.keyInfo.value }).then((val) { if (val != null) { - mockNetworkDataRequest(); + logic.mockNetworkDataRequest(); setState(() {}); } }); @@ -103,31 +122,28 @@ class _PasswordKeyListPageState extends State { ); } - //请求密码钥匙列表 - Future> mockNetworkDataRequest() async { - PasswordKeyListEntity entity = await ApiRepository.to - .passwordKeyList('0', keyInfo.lockId.toString(), '0', '1', '20'); - if (entity.errorCode!.codeIsSuccessful) { - print("密码钥匙列表成功:${entity.data?.itemList}"); - } - if (entity.data != null) { - return entity.data!.itemList!; + ///加载更多函数 + Future _loadMore() async { + if (state.pageNum.value == 1) { + if (_itemDataList.length < 10) { + _refreshController.loadComplete(); + } else { + state.pageNum.value++; + await logic.mockNetworkDataRequest(); + _refreshController.loadComplete(); + } } else { - List dataList = []; - return dataList; + state.pageNum.value++; + await logic.mockNetworkDataRequest(); + _refreshController.loadComplete(); } } - //密码钥匙重置请求 - Future resetPasswordKeyListRequest() async { - PasswordKeyListEntity entity = - await ApiRepository.to.resetPasswordKey(keyInfo.lockId.toString(), '0'); - if (entity.errorCode!.codeIsSuccessful) { - print("重置电子钥匙成功啦啦啦啦啦"); - Toast.show(msg: "重置成功"); - mockNetworkDataRequest(); - setState(() {}); - } + ///刷新函数 + Future _refresh() async { + state.pageNum.value = 1; + await logic.mockNetworkDataRequest(); + _refreshController.refreshCompleted(); } Widget _searchWidget() { @@ -300,4 +316,47 @@ class _PasswordKeyListPageState extends State { ), ); } + + void showCupertinoDialogStyle() async { + var result = await showCupertinoDialog( + context: context, + builder: (context) { + return CupertinoAlertDialog( + title: const Text(''), + content: Text( + "该锁的密码钥匙都将被删除", + style: TextStyle( + color: Colors.black, + fontSize: 24.sp, + fontWeight: FontWeight.w700), + ), + actions: [ + CupertinoButton( + child: Text( + "取消", + style: TextStyle( + color: Colors.blue, + fontSize: 24.sp, + fontWeight: FontWeight.w600), + ), + onPressed: () { + Navigator.pop(context); + }, + ), + CupertinoButton( + child: Text( + "重置", + style: TextStyle( + color: Colors.blue, + fontSize: 24.sp, + fontWeight: FontWeight.w600), + ), + onPressed: () { + logic.resetPasswordKeyListRequest(); + }, + ), + ], + ); + }); + } } diff --git a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_state.dart b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_state.dart new file mode 100644 index 00000000..6b2e9d15 --- /dev/null +++ b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_state.dart @@ -0,0 +1,15 @@ +import 'package:get/get.dart'; +import 'package:star_lock/main/lockMian/entity/lockInfoEntity.dart'; + +class PasswordKeyListState { + final keyInfo = KeyInfos().obs; + final lockMainEntity = LockMainEntity().obs; + var pageNum = 1.obs; //请求页码 + final pageSize = 20.obs; //请求每页数据条数 + + PasswordKeyListState() { + Map map = Get.arguments; + lockMainEntity.value = map["lockMainEntity"]; + keyInfo.value = map["keyInfo"]; + } +} 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 041fefff..ce30b1e2 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 @@ -353,7 +353,7 @@ class _PasswordKeyPerpetualPageState extends State { btnName: TranslationLoader.lanKeys!.getPassword!.tr, onClick: () { // logic.senderCustomPasswords(); - + /* int getWidgetNumber = int.parse(widget.type); @@ -429,7 +429,7 @@ class _PasswordKeyPerpetualPageState extends State { //清空码 getKeyType = '4'; } - if (widget.type != '0' || widget.type != '2' || widget.type != '5') { + if (widget.type != '0' && widget.type != '2' && widget.type != '5') { getFailureDateTime = DateTime.parse(_selectFailureDate).millisecondsSinceEpoch.toString(); getEffectiveDateTime = DateTime.parse(_selectEffectiveDate) diff --git a/star_lock/lib/main/lockMian/lockMain/lockMain_page.dart b/star_lock/lib/main/lockMian/lockMain/lockMain_page.dart index 7e7e2cc1..b7baff7b 100644 --- a/star_lock/lib/main/lockMian/lockMain/lockMain_page.dart +++ b/star_lock/lib/main/lockMian/lockMain/lockMain_page.dart @@ -1,4 +1,3 @@ - import 'dart:async'; import 'package:flutter/material.dart'; @@ -26,13 +25,11 @@ class StarLockMainPage extends StatefulWidget { // GlobalKey<_StarLockMainPageState> starLockMainKey = GlobalKey(); class _StarLockMainPageState extends State with BaseWidget { - final logic = Get.put(LockMainLogic()); final state = Get.find().state; @override Widget build(BuildContext context) { - return Scaffold( backgroundColor: const Color(0xFFF5F5F5), appBar: TitleAppBar( @@ -77,17 +74,21 @@ class _StarLockMainPageState extends State with BaseWidget { ); } - Widget getDataReturnUI(int type){ + Widget getDataReturnUI(int type) { Widget returnWidget; - switch(type){ + switch (type) { case 0: returnWidget = unHaveData(); - break; + break; case 1: - returnWidget = LockDetailPage(lockMainEntity: logic.state.lockMainEntity.value, isFrist: true, keyInfo:logic.state.lockMainEntity.value.data!.keyInfos![0]); + returnWidget = LockDetailPage( + lockMainEntity: logic.state.lockMainEntity.value, + isFrist: true, + keyInfo: logic.state.lockMainEntity.value.data!.keyInfos![0]); break; case 2: - returnWidget = LockListPage(lockMainEntity:logic.state.lockMainEntity.value); + returnWidget = + LockListPage(lockMainEntity: logic.state.lockMainEntity.value); break; default: returnWidget = unHaveData(); @@ -104,7 +105,7 @@ class _StarLockMainPageState extends State with BaseWidget { mainAxisAlignment: MainAxisAlignment.center, children: [ Container( - width: 330.w, + width: 330.w, height: 330.w, // decoration: BoxDecoration( // border: Border.all(width: 4.w, color: AppColors.mainColor), diff --git a/star_lock/lib/mine/addLock/saveLock/saveLock_logic.dart b/star_lock/lib/mine/addLock/saveLock/saveLock_logic.dart index dc104426..65f8347d 100644 --- a/star_lock/lib/mine/addLock/saveLock/saveLock_logic.dart +++ b/star_lock/lib/mine/addLock/saveLock/saveLock_logic.dart @@ -265,7 +265,7 @@ class SaveLockLogic extends BaseGetXController { deviceNo:"123456", // lockUserNo:userNo.toString(), lockUserNo:"1234", - pwdTimestamp:"11223344" + pwdTimestamp:DateTime.now().millisecondsSinceEpoch.toString() ); if(entity.errorCode!.codeIsSuccessful){ eventBus.fire(RefreshLockListInfoDataEvent()); diff --git a/star_lock/lib/mine/mine/safeVerify/safeVerify_logic.dart b/star_lock/lib/mine/mine/safeVerify/safeVerify_logic.dart new file mode 100644 index 00000000..f8f09eb7 --- /dev/null +++ b/star_lock/lib/mine/mine/safeVerify/safeVerify_logic.dart @@ -0,0 +1,88 @@ +import 'dart:async'; + +import 'package:flutter/cupertino.dart'; +import 'package:get/get_core/src/get_main.dart'; +import 'package:get/get_navigation/src/extension_navigation.dart'; +import 'package:get/get_utils/get_utils.dart'; +import 'package:star_lock/appRouters.dart'; +import 'package:star_lock/login/login/entity/LoginEntity.dart'; +import 'package:star_lock/mine/mine/safeVerify/safeVerify_state.dart'; +import 'package:star_lock/network/api_repository.dart'; +import 'package:star_lock/tools/baseGetXController.dart'; +import 'package:star_lock/tools/toast.dart'; + +class SafeVerifyLogic extends BaseGetXController { + final SafeVerifyState state = SafeVerifyState(); + + late Timer _timer; + void _startTimer() { + _timer = Timer.periodic(1.seconds, (timer) { + if (state.currentSecond > 1) { + state.currentSecond--; + } else { + _cancelTimer(); + state.currentSecond = state.totalSeconds; + } + state.resetResend(); + }); + } + + void _cancelTimer() { + _timer.cancel(); + } + + //获取验证码请求 + void sendValidationCode() async { + var entity = await ApiRepository.to.sendValidationCode( + "+86", + state.loginData.value.mobile!, + '1', + state.codeType.value, + "B748F838-94EE-4BDB-A0E6-7B2D16849792", + state.xWidth.value.toString()); + if (entity.errorCode!.codeIsSuccessful) { + _startTimer(); + } else {} + } + + //删除账号请求 + Future userLogoutRequest() async { + LoginEntity entity = await ApiRepository.to.userLogout(); + if (entity.errorCode!.codeIsSuccessful) { + Toast.show(msg: '验证成功,账号已删除'); + //删除账号成功, + Get.offNamedUntil(Routers.starLockLoginPage, (route) => false); + } + } + + void checkNext(TextEditingController controller) { + changeInput(controller); + } + + void changeInput(TextEditingController controller) { + if (controller == state.codeController) { + state.verificationCode.value = controller.text; + } + _resetCanSub(); + } + + void _resetCanSub() { + state.canSub.value = state.codeIsOK; + } + + @override + void onReady() { + super.onReady(); + } + + @override + void onInit() { + super.onInit(); + state.initLoginData(); + } + + @override + void onClose() { + super.onClose(); + } +} diff --git a/star_lock/lib/mine/mine/safeVerify/safeVerify_page.dart b/star_lock/lib/mine/mine/safeVerify/safeVerify_page.dart new file mode 100644 index 00000000..9910063b --- /dev/null +++ b/star_lock/lib/mine/mine/safeVerify/safeVerify_page.dart @@ -0,0 +1,101 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:get/get.dart'; +import 'package:star_lock/app_settings/app_colors.dart'; +import 'package:star_lock/mine/mine/safeVerify/safeVerify_logic.dart'; +import 'package:star_lock/tools/submitBtn.dart'; +import 'package:star_lock/tools/titleAppBar.dart'; +import 'package:star_lock/translations/trans_lib.dart'; + +class SafeVerifyPage extends StatefulWidget { + const SafeVerifyPage({Key? key}) : super(key: key); + + @override + State createState() => _SafeVerifyPageState(); +} + +class _SafeVerifyPageState extends State { + final logic = Get.put(SafeVerifyLogic()); + final state = Get.find().state; + String mobilePhone = ''; + + @override + void initState() { + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + resizeToAvoidBottomInset: false, + backgroundColor: const Color(0xFFFFFFFF), + appBar: TitleAppBar( + barTitle: TranslationLoader.lanKeys!.safeVerify!.tr, + haveBack: true, + backgroundColor: AppColors.mainColor), + body: safeVerifyColumn()); + } + + Widget safeVerifyColumn() { + return Column( + children: [ + SizedBox( + height: 60.h, + ), + Container( + margin: EdgeInsets.only(left: 60.w, right: 60.w), + height: 60.h, + decoration: BoxDecoration( + color: Colors.white, borderRadius: BorderRadius.circular(30.w)), + child: TextField( + //输入框一行 + maxLines: 1, + controller: state.codeController, + autofocus: false, + decoration: InputDecoration( + contentPadding: + const EdgeInsets.only(left: 5, top: -8, bottom: 6), + hintText: TranslationLoader.lanKeys!.pleaseEnter!.tr, + hintStyle: TextStyle(fontSize: 22.sp, height: 1.0), + //不需要输入框下划线 + border: const OutlineInputBorder(), + ), + ), + ), + SizedBox( + height: 30.h, + ), + SizedBox( + width: 200.w, + child: SubmitBtn( + btnName: TranslationLoader.lanKeys!.getVerificationCode!.tr, + onClick: () { + logic.sendValidationCode(); + }, + ), + ), + SizedBox( + height: 60.h, + ), + Obx(() => Padding( + padding: EdgeInsets.only(left: 60.w, right: 60.w), + child: Text( + '请点击获取验证码,验证码将发送到${state.loginData.value.mobile}', + style: TextStyle( + color: AppColors.darkGrayTextColor, fontSize: 22.sp), + ), + )), + SizedBox( + height: 120.h, + ), + Obx(() => SubmitBtn( + btnName: '验证', + isDisabled: state.canSub.value, + onClick: () { + logic.userLogoutRequest(); + }, + )) + ], + ); + } +} diff --git a/star_lock/lib/mine/mine/safeVerify/safeVerify_state.dart b/star_lock/lib/mine/mine/safeVerify/safeVerify_state.dart new file mode 100644 index 00000000..8b0e129a --- /dev/null +++ b/star_lock/lib/mine/mine/safeVerify/safeVerify_state.dart @@ -0,0 +1,60 @@ +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:star_lock/login/login/entity/LoginData.dart'; +import 'package:star_lock/login/seletCountryRegion/common/index.dart'; +import 'package:star_lock/tools/storage.dart'; +import 'package:star_lock/translations/trans_lib.dart'; + +class SafeVerifyState { + final TextEditingController codeController = TextEditingController(); + + static int currentTimeMillis() { + return DateTime.now().millisecondsSinceEpoch; + } + + var countryCode = '+86'.obs; + var countryId = '9'.obs; + var codeType = '5'.obs; + var verificationCode = ''.obs; + var xWidth = ''.obs; // 滑动验证码滑动位置 + var canSub = false.obs; + var date = currentTimeMillis().toString().obs; + + bool get codeIsOK => verificationCode.value.isNotEmpty; + + var canResend = false.obs; + var btnText = ''.obs; + var totalSeconds = 120; + var currentSecond = 120; + + final loginData = LoginData().obs; + + ///本地存储 登录信息 + void saveLoginData(LoginData? data) async { + print("saveLoginData:${data!.mobile}"); + await Storage.setString('userLoginData', jsonEncode(data)); + loginData.value = data; + } + + ///初始化本地数据 + void initLoginData() async { + final data = await Storage.getString('userLoginData'); + print("getLoginData:$data"); + if (data != null && data.isNotEmpty) { + loginData.value = LoginData.fromJson(jsonDecode(data)); + } + } + + SafeVerifyState() { + resetResend(); + } + + void resetResend() { + canResend.value = totalSeconds == currentSecond; + btnText.value = !canResend.value + ? '$currentSecond s' + : btnText.value = TranslationLoader.lanKeys!.getVerificationCode!.tr; + } + + void onClose() {} +} diff --git a/star_lock/lib/mine/mine/starLockMine_logic.dart b/star_lock/lib/mine/mine/starLockMine_logic.dart index aa4c120d..9545b955 100644 --- a/star_lock/lib/mine/mine/starLockMine_logic.dart +++ b/star_lock/lib/mine/mine/starLockMine_logic.dart @@ -1,9 +1,18 @@ +import 'package:star_lock/login/login/entity/LoginEntity.dart'; +import 'package:star_lock/network/api_repository.dart'; + import '../../tools/baseGetXController.dart'; import 'starLockMine_state.dart'; class StarLockMineLogic extends BaseGetXController { final StarLockMineState state = StarLockMineState(); + //删除账号请求 + Future userLogoutRequest() async { + LoginEntity entity = await ApiRepository.to.userLogout(); + if (entity.errorCode!.codeIsSuccessful) {} + } + @override void onReady() { print("ready home"); @@ -23,5 +32,4 @@ class StarLockMineLogic extends BaseGetXController { print("close home"); super.onClose(); } - -} \ No newline at end of file +} diff --git a/star_lock/lib/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator_page.dart b/star_lock/lib/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator_page.dart index d79cf444..fabdf376 100644 --- a/star_lock/lib/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator_page.dart +++ b/star_lock/lib/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator_page.dart @@ -272,10 +272,12 @@ class _AddAuthorizedAdministratorPageState action: () async { var result = await Navigator.pushNamed( context, Routers.seletCountryRegionPage); - result as Map; - countryCode = result['code']; - countryName = result['countryName']; - setState(() {}); + if (result != null) { + result as Map; + countryCode = result['code']; + countryName = result['countryName']; + setState(() {}); + } }, ), CommonItem( diff --git a/star_lock/lib/mine/mineSet/mineSet/mineSet_page.dart b/star_lock/lib/mine/mineSet/mineSet/mineSet_page.dart index e6558fc1..67f94794 100644 --- a/star_lock/lib/mine/mineSet/mineSet/mineSet_page.dart +++ b/star_lock/lib/mine/mineSet/mineSet/mineSet_page.dart @@ -3,6 +3,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/mine/mineSet/mineSet/mineSet_logic.dart'; +import 'package:star_lock/tools/showIosTipView.dart'; import '../../../appRouters.dart'; import '../../../app_settings/app_colors.dart'; import '../../../tools/commonItem.dart'; @@ -240,7 +241,9 @@ class _MineSetPageState extends State { style: TextStyle( color: AppColors.darkGrayTextColor, fontSize: 18.sp), ), - onPressed: () {}, + onPressed: () { + showCupertinoAlertDialog(context); + }, ), ], ), @@ -252,6 +255,25 @@ class _MineSetPageState extends State { ); } + void showCupertinoAlertDialog(BuildContext context) { + showDialog( + context: context, + builder: (BuildContext context) { + return ShowIosTipView( + title: "", + tipTitle: TranslationLoader.lanKeys!.deleteAccountTips!.tr, + sureClick: () { + //安全验证 + Navigator.pushNamed(context, Routers.safeVerifyPage); + }, + cancelClick: () { + Navigator.pop(context); + }, + ); + }, + ); + } + CupertinoSwitch _isPrompToneSwitch() { return CupertinoSwitch( activeColor: CupertinoColors.activeBlue, diff --git a/star_lock/lib/mine/mineSet/transferSmartLock/recipientInformation/recipientInformation_page.dart b/star_lock/lib/mine/mineSet/transferSmartLock/recipientInformation/recipientInformation_page.dart index 83ba7af6..29674d7b 100644 --- a/star_lock/lib/mine/mineSet/transferSmartLock/recipientInformation/recipientInformation_page.dart +++ b/star_lock/lib/mine/mineSet/transferSmartLock/recipientInformation/recipientInformation_page.dart @@ -45,7 +45,9 @@ class _RecipientInformationPageState extends State { Visibility( visible: state.isFromType.value == 2 ? true : false, child: _buildRemoveBadLockBtn()), - SizedBox(height: 64.h,) + SizedBox( + height: 64.h, + ) ], ), ); @@ -53,19 +55,27 @@ class _RecipientInformationPageState extends State { Widget _buildMainUI() { return Obx(() => Column( - children: [ - _electronicKeyItem(state.type.value == 1 ? 'images/select_circle.png' : 'images/normal_circle.png', "个人用户", () { - setState(() { - state.type.value = 1; - }); - }), - _electronicKeyItem(state.type.value == 2 ? 'images/select_circle.png' : 'images/normal_circle.png', "星寓", () { - setState(() { - state.type.value = 2; - }); - }) - ], - )); + children: [ + _electronicKeyItem( + state.type.value == 1 + ? 'images/select_circle.png' + : 'images/normal_circle.png', + "个人用户", () { + setState(() { + state.type.value = 1; + }); + }), + _electronicKeyItem( + state.type.value == 2 + ? 'images/select_circle.png' + : 'images/normal_circle.png', + "星寓", () { + setState(() { + state.type.value = 2; + }); + }) + ], + )); } Widget _electronicKeyItem( @@ -110,26 +120,39 @@ class _RecipientInformationPageState extends State { children: [ Row( children: [ - SizedBox(width: 40.w,), - Text('账号', style: TextStyle(color: AppColors.darkGrayTextColor, fontSize: 22.sp)), + SizedBox( + width: 40.w, + ), + Text('账号', + style: TextStyle( + color: AppColors.darkGrayTextColor, fontSize: 22.sp)), Expanded( child: TextField( - controller: state.numberController, - textAlign: TextAlign.right, - keyboardType: TextInputType.text, - onChanged: (value) {}, - decoration: InputDecoration( - border: InputBorder.none, - hintText: state.type.value == 1 ? "请输入手机号或email" : "请输入星寓管理员的账号", - hintStyle: TextStyle( - color: AppColors.placeholderTextColor, - fontSize: ScreenUtil().setSp(22), - textBaseline: TextBaseline.alphabetic), - ), + controller: state.numberController, + textAlign: TextAlign.right, + keyboardType: TextInputType.text, + onChanged: (value) {}, + decoration: InputDecoration( + border: InputBorder.none, + hintText: + state.type.value == 1 ? "请输入手机号或email" : "请输入星寓管理员的账号", + hintStyle: TextStyle( + color: AppColors.placeholderTextColor, + fontSize: ScreenUtil().setSp(22), + textBaseline: TextBaseline.alphabetic), + ), )), - SizedBox(width: 20.w,), - Image.asset('images/icon_addressBook.png', width: 28.w, height: 28.h,), - SizedBox(width: 40.w,) + SizedBox( + width: 20.w, + ), + Image.asset( + 'images/icon_addressBook.png', + width: 28.w, + height: 28.h, + ), + SizedBox( + width: 40.w, + ) ], ), Divider( @@ -147,16 +170,18 @@ class _RecipientInformationPageState extends State { rightWidget: Text( '${state.countryName.value} +${state.countryCode.value}', textAlign: TextAlign.end, - style: - TextStyle(fontSize: 22.sp, color: AppColors.darkGrayTextColor), + style: TextStyle( + fontSize: 22.sp, color: AppColors.darkGrayTextColor), ), action: () async { var result = await Navigator.pushNamed( context, Routers.seletCountryRegionPage); - result as Map; - state.countryCode.value = result['code']; - state.countryName.value = result['countryName']; - setState(() {}); + if (result != null) { + result as Map; + state.countryCode.value = result['code']; + state.countryName.value = result['countryName']; + setState(() {}); + } }, ), ], @@ -177,41 +202,43 @@ class _RecipientInformationPageState extends State { } Widget _buildNextBtn(BuildContext context) { - return SubmitBtn(btnName: '下一步', onClick: () { - if(state.numberController.text.isEmpty){ - Toast.show(msg: "请输入手机号或email"); - return; - } - if(state.isFromType.value == 1){ - // 转移智能锁 - if(state.type.value == 1){ - logic.transferLockConfirmInfoData((v){ - showCupertinoAlertDialog(context, v); - }); - }else{ - Get.toNamed(Routers.selectBranchPage, arguments: { - "idList":state.idList.value, - "countryCode":state.countryCode.value, - "number":state.numberController.text, - "isFromType":state.isFromType.value, - }); - } - }else{ - // 转移网关 - if(state.type.value == 1){ - logic.transferGateWayConfirmInfoData((v){ - showCupertinoAlertDialog(context, v); - }); - }else{ - Get.toNamed(Routers.selectBranchPage, arguments: { - "idList":state.idList.value, - "countryCode":state.countryCode.value, - "number":state.numberController.text, - "isFromType":state.isFromType.value - }); - } - } - }); + return SubmitBtn( + btnName: '下一步', + onClick: () { + if (state.numberController.text.isEmpty) { + Toast.show(msg: "请输入手机号或email"); + return; + } + if (state.isFromType.value == 1) { + // 转移智能锁 + if (state.type.value == 1) { + logic.transferLockConfirmInfoData((v) { + showCupertinoAlertDialog(context, v); + }); + } else { + Get.toNamed(Routers.selectBranchPage, arguments: { + "idList": state.idList.value, + "countryCode": state.countryCode.value, + "number": state.numberController.text, + "isFromType": state.isFromType.value, + }); + } + } else { + // 转移网关 + if (state.type.value == 1) { + logic.transferGateWayConfirmInfoData((v) { + showCupertinoAlertDialog(context, v); + }); + } else { + Get.toNamed(Routers.selectBranchPage, arguments: { + "idList": state.idList.value, + "countryCode": state.countryCode.value, + "number": state.numberController.text, + "isFromType": state.isFromType.value + }); + } + } + }); } Widget _buildRemoveBadLockBtn() { @@ -219,30 +246,35 @@ class _RecipientInformationPageState extends State { children: [ const Expanded(child: SizedBox()), TextButton( - onPressed: () { - - }, - child: Text('移除坏锁', style: TextStyle(fontSize: 22.sp, color: AppColors.darkGrayTextColor), textAlign: TextAlign.end,)), - SizedBox(width: 10.h,) + onPressed: () {}, + child: Text( + '移除坏锁', + style: TextStyle( + fontSize: 22.sp, color: AppColors.darkGrayTextColor), + textAlign: TextAlign.end, + )), + SizedBox( + width: 10.h, + ) ], ); } // 点击确认 - void showCupertinoAlertDialog(BuildContext context, RecipientInformationData recipientInformationData) { + void showCupertinoAlertDialog( + BuildContext context, RecipientInformationData recipientInformationData) { showGeneralDialog( context: context, barrierColor: Colors.black.withOpacity(.5), barrierDismissible: true, barrierLabel: '', transitionDuration: const Duration(milliseconds: 200), - transitionBuilder: (BuildContext context, - Animation animation, - Animation secondaryAnimation, - Widget child) { + transitionBuilder: (BuildContext context, Animation animation, + Animation secondaryAnimation, Widget child) { return ScaleTransition(scale: animation, child: child); }, - pageBuilder: (BuildContext context, Animation animation, Animation secondaryAnimation) { + pageBuilder: (BuildContext context, Animation animation, + Animation secondaryAnimation) { // recipientInformationData.nickname = "张三张三张三"; return Center( child: Container( @@ -254,27 +286,35 @@ class _RecipientInformationPageState extends State { SizedBox(height: 20.h), Text("转移确认", style: TextStyle(fontSize: 24.sp)), SizedBox(height: 20.h), - Image.asset('images/icon_lockGroup_item.png', width: 70.h, height: 70.h, fit: BoxFit.fill), + Image.asset('images/icon_lockGroup_item.png', + width: 70.h, height: 70.h, fit: BoxFit.fill), SizedBox(height: 15.h), Stack( - alignment: Alignment.center, - clipBehavior: Clip.none, - children: [ - Text(recipientInformationData.nickname!, style: TextStyle(fontSize: 22.sp)), - Positioned( - left: (recipientInformationData.nickname!.length*19.w).w, - child: Container( - width: 80.w, - color: Colors.red, - child: Center(child: Text(state.type.value == 1 ? "个人用户" : "星寓", style: TextStyle(fontSize: 18.sp, color: Colors.white))), - ), - ) - ], + alignment: Alignment.center, + clipBehavior: Clip.none, + children: [ + Text(recipientInformationData.nickname!, + style: TextStyle(fontSize: 22.sp)), + Positioned( + left: (recipientInformationData.nickname!.length * 19.w) + .w, + child: Container( + width: 80.w, + color: Colors.red, + child: Center( + child: Text(state.type.value == 1 ? "个人用户" : "星寓", + style: TextStyle( + fontSize: 18.sp, color: Colors.white))), + ), + ) + ], ), SizedBox(height: 8.h), - Text(recipientInformationData.userid!, style: TextStyle(fontSize: 22.sp)), + Text(recipientInformationData.userid!, + style: TextStyle(fontSize: 22.sp)), SizedBox(height: 8.h), - Text("本次共转移${state.idList.value.length}把智能锁", style: TextStyle(fontSize: 20.sp)), + Text("本次共转移${state.idList.value.length}把智能锁", + style: TextStyle(fontSize: 20.sp)), SizedBox(height: 20.h), Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, @@ -297,10 +337,10 @@ class _RecipientInformationPageState extends State { ElevatedButton( onPressed: () { Get.back(); - if(state.isFromType.value == 1){ + if (state.isFromType.value == 1) { // 转移智能锁 transferGatewayInfoData logic.transferLockInfoData(); - }else{ + } else { // 转移网关 logic.transferGatewayInfoData(); } diff --git a/star_lock/lib/network/api.dart b/star_lock/lib/network/api.dart index 6cc7fe5b..240eda61 100644 --- a/star_lock/lib/network/api.dart +++ b/star_lock/lib/network/api.dart @@ -3,6 +3,7 @@ abstract class Api { // final String baseUrl = "https://lock.star-lock.cn/api"; // 测试环境 // final String baseUrl = "http://wenlin.lock.star-lock.cn/api"; //曾工 final String baseUrl = "http://192.168.56.101:8099/api"; //曾工本地 + // final String baseUrl = "http://192.168.1.14:8099/api"; //葛工开发环境地址 // 登录注册 final String getVerificationCodeUrl = '/user/sendValidationCode'; @@ -25,7 +26,7 @@ abstract class Api { '/key/modifyKeyNameForAdmin'; //编辑电子钥匙名字 final String updateKeyDateURL = '/key/updateKeyDate'; //编辑电子钥匙的有效期、有效时间、有效日 final String passwordKeyListURL = '/keyboardPwd/listSendRecords'; //密码钥匙列表 - final String passwordKeyResetURL = '/keyboardPwd/reset'; //密码钥匙重置 + final String keyboardPwdResetURL = '/keyboardPwd/reset'; //密码钥匙重置 final String deleteElectronicKeyURL = '/key/delete'; //删除电子钥匙 final String deleteKeyboardPwdURL = '/keyboardPwd/delete'; //删除密码 final String getLockInfoURL = '/lock/syncDataPage'; // 获取锁信息 @@ -117,4 +118,6 @@ abstract class Api { final String setAppUnlockMustOnlineURL = '/room/setAppUnlockMustOnline'; //APP开锁时需手机联网的锁 final String userLogoutURL = '/user/logout'; //退出登录 + final String deleteAccountURL = '/user/delete'; //删除账号 + final String getUserInfoURL = '/user/getUserInfo'; //获取个人信息 } diff --git a/star_lock/lib/network/api_provider.dart b/star_lock/lib/network/api_provider.dart index 9af993ca..b7054e82 100644 --- a/star_lock/lib/network/api_provider.dart +++ b/star_lock/lib/network/api_provider.dart @@ -439,7 +439,7 @@ class ApiProvider extends BaseProvider { })); Future deleteKeyboardPwd( - String lockId, String keyboardPwdId, String deleteType) => + String lockId, String keyboardPwdId, int deleteType) => post( deleteKeyboardPwdURL.toUrl, jsonEncode({ @@ -943,78 +943,56 @@ class ApiProvider extends BaseProvider { // 获取转移锁锁列表 Future getTransferLockListData() => - post( - transferLockListURL.toUrl, - jsonEncode({}) - ); + post(transferLockListURL.toUrl, jsonEncode({})); // 转移智能锁确认 Future transferLockConfirmInfoData( - String receiverUserid, - String type, - String countryCode) => + String receiverUserid, String type, String countryCode) => post( transferLockConfirmURL.toUrl, jsonEncode({ 'receiverUserid': receiverUserid, 'type': type, 'countryCode': countryCode - }) - ); + })); // 转移智能锁 Future transferLockInfoData( - String receiverUserid, - List lockIdList, - String countryCode) => + String receiverUserid, List lockIdList, String countryCode) => post( transferLockURL.toUrl, jsonEncode({ 'receiverUserid': receiverUserid, 'lockIdList': lockIdList, 'countryCode': countryCode - }) - ); + })); // 获取网关列表 - Future getGatewayListData( - String pageNo, - String pageSize) => - post( - gatewaykListURL.toUrl, - jsonEncode({ - 'pageNo': pageNo, - 'pageSize': pageSize - }) - ); + Future getGatewayListData(String pageNo, String pageSize) => post( + gatewaykListURL.toUrl, + jsonEncode({'pageNo': pageNo, 'pageSize': pageSize})); // 转移网关确认 Future transferGatewayConfirmInfoData( - String receiverUserid, - String type, - String countryCode) => + String receiverUserid, String type, String countryCode) => post( transferGatewayConfirmURL.toUrl, jsonEncode({ 'receiverUserid': receiverUserid, 'type': type, 'countryCode': countryCode - }) - ); + })); // 转移网关 Future transferGatewayInfoData( - String receiverUserid, - List plugIdList, - String countryCode) => + String receiverUserid, List plugIdList, String countryCode) => post( transferGatewayURL.toUrl, jsonEncode({ 'receiverUserid': receiverUserid, 'plugIdList': plugIdList, 'countryCode': countryCode - }) - ); + })); Future listLockByGroup(String type, String keyGroupId) => post( listLockByGroupURL.toUrl, @@ -1140,6 +1118,25 @@ class ApiProvider extends BaseProvider { //退出登录 Future userLogout() => get(userLogoutURL.toUrl); + + //删除账号 + Future deleteAccount( + String operatorUid, String uniqueid, String verificationCode) => + post( + deleteAccountURL.toUrl, + jsonEncode({ + 'operatorUid': operatorUid, + 'uniqueid': uniqueid, + 'verificationCode': verificationCode + })); + + // 获取个人信息 + Future getUserInfo(String operatorUid) => + post(getUserInfoURL.toUrl, jsonEncode({'operatorUid': operatorUid})); + + // 重置密码钥匙 + Future keyboardPwdReset(String lockId) => + post(keyboardPwdResetURL.toUrl, jsonEncode({'lockId': lockId})); } extension ExtensionString on String { diff --git a/star_lock/lib/network/api_provider_base.dart b/star_lock/lib/network/api_provider_base.dart index 8a5933c8..9dfe773f 100644 --- a/star_lock/lib/network/api_provider_base.dart +++ b/star_lock/lib/network/api_provider_base.dart @@ -28,9 +28,9 @@ class BaseProvider extends GetConnect with Api { Map? query, Decoder? decoder, Progress? uploadProgress, - bool? isUnShowLoading = false}) async { + bool? isUnShowLoading = false}) async { // print("post: url:${url} body:${body} contentType:${contentType} headers:${headers} query:${query}"); - if(isUnShowLoading == false) EasyLoading.show(); + if (isUnShowLoading == false) EasyLoading.show(); print('哈喽请求body体为:${body}'); var res = await super.post(url, body, diff --git a/star_lock/lib/network/api_repository.dart b/star_lock/lib/network/api_repository.dart index 5c606d69..d297ea35 100644 --- a/star_lock/lib/network/api_repository.dart +++ b/star_lock/lib/network/api_repository.dart @@ -440,7 +440,7 @@ class ApiRepository { //删除密码 Future deleteKeyboardPwd( - String lockId, String keyboardPwdId, String deleteType) async { + String lockId, String keyboardPwdId, int deleteType) async { final res = await apiProvider.deleteKeyboardPwd(lockId, keyboardPwdId, deleteType); return PasswordKeyEntity.fromJson(res.body); @@ -449,7 +449,7 @@ class ApiRepository { //标记房态 Future updateSetting( String lockId, String isOn, String type) async { - final res = await apiProvider.deleteKeyboardPwd(lockId, isOn, type); + final res = await apiProvider.updateSetting(lockId, isOn, type); return PasswordKeyEntity.fromJson(res.body); } @@ -1109,4 +1109,24 @@ class ApiRepository { receiverUserid, plugIdList, countryCode); return RecipientInformationEntity.fromJson(res.body); } + + //删除账号 + Future deleteAccount( + String operatorUid, String uniqueid, String verificationCode) async { + final res = await apiProvider.deleteAccount( + operatorUid, uniqueid, verificationCode); + return AuthorizedAdminListEntity.fromJson(res.body); + } + + //获取个人信息 + Future getUserInfo(String operatorUid) async { + final res = await apiProvider.getUserInfo(operatorUid); + return AuthorizedAdminListEntity.fromJson(res.body); + } + + //重置密码钥匙 + Future keyboardPwdReset(String lockId) async { + final res = await apiProvider.keyboardPwdReset(lockId); + return PasswordKeyListEntity.fromJson(res.body); + } } diff --git a/star_lock/lib/tools/showCupertinoAlert.dart b/star_lock/lib/tools/showCupertinoAlert.dart new file mode 100644 index 00000000..3550be82 --- /dev/null +++ b/star_lock/lib/tools/showCupertinoAlert.dart @@ -0,0 +1,56 @@ +import 'dart:async'; +import 'package:flutter/cupertino.dart'; + +//封装一个适合我们项目的,结果返回一个 future +//颜色等受系统默认的值影响,这里面就不填写属性了,primaryColor 更新会影响到所有的默认效果 +Future showCupertinoAlert({ + BuildContext? context, //如果没设置全局,需要传递自己的context + String title = '', + String message = '', + confirmText = '确定', + cancelText = '取消', + isShowCancel = true, + isDestructiveConfirm = false, + isDestructiveCancel = false, +}) { + // context = context ?? DialogConfig.context; + final completer = Completer(); + final actions = [ + CupertinoDialogAction( + isDestructiveAction: isDestructiveConfirm, + onPressed: () { + completer.complete(true); + Navigator.of(context!).pop(); + }, + child: Text(confirmText), + ), + ]; + if (isShowCancel) { + actions.insert( + 0, + CupertinoDialogAction( + isDestructiveAction: isDestructiveCancel, + onPressed: () { + completer.complete(false); + Navigator.of(context!).pop(); + }, + child: Text( + cancelText, + ), + ), + ); + } + // showCupertinoModalPopup( + // context: context, + // barrierDismissible: false, + // builder: (BuildContext context) => CupertinoAlertDialog( + // title: Text(title), + // content: Padding( + // padding: const EdgeInsets.only(top: 10), + // child: Text(message), + // ), + // actions: actions, + // ), + // ); + return completer.future; +} diff --git a/star_lock/lib/translations/lanKeyEntity.dart b/star_lock/lib/translations/lanKeyEntity.dart index 577ee896..b2c895fc 100644 --- a/star_lock/lib/translations/lanKeyEntity.dart +++ b/star_lock/lib/translations/lanKeyEntity.dart @@ -185,7 +185,8 @@ class LanKeyEntity { this.workingHoursWereNotReleased, this.beLate, this.leaveEarly, - this.noCardPunched, this.holidayInfo, + this.noCardPunched, + this.holidayInfo, this.lanEnglish, this.lanChinese, this.multilingual, @@ -400,7 +401,8 @@ class LanKeyEntity { this.getKey, this.getCard, this.getFingerprint, -}); + this.safeVerify, + this.deleteAccountTips}); LanKeyEntity.fromJson(dynamic json) { starLock = json['starLock']; @@ -833,6 +835,8 @@ class LanKeyEntity { getKey = json['getKey']; getCard = json['getCard']; getFingerprint = json['getFingerprint']; + safeVerify = json['safeVerify']; + deleteAccountTips = json['deleteAccountTips']; } String? starLock; String? clickUnlockAndHoldDownClose; @@ -1252,6 +1256,8 @@ class LanKeyEntity { String? getKey; String? getCard; String? getFingerprint; + String? safeVerify; + String? deleteAccountTips; Map toJson() { final map = {}; @@ -1682,6 +1688,8 @@ class LanKeyEntity { map['getKey'] = getKey; map['getCard'] = getCard; map['getFingerprint'] = getFingerprint; + map['safeVerify'] = safeVerify; + map['deleteAccountTips'] = deleteAccountTips; return map; } }