1,新增添加开门通知接口对接

2,新增开门通知列表接口对接
3,添加邮件提醒、短信提醒多个提醒方式的逻辑处理
4,家人到家提醒模块逻辑处理及数据同步处理
This commit is contained in:
Daisy 2024-04-22 16:57:59 +08:00
parent 48d6c32afd
commit 94abb99ff2
21 changed files with 619 additions and 324 deletions

View File

@ -762,5 +762,7 @@
"自动亮屏":"Automatic bright screen", "自动亮屏":"Automatic bright screen",
"亮屏持续时间":"Screen on time", "亮屏持续时间":"Screen on time",
"逗留警告":"Stay warning", "逗留警告":"Stay warning",
"异常警告":"Abnormal warning" "异常警告":"Abnormal warning",
"短信提醒":"SMS reminder",
"邮件提醒":"Email reminder"
} }

View File

@ -761,5 +761,7 @@
"自动亮屏":"自动亮屏", "自动亮屏":"自动亮屏",
"亮屏持续时间":"亮屏持续时间", "亮屏持续时间":"亮屏持续时间",
"逗留警告":"逗留警告", "逗留警告":"逗留警告",
"异常警告":"异常警告" "异常警告":"异常警告",
"短信提醒":"短信提醒",
"邮件提醒":"邮件提醒"
} }

View File

@ -764,5 +764,7 @@
"自动亮屏":"自动亮屏", "自动亮屏":"自动亮屏",
"亮屏持续时间":"亮屏持续时间", "亮屏持续时间":"亮屏持续时间",
"逗留警告":"逗留警告", "逗留警告":"逗留警告",
"异常警告":"异常警告" "异常警告":"异常警告",
"短信提醒":"短信提醒",
"邮件提醒":"邮件提醒"
} }

View File

@ -1,6 +1,91 @@
import 'package:get/get.dart';
import 'package:star_lock/main/lockDetail/messageWarn/addFamily/addFamily_state.dart'; import 'package:star_lock/main/lockDetail/messageWarn/addFamily/addFamily_state.dart';
import 'package:star_lock/main/lockDetail/messageWarn/notificationMode/notificationMode_data.dart';
import 'package:star_lock/network/api_repository.dart';
import 'package:star_lock/tools/baseGetXController.dart'; import 'package:star_lock/tools/baseGetXController.dart';
class AddFamilyLogic extends BaseGetXController { class AddFamilyLogic extends BaseGetXController {
final AddFamilyState state = AddFamilyState(); final AddFamilyState state = AddFamilyState();
void addLockNoticeSetting() async {
var entity = await ApiRepository.to.addLockNoticeSetting(
lockId: state.getLockId.value,
noticeType: 10,
settingValue: {
'openDoorId': state.lockUserKeys.value.currentOpenDoorID,
'openDoorType': state.lockUserKeys.value.currentKeyType,
'remark': state.lockUserKeys.value.currentKeyName ?? '',
'noticeWay': [
{'type': 'mail', 'accounts': getEmailAndSMSAccountList(true)},
{'type': 'sms', 'accounts': getEmailAndSMSAccountList(false)}
]
},
);
if (entity.errorCode!.codeIsSuccessful) {
showToast('添加成功'.tr);
Get.back(result: true);
}
}
List getEmailAndSMSAccountList(bool isEmail) {
List list = [];
List accountList = [];
isEmail
? accountList = state.emailReceiverList.value
: accountList = state.phoneReceiverList.value;
for (int i = 0; i < accountList.length; i++) {
MsgNoticeModeData item = accountList[i];
Map map = {};
map['countryCode'] = isEmail ? 0 : item.countryCode;
map['account'] = isEmail ? item.receiveEmail : item.receivePhone;
list.add(map);
}
return list;
}
String getEmailListStr(Map val) {
String emailListStr = '';
if (val['emailReceiverList'] != null) {
state.emailReceiverList.value = val['emailReceiverList'];
List emailReceiverList = state.emailReceiverList.value;
for (int i = 0; i < emailReceiverList.length; i++) {
MsgNoticeModeData item = emailReceiverList[i];
emailListStr += item.receiveEmail;
//
if (i < emailReceiverList.length - 1) {
emailListStr += ',';
}
}
}
return emailListStr;
}
String getPhoneListStr(Map val) {
String phoneListStr = '';
if (val['phoneReceiverList'] != null) {
state.phoneReceiverList.value = val['phoneReceiverList'];
List phoneReceiverList = state.phoneReceiverList.value;
for (int i = 0; i < phoneReceiverList.length; i++) {
MsgNoticeModeData item = phoneReceiverList[i];
phoneListStr += item.receivePhone;
//
if (i < phoneReceiverList.length - 1) {
phoneListStr += ',';
}
}
}
return phoneListStr;
}
bool checkBtnDisable() {
if ((state.emailListStr.value.isEmpty ||
state.phontListStr.value.isEmpty) ||
state.lockUserKeys.value.currentKeyTypeStr!.isEmpty ||
state.lockUserKeys.value.currentKeyName!.isEmpty) {
return false;
} else {
return true;
}
}
} }

View File

@ -74,22 +74,23 @@ class _AddFamilyPageState extends State<AddFamilyPage> {
isHaveRightWidget: false, isHaveRightWidget: false,
isHaveDirection: true, isHaveDirection: true,
action: () { action: () {
Get.toNamed(Routers.notificationModePage); Get.toNamed(Routers.notificationModePage)?.then((val) {
if (val != null) {
state.emailListStr.value = logic.getEmailListStr(val);
state.phontListStr.value = logic.getPhoneListStr(val);
print(
'emailListStr:${state.emailListStr.value},phontListStr:${state.phontListStr.value}');
}
});
}, },
), ),
Container( _buildNotifyContain('APP推送'.tr, '管理员'.tr),
padding: EdgeInsets.only( Obx(() => state.emailListStr.value.isNotEmpty
left: 10.w, right: 10.w, top: 12.h, bottom: 12.h), ? _buildNotifyContain('邮件提醒'.tr, state.emailListStr.value)
margin: EdgeInsets.only(bottom: 20.h, top: 10.h), : Container()),
decoration: BoxDecoration( Obx(() => state.phontListStr.value.isNotEmpty
color: AppColors.mainBackgroundColor, ? _buildNotifyContain('短信提醒'.tr, state.phontListStr.value)
borderRadius: BorderRadius.circular(6.0.w), : Container()),
),
child: Text(
'${'APP推送'.tr} ${'管理员'.tr}',
style: TextStyle(color: Colors.black, fontSize: 20.sp),
),
)
], ],
), ),
), ),
@ -97,11 +98,13 @@ class _AddFamilyPageState extends State<AddFamilyPage> {
child: SizedBox( child: SizedBox(
height: 40.h, height: 40.h,
)), )),
SubmitBtn( Obx(() => SubmitBtn(
btnName: '保存'.tr, btnName: '保存'.tr,
isDisabled: false, isDisabled: logic.checkBtnDisable(),
onClick: () {}, onClick: () {
), logic.addLockNoticeSetting();
},
)),
SizedBox( SizedBox(
height: 60.h, height: 60.h,
) )
@ -111,6 +114,34 @@ class _AddFamilyPageState extends State<AddFamilyPage> {
); );
} }
Widget _buildNotifyContain(String notifyTitle, String notifyContent) {
return Container(
padding:
EdgeInsets.only(left: 10.w, right: 10.w, top: 12.h, bottom: 12.h),
margin: EdgeInsets.only(bottom: 20.h, top: 10.h, left: 20.w, right: 20.w),
decoration: BoxDecoration(
color: AppColors.mainBackgroundColor,
borderRadius: BorderRadius.circular(6.0.w),
),
child: Row(
children: [
Text(
notifyTitle,
style: TextStyle(color: Colors.black, fontSize: 20.sp),
),
Expanded(
child: SizedBox(
width: 20.w,
)),
Text(notifyContent,
textAlign: TextAlign.end,
style: TextStyle(
color: AppColors.placeholderTextColor, fontSize: 20.sp)),
],
),
);
}
// //
Widget getFamilyWidget(String tfStr) { Widget getFamilyWidget(String tfStr) {
TextEditingController emailController = TextEditingController(); TextEditingController emailController = TextEditingController();

View File

@ -4,6 +4,13 @@ import 'package:star_lock/main/lockDetail/messageWarn/lockUser/lockUser_entity.d
class AddFamilyState { class AddFamilyState {
var getLockId = 0.obs; var getLockId = 0.obs;
var lockUserKeys = LockUserListKeys().obs; var lockUserKeys = LockUserListKeys().obs;
var emailReceiverList = [].obs;
var phoneReceiverList = [].obs;
var emailListStr = ''.obs;
var phontListStr = ''.obs;
var openDoorId = 0.obs;
var openDoorType = 0.obs;
AddFamilyState() { AddFamilyState() {
Map map = Get.arguments; Map map = Get.arguments;

View File

@ -64,7 +64,7 @@ class _FamilyDetailsPageState extends State<FamilyDetailsPage> {
child: Column( child: Column(
children: [ children: [
CommonItem( CommonItem(
leftTitel: '提醒方式', leftTitel: '提醒方式'.tr,
rightTitle: "", rightTitle: "",
isHaveLine: false, isHaveLine: false,
isHaveRightWidget: false, isHaveRightWidget: false,

View File

@ -60,7 +60,7 @@ class LockUserData {
} }
class LockUserListKeys { class LockUserListKeys {
// int? id; int? id;
String? clientId; String? clientId;
int? lockOwnerId; int? lockOwnerId;
int? apiUserId; int? apiUserId;
@ -116,10 +116,10 @@ class LockUserListKeys {
String? currentKeyName; // String? currentKeyName; //
bool? isCurrentSelect; // bool? isCurrentSelect; //
int? currentDateType; // 1: 2: 3: 4: int? currentDateType; // 1: 2: 3: 4:
int? currentOpenDoorID; //ID
LockUserListKeys( LockUserListKeys(
{ {this.id,
// this.id,
this.clientId, this.clientId,
this.lockOwnerId, this.lockOwnerId,
this.apiUserId, this.apiUserId,
@ -176,7 +176,9 @@ class LockUserListKeys {
this.currentDateType}); this.currentDateType});
LockUserListKeys.fromJson(Map<String, dynamic> json) { LockUserListKeys.fromJson(Map<String, dynamic> json) {
// id = json['id']; if (json['id'] != null) {
id = json['id'];
}
clientId = json['clientId']; clientId = json['clientId'];
lockOwnerId = json['lockOwnerId']; lockOwnerId = json['lockOwnerId'];
apiUserId = json['apiUserId']; apiUserId = json['apiUserId'];
@ -243,7 +245,9 @@ class LockUserListKeys {
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{}; final Map<String, dynamic> data = <String, dynamic>{};
// data['id'] = id; if (id != null) {
data['id'] = id;
}
data['clientId'] = clientId; data['clientId'] = clientId;
data['lockOwnerId'] = lockOwnerId; data['lockOwnerId'] = lockOwnerId;
data['apiUserId'] = apiUserId; data['apiUserId'] = apiUserId;

View File

@ -24,6 +24,7 @@ class LockUserLogic extends BaseGetXController {
element.currentKeyName = element.keyName; element.currentKeyName = element.keyName;
element.isCurrentSelect = false; element.isCurrentSelect = false;
element.currentDateType = element.keyType; element.currentDateType = element.keyType;
element.currentOpenDoorID = element.id;
}); });
LockUserData data2 = entity.data![1]; LockUserData data2 = entity.data![1];
data2.lockUserList?.forEach((element) { data2.lockUserList?.forEach((element) {
@ -33,6 +34,7 @@ class LockUserLogic extends BaseGetXController {
element.currentKeyName = element.keyboardPwdName; element.currentKeyName = element.keyboardPwdName;
element.isCurrentSelect = false; element.isCurrentSelect = false;
element.currentDateType = element.keyboardPwdType; element.currentDateType = element.keyboardPwdType;
element.currentOpenDoorID = element.keyboardPwdId;
}); });
LockUserData data3 = entity.data![2]; LockUserData data3 = entity.data![2];
data3.lockUserList?.forEach((element) { data3.lockUserList?.forEach((element) {

View File

@ -46,7 +46,7 @@ class _CoerceFingerprintPageState extends State<CoerceFingerprintPage> {
child: Column( child: Column(
children: [ children: [
CommonItem( CommonItem(
leftTitel: '提醒方式', leftTitel: '提醒方式'.tr,
rightTitle: "", rightTitle: "",
isHaveLine: false, isHaveLine: false,
isHaveRightWidget: false, isHaveRightWidget: false,

View File

@ -83,7 +83,7 @@ class _NDaysUnopenedPageState extends State<NDaysUnopenedPage> {
child: Column( child: Column(
children: [ children: [
CommonItem( CommonItem(
leftTitel: '提醒方式', leftTitel: '提醒方式'.tr,
rightTitle: "", rightTitle: "",
isHaveLine: false, isHaveLine: false,
isHaveRightWidget: false, isHaveRightWidget: false,

View File

@ -0,0 +1,178 @@
class OpenDoorNotifyEntity {
int? errorCode;
String? description;
String? errorMsg;
Data? data;
OpenDoorNotifyEntity(
{this.errorCode, this.description, this.errorMsg, this.data});
OpenDoorNotifyEntity.fromJson(Map<String, dynamic> json) {
errorCode = json['errorCode'];
description = json['description'];
errorMsg = json['errorMsg'];
data = json['data'] != null ? Data.fromJson(json['data']) : null;
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['errorCode'] = errorCode;
data['description'] = description;
data['errorMsg'] = errorMsg;
if (this.data != null) {
data['data'] = this.data!.toJson();
}
return data;
}
}
class Data {
List<DataList>? list;
int? total;
int? pageNo;
int? pageSize;
Data({this.list, this.total, this.pageNo, this.pageSize});
Data.fromJson(Map<String, dynamic> json) {
if (json['list'] != null) {
list = <DataList>[];
json['list'].forEach((v) {
list!.add(DataList.fromJson(v));
});
}
total = json['total'];
pageNo = json['pageNo'];
pageSize = json['pageSize'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
if (list != null) {
data['list'] = list!.map((v) => v.toJson()).toList();
}
data['total'] = total;
data['pageNo'] = pageNo;
data['pageSize'] = pageSize;
return data;
}
}
class DataList {
int? id;
int? lockId;
int? noticeType;
SettingValue? settingValue;
String? createdAt;
String? updatedAt;
DataList(
{this.id,
this.lockId,
this.noticeType,
this.settingValue,
this.createdAt,
this.updatedAt});
DataList.fromJson(Map<String, dynamic> json) {
id = json['id'];
lockId = json['lockId'];
noticeType = json['noticeType'];
settingValue = json['settingValue'] != null
? SettingValue.fromJson(json['settingValue'])
: null;
createdAt = json['created_at'];
updatedAt = json['updated_at'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['lockId'] = lockId;
data['noticeType'] = noticeType;
if (settingValue != null) {
data['settingValue'] = settingValue!.toJson();
}
data['created_at'] = createdAt;
data['updated_at'] = updatedAt;
return data;
}
}
class SettingValue {
int? openDoorId;
int? openDoorType;
String? remark;
List<NoticeWay>? noticeWay;
SettingValue(
{this.openDoorId, this.openDoorType, this.remark, this.noticeWay});
SettingValue.fromJson(Map<String, dynamic> json) {
openDoorId = json['openDoorId'];
openDoorType = json['openDoorType'];
remark = json['remark'];
if (json['noticeWay'] != null) {
noticeWay = <NoticeWay>[];
json['noticeWay'].forEach((v) {
noticeWay!.add(NoticeWay.fromJson(v));
});
}
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['openDoorId'] = openDoorId;
data['openDoorType'] = openDoorType;
data['remark'] = remark;
if (noticeWay != null) {
data['noticeWay'] = noticeWay!.map((v) => v.toJson()).toList();
}
return data;
}
}
class NoticeWay {
String? type;
List<Accounts>? accounts;
NoticeWay({this.type, this.accounts});
NoticeWay.fromJson(Map<String, dynamic> json) {
type = json['type'];
if (json['accounts'] != null) {
accounts = <Accounts>[];
json['accounts'].forEach((v) {
accounts!.add(Accounts.fromJson(v));
});
}
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['type'] = type;
if (accounts != null) {
data['accounts'] = accounts!.map((v) => v.toJson()).toList();
}
return data;
}
}
class Accounts {
int? countryCode;
String? account;
Accounts({this.countryCode, this.account});
Accounts.fromJson(Map<String, dynamic> json) {
countryCode = json['countryCode'];
account = json['account'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['countryCode'] = countryCode;
data['account'] = account;
return data;
}
}

View File

@ -1,6 +1,19 @@
import 'package:star_lock/main/lockDetail/messageWarn/msgNotification/openDoorNotify/openDoorNotify_entity.dart';
import 'package:star_lock/network/api_repository.dart';
import 'package:star_lock/tools/baseGetXController.dart'; import 'package:star_lock/tools/baseGetXController.dart';
import 'openDoorNotify_state.dart'; import 'openDoorNotify_state.dart';
class OpenDoorNotifyLogic extends BaseGetXController { class OpenDoorNotifyLogic extends BaseGetXController {
final OpenDoorNotifyState state = OpenDoorNotifyState(); final OpenDoorNotifyState state = OpenDoorNotifyState();
void lockNoticeSettingAccountList() async {
OpenDoorNotifyEntity entity =
await ApiRepository.to.lockNoticeSettingAccountList(
lockId: state.getLockId.value,
noticeType: 10,
);
if (entity.errorCode!.codeIsSuccessful) {
state.openDoorNotifyList.value = entity.data!.list!;
}
}
} }

View File

@ -22,6 +22,8 @@ class _OpenDoorNotifyPageState extends State<OpenDoorNotifyPage> {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
logic.lockNoticeSettingAccountList();
} }
@override @override
@ -39,12 +41,17 @@ class _OpenDoorNotifyPageState extends State<OpenDoorNotifyPage> {
SizedBox( SizedBox(
height: 20.h, height: 20.h,
), ),
Expanded(child: _buildMainUI()), Expanded(child: Obx(() => _buildMainUI())),
AddBottomWhiteBtn( AddBottomWhiteBtn(
btnName: '添加家人'.tr, btnName: '添加家人'.tr,
onClick: () { onClick: () {
Get.toNamed(Routers.addFamilyPage, Get.toNamed(Routers.addFamilyPage,
arguments: {'getLockId': state.getLockId.value}); arguments: {'getLockId': state.getLockId.value})
?.then((value) {
if (value != null) {
logic.lockNoticeSettingAccountList();
}
});
}, },
), ),
SizedBox( SizedBox(
@ -67,7 +74,7 @@ class _OpenDoorNotifyPageState extends State<OpenDoorNotifyPage> {
Widget _buildMainUI() { Widget _buildMainUI() {
return ListView.separated( return ListView.separated(
shrinkWrap: true, shrinkWrap: true,
itemCount: state.msgNoticeInfo.value.openDoorNoticeList?.length ?? 0, itemCount: state.openDoorNotifyList.length,
itemBuilder: (c, index) { itemBuilder: (c, index) {
return _electronicKeyItem( return _electronicKeyItem(
'images/controls_user.png', '18682150237', '电子钥匙', () { 'images/controls_user.png', '18682150237', '电子钥匙', () {

View File

@ -7,6 +7,7 @@ class OpenDoorNotifyState {
final pageSize = 20.obs; // final pageSize = 20.obs; //
var itemDataList = [].obs; var itemDataList = [].obs;
var getLockId = 0.obs; var getLockId = 0.obs;
var openDoorNotifyList = [].obs;
OpenDoorNotifyState() { OpenDoorNotifyState() {
Map map = Get.arguments; Map map = Get.arguments;

View File

@ -0,0 +1,8 @@
import 'package:flutter/material.dart';
class MsgNoticeModeData {
final TextEditingController receiverTF = TextEditingController();
var receiveEmail = '';
var receivePhone = '';
var countryCode = 86;
}

View File

@ -1,7 +1,10 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:star_lock/appRouters.dart'; import 'package:star_lock/appRouters.dart';
import 'package:star_lock/main/lockDetail/messageWarn/msgNotification/msgNotification/msgNotification_entity.dart';
import 'package:star_lock/main/lockDetail/messageWarn/notificationMode/notificationMode_data.dart';
import 'package:star_lock/main/lockDetail/messageWarn/notificationMode/notificationMode_logic.dart'; import 'package:star_lock/main/lockDetail/messageWarn/notificationMode/notificationMode_logic.dart';
import 'package:star_lock/tools/commonItem.dart'; import 'package:star_lock/tools/commonItem.dart';
import 'package:star_lock/tools/submitBtn.dart'; import 'package:star_lock/tools/submitBtn.dart';
@ -31,11 +34,11 @@ class _NotificationModePageState extends State<NotificationModePage> {
return Scaffold( return Scaffold(
backgroundColor: AppColors.mainBackgroundColor, backgroundColor: AppColors.mainBackgroundColor,
appBar: TitleAppBar( appBar: TitleAppBar(
barTitle: '提醒方式', barTitle: '提醒方式'.tr,
haveBack: true, haveBack: true,
backgroundColor: AppColors.mainColor), backgroundColor: AppColors.mainColor),
body: SingleChildScrollView( body: SingleChildScrollView(
child: _buildMainView(), child: Obx(() => _buildMainView()),
)); ));
} }
@ -43,297 +46,218 @@ class _NotificationModePageState extends State<NotificationModePage> {
return Column( return Column(
children: [ children: [
CommonItem( CommonItem(
leftTitel: 'APP推送', leftTitel: 'APP推送'.tr,
rightTitle: '管理员', rightTitle: '管理员'.tr,
isHaveLine: true, isHaveLine: true,
isHaveDirection: false, isHaveDirection: false,
action: () {}), action: () {}),
SizedBox( SizedBox(
height: 10.h, height: 10.h,
), ),
CommonItem( _buildNotifyWayItem('邮件提醒'.tr, isEmail: true),
leftTitel: '邮件提醒', _buildListView(isEmail: true),
rightTitle: '',
isHaveLine: true,
isHaveDirection: false,
isHaveRightWidget: true,
rightWidget: state.emailReceiverList.value.length < 3
? Image.asset(
'images/icon_btn_add.png',
width: 32.w,
height: 32.w,
)
: Container(),
action: () {
if (state.emailReceiverList.value.length < 3) {
setState(() {
state.emailReceiverList.value.add(1);
});
}
}),
Obx(() => SizedBox(
height: state.emailReceiverList.value.length * 62.h,
child: ListView.separated(
itemCount: state.emailReceiverList.value.length,
itemBuilder: (BuildContext context, int index) {
return _buildReceiverItem(index, true);
},
separatorBuilder: (BuildContext context, int index) {
return Divider(
height: 1.h,
color: AppColors.greyBackgroundColor,
);
},
),
)),
SizedBox( SizedBox(
height: 10.h, height: 10.h,
), ),
CommonItem( _buildNotifyWayItem('短信提醒'.tr, isEmail: false),
leftTitel: '短信提醒', _buildListView(isEmail: false),
rightTitle: '',
isHaveLine: true,
isHaveDirection: false,
isHaveRightWidget: true,
rightWidget: state.phoneReceiverList.value.length < 3
? Image.asset(
'images/icon_btn_add.png',
width: 32.w,
height: 32.w,
)
: Container(),
action: () {
if (state.phoneReceiverList.value.length < 3) {
setState(() {
state.phoneReceiverList.value.add(1);
});
}
}),
SizedBox(
height: state.phoneReceiverList.value.length * 62.h,
child: ListView.separated(
itemCount: state.phoneReceiverList.value.length,
itemBuilder: (BuildContext context, int index) {
return _buildReceiverItem(index, false);
},
separatorBuilder: (BuildContext context, int index) {
return Divider(
height: 1.h,
color: AppColors.greyBackgroundColor,
);
},
),
),
SizedBox( SizedBox(
height: 60.h, height: 60.h,
), ),
SubmitBtn( SubmitBtn(
btnName: '确定'.tr, btnName: '确定'.tr,
onClick: () {}, onClick: () {
Get.back(result: {
'emailReceiverList': state.emailReceiverList.value,
'phoneReceiverList': state.phoneReceiverList.value
});
},
) )
], ],
); );
} }
Widget _buildReceiverItem(int index, bool isEmail) { Widget _buildNotifyWayItem(String title, {required bool isEmail}) {
return CommonItem(
leftTitel: title,
rightTitle: '',
isHaveLine: true,
isHaveDirection: false,
isHaveRightWidget: true,
rightWidget: (!isEmail
? state.phoneReceiverList.value.length < 3
: state.emailReceiverList.value.length < 3)
? Image.asset(
'images/icon_btn_add.png',
width: 32.w,
height: 32.w,
)
: Container(),
action: () {
if (isEmail) {
if (state.emailReceiverList.value.length < 3) {
state.emailReceiverList.value.add(MsgNoticeModeData());
}
state.emailReceiverList.refresh();
} else {
if (state.phoneReceiverList.value.length < 3) {
state.phoneReceiverList.value.add(MsgNoticeModeData());
}
state.phoneReceiverList.refresh();
}
});
}
Widget _buildListView({required bool isEmail}) {
return SizedBox(
height: isEmail
? state.emailReceiverList.value.length * 62.h
: state.phoneReceiverList.value.length * 62.h,
child: ListView.separated(
itemCount: isEmail
? state.emailReceiverList.value.length
: state.phoneReceiverList.value.length,
itemBuilder: (BuildContext context, int index) {
return _buildReceiverItemWidget(index, isEmail: isEmail);
},
separatorBuilder: (BuildContext context, int index) {
return Divider(
height: 1.h,
color: AppColors.greyBackgroundColor,
);
},
),
);
}
Widget _buildReceiverItemWidget(int index, {required bool isEmail}) {
return Container( return Container(
padding: EdgeInsets.only(left: 20.w, right: 20.w),
height: 62.h,
color: Colors.white, color: Colors.white,
child: Row( child: Row(
children: [ children: [
GestureDetector( GestureDetector(
child: SizedBox( onTap: (() {
// width: 40.w, if (isEmail) {
child: Row( state.emailReceiverList.value.removeAt(index);
children: [ state.emailReceiverList.refresh();
SizedBox( } else {
width: 20.w, state.phoneReceiverList.value.removeAt(index);
), state.phoneReceiverList.refresh();
Image.asset(
'images/icon_massSend_delete.png',
width: 26.w,
height: 26.w,
)
],
),
),
onTap: () {
setState(() {
if (isEmail) {
state.emailReceiverList.value.removeAt(index);
} else {
state.phoneReceiverList.value.removeAt(index);
}
});
},
),
Expanded(
child: Column(
children: [
massSendReceiverCellWidget(
leftTitel: TranslationLoader.lanKeys!.receiver!.tr,
rightTitle: state.inputEmailStr.value,
isHaveLine: true,
isHaveRightWidget: true,
rightWidget: isEmail
? getEmailTFWidget('请输入Email'.tr, 1)
: getPhoneWidget('请输入手机号'.tr, 1)),
Divider(
color: AppColors.greyLineColor,
indent: 20.w,
endIndent: 20.w,
height: 1,
),
],
))
],
),
);
}
// TextEditingController _receiverController(String getStr) {
// TextEditingController controller = TextEditingController(text: getStr);
// controller.addListener(() {
// state.inputEmailStr.value = controller.text;
// print(controller.text);
// });
// return controller;
// }
//
Widget getEmailTFWidget(String tfStr, int lineIndex) {
TextEditingController emailController = TextEditingController();
return SizedBox(
height: 50.h,
width: 360.w,
child: Row(
children: [
Expanded(
child: TextField(
controller: emailController,
//
maxLines: 1,
autofocus: false,
textAlign: TextAlign.end,
decoration: InputDecoration(
hintText: tfStr,
hintStyle: TextStyle(fontSize: 22.sp),
//线
border: InputBorder.none,
),
),
),
],
),
);
}
//
Widget getPhoneWidget(String tfStr, int lineIndex) {
TextEditingController phoneController = TextEditingController();
return SizedBox(
height: 50.h,
width: 360.w,
child: Row(
children: [
Expanded(
child: GestureDetector(
child: Container(
width: 90.w,
color: Colors.white,
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Obx(() => Text(
'+${state.countryCode}',
style: TextStyle(
color: AppColors.darkGrayTextColor,
fontSize: 20.sp),
)),
Image.asset(
'images/icon_grayPullDown.png',
width: 20.w,
height: 20.w,
),
],
),
),
onTap: () async {
var result = await Get.toNamed(Routers.selectCountryRegionPage);
if (result != null) {
result as Map<String, dynamic>;
state.countryCode.value = result['code'];
state.countryName.value = result['countryName'];
} }
}, }),
)), child: Container(
SizedBox( color: Colors.white,
width: 5.w, child: Image.asset(
), 'images/icon_massSend_delete.png',
SizedBox( width: 26.w,
width: 180.w, height: 26.w,
child: TextField(
controller: phoneController,
//
maxLines: 1,
autofocus: false,
textAlign: TextAlign.end,
decoration: InputDecoration(
hintText: tfStr,
hintStyle: TextStyle(fontSize: 22.sp),
//线
border: InputBorder.none,
), ),
), ),
), ),
SizedBox(
width: 20.w,
),
Text(
TranslationLoader.lanKeys!.receiver!.tr,
style: TextStyle(fontSize: 22.sp),
),
Expanded(child: SizedBox(width: 10.w)),
!isEmail
? GestureDetector(
child: Container(
width: 90.w,
color: Colors.white,
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Obx(() => Text(
'+${state.countryCode}',
style: TextStyle(
color: AppColors.darkGrayTextColor,
fontSize: 20.sp),
)),
Image.asset(
'images/icon_grayPullDown.png',
width: 20.w,
height: 20.w,
),
],
),
),
onTap: () async {
var result =
await Get.toNamed(Routers.selectCountryRegionPage);
if (result != null) {
result as Map<String, dynamic>;
state.countryCode.value = result['code'];
state.countryName.value = result['countryName'];
}
},
)
: Container(),
getReceiverTFWidget(isEmail ? '请输入Email'.tr : '请输入手机号', index,
isEmail: isEmail)
], ],
), ),
); );
} }
Widget massSendReceiverCellWidget({ //
String? leftTitel, Widget getReceiverTFWidget(String tfStr, int lineIndex,
String? rightTitle, {required bool isEmail}) {
bool? isHaveDirection, MsgNoticeModeData msgData = isEmail
bool? isHaveLine, ? state.emailReceiverList.value[lineIndex]
bool? isHaveRightWidget, : state.phoneReceiverList.value[lineIndex];
Widget? rightWidget, return SizedBox(
Function()? action, height: 65.h,
double? allHeight, width: 200.w,
}) { child: Row(
return Column( children: [
// mainAxisAlignment: MainAxisAlignment.center, Expanded(
children: [ child: TextField(
Container( controller: msgData.receiverTF,
height: 60.h, //
color: Colors.white, maxLines: 1,
padding: EdgeInsets.only(right: 20.w), // , top: 20.w, bottom: 20.w inputFormatters: <TextInputFormatter>[
child: Row( FilteringTextInputFormatter.deny('\n'),
children: [ LengthLimitingTextInputFormatter(30),
SizedBox(width: 20.w), ],
Text(leftTitel!, style: TextStyle(fontSize: 22.sp)), autofocus: false,
Expanded(child: SizedBox(width: 10.w)), textAlign: TextAlign.end,
Row( decoration: InputDecoration(
mainAxisAlignment: MainAxisAlignment.end, hintText: tfStr,
children: [ hintStyle: TextStyle(fontSize: 22.sp),
isHaveRightWidget! focusedBorder: const OutlineInputBorder(
? rightWidget! borderSide:
: Text( BorderSide(width: 0, color: Colors.transparent)),
rightTitle ?? "", disabledBorder: const OutlineInputBorder(
textAlign: TextAlign.end, borderSide:
// overflow: TextOverflow.ellipsis, BorderSide(width: 0, color: Colors.transparent)),
// maxLines: 1, enabledBorder: const OutlineInputBorder(
style: TextStyle( borderSide:
fontSize: 22.sp, BorderSide(width: 0, color: Colors.transparent)),
color: AppColors.darkGrayTextColor), border: const OutlineInputBorder(
) borderSide:
], BorderSide(width: 0, color: Colors.transparent)),
) contentPadding: const EdgeInsets.symmetric(vertical: 0),
], ),
style: TextStyle(
fontSize: 22.sp, textBaseline: TextBaseline.alphabetic),
onChanged: (value) {
if (isEmail) {
msgData.receiveEmail = value;
state.emailReceiverList.value[lineIndex] = msgData;
} else {
msgData.receivePhone = value;
state.phoneReceiverList.value[lineIndex] = msgData;
}
},
),
), ),
) ],
], ),
); );
} }
} }

View File

@ -1,9 +1,9 @@
import 'package:get/get.dart'; import 'package:get/get.dart';
class NotificationModeState { class NotificationModeState {
var inputEmailStr = ''.obs; //
var emailReceiverList = [].obs; var emailReceiverList = [].obs;
var phoneReceiverList = [].obs; var phoneReceiverList = [].obs;
var countryName = '中国'.obs; var countryName = '中国'.obs;
var countryCode = '86'.obs; var countryCode = 86.obs;
} }

View File

@ -45,7 +45,8 @@ abstract class Api {
final String passwordKeyGetURL = '/keyboardPwd/get'; // final String passwordKeyGetURL = '/keyboardPwd/get'; //
final String passwordKeyAddURL = '/keyboardPwd/add'; // final String passwordKeyAddURL = '/keyboardPwd/add'; //
final String passwordKeyCheckKeyboardpwdNameURL = '/keyboardPwd/checkKeyboardpwdName'; // final String passwordKeyCheckKeyboardpwdNameURL =
'/keyboardPwd/checkKeyboardpwdName'; //
final String updatePasswordKeyURL = '/keyboardPwd/update'; // final String updatePasswordKeyURL = '/keyboardPwd/update'; //
final String updatePWDNumberURL = '/keyboardPwd/updatePwdUserNo'; // final String updatePWDNumberURL = '/keyboardPwd/updatePwdUserNo'; //
final String clearOperationRecordURL = '/lockRecords/clear'; // final String clearOperationRecordURL = '/lockRecords/clear'; //
@ -199,6 +200,10 @@ abstract class Api {
final String updateLockNoticeSettingURL = final String updateLockNoticeSettingURL =
'/lockSetting/updateLockNoticeSetting'; // '/lockSetting/updateLockNoticeSetting'; //
final String lockKeysListURL = '/lock/lockKeysList'; // final String lockKeysListURL = '/lock/lockKeysList'; //
final String addLockNoticeSettingURL =
'/lockNoticeSettingAccount/add'; //
final String lockNoticeSettingListURL =
'/lockNoticeSettingAccount/list'; //
final String setWechatPushSwitchURL = final String setWechatPushSwitchURL =
'/user/setMpWechatPushSwitch'; // '/user/setMpWechatPushSwitch'; //

View File

@ -432,12 +432,15 @@ class ApiProvider extends BaseProvider {
})); }));
// //
Future<Response> updatePWDNumber(String lockId, String keyboardPwdId, String pwdUserNo) => post( Future<Response> updatePWDNumber(
updatePWDNumberURL.toUrl, String lockId, String keyboardPwdId, String pwdUserNo) =>
jsonEncode({ post(
'lockId': lockId, updatePWDNumberURL.toUrl,
'keyboardPwdId': keyboardPwdId, jsonEncode({
'pwdUserNo': pwdUserNo})); 'lockId': lockId,
'keyboardPwdId': keyboardPwdId,
'pwdUserNo': pwdUserNo
}));
Future<Response> addKeyboardPwd( Future<Response> addKeyboardPwd(
String lockId, String lockId,
@ -1861,6 +1864,22 @@ class ApiProvider extends BaseProvider {
Future<Response> getLockKeysList(int lockId) => Future<Response> getLockKeysList(int lockId) =>
post(lockKeysListURL.toUrl, jsonEncode({'lockId': lockId})); post(lockKeysListURL.toUrl, jsonEncode({'lockId': lockId}));
//
Future<Response> addLockNoticeSetting(
int lockId, int noticeType, Map settingValue) =>
post(
addLockNoticeSettingURL.toUrl,
jsonEncode({
'lockId': lockId,
'noticeType': noticeType,
'settingValue': settingValue
}));
//
Future<Response> lockNoticeSettingAccountList(int lockId, int noticeType) =>
post(lockNoticeSettingListURL.toUrl,
jsonEncode({'lockId': lockId, 'noticeType': noticeType}));
// //
Future<Response> setMpWechatPushSwitch(int mpWechatPushSwitch) => post( Future<Response> setMpWechatPushSwitch(int mpWechatPushSwitch) => post(
setWechatPushSwitchURL.toUrl, setWechatPushSwitchURL.toUrl,

View File

@ -48,6 +48,7 @@ import '../main/lockDetail/lockSet/lockSet/lockSetInfo_entity.dart';
import '../main/lockDetail/lockSet/lockTime/getServerDatetime_entity.dart'; import '../main/lockDetail/lockSet/lockTime/getServerDatetime_entity.dart';
import '../main/lockDetail/lockDetail/lockNetToken_entity.dart'; import '../main/lockDetail/lockDetail/lockNetToken_entity.dart';
import '../main/lockDetail/lockOperatingRecord/lockOperatingRecordGetLastRecordTime_entity.dart'; import '../main/lockDetail/lockOperatingRecord/lockOperatingRecordGetLastRecordTime_entity.dart';
import '../main/lockDetail/messageWarn/msgNotification/openDoorNotify/openDoorNotify_entity.dart';
import '../main/lockMian/entity/lockListInfo_entity.dart'; import '../main/lockMian/entity/lockListInfo_entity.dart';
import '../mine/addLock/saveLock/entity/SaveLockEntity.dart'; import '../mine/addLock/saveLock/entity/SaveLockEntity.dart';
import '../mine/message/messageList/messageList_entity.dart'; import '../mine/message/messageList/messageList_entity.dart';
@ -447,13 +448,10 @@ class ApiRepository {
// //
Future<PasswordKeyEntity> updatePWDNumber( Future<PasswordKeyEntity> updatePWDNumber(
{required String lockId, {required String lockId,
required String keyboardPwdId, required String keyboardPwdId,
required String pwdUserNo}) async { required String pwdUserNo}) async {
final res = await apiProvider.updatePWDNumber( final res =
lockId, await apiProvider.updatePWDNumber(lockId, keyboardPwdId, pwdUserNo);
keyboardPwdId,
pwdUserNo
);
return PasswordKeyEntity.fromJson(res.body); return PasswordKeyEntity.fromJson(res.body);
} }
@ -668,11 +666,9 @@ class ApiRepository {
// //
Future<PasswordKeyEntity> deleteKeyboardPwd( Future<PasswordKeyEntity> deleteKeyboardPwd(
{ {required String lockId,
required String lockId, required String keyboardPwdId,
required String keyboardPwdId, required int deleteType}) async {
required int deleteType
}) async {
final res = final res =
await apiProvider.deleteKeyboardPwd(lockId, keyboardPwdId, deleteType); await apiProvider.deleteKeyboardPwd(lockId, keyboardPwdId, deleteType);
return PasswordKeyEntity.fromJson(res.body); return PasswordKeyEntity.fromJson(res.body);
@ -1350,17 +1346,8 @@ class ApiRepository {
required String addType, required String addType,
required List weekDay, required List weekDay,
required int faceRight}) async { required int faceRight}) async {
final res = await apiProvider.addFaceData( final res = await apiProvider.addFaceData(lockId, faceName, faceNumber,
lockId, faceType, startDate, endDate, featureData, addType, weekDay, faceRight);
faceName,
faceNumber,
faceType,
startDate,
endDate,
featureData,
addType,
weekDay,
faceRight);
return AddFaceEntity.fromJson(res.body); return AddFaceEntity.fromJson(res.body);
} }
@ -1893,6 +1880,24 @@ class ApiRepository {
return LockUserEntity.fromJson(res.body); return LockUserEntity.fromJson(res.body);
} }
//
Future<MsgNotificationEntity> addLockNoticeSetting(
{required int lockId,
required int noticeType,
required Map settingValue}) async {
final res = await apiProvider.addLockNoticeSetting(
lockId, noticeType, settingValue);
return MsgNotificationEntity.fromJson(res.body);
}
//
Future<OpenDoorNotifyEntity> lockNoticeSettingAccountList(
{required int lockId, required int noticeType}) async {
final res =
await apiProvider.lockNoticeSettingAccountList(lockId, noticeType);
return OpenDoorNotifyEntity.fromJson(res.body);
}
// //
Future<VersionUndateEntity> setMpWechatPushSwitch( Future<VersionUndateEntity> setMpWechatPushSwitch(
{required int mpWechatPushSwitch}) async { {required int mpWechatPushSwitch}) async {