import 'package:flutter/cupertino.dart'; import 'package:get/get.dart'; import 'package:star_lock/tools/baseGetXController.dart'; import '../../../../network/api_repository.dart'; import '../../../../tools/eventBusEventManage.dart'; import '../../../../translations/trans_lib.dart'; import 'recipientInformation_entity.dart'; import 'recipientInformation_state.dart'; class RecipientInformationLogic extends BaseGetXController{ RecipientInformationState state = RecipientInformationState(); // 转移智能锁确认 Future transferLockConfirmInfoData(void Function(RecipientInformationData recipientInformationData) action) async{ var entity = await ApiRepository.to.transferLockConfirmInfoData( receiverUserid: state.numberController.text, type: state.type.value.toString(), countryCode: state.countryCode.value ); if(entity.errorCode!.codeIsSuccessful){ action(entity.data!); }else { if(entity.errorCode! == 425){ showToast(entity.errorMsg!); } } } // 转移智能锁 Future transferLockInfoData() async{ var entity = await ApiRepository.to.transferLockInfoData( receiverUserid: state.numberController.text, lockIdList: state.idList.value, countryCode: state.countryCode.value ); if(entity.errorCode!.codeIsSuccessful){ Get.back(result: "scuess"); eventBus.fire(RefreshLockListInfoDataEvent()); } } // 移除坏锁 Future removeBrokenLockData() async{ var entity = await ApiRepository.to.removeBrokenLockData( lockIdList: state.idList.value, ); if(entity.errorCode!.codeIsSuccessful){ eventBus.fire(RefreshLockListInfoDataEvent()); Get.back(result: "scuess"); } } // 转移网关确认 Future transferGateWayConfirmInfoData(void Function(RecipientInformationData recipientInformationData) action) async{ var entity = await ApiRepository.to.transferGatewayConfirmInfoData( receiverUserid: state.numberController.text, type: state.type.value.toString(), countryCode: state.countryCode.value ); if(entity.errorCode!.codeIsSuccessful){ action(entity.data!); } } // 转移网关 Future transferGatewayInfoData() async{ var entity = await ApiRepository.to.transferGatewayInfoData( receiverUserid: state.numberController.text, plugIdList: state.idList.value, countryCode: state.countryCode.value ); if(entity.errorCode!.codeIsSuccessful){ Get.back(result: "scuess"); } } // 移除坏锁提示 void showDeletAlertDialog() { showCupertinoDialog( context: Get.context!, builder: (context) { return CupertinoAlertDialog( title: const Text("提示"), content: const Text('确定要移除所选中的坏锁吗?'), actions: [ CupertinoDialogAction( child: Text(TranslationLoader.lanKeys!.cancel!.tr), onPressed: () { Get.back(); }, ), CupertinoDialogAction( child: Text(TranslationLoader.lanKeys!.sure!.tr), onPressed: () { Get.back(); removeBrokenLockData(); }, ), ], ); }, ); } @override void onReady() { // TODO: implement onReady super.onReady(); } @override void onInit() { // TODO: implement onInit super.onInit(); } @override void onClose() { // TODO: implement onClose super.onClose(); } }