魏少阳 15af50d951 1、完善星锁APP国际化 36种语言。
2、修复国际化问题
2024-10-15 18:32:11 +08:00

122 lines
3.8 KiB
Dart
Executable File

import 'package:flutter/cupertino.dart';
import 'package:get/get.dart';
import 'package:star_lock/tools/baseGetXController.dart';
import '../../../../main/lockMian/entity/lockListInfo_entity.dart';
import '../../../../network/api_repository.dart';
import 'recipientInformation_entity.dart';
import 'recipientInformation_state.dart';
class RecipientInformationLogic extends BaseGetXController{
RecipientInformationState state = RecipientInformationState();
// 转移智能锁确认
Future<void> transferLockConfirmInfoData(void Function(RecipientInformationData recipientInformationData) action) async{
final RecipientInformationEntity entity = await ApiRepository.to.transferLockConfirmInfoData(
receiverUsername: 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<void> transferLockInfoData() async{
final RecipientInformationEntity entity = await ApiRepository.to.transferLockInfoData(
receiverUsername: state.numberController.text,
lockIdList: state.idList.value,
countryCode: state.countryCode.value
);
if(entity.errorCode!.codeIsSuccessful){
showToast('转移成功'.tr, something: (){
Get.back(result: 'scuess');
});
}
}
// 移除坏锁
Future<void> removeBrokenLockData() async{
final RecipientInformationEntity entity = await ApiRepository.to.removeBrokenLockData(
lockIdList: state.idList.value,
);
if(entity.errorCode!.codeIsSuccessful){
showToast('移除成功'.tr, something: (){
Get.back(result: 'scuess');
});
}
}
// 查询账户密码
Future<void> checkLoginPassword() async {
final LockListInfoEntity entity = await ApiRepository.to.checkLoginPassword(
password: state.passwordTF.text,
);
if (entity.errorCode!.codeIsSuccessful) {
Get.back();
if (state.isFromType.value == 1) {
// 转移智能锁 transferGatewayInfoData
transferLockInfoData();
} else {
// 转移网关
transferGatewayInfoData();
}
}
}
// 转移网关确认
Future<void> transferGateWayConfirmInfoData(void Function(RecipientInformationData recipientInformationData) action) async{
final RecipientInformationEntity entity = await ApiRepository.to.transferGatewayConfirmInfoData(
receiverUsername: state.numberController.text,
type: state.type.value.toString(),
countryCode: state.countryCode.value
);
if(entity.errorCode!.codeIsSuccessful){
action(entity.data!);
}
}
// 转移网关
Future<void> transferGatewayInfoData() async{
final RecipientInformationEntity entity = await ApiRepository.to.transferGatewayInfoData(
receiverUsername: 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: (BuildContext context) {
return CupertinoAlertDialog(
title: Text('提示'.tr),
content: Text('确定要移除所选中的坏锁吗?'.tr),
actions: <Widget>[
CupertinoDialogAction(
child: Text('取消'.tr),
onPressed: Get.back,
),
CupertinoDialogAction(
child: Text('确定'.tr),
onPressed: () {
Get.back();
removeBrokenLockData();
},
),
],
);
},
);
}
}