1,解决N天未开门点击无效问题

2,修复实名认证使用记录页面bug
This commit is contained in:
Daisy 2024-05-22 09:16:25 +08:00
parent d5b2642efc
commit 4e81381b37
8 changed files with 235 additions and 260 deletions

View File

@ -11,32 +11,39 @@ class AddFamilyLogic extends BaseGetXController {
//
Future<void> addLockNoticeSetting() async {
final Map<String, Object?> settingValue = <String, Object?>{
'openDoorId': state.lockUserKeys.value.currentOpenDoorID,
'openDoorType': state.lockUserKeys.value.currentKeyType,
'remark': state.lockUserKeys.value.currentKeyName ?? '',
'noticeWay': getNoticeWayList(),
};
final MsgNotificationEntity 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': <Map<String, Object>>[
<String, Object>{
'type': 'mail',
'accounts': getEmailAndSMSAccountList(true)
},
<String, Object>{
'type': 'sms',
'accounts': getEmailAndSMSAccountList(false)
}
]
},
settingValue: settingValue,
);
if (entity.errorCode!.codeIsSuccessful) {
showToast('添加成功'.tr);
Get.back(result: true);
}
}
List<Map<String, Object>> getNoticeWayList() {
return <Map<String, Object>>[
<String, Object>{
'type': 'mail',
'accounts': getEmailAndSMSAccountList(true)
},
<String, Object>{
'type': 'sms',
'accounts': getEmailAndSMSAccountList(false)
},
];
}
//
Future<void> updateLockNoticeSetting() async {
final OpenDoorNotifyEntity entity =
@ -122,14 +129,14 @@ class AddFamilyLogic extends BaseGetXController {
//
bool checkBtnDisable() {
if ((state.emailListStr.value.isEmpty ||
state.phontListStr.value.isEmpty) ||
state.lockUserKeys.value.currentKeyTypeStr!.isEmpty ||
state.lockUserKeys.value.currentKeyName!.isEmpty) {
final String? keyTypeStr = state.lockUserKeys.value.currentKeyTypeStr;
final String? keyName = state.lockUserKeys.value.currentKeyName;
if (keyTypeStr == null || keyName == null) {
return false;
} else {
return true;
}
return keyTypeStr.isNotEmpty && keyName.isNotEmpty;
}
// 1: 2: 3: 4: 5:
@ -156,29 +163,27 @@ class AddFamilyLogic extends BaseGetXController {
final List<MsgNoticeModeData> mailAccounts = <MsgNoticeModeData>[];
final List<MsgNoticeModeData> smsAccounts = <MsgNoticeModeData>[];
if (state.familyData.value.settingValue != null) {
for (final NoticeWay item
in state.familyData.value.settingValue!.noticeWayList!) {
if (item.type == 'mail' && item.accounts != null) {
for (final Accounts account in item.accounts!) {
if (account.account != null) {
final MsgNoticeModeData msgNoticeModeData = MsgNoticeModeData();
msgNoticeModeData.receiveEmail = account.account!;
mailAccounts.add(msgNoticeModeData);
}
state.familyData.value.settingValue?.noticeWayList
?.forEach((NoticeWay item) {
if (item.type == 'mail') {
item.accounts?.forEach((Accounts account) {
if (account.account != null) {
final MsgNoticeModeData msgNoticeModeData = MsgNoticeModeData();
msgNoticeModeData.receiveEmail = account.account!;
mailAccounts.add(msgNoticeModeData);
}
} else if (item.type == 'sms' && item.accounts != null) {
for (final Accounts account in item.accounts!) {
if (account.account != null && account.countryCode != null) {
final MsgNoticeModeData msgNoticeModeData = MsgNoticeModeData();
msgNoticeModeData.receivePhone = account.account!;
msgNoticeModeData.countryCode = account.countryCode!;
smsAccounts.add(msgNoticeModeData);
}
});
} else if (item.type == 'sms') {
item.accounts?.forEach((Accounts account) {
if (account.account != null && account.countryCode != null) {
final MsgNoticeModeData msgNoticeModeData = MsgNoticeModeData();
msgNoticeModeData.receivePhone = account.account!;
msgNoticeModeData.countryCode = account.countryCode!;
smsAccounts.add(msgNoticeModeData);
}
}
});
}
}
});
return <String, List<MsgNoticeModeData>>{
'emailReceiverList': mailAccounts,

View File

@ -120,7 +120,7 @@ class _AddFamilyPageState extends State<AddFamilyPage> {
: logic.checkBtnDisable(),
isDelete: state.isDetail.value,
onClick: () async {
bool? isVip = await Storage.getBool(saveIsVip);
final bool? isVip = await Storage.getBool(saveIsVip);
if (isVip == true) {
if (state.isDetail.value) {
logic.deleteLockNoticeSetting();

View File

@ -5,9 +5,9 @@ import 'package:star_lock/main/lockDetail/messageWarn/msgNotification/openDoorNo
class AddFamilyState {
final TextEditingController changeNameController = TextEditingController();
var getLockId = 0.obs;
var lockUserKeys = LockUserListKeys().obs;
var emailReceiverList = [].obs;
RxInt getLockId = 0.obs;
Rx<LockUserListKeys> lockUserKeys = LockUserListKeys().obs;
RxList emailReceiverList = [].obs;
var phoneReceiverList = [].obs;
var emailListStr = ''.obs;
var phontListStr = ''.obs;

View File

@ -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/appRouters.dart';
import 'package:star_lock/app_settings/app_settings.dart';
import 'package:star_lock/main/lockDetail/messageWarn/msgNotification/msgNotification/msgNotification_entity.dart';
import 'package:star_lock/main/lockDetail/messageWarn/msgNotification/nDaysUnopened/nDaysUnopened_state.dart';
import 'package:star_lock/tools/commonItem.dart';
@ -32,122 +33,113 @@ class _NDaysUnopenedPageState extends State<NDaysUnopenedPage> {
return Scaffold(
backgroundColor: AppColors.mainBackgroundColor,
appBar: TitleAppBar(
barTitle: 'N天未开门'.tr,
haveBack: true,
backgroundColor: AppColors.mainColor),
body: ListView(
barTitle: 'N天未开门'.tr,
haveBack: true,
backgroundColor: AppColors.mainColor,
),
body: Padding(
padding: EdgeInsets.all(30.w),
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Expanded(
child: Column(
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Expanded(
child: Text(
'经过以上设定的时间,锁没有被开启,系统会给指定对象发送提醒消息,该功能需要锁联网'.tr,
style: TextStyle(
fontSize: 20.sp, color: AppColors.darkGrayTextColor),
)),
],
),
SizedBox(
height: 20.h,
),
CommonItem(
'经过以上设定的时间,锁没有被开启,系统会给指定对象发送提醒消息,该功能需要锁联网'.tr,
style: TextStyle(
fontSize: 20.sp, color: AppColors.darkGrayTextColor),
),
),
],
),
SizedBox(height: 20.h),
CommonItem(
leftTitel: 'N天未开门提醒'.tr,
rightTitle: '',
isHaveLine: true,
isHaveDirection: false,
isHaveRightWidget: true,
rightWidget: _unOpenDoorSwitch(),
action: () {}),
_buildOpenNoticeWidget(),
Expanded(
child: SizedBox(
height: 20.h,
)),
SubmitBtn(
btnName: '保存'.tr,
onClick: () async {
bool? isVip = await Storage.getBool(saveIsVip);
if (isVip == false) {
ShowCupertinoAlertView().advancedFeatureAlert();
} else {
logic.lockNoticeSettingAccountList();
}
},
),
SizedBox(
height: 60.h,
)
],
rightWidget: Obx(_unOpenDoorSwitch),
),
Obx(_buildOpenNoticeWidget),
Expanded(child: Container()),
SubmitBtn(
btnName: '保存'.tr,
onClick: () async {
final bool? isVip = await Storage.getBool(saveIsVip);
if (isVip == false) {
ShowCupertinoAlertView().advancedFeatureAlert();
} else {
logic.lockNoticeSettingAccountList();
}
},
),
SizedBox(height: 60.h),
],
),
),
);
}
Widget _buildOpenNoticeWidget() {
return Visibility(
visible: state.isUnOpenNotice.value,
child: Column(
children: <Widget>[
Obx(() => CommonItem(
leftTitel: '门未开时间'.tr,
rightTitle: '${state.unOpenDoorTime.value}',
isHaveLine: true,
isHaveRightWidget: false,
isHaveDirection: true,
action: () {
_openBottomItemSheet(context, state.unopenDoorTimeList);
},
)),
SizedBox(
height: 20.h,
),
GestureDetector(
onTap: () {
Get.toNamed(Routers.notificationModePage,
arguments: <String, MsgNoticeData>{
'msgNoticeInfo': state.msgNoticeInfo.value
})?.then((val) {
if (val != null) {
state.emailListStr.value = logic.getEmailListStr(val);
state.phontListStr.value = logic.getPhoneListStr(val);
}
});
},
child: Container(
color: Colors.white,
margin: EdgeInsets.only(bottom: 10.h),
child: Column(
children: <Widget>[
CommonItem(
leftTitel: '提醒方式'.tr,
rightTitle: '',
isHaveLine: false,
isHaveRightWidget: false,
isHaveDirection: true,
),
_buildNotifyContain('APP推送'.tr, '管理员'.tr),
Obx(() => state.emailListStr.value.isNotEmpty
? _buildNotifyContain(
'邮件提醒'.tr, state.emailListStr.value)
: Container()),
Obx(() => state.phontListStr.value.isNotEmpty
? _buildNotifyContain(
'短信提醒'.tr, state.phontListStr.value)
: Container()),
],
),
visible: state.isUnOpenNotice.value,
child: Column(
children: <Widget>[
CommonItem(
leftTitel: '门未开时间'.tr,
rightTitle: '${state.unOpenDoorTime.value}',
isHaveLine: true,
isHaveRightWidget: false,
isHaveDirection: true,
action: () {
_openBottomItemSheet(context, state.unopenDoorTimeList);
},
),
SizedBox(height: 20.h),
GestureDetector(
onTap: () {
Get.toNamed(Routers.notificationModePage,
arguments: <String, MsgNoticeData>{
'msgNoticeInfo': state.msgNoticeInfo.value
})?.then((val) {
if (val != null) {
state.emailListStr.value = logic.getEmailListStr(val);
state.phontListStr.value = logic.getPhoneListStr(val);
}
});
},
child: Container(
color: Colors.white,
margin: EdgeInsets.only(bottom: 10.h),
child: Column(
children: <Widget>[
CommonItem(
leftTitel: '提醒方式'.tr,
rightTitle: '',
isHaveLine: false,
isHaveRightWidget: false,
isHaveDirection: true,
),
_buildNotifyContain('APP推送'.tr, '管理员'.tr),
if (state.emailListStr.value.isNotEmpty)
_buildNotifyContain('邮件提醒'.tr, state.emailListStr.value),
if (state.phontListStr.value.isNotEmpty)
_buildNotifyContain('短信提醒'.tr, state.phontListStr.value),
],
),
),
],
));
),
],
),
);
}
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),
padding: EdgeInsets.symmetric(horizontal: 10.w, vertical: 12.h),
margin: EdgeInsets.symmetric(vertical: 10.h, horizontal: 20.w),
decoration: BoxDecoration(
color: AppColors.mainBackgroundColor,
borderRadius: BorderRadius.circular(6.0.w),
@ -158,14 +150,13 @@ class _NDaysUnopenedPageState extends State<NDaysUnopenedPage> {
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)),
Expanded(child: Container()),
Text(
notifyContent,
textAlign: TextAlign.end,
style: TextStyle(
color: AppColors.placeholderTextColor, fontSize: 20.sp),
),
],
),
);
@ -178,23 +169,21 @@ class _NDaysUnopenedPageState extends State<NDaysUnopenedPage> {
thumbColor: CupertinoColors.white,
value: state.isUnOpenNotice.value,
onChanged: (bool value) {
setState(() {
state.isUnOpenNotice.value = value;
if (!state.isUnOpenNotice.value) {
state.msgNoticeInfo.value = MsgNoticeData();
}
});
state.isUnOpenNotice.value = value;
if (!state.isUnOpenNotice.value) {
state.msgNoticeInfo.value = MsgNoticeData();
}
},
);
}
//pickerView
// pickerView
void _openBottomItemSheet(BuildContext context, List dataList) {
Pickers.showSinglePicker(context,
data: dataList,
pickerStyle: DefaultPickerStyle(), onConfirm: (p, int position) {
state.unOpenDoorTime.value =
int.parse(state.unopenDoorTimeList[position].replaceAll('', ''));
}, onChanged: (p, int position) {});
});
}
}

View File

@ -72,6 +72,7 @@ class RecordItem {
String? amount;
String? createdAt;
String? updatedAt;
String? useDate;
RecordItem(
{this.id,
@ -86,7 +87,8 @@ class RecordItem {
this.vipYear,
this.amount,
this.createdAt,
this.updatedAt});
this.updatedAt,
this.useDate});
RecordItem.fromJson(Map<String, dynamic> json) {
id = json['id'];
@ -102,6 +104,7 @@ class RecordItem {
amount = json['amount'];
createdAt = json['created_at'];
updatedAt = json['updated_at'];
useDate = json['useDate'];
}
Map<String, dynamic> toJson() {
@ -119,6 +122,7 @@ class RecordItem {
data['amount'] = amount;
data['created_at'] = createdAt;
data['updated_at'] = updatedAt;
data['useDate'] = useDate;
return data;
}
}

View File

@ -70,6 +70,7 @@ class UseItemData {
int? consCount;
String? createdAt;
String? updatedAt;
String? useDate;
UseItemData(
{this.id,
@ -96,6 +97,7 @@ class UseItemData {
consCount = json['cons_count'];
createdAt = json['created_at'];
updatedAt = json['updated_at'];
useDate = json['useDate'];
}
Map<String, dynamic> toJson() {
@ -111,6 +113,7 @@ class UseItemData {
data['cons_count'] = consCount;
data['created_at'] = createdAt;
data['updated_at'] = updatedAt;
data['useDate'] = useDate;
return data;
}
}

View File

@ -18,7 +18,7 @@ class ValueAddedServicesRecordLogic extends BaseGetXController {
@override
void onInit() {
super.onInit();
dynamic data = Get.arguments;
final dynamic data = Get.arguments;
if (data is! Map || data['type'] is! String) {
Get.back();
return;
@ -31,7 +31,7 @@ class ValueAddedServicesRecordLogic extends BaseGetXController {
if (!load) {
buyPageNo = 1;
}
AdvancedFunctionRecordEntity entity =
final AdvancedFunctionRecordEntity entity =
await ApiRepository.to.getBuyRecordList(
type: type,
recordType: 10,
@ -48,7 +48,7 @@ class ValueAddedServicesRecordLogic extends BaseGetXController {
if (!load) {
usePageNo = 1;
}
UseRecordListEntity entity = await ApiRepository.to.getUseRecordList(
final UseRecordListEntity entity = await ApiRepository.to.getUseRecordList(
type: type,
pageNo: buyPageNo,
);
@ -62,7 +62,7 @@ class ValueAddedServicesRecordLogic extends BaseGetXController {
void onReady() {
super.onReady();
loadBuyRecordList(true);
loadUseRecordList(true);
loadBuyRecordList(false);
loadUseRecordList(false);
}
}

View File

@ -10,16 +10,14 @@ import '../../../app_settings/app_colors.dart';
import '../../../tools/titleAppBar.dart';
class ValueAddedServicesRecordPage extends StatefulWidget {
const ValueAddedServicesRecordPage({
Key? key,
}) : super(key: key);
const ValueAddedServicesRecordPage({Key? key}) : super(key: key);
@override
State<ValueAddedServicesRecordPage> createState() =>
_ValueAddedServicesRealNamePageState();
_ValueAddedServicesRecordPageState();
}
class _ValueAddedServicesRealNamePageState
class _ValueAddedServicesRecordPageState
extends State<ValueAddedServicesRecordPage> {
@override
Widget build(BuildContext context) {
@ -43,16 +41,16 @@ class _ValueAddedServicesRealNamePageState
labelColor: AppColors.mainColor,
unselectedLabelColor: AppColors.darkGrayTextColor,
),
Obx(() => Expanded(
child: TabBarView(children: [
Expanded(
child: Obx(() => TabBarView(children: [
_PurchaseRecords(
buyRecordList: logic.state.buyRecordList.value,
),
_UseRecordsTable(
useRecordList: logic.state.useRecordList.value,
),
]),
)),
])),
),
],
),
),
@ -63,7 +61,7 @@ class _ValueAddedServicesRealNamePageState
Widget tabTextItem(String tabText) {
return Container(
margin: EdgeInsets.only(top: 16.h, bottom: 16.h),
margin: EdgeInsets.symmetric(vertical: 16.h),
child: Text(
tabText,
style: TextStyle(fontSize: 24.sp),
@ -71,29 +69,27 @@ Widget tabTextItem(String tabText) {
);
}
//
class _PurchaseRecords extends StatefulWidget {
//
class _PurchaseRecords extends StatelessWidget {
const _PurchaseRecords({required this.buyRecordList});
final List buyRecordList;
const _PurchaseRecords({required this.buyRecordList});
@override
State<_PurchaseRecords> createState() => _PurchaseRecordsState();
}
class _PurchaseRecordsState extends State<_PurchaseRecords> {
@override
Widget build(BuildContext context) {
return GetBuilder<ValueAddedServicesRecordLogic>(
builder: (ValueAddedServicesRecordLogic logic) {
return EasyRefresh(
onRefresh: () async {},
onLoad: () async {},
child: widget.buyRecordList.isNotEmpty
onRefresh: () async {
logic.loadBuyRecordList(false);
},
onLoad: () async {
logic.loadBuyRecordList(true);
},
child: buyRecordList.isNotEmpty
? ListView.builder(
itemCount: widget.buyRecordList.length,
itemCount: buyRecordList.length,
itemBuilder: (BuildContext context, int index) {
return _recordKeyItem(widget.buyRecordList[index]);
return _recordKeyItem(buyRecordList[index]);
})
: NoData(),
);
@ -103,17 +99,15 @@ class _PurchaseRecordsState extends State<_PurchaseRecords> {
Widget _recordKeyItem(RecordItem itemData) {
return Container(
color: Colors.white,
margin: EdgeInsets.only(left: 20.w, right: 20.w, top: 10.h),
padding:
EdgeInsets.only(left: 20.w, right: 20.w, top: 16.h, bottom: 16.h),
margin: EdgeInsets.symmetric(horizontal: 20.w, vertical: 10.h),
padding: EdgeInsets.all(20.w),
child: Column(
children: [
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(
children: [
children: <Widget>[
Text(
itemData.createdAt!.length > 10
? itemData.createdAt!.substring(0, 10)
: itemData.createdAt!,
itemData.createdAt?.substring(0, 10) ?? '',
style: TextStyle(
fontSize: 24.sp,
color: AppColors.blackColor,
@ -127,60 +121,53 @@ class _PurchaseRecordsState extends State<_PurchaseRecords> {
fontWeight: FontWeight.bold)),
],
),
SizedBox(
height: 8.h,
),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text('实名认证/${itemData.cloudauthCount}',
textAlign: TextAlign.left,
style: TextStyle(
fontSize: 22.sp, color: AppColors.darkGrayTextColor))
],
),
SizedBox(height: 8.h),
Text('实名认证/${itemData.cloudauthCount}',
style: TextStyle(
fontSize: 22.sp, color: AppColors.darkGrayTextColor)),
],
),
);
}
}
//使
class _UseRecordsTable extends StatefulWidget {
// 使
class _UseRecordsTable extends StatelessWidget {
const _UseRecordsTable({required this.useRecordList});
final List useRecordList;
const _UseRecordsTable({required this.useRecordList});
@override
State<_UseRecordsTable> createState() => _UseRecordsTableState();
}
class _UseRecordsTableState extends State<_UseRecordsTable> {
@override
Widget build(BuildContext context) {
return EasyRefresh(
onRefresh: () async {},
onLoad: () async {},
child: widget.useRecordList.isNotEmpty
? ListView.builder(
itemCount: widget.useRecordList.length,
itemBuilder: (BuildContext context, int index) {
return _recordKeyItem(widget.useRecordList[index]);
})
: NoData(),
);
return GetBuilder<ValueAddedServicesRecordLogic>(
builder: (ValueAddedServicesRecordLogic logic) {
return EasyRefresh(
onRefresh: () async {
logic.loadUseRecordList(false);
},
onLoad: () async {
logic.loadUseRecordList(true);
},
child: useRecordList.isNotEmpty
? ListView.builder(
itemCount: useRecordList.length,
itemBuilder: (BuildContext context, int index) {
return _recordKeyItem(useRecordList[index]);
})
: NoData(),
);
});
}
Widget _recordKeyItem(UseItemData itemData) {
return Container(
color: Colors.white,
margin: EdgeInsets.only(left: 20.w, right: 20.w, top: 10.h),
padding:
EdgeInsets.only(left: 20.w, right: 20.w, top: 16.h, bottom: 16.h),
margin: EdgeInsets.symmetric(horizontal: 20.w, vertical: 10.h),
padding: EdgeInsets.all(20.w),
child: Column(
children: [
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(
children: [
children: <Widget>[
Text(
'${itemData.lockName ?? ""} ${itemData.realName ?? ""}',
style: TextStyle(
@ -189,35 +176,22 @@ class _UseRecordsTableState extends State<_UseRecordsTable> {
fontWeight: FontWeight.bold),
),
Expanded(child: Container()),
itemData.authStatus == 0
? Container(
padding: EdgeInsets.only(
right: 6.w, left: 6.w, top: 2.h, bottom: 2.h),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5.w),
color: AppColors.toBeReceiveBgColor,
),
child: Text('失败',
style: TextStyle(fontSize: 16.sp, color: Colors.red)),
)
: Container()
],
),
SizedBox(
height: 8.h,
),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
itemData.createdAt!.length > 10
? itemData.createdAt!.substring(0, 10)
: itemData.createdAt!,
textAlign: TextAlign.left,
style: TextStyle(
fontSize: 22.sp, color: AppColors.darkGrayTextColor))
if (itemData.authStatus == 0)
Container(
padding: EdgeInsets.symmetric(horizontal: 6.w, vertical: 2.h),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5.w),
color: AppColors.toBeReceiveBgColor,
),
child: Text('失败',
style: TextStyle(fontSize: 16.sp, color: Colors.red)),
),
],
),
SizedBox(height: 8.h),
Text(itemData.useDate ?? '',
style: TextStyle(
fontSize: 22.sp, color: AppColors.darkGrayTextColor)),
],
),
);