From d5853eaacecf1d7eb45f65085fee289e145d5177 Mon Sep 17 00:00:00 2001 From: anfe <448468458@qq.com> Date: Thu, 6 Jun 2024 17:42:03 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E7=BE=A4=E5=8F=91?= =?UTF-8?q?=E6=89=80=E9=92=A5=E5=8C=99=E7=9A=84=E6=B7=BB=E5=8A=A0=E8=A7=A3?= =?UTF-8?q?=E9=94=81=E8=80=85=E9=80=BB=E8=BE=91=EF=BC=8C=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=EF=BC=8C=E6=97=A0=E6=B3=95=E7=AC=AC=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=E5=88=A0=E9=99=A4=EF=BC=8C=E5=88=A0=E9=99=A4=E6=8C=89?= =?UTF-8?q?=E9=92=AE=E7=82=B9=E5=87=BB=E4=B8=8D=E7=81=B5=E6=95=8F=E3=80=82?= =?UTF-8?q?=E8=BE=93=E5=85=A5=E6=89=8B=E6=9C=BA=E5=8F=B7=E6=88=96=E9=82=AE?= =?UTF-8?q?=E7=AE=B1=E6=A0=BC=E5=BC=8F=E8=AF=86=E5=88=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- android/app/build.gradle | 16 +- images/lan/lan_en.json | 7 +- images/lan/lan_keys.json | 7 +- images/lan/lan_zh.json | 16 +- .../massSendElectronicKey_page.dart | 1 - .../massSendReceiverCell.dart | 146 ++++++++++++------ .../massSendReceiver_logic.dart | 16 +- .../massSendReceiver_page.dart | 88 +++++++---- .../massSendReceiver_state.dart | 8 +- .../lockMain/xhj/lockMain_xhj_logic.dart | 12 ++ lib/mine/mine/starLockMine_logic.dart | 3 +- lib/mine/mine/starLockMine_page.dart | 2 +- .../lockUserManageList_logic.dart | 13 +- .../lockUserManageList_page.dart | 1 - lib/tools/regexp_tool.dart | 18 +++ 15 files changed, 239 insertions(+), 115 deletions(-) create mode 100644 lib/tools/regexp_tool.dart diff --git a/android/app/build.gradle b/android/app/build.gradle index e71f2d1c..d7c56a09 100755 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -52,14 +52,14 @@ android { // 这里“debug”不是一个自定义变量,而是一个特定的关键词,凡是使用--debug模式,都会引用到这里 // 目前看来,debug模式没办法在buildTypes里面按flavors指定编译签名,所有口味的debug模式只能用同一个签名 debug { - // storeFile file("starlock.keystore") - // storePassword '123456' - // keyAlias = 'starlock' - // keyPassword '123456' - storeFile file("xhj.jks") - storePassword 'xhj8872' - keyAlias = 'upload' - keyPassword 'xhj8872' + storeFile file("starlock.keystore") + storePassword '123456' + keyAlias = 'starlock' + keyPassword '123456' +// storeFile file("xhj.jks") +// storePassword 'xhj8872' +// keyAlias = 'upload' +// keyPassword 'xhj8872' } sky { // CN=Unknown, OU=Unknown, O=Unknown, L=Unknown, ST=Unknown, C=Unknown diff --git a/images/lan/lan_en.json b/images/lan/lan_en.json index 101e886b..521e460e 100755 --- a/images/lan/lan_en.json +++ b/images/lan/lan_en.json @@ -868,6 +868,9 @@ "自定义邮件模版":"Custom email template", "名称":"Name", "星星锁": "Star lock", - "为了让您及时收到重要通知和更新,我们需要获取通知权限。请点击“确定”按钮,然后在设置页面中启用通知权限。": "To receive important updates, please click 'OK' and enable notifications in the settings." - + "为了让您及时收到重要通知和更新,我们需要获取通知权限。请点击“确定”按钮,然后在设置页面中启用通知权限。": "To receive important updates, please click 'OK' and enable notifications in the settings.", + "已有": "Already has", + "新增": "New", + "账号格式错误": "The account format is incorrect", + "接收者信息为空": "The recipient information is empty" } diff --git a/images/lan/lan_keys.json b/images/lan/lan_keys.json index c8130c70..dab00332 100755 --- a/images/lan/lan_keys.json +++ b/images/lan/lan_keys.json @@ -900,6 +900,9 @@ "自定义邮件模版":"自定义邮件模版", "名称":"名称", "星星锁": "星星锁", - "为了让您及时收到重要通知和更新,我们需要获取通知权限。请点击“确定”按钮,然后在设置页面中启用通知权限。": "为了让您及时收到重要通知和更新,我们需要获取通知权限。请点击“确定”按钮,然后在设置页面中启用通知权限。" - + "为了让您及时收到重要通知和更新,我们需要获取通知权限。请点击“确定”按钮,然后在设置页面中启用通知权限。": "为了让您及时收到重要通知和更新,我们需要获取通知权限。请点击“确定”按钮,然后在设置页面中启用通知权限。", + "已有": "已有", + "新增": "新增", + "账号格式错误": "账号格式错误", + "接收者信息为空": "接收者信息为空" } diff --git a/images/lan/lan_zh.json b/images/lan/lan_zh.json index 193c6d36..ac9966e6 100755 --- a/images/lan/lan_zh.json +++ b/images/lan/lan_zh.json @@ -862,11 +862,15 @@ "五": "五", "六": "六", "日": "日", - "新建短信模版":"新建短信模版", - "新建邮件模版":"新建邮件模版", - "自定义短信模版":"自定义短信模版", - "自定义邮件模版":"自定义邮件模版", - "名称":"名称", + "新建短信模版": "新建短信模版", + "新建邮件模版": "新建邮件模版", + "自定义短信模版": "自定义短信模版", + "自定义邮件模版": "自定义邮件模版", + "名称": "名称", "星星锁": "星星锁", - "为了让您及时收到重要通知和更新,我们需要获取通知权限。请点击“确定”按钮,然后在设置页面中启用通知权限。": "为了让您及时收到重要通知和更新,我们需要获取通知权限。请点击“确定”按钮,然后在设置页面中启用通知权限。" + "为了让您及时收到重要通知和更新,我们需要获取通知权限。请点击“确定”按钮,然后在设置页面中启用通知权限。": "为了让您及时收到重要通知和更新,我们需要获取通知权限。请点击“确定”按钮,然后在设置页面中启用通知权限。", + "已有": "已有", + "新增": "新增", + "账号格式错误": "账号格式错误", + "接收者信息为空": "接收者信息为空" } diff --git a/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendElectronicKey/massSendElectronicKey_page.dart b/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendElectronicKey/massSendElectronicKey_page.dart index 12ecdf09..66ca8f01 100755 --- a/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendElectronicKey/massSendElectronicKey_page.dart +++ b/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendElectronicKey/massSendElectronicKey_page.dart @@ -170,7 +170,6 @@ class _MassSendElectronicKeyPageState extends State { if (value != null) { value as Map; state.receiverList = value['lockUserList']; - setState(() {}); } }); diff --git a/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendReceiver/massSendReceiverCell.dart b/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendReceiver/massSendReceiverCell.dart index e59c8a9a..3048b287 100755 --- a/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendReceiver/massSendReceiverCell.dart +++ b/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendReceiver/massSendReceiverCell.dart @@ -3,6 +3,7 @@ import 'package:flutter_native_contact_picker/flutter_native_contact_picker.dart import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/lockUserList/lockUserList_entity.dart'; +import 'package:star_lock/tools/regexp_tool.dart'; import 'package:star_lock/translations/trans_lib.dart'; import '../../../../../../app_settings/app_colors.dart'; @@ -13,6 +14,7 @@ class MassSendReceiverCell extends StatefulWidget { required this.onDeleteUser, Key? key, }) : super(key: key); + final int currentIndex; final LockUserItemData userData; final VoidCallback onDeleteUser; @@ -25,6 +27,7 @@ class _MassSendReceiverCellState extends State { final FlutterContactPicker contactPicker = FlutterContactPicker(); late TextEditingController _receiverController; late TextEditingController _nickNameController; + RxString errorTxt = ''.obs; @override void initState() { @@ -50,50 +53,95 @@ class _MassSendReceiverCellState extends State { @override Widget build(BuildContext context) { - return Container( - color: Colors.white, - child: Row( - children: [ - GestureDetector( - onTap: widget.onDeleteUser, - child: Padding( - padding: EdgeInsets.symmetric(horizontal: 20.w), - child: Image.asset( - 'images/icon_massSend_delete.png', - width: 26.w, - height: 26.w, + return Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + color: Colors.white, + child: Row( + children: [ + GestureDetector( + onTap: widget.onDeleteUser, + child: Container( + color: Colors.transparent, + padding: EdgeInsets.all(20.r), + child: Image.asset( + 'images/icon_massSend_delete.png', + width: 26.w, + height: 26.w, + ), + ), ), - ), + Expanded( + child: Column( + children: [ + _buildCellWidget( + leftTitle: TranslationLoader.lanKeys!.receiver!.tr, + isInputField: true, + inputHint: TranslationLoader + .lanKeys!.pleaseEnterNumberOrEmail!.tr, + controller: _receiverController, + isContactPickerEnabled: true, + onSubmitted: (String text) { + final bool isEmail = RegexpTool.isEmail(text); + final bool isPhoneNumber = + RegexpTool.isPhoneNumber(text); + if (text.trim() == '' || isEmail || isPhoneNumber) { + errorTxt.value = ''; + } else { + errorTxt.value = '账号格式错误'.tr; + } + }), + Divider( + color: AppColors.greyLineColor, + indent: 20.w, + endIndent: 20.w, + height: 1, + ), + _buildCellWidget( + leftTitle: TranslationLoader.lanKeys!.name!.tr, + isInputField: true, + inputHint: TranslationLoader.lanKeys!.enterYourName!.tr, + controller: _nickNameController, + isContactPickerEnabled: false, + onSubmitted: (String text) { + final bool isEmail = RegexpTool.isEmail(text); + final bool isPhoneNumber = + RegexpTool.isPhoneNumber(text); + if (text.trim() == '' || isEmail || isPhoneNumber) { + errorTxt.value = ''; + } else { + errorTxt.value = '账号格式错误'.tr; + } + }), + ], + ), + ), + ], ), - Expanded( - child: Column( - children: [ - _buildCellWidget( - leftTitle: TranslationLoader.lanKeys!.receiver!.tr, - isInputField: true, - inputHint: - TranslationLoader.lanKeys!.pleaseEnterNumberOrEmail!.tr, - controller: _receiverController, - isContactPickerEnabled: true, - ), - Divider( - color: AppColors.greyLineColor, - indent: 20.w, - endIndent: 20.w, - height: 1, - ), - _buildCellWidget( - leftTitle: TranslationLoader.lanKeys!.name!.tr, - isInputField: true, - inputHint: TranslationLoader.lanKeys!.enterYourName!.tr, - controller: _nickNameController, - isContactPickerEnabled: false, - ), - ], - ), - ), - ], - ), + ), + Obx(() { + return errorTxt.value.trim() != '' + ? Padding( + padding: EdgeInsets.only( + left: 80.w, + top: 10.h, + bottom: 10.h, + ), + child: Text( + errorTxt.value, + style: TextStyle( + color: Colors.red, + fontSize: 18.sp, + ), + ), + ) + : SizedBox( + height: 10.w, + ); + }), + ], ); } @@ -103,20 +151,22 @@ class _MassSendReceiverCellState extends State { required String inputHint, required TextEditingController controller, required bool isContactPickerEnabled, + ValueChanged? onSubmitted, }) { return Container( height: 60.h, padding: EdgeInsets.only(right: 20.w), child: Row( - children: [ + children: [ SizedBox(width: 20.w), Text(leftTitle, style: TextStyle(fontSize: 22.sp)), Expanded(child: SizedBox(width: 10.w)), Row( mainAxisAlignment: MainAxisAlignment.end, - children: [ + children: [ if (isInputField) - _buildTextField(controller, inputHint, isContactPickerEnabled) + _buildTextField(controller, inputHint, isContactPickerEnabled, + onSubmitted: onSubmitted) else Text( controller.text, @@ -132,11 +182,12 @@ class _MassSendReceiverCellState extends State { } Widget _buildTextField(TextEditingController controller, String hintText, - bool isContactPickerEnabled) { + bool isContactPickerEnabled, + {ValueChanged? onSubmitted}) { return SizedBox( width: 380.w, child: Row( - children: [ + children: [ Expanded( child: TextField( controller: controller, @@ -148,6 +199,7 @@ class _MassSendReceiverCellState extends State { hintStyle: TextStyle(fontSize: 22.sp), border: InputBorder.none, ), + onSubmitted: onSubmitted, ), ), if (isContactPickerEnabled) diff --git a/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendReceiver/massSendReceiver_logic.dart b/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendReceiver/massSendReceiver_logic.dart index 3de713fa..d727ec46 100755 --- a/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendReceiver/massSendReceiver_logic.dart +++ b/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendReceiver/massSendReceiver_logic.dart @@ -1,3 +1,4 @@ +import 'package:get/get.dart'; import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/lockUserList/lockUserList_entity.dart'; import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendReceiver/massSendReceiver_state.dart'; import 'package:star_lock/tools/baseGetXController.dart'; @@ -6,14 +7,25 @@ import 'package:star_lock/tools/storage.dart'; class MassSendReceiverLogic extends BaseGetXController { MassSendReceiverState state = MassSendReceiverState(); + @override + void onInit() { + super.onInit(); + final dynamic data = Get.arguments; + if (data is Map && data['lockUserList'] is List) { + data['lockUserList'].forEach((dynamic lockUser) { + state.lockUserList.add(lockUser); + }); + } + } + @override Future onReady() async { super.onReady(); - LockUserItemData data = LockUserItemData(); + final LockUserItemData data = LockUserItemData(); state.lockUserList.add(data); - var isVip = await Storage.getBool(saveIsVip); + final bool? isVip = await Storage.getBool(saveIsVip); state.isVip.value = isVip ?? false; state.isVip.refresh(); } diff --git a/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendReceiver/massSendReceiver_page.dart b/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendReceiver/massSendReceiver_page.dart index 7a6175f3..546c7215 100755 --- a/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendReceiver/massSendReceiver_page.dart +++ b/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendReceiver/massSendReceiver_page.dart @@ -1,13 +1,17 @@ import 'package:flutter/material.dart'; +import 'package:flutter_easyloading/flutter_easyloading.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_colors.dart'; +import 'package:star_lock/app_settings/app_settings.dart'; import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/lockUserList/lockUserList_entity.dart'; import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendReceiver/massSendReceiverCell.dart'; import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendReceiver/massSendReceiver_logic.dart'; -import 'package:star_lock/tools/showCupertinoAlertView.dart'; +import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendReceiver/massSendReceiver_state.dart'; import 'package:star_lock/tools/commonItem.dart'; +import 'package:star_lock/tools/regexp_tool.dart'; +import 'package:star_lock/tools/showCupertinoAlertView.dart'; import 'package:star_lock/translations/trans_lib.dart'; class MassSendReceiverPage extends StatefulWidget { @@ -20,8 +24,8 @@ class MassSendReceiverPage extends StatefulWidget { } class _MassSendReceiverPageState extends State { - final logic = Get.put(MassSendReceiverLogic()); - final state = Get.find().state; + final MassSendReceiverLogic logic = Get.put(MassSendReceiverLogic()); + final MassSendReceiverState state = Get.find().state; @override Widget build(BuildContext context) { @@ -40,7 +44,7 @@ class _MassSendReceiverPageState extends State { icon: const Icon(Icons.arrow_back_ios, color: Colors.white), onPressed: () => Navigator.of(context).pop(), ), - actions: [ + actions: [ TextButton( child: Text( TranslationLoader.lanKeys!.save!.tr, @@ -50,24 +54,37 @@ class _MassSendReceiverPageState extends State { if (!state.isVip.value) { return; } - Map resultMap = {}; - resultMap['lockUserList'] = state.lockUserList.value; + if (state.lockUserList.isEmpty) { + 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; + } + } + final Map resultMap = {}; + resultMap['lockUserList'] = state.lockUserList; Navigator.pop(context, resultMap); }, ), ], ), body: Column( - children: [ + children: [ Obx(() => Visibility( - visible: state.isVip.value ? false : true, + visible: !state.isVip.value, child: ShowCupertinoAlertView() .topTipsAdvancedFeatures('开通高级功能后才可以选择和添加接收者'.tr))), Obx(() => Visibility( - visible: state.isVip.value ? true : false, + visible: state.isVip.value, child: CommonItem( leftTitel: TranslationLoader.lanKeys!.countryAndRegion!.tr, - rightTitle: "", + rightTitle: '', isHaveLine: true, isHaveRightWidget: true, isHaveDirection: true, @@ -78,7 +95,7 @@ class _MassSendReceiverPageState extends State { fontSize: 22.sp, color: AppColors.darkGrayTextColor), ), action: () async { - var result = await Navigator.pushNamed( + final Object? result = await Navigator.pushNamed( context, Routers.selectCountryRegionPage); if (result != null) { result as Map; @@ -88,24 +105,26 @@ class _MassSendReceiverPageState extends State { } }, ))), - Obx(() => Row( - children: [controlViewTitle(0), controlViewTitle(1)], + Obx(() => Padding( + padding: EdgeInsets.symmetric(vertical: 20.h), + child: Row( + children: [controlViewTitle(0), controlViewTitle(1)], + ), )), SizedBox( height: 2.h, ), Obx(() => Visibility( - visible: state.isVip.value ? true : false, + visible: state.isVip.value, child: Expanded( child: ListView.separated( itemBuilder: (BuildContext context, int index) { - LockUserItemData data = state.lockUserList.value[index]; + final LockUserItemData data = state.lockUserList[index]; state.emailOrPhoneController.text = data.userid ?? ''; state.keyNameController.text = data.nickname ?? ''; - return _itemBuilder(index, data); }, - itemCount: state.lockUserList.value.length, + itemCount: state.lockUserList.length, separatorBuilder: (BuildContext context, int index) { return Divider( height: 20.h, @@ -129,7 +148,7 @@ class _MassSendReceiverPageState extends State { child: Row( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ Image.asset( state.isVip.value ? 'images/icon_btn_add.png' @@ -141,7 +160,7 @@ class _MassSendReceiverPageState extends State { width: 6.w, ), Text( - btnIndex == 0 ? '已有' : '新增', + btnIndex == 0 ? '已有'.tr : '新增'.tr, style: TextStyle( color: state.isVip.value ? AppColors.mainColor @@ -158,17 +177,27 @@ class _MassSendReceiverPageState extends State { } if (btnIndex == 0) { //已有 - Navigator.pushNamed(context, Routers.lockUserListPage).then((val) { + Navigator.pushNamed(context, Routers.lockUserListPage) + .then((Object? val) { if (val != null) { val as Map; - state.lockUserList.value = val['lockUserList']; - + if (val['lockUserList'] is List) { + final List uid = state.lockUserList + .where((LockUserItemData e) => e.isCheck ?? false) + .map((LockUserItemData e) => e.uid) + .toList(); + val['lockUserList'].forEach((LockUserItemData itemData) { + if (!uid.contains(itemData.uid)) { + state.lockUserList.add(itemData); + } + }); + } setState(() {}); } }); } else if (btnIndex == 1) { //新增 - state.lockUserList.value.add(LockUserItemData()); + state.lockUserList.add(LockUserItemData()); setState(() {}); } }, @@ -177,12 +206,11 @@ class _MassSendReceiverPageState extends State { Widget _itemBuilder(int index, LockUserItemData userData) { return MassSendReceiverCell( - currentIndex: index, - userData: userData, - onDeleteUser: () { - state.lockUserList.removeAt(index - 1); - setState(() {}); - }, - ); + currentIndex: index, + userData: userData, + onDeleteUser: () { + state.lockUserList.removeAt(index); + setState(() {}); + }); } } diff --git a/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendReceiver/massSendReceiver_state.dart b/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendReceiver/massSendReceiver_state.dart index a742cbfe..7617a81b 100755 --- a/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendReceiver/massSendReceiver_state.dart +++ b/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendReceiver/massSendReceiver_state.dart @@ -10,11 +10,11 @@ class MassSendReceiverState { // } // } - var isVip = false.obs; - var lockUserList = [].obs; + RxBool isVip = false.obs; + RxList lockUserList = [].obs; TextEditingController emailOrPhoneController = TextEditingController(); TextEditingController keyNameController = TextEditingController(); - var countryCode = '86'.obs; - var countryName = '中国'.obs; + RxString countryCode = '86'.obs; + RxString countryName = '中国'.obs; } diff --git a/lib/main/lockMian/lockMain/xhj/lockMain_xhj_logic.dart b/lib/main/lockMian/lockMain/xhj/lockMain_xhj_logic.dart index 0e28f379..07326628 100755 --- a/lib/main/lockMian/lockMain/xhj/lockMain_xhj_logic.dart +++ b/lib/main/lockMian/lockMain/xhj/lockMain_xhj_logic.dart @@ -5,7 +5,10 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/main/lockMian/lockMain/lockMain_page.dart'; import 'package:star_lock/main/lockMian/lockMain/xhj/lockMain_xhj_state.dart'; +import 'package:star_lock/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_entity.dart'; +import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/tools/baseGetXController.dart'; +import 'package:star_lock/tools/storage.dart'; class LockMainXHJLogic extends BaseGetXController { final LockMainXHJState state = LockMainXHJState(); @@ -17,6 +20,14 @@ class LockMainXHJLogic extends BaseGetXController { bool get isMall => state.index ==1; + //用户信息 + Future getUserInfoRequest() async { + final MinePersonInfoEntity entity = await ApiRepository.to.getUserInfo(); + if (entity.errorCode!.codeIsSuccessful) { + Storage.setBool(saveIsVip, entity.data!.isVip==1); + } + } + //打开设备弹窗 void openEquipment() { showModalBottomSheet( @@ -48,6 +59,7 @@ class LockMainXHJLogic extends BaseGetXController { @override void onInit() { super.onInit(); + getUserInfoRequest(); } @override diff --git a/lib/mine/mine/starLockMine_logic.dart b/lib/mine/mine/starLockMine_logic.dart index 106bcf08..c1d1bdf2 100755 --- a/lib/mine/mine/starLockMine_logic.dart +++ b/lib/mine/mine/starLockMine_logic.dart @@ -39,7 +39,7 @@ class StarLockMineLogic extends BaseGetXController { }); } - getMineInfoData() async { + Future getMineInfoData() async { final String? data = await Storage.getString(saveUserLoginData); if (data != null && data.isNotEmpty) { state.userNickName.value = (await Storage.getNickname())!; @@ -59,7 +59,6 @@ class StarLockMineLogic extends BaseGetXController { @override Future onInit() async { super.onInit(); - getMineInfoData(); } diff --git a/lib/mine/mine/starLockMine_page.dart b/lib/mine/mine/starLockMine_page.dart index f13d35d6..55ea2ce8 100755 --- a/lib/mine/mine/starLockMine_page.dart +++ b/lib/mine/mine/starLockMine_page.dart @@ -28,7 +28,7 @@ class StarLockMinePageState extends State with BaseWidget { final StarLockMineState state = Get.find().state; @override - initState() { + void initState() { super.initState(); logic.getUserInfoRequest(); } diff --git a/lib/mine/mineSet/lockUserManage/lockUserManageList/lockUserManageList_logic.dart b/lib/mine/mineSet/lockUserManage/lockUserManageList/lockUserManageList_logic.dart index ba999e85..39f8edf7 100755 --- a/lib/mine/mineSet/lockUserManage/lockUserManageList/lockUserManageList_logic.dart +++ b/lib/mine/mineSet/lockUserManage/lockUserManageList/lockUserManageList_logic.dart @@ -12,10 +12,11 @@ import 'lockUserManageList_state.dart'; class LockUserManageListLogic extends BaseGetXController { final LockUserManageListState state = LockUserManageListState(); + StreamSubscription? _getElectronicKeyListRefreshUIEvent; //请求锁用户列表 Future lockUserListRequest() async { - LockUserListEntity entity = + final LockUserListEntity entity = await ApiRepository.to.lockUserList(pageNo.toString(), pageSize, state.searchController.text); if(entity.errorCode!.codeIsSuccessful){ if (pageNo == 1) { @@ -23,7 +24,7 @@ class LockUserManageListLogic extends BaseGetXController { pageNo++; } else { if (entity.data!.isNotEmpty) { - state.dataList.value.addAll(entity.data!); + state.dataList.addAll(entity.data!); pageNo++; } } @@ -33,7 +34,7 @@ class LockUserManageListLogic extends BaseGetXController { //删除锁用户管理 Future deletelockUserRequest(int uid) async { - var entity = await ApiRepository.to.deletLockUser(uid); + final entity = await ApiRepository.to.deletLockUser(uid); if (entity.errorCode!.codeIsSuccessful) { EasyLoading.showToast('删除成功',duration: 2000.milliseconds); showToast('删除成功', something: (){ @@ -44,7 +45,6 @@ class LockUserManageListLogic extends BaseGetXController { } /// 刷新电子钥匙列表 - StreamSubscription? _getElectronicKeyListRefreshUIEvent; void _getElectronicKeyListRefreshUIAction() { // 蓝牙协议通知传输跟蓝牙之外的数据传输类不一样 eventBus _getElectronicKeyListRefreshUIEvent = eventBus.on().listen((event) { @@ -55,23 +55,18 @@ class LockUserManageListLogic extends BaseGetXController { @override void onReady() { - // TODO: implement onReady super.onReady(); - _getElectronicKeyListRefreshUIAction(); } @override void onInit() { - // TODO: implement onInit super.onInit(); } @override void onClose() { - // TODO: implement onClose super.onClose(); - _getElectronicKeyListRefreshUIEvent?.cancel(); } } \ No newline at end of file diff --git a/lib/mine/mineSet/lockUserManage/lockUserManageList/lockUserManageList_page.dart b/lib/mine/mineSet/lockUserManage/lockUserManageList/lockUserManageList_page.dart index 101d64b7..6a347f1c 100755 --- a/lib/mine/mineSet/lockUserManage/lockUserManageList/lockUserManageList_page.dart +++ b/lib/mine/mineSet/lockUserManage/lockUserManageList/lockUserManageList_page.dart @@ -38,7 +38,6 @@ class _LockUserManageListPageState extends State { @override void initState() { super.initState(); - getHttpData(); } diff --git a/lib/tools/regexp_tool.dart b/lib/tools/regexp_tool.dart new file mode 100644 index 00000000..0ae87b30 --- /dev/null +++ b/lib/tools/regexp_tool.dart @@ -0,0 +1,18 @@ +/// +/// 正则判断工具 +/// +class RegexpTool { + //判断手机号 + static bool isPhoneNumber(String input) { + // 手机号正则表达式 + final RegExp phoneNumberRegExp = RegExp(r'^1[0-9]{10}$'); + return phoneNumberRegExp.hasMatch(input); + } + + //判断邮箱 + static bool isEmail(String input) { + // 邮箱正则表达式 + final RegExp emailRegExp = RegExp(r'^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$'); + return emailRegExp.hasMatch(input); + } +}