From 4e81381b37ae2e05e296fdb6bd23bccd37ea0345 Mon Sep 17 00:00:00 2001 From: Daisy <> Date: Wed, 22 May 2024 09:16:25 +0800 Subject: [PATCH] =?UTF-8?q?1=EF=BC=8C=E8=A7=A3=E5=86=B3N=E5=A4=A9=E6=9C=AA?= =?UTF-8?q?=E5=BC=80=E9=97=A8=E7=82=B9=E5=87=BB=E6=97=A0=E6=95=88=E9=97=AE?= =?UTF-8?q?=E9=A2=98=202=EF=BC=8C=E4=BF=AE=E5=A4=8D=E5=AE=9E=E5=90=8D?= =?UTF-8?q?=E8=AE=A4=E8=AF=81=E4=BD=BF=E7=94=A8=E8=AE=B0=E5=BD=95=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../addFamily/addFamily_logic.dart | 87 +++---- .../messageWarn/addFamily/addFamily_page.dart | 2 +- .../addFamily/addFamily_state.dart | 6 +- .../nDaysUnopened/nDaysUnopened_page.dart | 215 +++++++++--------- .../advancedFunctionRecord_entity.dart | 6 +- .../use_record_list_entity.dart | 3 + .../value_added_services_record_logic.dart | 10 +- .../value_added_services_record_page.dart | 166 ++++++-------- 8 files changed, 235 insertions(+), 260 deletions(-) diff --git a/lib/main/lockDetail/messageWarn/addFamily/addFamily_logic.dart b/lib/main/lockDetail/messageWarn/addFamily/addFamily_logic.dart index 1f3ddf37..8bdf205f 100755 --- a/lib/main/lockDetail/messageWarn/addFamily/addFamily_logic.dart +++ b/lib/main/lockDetail/messageWarn/addFamily/addFamily_logic.dart @@ -11,32 +11,39 @@ class AddFamilyLogic extends BaseGetXController { //添加开门通知 Future addLockNoticeSetting() async { + final Map settingValue = { + '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': >[ - { - 'type': 'mail', - 'accounts': getEmailAndSMSAccountList(true) - }, - { - 'type': 'sms', - 'accounts': getEmailAndSMSAccountList(false) - } - ] - }, + settingValue: settingValue, ); + if (entity.errorCode!.codeIsSuccessful) { showToast('添加成功'.tr); Get.back(result: true); } } + List> getNoticeWayList() { + return >[ + { + 'type': 'mail', + 'accounts': getEmailAndSMSAccountList(true) + }, + { + 'type': 'sms', + 'accounts': getEmailAndSMSAccountList(false) + }, + ]; + } + //更新开门通知 Future 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 mailAccounts = []; final List smsAccounts = []; - 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 >{ 'emailReceiverList': mailAccounts, diff --git a/lib/main/lockDetail/messageWarn/addFamily/addFamily_page.dart b/lib/main/lockDetail/messageWarn/addFamily/addFamily_page.dart index 98259c99..4e7f53f3 100755 --- a/lib/main/lockDetail/messageWarn/addFamily/addFamily_page.dart +++ b/lib/main/lockDetail/messageWarn/addFamily/addFamily_page.dart @@ -120,7 +120,7 @@ class _AddFamilyPageState extends State { : 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(); diff --git a/lib/main/lockDetail/messageWarn/addFamily/addFamily_state.dart b/lib/main/lockDetail/messageWarn/addFamily/addFamily_state.dart index a8bfce2b..63380b14 100755 --- a/lib/main/lockDetail/messageWarn/addFamily/addFamily_state.dart +++ b/lib/main/lockDetail/messageWarn/addFamily/addFamily_state.dart @@ -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 lockUserKeys = LockUserListKeys().obs; + RxList emailReceiverList = [].obs; var phoneReceiverList = [].obs; var emailListStr = ''.obs; var phontListStr = ''.obs; diff --git a/lib/main/lockDetail/messageWarn/msgNotification/nDaysUnopened/nDaysUnopened_page.dart b/lib/main/lockDetail/messageWarn/msgNotification/nDaysUnopened/nDaysUnopened_page.dart index dbfd3b42..1aed9f7c 100755 --- a/lib/main/lockDetail/messageWarn/msgNotification/nDaysUnopened/nDaysUnopened_page.dart +++ b/lib/main/lockDetail/messageWarn/msgNotification/nDaysUnopened/nDaysUnopened_page.dart @@ -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 { 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: [ - Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Expanded( + child: Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + 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: [ - 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: { - '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: [ - 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: [ + 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: { + '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: [ + 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 { 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 { 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) {}); + }); } } diff --git a/lib/mine/valueAddedServices/advancedFunctionRecord/advancedFunctionRecord_entity.dart b/lib/mine/valueAddedServices/advancedFunctionRecord/advancedFunctionRecord_entity.dart index a68e73b6..72e4de70 100755 --- a/lib/mine/valueAddedServices/advancedFunctionRecord/advancedFunctionRecord_entity.dart +++ b/lib/mine/valueAddedServices/advancedFunctionRecord/advancedFunctionRecord_entity.dart @@ -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 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 toJson() { @@ -119,6 +122,7 @@ class RecordItem { data['amount'] = amount; data['created_at'] = createdAt; data['updated_at'] = updatedAt; + data['useDate'] = useDate; return data; } } diff --git a/lib/mine/valueAddedServices/valueAddedServicesRecord/use_record_list_entity.dart b/lib/mine/valueAddedServices/valueAddedServicesRecord/use_record_list_entity.dart index 6acd6ea7..d0d6092a 100755 --- a/lib/mine/valueAddedServices/valueAddedServicesRecord/use_record_list_entity.dart +++ b/lib/mine/valueAddedServices/valueAddedServicesRecord/use_record_list_entity.dart @@ -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 toJson() { @@ -111,6 +113,7 @@ class UseItemData { data['cons_count'] = consCount; data['created_at'] = createdAt; data['updated_at'] = updatedAt; + data['useDate'] = useDate; return data; } } diff --git a/lib/mine/valueAddedServices/valueAddedServicesRecord/value_added_services_record_logic.dart b/lib/mine/valueAddedServices/valueAddedServicesRecord/value_added_services_record_logic.dart index f7573588..c493bcb6 100755 --- a/lib/mine/valueAddedServices/valueAddedServicesRecord/value_added_services_record_logic.dart +++ b/lib/mine/valueAddedServices/valueAddedServicesRecord/value_added_services_record_logic.dart @@ -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); } } diff --git a/lib/mine/valueAddedServices/valueAddedServicesRecord/value_added_services_record_page.dart b/lib/mine/valueAddedServices/valueAddedServicesRecord/value_added_services_record_page.dart index a4cbd4c2..b8aba35b 100755 --- a/lib/mine/valueAddedServices/valueAddedServicesRecord/value_added_services_record_page.dart +++ b/lib/mine/valueAddedServices/valueAddedServicesRecord/value_added_services_record_page.dart @@ -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 createState() => - _ValueAddedServicesRealNamePageState(); + _ValueAddedServicesRecordPageState(); } -class _ValueAddedServicesRealNamePageState +class _ValueAddedServicesRecordPageState extends State { @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( 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: [ Row( - children: [ + children: [ 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( + 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: [ Row( - children: [ + children: [ 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)), ], ), );