添加群发电子钥匙进度功能,修改群发电子钥匙bug
This commit is contained in:
parent
178dbdb937
commit
4b2ebf5d85
BIN
images/.DS_Store
vendored
BIN
images/.DS_Store
vendored
Binary file not shown.
BIN
images/icon_close_black.png
Normal file
BIN
images/icon_close_black.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 720 B |
@ -0,0 +1,193 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../../../../appRouters.dart';
|
||||
import '../../../../../app_settings/app_colors.dart';
|
||||
import '../massSendLockGroupList/lockUserList/lockUserList_entity.dart';
|
||||
|
||||
class MassSendElectronicKeyProgressPage extends StatefulWidget {
|
||||
MassSendElectronicKeyProgressPage({required this.receiverList, Key? key}) : super(key: key);
|
||||
List receiverList;
|
||||
|
||||
@override
|
||||
State<MassSendElectronicKeyProgressPage> createState() => _MassSendElectronicKeyProgressPageState();
|
||||
}
|
||||
|
||||
class _MassSendElectronicKeyProgressPageState extends State<MassSendElectronicKeyProgressPage> {
|
||||
int failCount = 0;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// 遍历receiverList,统计失败的数量
|
||||
widget.receiverList.forEach((element) {
|
||||
if (element is LockUserItemData) {
|
||||
if (element.isSendSuccess == false || element.isSendSuccess == null) {
|
||||
failCount++;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return Container(
|
||||
width: 1.sw - 20*2,
|
||||
height: 500.h,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
topTitle(),
|
||||
Divider(height: 1.h, color: AppColors.greyLineColor),
|
||||
progressTitle(),
|
||||
Expanded(child: progressList()),
|
||||
Divider(height: 1.h, color: AppColors.greyLineColor),
|
||||
bottomBtn(),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget topTitle(){
|
||||
return SizedBox(
|
||||
height: 70.h,
|
||||
child: Stack(
|
||||
children: [
|
||||
Center(
|
||||
child: Text(
|
||||
'发送钥匙'.tr,
|
||||
style: TextStyle(fontSize: 24.sp),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
right: 0,
|
||||
child: GestureDetector(
|
||||
onTap: Get.back,
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(15.w),
|
||||
child: Image.asset(
|
||||
'images/icon_close_black.png',
|
||||
width: 35.w,
|
||||
height: 35.w,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget progressTitle(){
|
||||
return Container(
|
||||
padding: EdgeInsets.only(left: 15.w, top: 10.h, bottom: 10.h),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Text('进度'.tr + ':' + '$failCount/${widget.receiverList.length}', style: TextStyle(fontSize: 24.sp)),
|
||||
SizedBox(width: 20.w),
|
||||
Text('失败:$failCount', style: TextStyle(fontSize: 24.sp, color: Colors.red))
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget progressList(){
|
||||
return ListView.builder(
|
||||
itemCount: widget.receiverList.length,
|
||||
itemBuilder: (BuildContext c, int index) {
|
||||
LockUserItemData data = widget.receiverList[index];
|
||||
return Container(
|
||||
margin: EdgeInsets.only(left: 15.w, top: 5.h, bottom: 5.h, right: 15.w),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: <Widget>[
|
||||
Text(data.userid??'', style: TextStyle(fontSize: 24.sp)),
|
||||
SizedBox(width: 10.w),
|
||||
if (data.isSendSuccess ?? false) const Icon(Icons.check, color: Colors.green) else const Icon(Icons.close, color: Colors.red),
|
||||
],
|
||||
),
|
||||
if (!(data.isSendSuccess ?? false)) Text(data.sendFailReason??'', style: TextStyle(fontSize: 20.sp, color: Colors.red))
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget progressItem(){
|
||||
return Container(
|
||||
padding: EdgeInsets.only(left: 15.w, top: 15.h, bottom: 10.h),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Text('发送中'.tr+'1/2', style: TextStyle(fontSize: 24.sp)),
|
||||
SizedBox(width: 20.w),
|
||||
Text('失败:1', style: TextStyle(fontSize: 24.sp, color: Colors.red))
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget bottomBtn(){
|
||||
return Container(
|
||||
height: 80.h,
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: GestureDetector(
|
||||
onTap: Get.back,
|
||||
child: Container(
|
||||
alignment: Alignment.center,
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.only(
|
||||
bottomLeft: Radius.circular(10)),
|
||||
),
|
||||
child: Text(
|
||||
'完成'.tr,
|
||||
style: TextStyle(
|
||||
fontSize: 24.sp, color: AppColors.mainColor),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(width: 1.h, color: AppColors.greyLineColor),
|
||||
Expanded(
|
||||
child: GestureDetector(
|
||||
onTap: (){
|
||||
Get.back();
|
||||
// 剔除发送失败的数据,重新发送
|
||||
widget.receiverList.removeWhere((element) => (element as LockUserItemData).isSendSuccess == true);
|
||||
Navigator.pushNamed(context, Routers.massSendReceiverPage,
|
||||
arguments: <String, List>{
|
||||
'lockUserList': widget.receiverList,
|
||||
}).then((Object? value) {
|
||||
// if (value != null) {
|
||||
// value as Map<String, dynamic>;
|
||||
// state.receiverList = value['lockUserList'];
|
||||
// setState(() {});
|
||||
// }
|
||||
});
|
||||
},
|
||||
child: Container(
|
||||
alignment: Alignment.center,
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.only(
|
||||
bottomRight: Radius.circular(10)),
|
||||
),
|
||||
child: Text(
|
||||
'重试'.tr,
|
||||
style: TextStyle(
|
||||
fontSize: 24.sp, color: AppColors.mainColor),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,7 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/app_settings/app_settings.dart';
|
||||
import 'package:star_lock/main/lockDetail/lockSet/basicInformation/basicInformation/KeyDetailEntity.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import 'package:star_lock/tools/pickers/time_picker/time_utils.dart';
|
||||
@ -6,6 +9,7 @@ import '../../../../../common/XSConstantMacro/XSConstantMacro.dart';
|
||||
import '../../../../../network/api_repository.dart';
|
||||
import '../../../../../tools/dateTool.dart';
|
||||
import '../massSendLockGroupList/lockUserList/lockUserList_entity.dart';
|
||||
import 'massSendElectronicKeyProgress_page.dart';
|
||||
import 'massSendElectronicKey_state.dart';
|
||||
|
||||
class MassSendElectronicKeyLogic extends BaseGetXController {
|
||||
@ -19,9 +23,9 @@ class MassSendElectronicKeyLogic extends BaseGetXController {
|
||||
Future<void> massKeyChecksRequest() async {
|
||||
String getFailureDateTime = '0';
|
||||
if (int.parse(state.type.value) != 1) {
|
||||
getFailureDateTime =
|
||||
DateTool().dateToTimestamp(state.endTime.value, 1).toString();
|
||||
getFailureDateTime = DateTool().dateToTimestamp(state.endTime.value, 1).toString();
|
||||
}
|
||||
|
||||
if (state.lockIdList.isEmpty) {
|
||||
showToast('请选择锁'.tr);
|
||||
return;
|
||||
@ -31,11 +35,67 @@ class MassSendElectronicKeyLogic extends BaseGetXController {
|
||||
showToast('请选择接收者'.tr);
|
||||
return;
|
||||
}
|
||||
|
||||
if(state.type.value == '0'){
|
||||
final String startDate = DateTool().dateToTimestamp(state.beginTime.value, 1).toString();
|
||||
final String endDate = DateTool().dateToTimestamp(state.endTime.value, 1).toString();
|
||||
|
||||
if (startDate.isEmpty) {
|
||||
showToast('请选择开始时间'.tr);
|
||||
return;
|
||||
}
|
||||
if (endDate.isEmpty) {
|
||||
showToast('请选择结束时间'.tr);
|
||||
return;
|
||||
}
|
||||
|
||||
if (int.parse(startDate) >= int.parse(endDate)) {
|
||||
showToast('失效时间要大于生效时间'.tr);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
final KeyDetailEntity entity = await ApiRepository.to.canSendKey(getFailureDateTime, state.lockIdList);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
|
||||
// final List<Future> futures = <Future>[];
|
||||
// 遍历发送
|
||||
for (int i = 0; i < state.receiverList.length; i++) {
|
||||
final LockUserItemData data = state.receiverList[i];
|
||||
batchSendElectronicKeyRequest(data.userid ?? '', data.nickname ?? '');
|
||||
AppLog.log('receiverUserID:${data.userid} receiverUserName:${data.nickname} data.isSendSuccess:${data.isSendSuccess} data.sendFailReason:${data.sendFailReason}');
|
||||
await batchSendElectronicKeyRequest(data.userid ?? '', data.nickname ?? '');
|
||||
// futures.add(
|
||||
// batchSendElectronicKeyRequest(data.userid ?? '', data.nickname ?? '').catchError((error) {
|
||||
// // 处理异常,例如打印错误信息
|
||||
// AppLog.log('Error in batchSendElectronicKeyRequest: $error');
|
||||
// })
|
||||
// );
|
||||
AppLog.log('接口调用成功 receiverUserID:${data.userid} receiverUserName:${data.nickname} data.isSendSuccess:${data.isSendSuccess} data.sendFailReason:${data.sendFailReason}');
|
||||
}
|
||||
// 等待所有的Future完成
|
||||
// try {
|
||||
// await Future.wait(futures);
|
||||
// } catch (e) {
|
||||
// AppLog.log('Error in Future.wait: $e');
|
||||
// }
|
||||
|
||||
// 发送完成之后遍历数据,如果所有的数据都发送成功,改变state.isSendSuccess的值,如果有一个发送失败,不改变state.isSendSuccess的值,然后弹框显示进度
|
||||
bool isSendSuccess = true;
|
||||
for (int i = 0; i < state.receiverList.length; i++) {
|
||||
final LockUserItemData data = state.receiverList[i];
|
||||
AppLog.log('遍历是否弹框 receiverUserID:${data.userid} receiverUserName:${data.nickname} data.isSendSuccess:${data.isSendSuccess} data.sendFailReason:${data.sendFailReason}');
|
||||
if (!(data.isSendSuccess ?? false)) {
|
||||
isSendSuccess = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
state.isSendSuccess.value = isSendSuccess;
|
||||
if(!state.isSendSuccess.value){
|
||||
// 如果有发送失败的,弹框显示发送失败的原因
|
||||
showMassSendElectronicKeyProgress();
|
||||
}else{
|
||||
// 如果全部发送成功,重置数据改变状态
|
||||
resetData();
|
||||
}
|
||||
} else {
|
||||
showToast(entity.errorMsg!);
|
||||
@ -43,8 +103,7 @@ class MassSendElectronicKeyLogic extends BaseGetXController {
|
||||
}
|
||||
|
||||
//批处理群发钥匙
|
||||
Future<void> batchSendElectronicKeyRequest(
|
||||
String receiverUserID, String receiverUserName) async {
|
||||
Future<void> batchSendElectronicKeyRequest(String receiverUserID, String receiverUserName) async {
|
||||
//发送钥匙请求
|
||||
String startDate = '0';
|
||||
String endDate = '0';
|
||||
@ -55,10 +114,8 @@ class MassSendElectronicKeyLogic extends BaseGetXController {
|
||||
case 0:
|
||||
{
|
||||
typeValue = XSConstantMacro.keyTypeTime;
|
||||
startDate =
|
||||
DateTool().dateToTimestamp(state.beginTime.value, 1).toString();
|
||||
endDate =
|
||||
DateTool().dateToTimestamp(state.endTime.value, 1).toString();
|
||||
startDate = DateTool().dateToTimestamp(state.beginTime.value, 1).toString();
|
||||
endDate = DateTool().dateToTimestamp(state.endTime.value, 1).toString();
|
||||
startTime = '0';
|
||||
endTime = '0';
|
||||
|
||||
@ -71,11 +128,6 @@ class MassSendElectronicKeyLogic extends BaseGetXController {
|
||||
return;
|
||||
}
|
||||
|
||||
// if(DateTime.now().millisecondsSinceEpoch > int.parse(state.beginTimeTimestamp.value)){
|
||||
// Toast.show(msg: "生效时间要大于当前时间");
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (int.parse(startDate) >= int.parse(endDate)) {
|
||||
showToast('失效时间要大于生效时间'.tr);
|
||||
return;
|
||||
@ -94,15 +146,10 @@ class MassSendElectronicKeyLogic extends BaseGetXController {
|
||||
showToast('请选择有效期'.tr);
|
||||
return;
|
||||
}
|
||||
startDate =
|
||||
DateTool().dateToTimestamp(state.beginTime.value, 1).toString();
|
||||
startDate = DateTool().dateToTimestamp(state.beginTime.value, 1).toString();
|
||||
endDate = DateTool().dateToTimestamp(state.endTime.value, 1).toString();
|
||||
startTime = DateTool()
|
||||
.dateToTimestamp(state.effectiveDateTime.value, 0)
|
||||
.toString();
|
||||
endTime = DateTool()
|
||||
.dateToTimestamp(state.failureDateTime.value, 0)
|
||||
.toString();
|
||||
startTime = DateTool().dateToTimestamp(state.effectiveDateTime.value, 0).toString();
|
||||
endTime = DateTool().dateToTimestamp(state.failureDateTime.value, 0).toString();
|
||||
break;
|
||||
default:
|
||||
typeValue = XSConstantMacro.keyTypeLong;
|
||||
@ -123,16 +170,39 @@ class MassSendElectronicKeyLogic extends BaseGetXController {
|
||||
startTime: int.parse(startTime),
|
||||
endTime: int.parse(endTime),
|
||||
remoteUnlockSwitch: state.isRemoteUnlock.value ? 1 : 2,
|
||||
keyRight: 0);
|
||||
keyRight: 0,
|
||||
isShowNetworkErrorMsg: false
|
||||
);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
state.isSendSuccess.value = true;
|
||||
resetData();
|
||||
// 发送成功之后默认是需要创建的
|
||||
state.isCreateUser.value = false;
|
||||
|
||||
// 发送成功之后,查询发送类列表里面对应的数据,将发送成功的状态改为true
|
||||
for (int i = 0; i < state.receiverList.length; i++) {
|
||||
final LockUserItemData data = state.receiverList[i];
|
||||
if (data.userid == receiverUserID) {
|
||||
data.isSendSuccess = true;
|
||||
data.sendFailReason = '';
|
||||
}
|
||||
AppLog.log('发送成功:receiverUserID:$receiverUserID data.userid:${data.userid} receiverUserName:${data.nickname} data.isSendSuccess:${data.isSendSuccess} data.sendFailReason:${data.sendFailReason}');
|
||||
}
|
||||
// resetData();
|
||||
} else {
|
||||
showToast('${entity.errorMsg}');
|
||||
// showToast('${entity.errorMsg}');
|
||||
if (entity.errorCode == 425) {
|
||||
//用户未注册
|
||||
//用户未注册 重新发送
|
||||
state.isCreateUser.value = true;
|
||||
batchSendElectronicKeyRequest(receiverUserID, receiverUserName);
|
||||
}else{
|
||||
// 发送失败之后,查询发送类列表里面对应的数据,将发送成功的状态改为false
|
||||
for (int i = 0; i < state.receiverList.length; i++) {
|
||||
final LockUserItemData data = state.receiverList[i];
|
||||
if (data.userid == receiverUserID) {
|
||||
data.isSendSuccess = false;
|
||||
data.sendFailReason = entity.errorMsg;
|
||||
}
|
||||
AppLog.log('发送失败之后 receiverUserID:$receiverUserID data.userid:${data.userid} receiverUserName:${data.nickname} data.isSendSuccess:${data.isSendSuccess} data.sendFailReason:${data.sendFailReason}');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -148,4 +218,17 @@ class MassSendElectronicKeyLogic extends BaseGetXController {
|
||||
state.endTime.value = ''; //默认为当前时间
|
||||
}
|
||||
}
|
||||
|
||||
void showMassSendElectronicKeyProgress() {
|
||||
showDialog(
|
||||
context: Get.context!,
|
||||
builder: (BuildContext context) {
|
||||
return Dialog(
|
||||
backgroundColor: Colors.transparent,
|
||||
child: MassSendElectronicKeyProgressPage(receiverList:state.receiverList),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/app_settings/app_colors.dart';
|
||||
@ -18,9 +20,7 @@ import '../../../../../translations/trans_lib.dart';
|
||||
import 'massSendElectronicKey_logic.dart';
|
||||
|
||||
class MassSendElectronicKeyPage extends StatefulWidget {
|
||||
|
||||
const MassSendElectronicKeyPage({Key? key, required this.type})
|
||||
: super(key: key);
|
||||
const MassSendElectronicKeyPage({required this.type, Key? key}) : super(key: key);
|
||||
final String type;
|
||||
|
||||
@override
|
||||
@ -382,4 +382,5 @@ class _MassSendElectronicKeyPageState extends State<MassSendElectronicKeyPage> {
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -32,21 +32,31 @@ class LockUserListEntity {
|
||||
}
|
||||
|
||||
class LockUserItemData {
|
||||
|
||||
LockUserItemData(
|
||||
{this.uid, this.nickname, this.headUrl, this.userid, this.isCheck});
|
||||
LockUserItemData({
|
||||
this.uid,
|
||||
this.nickname,
|
||||
this.headUrl,
|
||||
this.userid,
|
||||
this.isCheck,
|
||||
this.isSendSuccess,
|
||||
this.sendFailReason,
|
||||
});
|
||||
|
||||
LockUserItemData.fromJson(Map<String, dynamic> json) {
|
||||
uid = json['uid'];
|
||||
nickname = json['nickname'];
|
||||
headUrl = json['headUrl'];
|
||||
userid = json['userid'];
|
||||
isSendSuccess = json['isSendSuccess'];
|
||||
sendFailReason = json['sendFailReason'];
|
||||
}
|
||||
int? uid;
|
||||
String? nickname;
|
||||
String? headUrl;
|
||||
String? userid;
|
||||
bool? isCheck = false;
|
||||
String? sendFailReason;
|
||||
bool? isSendSuccess = false;
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
@ -54,6 +64,8 @@ class LockUserItemData {
|
||||
data['nickname'] = nickname;
|
||||
data['headUrl'] = headUrl;
|
||||
data['userid'] = userid;
|
||||
data['isSendSuccess'] = isSendSuccess;
|
||||
data['sendFailReason'] = sendFailReason;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,15 +65,15 @@ class _MassSendReceiverPageState extends State<MassSendReceiverPage> {
|
||||
EasyLoading.showToast('接收者信息为空'.tr);
|
||||
return;
|
||||
}
|
||||
for (final LockUserItemData userItem in state.lockUserList) {
|
||||
final bool isEmail = RegexpTool.isEmail(userItem.userid ?? '');
|
||||
final bool isPhoneNumber =
|
||||
RegexpTool.isPhoneNumber(userItem.userid ?? '');
|
||||
if (!isEmail && !isPhoneNumber) {
|
||||
EasyLoading.showToast('账号格式错误'.tr);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// for (final LockUserItemData userItem in state.lockUserList) {
|
||||
// final bool isEmail = RegexpTool.isEmail(userItem.userid ?? '');
|
||||
// final bool isPhoneNumber =
|
||||
// RegexpTool.isPhoneNumber(userItem.userid ?? '');
|
||||
// if (!isEmail && !isPhoneNumber) {
|
||||
// EasyLoading.showToast('账号格式错误'.tr);
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
|
||||
// 遍历state.lockUserList,里面有重复的数据,留下第一个,其他去重
|
||||
final List<LockUserItemData> tempList = <LockUserItemData>[];
|
||||
@ -83,6 +83,18 @@ class _MassSendReceiverPageState extends State<MassSendReceiverPage> {
|
||||
}
|
||||
}
|
||||
|
||||
// 遍历state.lockUserList,如果里面LockUserItemData的userid为空提示 '请输入接收者账号' 并返回 如果nickname为空提示 '请输入接收者昵称' 并返回
|
||||
for (final LockUserItemData item in tempList) {
|
||||
if (item.userid == null || item.userid!.isEmpty) {
|
||||
EasyLoading.showToast('请输入接收者账号'.tr);
|
||||
return;
|
||||
}
|
||||
if (item.nickname == null || item.nickname!.isEmpty) {
|
||||
EasyLoading.showToast('请输入姓名'.tr);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
final Map<String, dynamic> resultMap = <String, dynamic>{};
|
||||
resultMap['lockUserList'] = tempList;
|
||||
Navigator.pop(context, resultMap);
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../../../../login/login/entity/LoginEntity.dart';
|
||||
import '../../../../../network/api_repository.dart';
|
||||
import '../../../../../tools/baseGetXController.dart';
|
||||
import '../../../../../tools/eventBusEventManage.dart';
|
||||
@ -11,7 +12,7 @@ class EditLockNameLogic extends BaseGetXController {
|
||||
|
||||
//修改锁名称请求
|
||||
Future<void> modifyKeyNameRequest() async {
|
||||
final KeyOperationRecordEntity entity = await ApiRepository.to.updateLockName(
|
||||
final LoginEntity entity = await ApiRepository.to.updateLockName(
|
||||
lockId: state.lockSetInfoData.value.lockId.toString(),
|
||||
lockName: state.changeLockNameController.text);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
|
||||
@ -5,7 +5,6 @@ import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/login/login/entity/LoginEntity.dart';
|
||||
import 'package:star_lock/main/lockMian/entity/lockListInfo_entity.dart';
|
||||
import 'package:star_lock/main/lockMian/lockMain/lockMain_logic.dart';
|
||||
import 'package:star_lock/tools/showTipView.dart';
|
||||
|
||||
import '../../../../blue/blue_manage.dart';
|
||||
@ -17,8 +16,6 @@ import '../../../../blue/io_tool/io_tool.dart';
|
||||
import '../../../../blue/io_tool/manager_event_bus.dart';
|
||||
import '../../../../blue/sender_manage.dart';
|
||||
|
||||
import '../../../../flavors.dart';
|
||||
|
||||
import '../../../../network/api_repository.dart';
|
||||
import '../../../../tools/baseGetXController.dart';
|
||||
import '../../../../tools/commonDataManage.dart';
|
||||
|
||||
@ -1602,7 +1602,9 @@ class ApiProvider extends BaseProvider {
|
||||
int startTime,
|
||||
int endTime,
|
||||
int remoteUnlockSwitch,
|
||||
int keyRight) =>
|
||||
int keyRight,
|
||||
bool isShowNetworkErrorMsg
|
||||
) =>
|
||||
post(
|
||||
batchSendKeyURL.toUrl,
|
||||
jsonEncode({
|
||||
@ -1619,7 +1621,9 @@ class ApiProvider extends BaseProvider {
|
||||
'endTime': endTime,
|
||||
'remoteUnlockSwitch': remoteUnlockSwitch,
|
||||
'keyRight': keyRight,
|
||||
}));
|
||||
}),
|
||||
isShowNetworkErrorMsg: isShowNetworkErrorMsg
|
||||
);
|
||||
|
||||
Future<Response> addAuthorizedAdmin(
|
||||
String createUser,
|
||||
|
||||
@ -35,7 +35,8 @@ class BaseProvider extends GetConnect with Api {
|
||||
Progress? uploadProgress,
|
||||
bool? isUnShowLoading = false, // 是否显示loading
|
||||
bool? isUserBaseUrl = true, // 文件上传不使用baseUrl
|
||||
bool? isShowErrMsg = true, // 文件上传不使用baseUrl
|
||||
bool? isShowErrMsg = true, // 是否显示没有网络时的提示
|
||||
bool? isShowNetworkErrorMsg = true, // 是否显示网络其他报错 如403 500等
|
||||
}) async {
|
||||
AppLog.log('post: url:$url body:$body');
|
||||
if (isUnShowLoading == false) {
|
||||
@ -77,7 +78,9 @@ class BaseProvider extends GetConnect with Api {
|
||||
statusText: res.statusText,
|
||||
);
|
||||
} else {}
|
||||
getDataResult(res.body);
|
||||
if(isShowNetworkErrorMsg ?? true){
|
||||
getDataResult(res.body);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@ -370,10 +370,10 @@ class ApiRepository {
|
||||
}
|
||||
|
||||
//修改锁名(新)
|
||||
Future<KeyOperationRecordEntity> updateLockName(
|
||||
Future<LoginEntity> updateLockName(
|
||||
{required String lockId, required String lockName}) async {
|
||||
final res = await apiProvider.updateLockName(lockId, lockName);
|
||||
return KeyOperationRecordEntity.fromJson(res.body);
|
||||
return LoginEntity.fromJson(res.body);
|
||||
}
|
||||
|
||||
//编辑电子钥匙名字
|
||||
@ -999,7 +999,9 @@ class ApiRepository {
|
||||
required int startTime,
|
||||
required int endTime,
|
||||
required int remoteUnlockSwitch,
|
||||
required int keyRight}) async {
|
||||
required int keyRight,
|
||||
required bool isShowNetworkErrorMsg
|
||||
}) async {
|
||||
final res = await apiProvider.batchSendKey(
|
||||
lockIds,
|
||||
createUser,
|
||||
@ -1013,7 +1015,9 @@ class ApiRepository {
|
||||
startTime,
|
||||
endTime,
|
||||
remoteUnlockSwitch,
|
||||
keyRight);
|
||||
keyRight,
|
||||
isShowNetworkErrorMsg
|
||||
);
|
||||
return KeyDetailEntity.fromJson(res.body);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user