diff --git a/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_logic.dart b/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_logic.dart new file mode 100644 index 00000000..0aba9876 --- /dev/null +++ b/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_logic.dart @@ -0,0 +1,48 @@ +import 'package:star_lock/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_state.dart'; +import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart'; +import 'package:star_lock/network/api_repository.dart'; +import 'package:star_lock/tools/baseGetXController.dart'; + +class AuthorizedAdminListLogic extends BaseGetXController { + final AuthorizedAdminListState state = AuthorizedAdminListState(); + + //请求电子钥匙列表 + Future> mockNetworkDataRequest() async { + ElectronicKeyListEntity entity = await ApiRepository.to.electronicKeyList( + '0', + state.keyInfo.value.keyId.toString(), + '', + state.keyInfo.value.lockId.toString(), + '', + state.pageNum.toString(), + state.pageSize.toString(), + '0', + '0'); + List dataList = []; + if (entity.errorCode!.codeIsSuccessful) { + print("电子钥匙列表成功:${entity.data?.itemList}"); + if (entity.data != null) { + dataList = entity.data!.itemList; + } + } + state.itemDataList.value = dataList; + return dataList; + } + + @override + void onReady() { + // TODO: implement onReady + super.onReady(); + } + + @override + void onInit() { + // TODO: implement onInit + super.onInit(); + } + + @override + void onClose() { + // TODO: implement onClose + } +} diff --git a/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_page.dart b/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_page.dart index 8cb98928..c67cfbd1 100644 --- a/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_page.dart +++ b/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_page.dart @@ -2,11 +2,10 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart'; +import 'package:star_lock/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_logic.dart'; import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart'; -import 'package:star_lock/main/lockMian/entity/lockInfoEntity.dart'; -import 'package:star_lock/network/api_repository.dart'; -import 'package:star_lock/tools/baseGetXController.dart'; import 'package:star_lock/tools/noData.dart'; +import 'package:star_lock/tools/storage.dart'; import '../../../../appRouters.dart'; import '../../../../app_settings/app_colors.dart'; @@ -23,27 +22,75 @@ class AuthorizedAdminListPage extends StatefulWidget { } class _AuthorizedAdminListPageState extends State { - late KeyInfos keyInfo; - late LockMainEntity lockMainEntity; + final logic = Get.put(AuthorizedAdminListLogic()); + final state = Get.find().state; + + // late KeyInfos keyInfo; + // late LockMainEntity lockMainEntity; + + @override + void initState() { + super.initState(); + + mockRequest(); + } + + Future mockRequest() async { + // 获取是否是演示模式 演示模式不获取接口 + var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); + if (isDemoMode == false) { + logic.mockNetworkDataRequest(); + } + } @override Widget build(BuildContext context) { - dynamic obj = ModalRoute.of(context)?.settings.arguments; - if (obj != null && (obj["lockMainEntity"] != null)) { - lockMainEntity = obj["lockMainEntity"]; - } - if (obj != null && (obj["keyInfo"] != null)) { - keyInfo = obj["keyInfo"]; - } + // dynamic obj = ModalRoute.of(context)?.settings.arguments; + // if (obj != null && (obj["lockMainEntity"] != null)) { + // lockMainEntity = obj["lockMainEntity"]; + // } + // if (obj != null && (obj["keyInfo"] != null)) { + // keyInfo = obj["keyInfo"]; + // } return Scaffold( - backgroundColor: AppColors.mainBackgroundColor, - appBar: TitleAppBar( - barTitle: TranslationLoader.lanKeys!.authorizedAdmin!.tr, - haveBack: true, - backgroundColor: AppColors.mainColor, - ), - body: FutureBuilder>( + backgroundColor: AppColors.mainBackgroundColor, + appBar: TitleAppBar( + barTitle: TranslationLoader.lanKeys!.authorizedAdmin!.tr, + haveBack: true, + backgroundColor: AppColors.mainColor, + ), + body: Column( + children: [ + Expanded( + child: Obx(() => state.itemDataList.value.isEmpty + ? const NoData() + : _buildMainUI(state.itemDataList.value))), + SizedBox( + height: 20.h, + ), + AddBottomWhiteBtn( + btnName: TranslationLoader.lanKeys!.addAuthorizedAdmin!.tr, + onClick: () { + Navigator.pushNamed(context, Routers.authorizedAdminManagePage, + arguments: { + "lockMainEntity": state.lockMainEntity.value, + "keyInfo": state.keyInfo.value + }).then((val) { + if (val != null) { + logic.mockNetworkDataRequest(); + setState(() {}); + } + }); + }, + ), + SizedBox( + height: 64.h, + ) + ], + ) + /* + FutureBuilder>( future: mockNetworkDataRequest(), builder: (BuildContext context, AsyncSnapshot> snapshot) { @@ -90,31 +137,32 @@ class _AuthorizedAdminListPageState extends State { return Container(); } }), - ); + */ + ); } - //请求授权管理员列表 跟电子钥匙列表的接口一样,但必须在参数中加keyRight=1为授权管理员 - Future> mockNetworkDataRequest() async { - ElectronicKeyListEntity entity = await ApiRepository.to.electronicKeyList( - '0', - keyInfo.keyId.toString(), - '', - keyInfo.lockId.toString(), - '', - '1', - '20', - '0', - '1'); - if (entity.errorCode!.codeIsSuccessful) { - print("电子钥匙列表成功:${entity.data?.itemList}"); - } - if (entity.data != null) { - return entity.data!.itemList; - } else { - List dataList = []; - return dataList; - } - } + // //请求授权管理员列表 跟电子钥匙列表的接口一样,但必须在参数中加keyRight=1为授权管理员 + // Future> mockNetworkDataRequest() async { + // ElectronicKeyListEntity entity = await ApiRepository.to.electronicKeyList( + // '0', + // keyInfo.keyId.toString(), + // '', + // keyInfo.lockId.toString(), + // '', + // '1', + // '20', + // '0', + // '1'); + // if (entity.errorCode!.codeIsSuccessful) { + // print("电子钥匙列表成功:${entity.data?.itemList}"); + // } + // if (entity.data != null) { + // return entity.data!.itemList; + // } else { + // List dataList = []; + // return dataList; + // } + // } Widget _buildMainUI(itemData) { List getItemData = itemData; @@ -143,7 +191,12 @@ class _AuthorizedAdminListPageState extends State { return _electronicKeyItem('images/controls_user.png', indexEntity.keyName!, useDateStr, keyStatus, isAdminKey, () { Navigator.pushNamed(context, Routers.electronicKeyDetailPage, - arguments: {'itemData': indexEntity}); + arguments: {'itemData': indexEntity}).then((val) { + if (val != null) { + logic.mockNetworkDataRequest(); + setState(() {}); + } + }); }); }); } diff --git a/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_state.dart b/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_state.dart new file mode 100644 index 00000000..11bd6b15 --- /dev/null +++ b/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_state.dart @@ -0,0 +1,17 @@ +import 'package:get/get.dart'; +import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart'; +import 'package:star_lock/main/lockMian/entity/lockInfoEntity.dart'; + +class AuthorizedAdminListState { + final keyInfo = KeyInfos().obs; + final lockMainEntity = LockMainEntity().obs; + var pageNum = 1.obs; //请求页码 + final pageSize = 20.obs; //请求每页数据条数 + final itemDataList = [].obs; + + AuthorizedAdminListState() { + Map map = Get.arguments; + lockMainEntity.value = map["lockMainEntity"]; + keyInfo.value = map["keyInfo"]; + } +} diff --git a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_page.dart b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_page.dart index 44f5ca03..5eb1d424 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_page.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_page.dart @@ -8,7 +8,6 @@ import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/tools/baseGetXController.dart'; import 'package:star_lock/tools/jh_pop_menus.dart'; -import 'package:star_lock/tools/showCupertinoAlert.dart'; import 'package:star_lock/tools/toast.dart'; import '../../../../../appRouters.dart'; diff --git a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_logic.dart b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_logic.dart index 84d2d74e..a0e94873 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_logic.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_logic.dart @@ -19,15 +19,15 @@ class ElectronicKeyListLogic extends BaseGetXController { state.pageSize.toString(), '0', '0'); + List dataList = []; if (entity.errorCode!.codeIsSuccessful) { print("电子钥匙列表成功:${entity.data?.itemList}"); + if (entity.data != null) { + dataList = entity.data!.itemList; + } } - if (entity.data != null) { - return entity.data!.itemList; - } else { - List dataList = []; - return dataList; - } + state.itemDataList.value = dataList; + return dataList; } //电子钥匙重置请求 diff --git a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_page.dart b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_page.dart index d018b966..1c100b0f 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_page.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_page.dart @@ -7,6 +7,7 @@ import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart'; import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_logic.dart'; import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart'; import 'package:star_lock/tools/noData.dart'; +import 'package:star_lock/tools/storage.dart'; import '../../../../appRouters.dart'; import '../../../../app_settings/app_colors.dart'; import '../../../../tools/submitBtn.dart'; @@ -24,35 +25,76 @@ class _ElectronicKeyListPageState extends State { final logic = Get.put(ElectronicKeyListLogic()); final state = Get.find().state; late RefreshController _refreshController; - late List itemDataList = []; + // late List itemDataList = []; @override void initState() { super.initState(); _refreshController = RefreshController(initialRefresh: true); + + mockRequest(); + } + + Future mockRequest() async { + // 获取是否是演示模式 演示模式不获取接口 + var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); + if (isDemoMode == false) { + logic.mockNetworkDataRequest(); + } } @override Widget build(BuildContext context) { return Scaffold( - backgroundColor: AppColors.mainBackgroundColor, - appBar: TitleAppBar( - barTitle: TranslationLoader.lanKeys!.electronicKey!.tr, - haveBack: true, - backgroundColor: AppColors.mainColor, - actionsList: [ - TextButton( - child: Text( - TranslationLoader.lanKeys!.reset!.tr, - style: TextStyle(color: Colors.white, fontSize: 24.sp), + backgroundColor: AppColors.mainBackgroundColor, + appBar: TitleAppBar( + barTitle: TranslationLoader.lanKeys!.electronicKey!.tr, + haveBack: true, + backgroundColor: AppColors.mainColor, + actionsList: [ + TextButton( + child: Text( + TranslationLoader.lanKeys!.reset!.tr, + style: TextStyle(color: Colors.white, fontSize: 24.sp), + ), + onPressed: () { + _showDialog(context); + }, ), - onPressed: () { - _showDialog(context); - }, - ), - ], - ), - body: FutureBuilder>( + ], + ), + body: Column( + children: [ + _searchWidget(), + SizedBox( + height: 20.h, + ), + Expanded( + child: Obx(() => state.itemDataList.value.isEmpty + ? const NoData() + : _buildMainUI(state.itemDataList.value))), + AddBottomWhiteBtn( + btnName: TranslationLoader.lanKeys!.sendKey!.tr, + onClick: () { + Navigator.pushNamed( + context, Routers.sendElectronicKeyManagePage, arguments: { + "lockMainEntity": state.lockMainEntity.value, + "keyInfo": state.keyInfo.value + }).then((val) { + if (val != null) { + logic.mockNetworkDataRequest(); + setState(() {}); + } + }); + }, + ), + SizedBox( + height: 64.h, + ) + ], + ) + /* + FutureBuilder>( future: logic.mockNetworkDataRequest(), builder: (BuildContext context, AsyncSnapshot> snapshot) { @@ -115,13 +157,14 @@ class _ElectronicKeyListPageState extends State { return Container(); } }), - ); + */ + ); } ///加载更多函数 Future _loadMore() async { if (state.pageNum.value == 1) { - if (itemDataList.length < 10) { + if (state.itemDataList.value.length < 10) { _refreshController.loadComplete(); } else { state.pageNum.value++; @@ -209,7 +252,6 @@ class _ElectronicKeyListPageState extends State { setState(() {}); } }); - ; }); }, separatorBuilder: (BuildContext context, int index) { diff --git a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_state.dart b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_state.dart index cd7b7a00..b51f5cef 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_state.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_state.dart @@ -1,12 +1,13 @@ import 'package:get/get.dart'; +import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart'; import 'package:star_lock/main/lockMian/entity/lockInfoEntity.dart'; -import 'package:star_lock/mine/mineSet/mineSet/userSettingInfoEntity.dart'; class ElectronicKeyListState { final keyInfo = KeyInfos().obs; final lockMainEntity = LockMainEntity().obs; var pageNum = 1.obs; //请求页码 final pageSize = 20.obs; //请求每页数据条数 + final itemDataList = [].obs; ElectronicKeyListState() { Map map = Get.arguments; diff --git a/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_page.dart b/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_page.dart index 41d19843..a55d88e7 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_page.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_page.dart @@ -1,5 +1,6 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:flutter_pickers/pickers.dart'; import 'package:flutter_pickers/time_picker/model/date_mode.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; @@ -28,6 +29,7 @@ class SendElectronicKeyPage extends StatefulWidget { class _SendElectronicKeyPageState extends State { final logic = Get.put(SendElectronicKeyLogic()); final state = Get.find().state; + static const methodChannel = MethodChannel('flutter_native_ios'); @override void initState() { @@ -345,21 +347,22 @@ class _SendElectronicKeyPageState extends State { height: 10.h, ), OutLineBtn( - btnName: '邮件通知', + btnName: '分享', onClick: () { - Navigator.pushNamed(context, Routers.sendEmailNotificationPage); + // Navigator.pushNamed(context, Routers.sendEmailNotificationPage); + _openModalBottomSheet(); }, ), SizedBox( height: 10.h, ), - OutLineBtn( - btnName: '微信通知', - onClick: () {}, - ), - SizedBox( - height: 10.h, - ), + // OutLineBtn( + // btnName: '微信通知', + // onClick: () {}, + // ), + // SizedBox( + // height: 10.h, + // ), OutLineBtn( btnName: '标记为已入住', onClick: () { @@ -484,4 +487,126 @@ class _SendElectronicKeyPageState extends State { String intToStr(int v) { return (v < 10) ? "0$v" : "$v"; } + + Future _openModalBottomSheet() async { + showModalBottomSheet( + context: context, + shape: RoundedRectangleBorder( + borderRadius: BorderRadiusDirectional.circular(10)), + constraints: BoxConstraints(maxHeight: 260.h), + builder: (BuildContext context) { + return Column( + children: [ + SizedBox( + width: ScreenUtil().screenWidth, + height: 180.h, + child: ListView( + scrollDirection: Axis.horizontal, //横向滚动 + children: initBottomSheetList()), + ), + Container( + height: 8.h, + color: AppColors.greyBackgroundColor, + ), + TextButton( + style: ButtonStyle( + overlayColor: + MaterialStateProperty.all(Colors.white)), + child: Text( + '取消', + style: TextStyle( + color: Colors.black, fontSize: ScreenUtil().setSp(24)), + ), + onPressed: () { + Navigator.pop(context); + }, + ) + ], + ); + }); + } + + List initBottomSheetList() { + List widgetList = []; + + widgetList.add(buildCenter3('images/icon_wechat.png', '微信好友', 0)); + widgetList.add(buildCenter3('images/icon_message.png', '短信', 1)); + widgetList.add(buildCenter3('images/icon_email.png', '邮件', 2)); + widgetList.add(buildCenter3('images/icon_more.png', '更多', 3)); + + return widgetList; + } + + GestureDetector buildCenter3( + String imageName, String titleStr, int itemIndex) { + return GestureDetector( + child: Container( + width: 120.w, + // height: 64.h, + margin: + EdgeInsets.only(top: 20.w, bottom: 20.w, left: 10.w, right: 10.w), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Image.asset( + imageName, + width: 50.w, + height: 50.h, + ), + SizedBox( + height: 16.w, + ), + Text( + titleStr, + style: TextStyle( + fontSize: ScreenUtil().setSp(20), color: Colors.black), + ), + ], + ), + ), + onTap: () => _jumpSmartDeviceRoute(itemIndex), + ); + } + + _jumpSmartDeviceRoute(int itemIndex) { + switch (itemIndex) { + case 0: + //微信好友 + { + Navigator.pop(context); + String pwdShareStr = '您好,您的电子钥匙生成成功'; + tokNative('flutter_sharePassword_to_ios', + arguments: {'pwdShareStr': pwdShareStr}).then((result) { + print('$result'); + }); + print('与原生交互'); + } + break; + case 1: + //短信 + {} + break; + case 2: + //邮件 + { + Navigator.pop(context); + Navigator.pushNamed(context, Routers.sendEmailNotificationPage); + } + break; + case 3: + //更多 + {} + break; + default: + } + } + + static Future tokNative(String method, + {required Map arguments}) async { + if (arguments == null) { + return await methodChannel.invokeMethod(method); + } else { + return await methodChannel.invokeMethod(method, arguments); + } + } } diff --git a/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_page.dart b/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_page.dart index 1dcd1833..63201932 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_page.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_page.dart @@ -515,29 +515,57 @@ class _LockSetPageState extends State with RouteAware { ); } - void showCupertinoAlertDialog( - BuildContext context, - ) { - showDialog( - context: context, - builder: (BuildContext context) { - return ShowIosTipView( - title: "提示", - tipTitle: "创建公司号,考勤功能才能使用", - sureClick: () { - // - Navigator.pop(context); - Get.toNamed(Routers.checkInCreatCompanyPage, - arguments: state.getKeyInfosData.value); - }, - cancelClick: () { - Navigator.pop(context); - }, + //确认弹窗 + void showCupertinoAlertDialog(widgetContext) { + showCupertinoDialog( + context: widgetContext, + builder: (context) { + return CupertinoAlertDialog( + title: const Text('创建公司号,考勤功能才能使用'), + actions: [ + CupertinoDialogAction( + child: Text(TranslationLoader.lanKeys!.cancel!.tr), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + CupertinoDialogAction( + child: Text(TranslationLoader.lanKeys!.sure!.tr), + onPressed: () { + Navigator.pop(context); + Get.toNamed(Routers.checkInCreatCompanyPage, + arguments: state.getKeyInfosData.value); + }, + ), + ], ); }, ); } + // void showCupertinoAlertDialog( + // BuildContext context, + // ) { + // showDialog( + // context: context, + // builder: (BuildContext context) { + // return ShowIosTipView( + // title: "提示", + // tipTitle: "创建公司号,考勤功能才能使用", + // sureClick: () { + // // + // Navigator.pop(context); + // Get.toNamed(Routers.checkInCreatCompanyPage, + // arguments: state.getKeyInfosData.value); + // }, + // cancelClick: () { + // Navigator.pop(context); + // }, + // ); + // }, + // ); + // } + void showDeletPasswordAlertDialog( BuildContext context, ) { diff --git a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_page.dart b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_page.dart index d82bd6fa..195892fb 100644 --- a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_page.dart +++ b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_page.dart @@ -1,4 +1,3 @@ -import 'package:date_format/date_format.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; @@ -193,7 +192,6 @@ class _PasswordKeyDetailPageState extends State { padding: EdgeInsets.only(top: 25.w, bottom: 25.w), onClick: () { deletePwdRequest(); - Navigator.pop(context, true); }), ], ), @@ -278,6 +276,9 @@ class _PasswordKeyDetailPageState extends State { itemData.lockId.toString(), itemData.keyboardPwdId.toString(), 1); if (entity.errorCode!.codeIsSuccessful) { Toast.show(msg: "删除成功"); + setState(() { + Navigator.pop(context, true); + }); } } @@ -409,6 +410,7 @@ class _PasswordKeyDetailPageState extends State { case 0: //微信好友 { + Navigator.pop(context); String pwdShareStr = '您好,您的密码是:${itemData.keyboardPwd}\n生效时间:${itemData.startDate}\n类型:永久\n锁名:${itemData.keyboardPwdName}'; tokNative('flutter_sharePassword_to_ios', @@ -425,6 +427,7 @@ class _PasswordKeyDetailPageState extends State { case 2: //邮件 { + Navigator.pop(context); Navigator.pushNamed(context, Routers.sendEmailNotificationPage); } break; diff --git a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_logic.dart b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_logic.dart index cde1378f..e3c7888c 100644 --- a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_logic.dart +++ b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_logic.dart @@ -15,15 +15,15 @@ class PasswordKeyListLogic extends BaseGetXController { '0', state.pageNum.toString(), state.pageSize.toString()); + List dataList = []; if (entity.errorCode!.codeIsSuccessful) { print("密码钥匙列表成功:${entity.data?.itemList}"); + if (entity.data != null) { + dataList = entity.data!.itemList!; + } } - if (entity.data != null) { - return entity.data!.itemList!; - } else { - List dataList = []; - return dataList; - } + state.itemDataList.value = dataList; + return dataList; } //密码钥匙重置请求 diff --git a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart index 2697fa90..86d82868 100644 --- a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart +++ b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart @@ -6,6 +6,7 @@ import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyListEntity.dart'; import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_logic.dart'; import 'package:star_lock/tools/noData.dart'; +import 'package:star_lock/tools/storage.dart'; import '../../../../appRouters.dart'; import '../../../../app_settings/app_colors.dart'; import '../../../../tools/submitBtn.dart'; @@ -22,7 +23,7 @@ class PasswordKeyListPage extends StatefulWidget { class _PasswordKeyListPageState extends State { final logic = Get.put(PasswordKeyListLogic()); final state = Get.find().state; - late List _itemDataList = []; + // late List _itemDataList = []; late RefreshController _refreshController; @@ -30,29 +31,70 @@ class _PasswordKeyListPageState extends State { void initState() { super.initState(); _refreshController = RefreshController(initialRefresh: true); + mockRequest(); + } + + Future mockRequest() async { + // 获取是否是演示模式 演示模式不获取接口 + var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); + if (isDemoMode == false) { + logic.mockNetworkDataRequest(); + } } @override Widget build(BuildContext context) { return Scaffold( - backgroundColor: AppColors.mainBackgroundColor, - appBar: TitleAppBar( - barTitle: TranslationLoader.lanKeys!.password!.tr, - haveBack: true, - backgroundColor: AppColors.mainColor, - actionsList: [ - TextButton( - child: Text( - TranslationLoader.lanKeys!.reset!.tr, - style: TextStyle(color: Colors.white, fontSize: 24.sp), + backgroundColor: AppColors.mainBackgroundColor, + appBar: TitleAppBar( + barTitle: TranslationLoader.lanKeys!.password!.tr, + haveBack: true, + backgroundColor: AppColors.mainColor, + actionsList: [ + TextButton( + child: Text( + TranslationLoader.lanKeys!.reset!.tr, + style: TextStyle(color: Colors.white, fontSize: 24.sp), + ), + onPressed: () { + _showDialog(context); + }, ), - onPressed: () { - _showDialog(context); - }, - ), - ], - ), - body: FutureBuilder>( + ], + ), + body: Column( + children: [ + _searchWidget(), + SizedBox( + height: 20.h, + ), + Expanded( + child: Obx(() => state.itemDataList.value.isEmpty + ? const NoData() + : _buildMainUI(state.itemDataList.value))), + SizedBox( + height: 20.h, + ), + AddBottomWhiteBtn( + btnName: TranslationLoader.lanKeys!.getPassword!.tr, + onClick: () { + Navigator.pushNamed(context, Routers.passwordKeyManagePage, + arguments: { + "lockMainEntity": state.lockMainEntity.value, + "keyInfo": state.keyInfo.value + }).then((val) { + if (val != null) { + logic.mockNetworkDataRequest(); + } + }); + }), + SizedBox( + height: 42.h, + ) + ], + ) + /* + FutureBuilder>( future: logic.mockNetworkDataRequest(), builder: (BuildContext context, AsyncSnapshot> snapshot) { @@ -119,13 +161,14 @@ class _PasswordKeyListPageState extends State { return Container(); } }), - ); + */ + ); } ///加载更多函数 Future _loadMore() async { if (state.pageNum.value == 1) { - if (_itemDataList.length < 10) { + if (state.itemDataList.length < 10) { _refreshController.loadComplete(); } else { state.pageNum.value++; @@ -195,7 +238,12 @@ class _PasswordKeyListPageState extends State { return _electronicKeyItem('images/controls_user.png', indexEntity.keyboardPwdName!, useDateStr, () { Navigator.pushNamed(context, Routers.passwordKeyDetailPage, - arguments: {"itemData": indexEntity}); + arguments: {"itemData": indexEntity}).then((val) { + if (val != null) { + logic.mockNetworkDataRequest(); + } + }); + ; }); }, separatorBuilder: (BuildContext context, int index) { diff --git a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_state.dart b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_state.dart index 6b2e9d15..c6c7cde1 100644 --- a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_state.dart +++ b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_state.dart @@ -1,4 +1,5 @@ import 'package:get/get.dart'; +import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyListEntity.dart'; import 'package:star_lock/main/lockMian/entity/lockInfoEntity.dart'; class PasswordKeyListState { @@ -6,6 +7,7 @@ class PasswordKeyListState { final lockMainEntity = LockMainEntity().obs; var pageNum = 1.obs; //请求页码 final pageSize = 20.obs; //请求每页数据条数 + final itemDataList = [].obs; PasswordKeyListState() { Map map = Get.arguments; diff --git a/star_lock/lib/main/lockMian/demoMode/demoModeLockDetail/demoModeLockDetail_page.dart b/star_lock/lib/main/lockMian/demoMode/demoModeLockDetail/demoModeLockDetail_page.dart index ffe51330..d8079371 100644 --- a/star_lock/lib/main/lockMian/demoMode/demoModeLockDetail/demoModeLockDetail_page.dart +++ b/star_lock/lib/main/lockMian/demoMode/demoModeLockDetail/demoModeLockDetail_page.dart @@ -1,4 +1,3 @@ - import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; @@ -26,7 +25,6 @@ class _DemoModeLockDetailPageState extends State { void initState() { // TODO: implement initState super.initState(); - } @override @@ -34,25 +32,21 @@ class _DemoModeLockDetailPageState extends State { return Scaffold( backgroundColor: AppColors.mainBackgroundColor, appBar: TitleAppBar( - barTitle: "演示模式", - haveBack: true, - backgroundColor: AppColors.mainColor, - ), - body: Container( - width: 1.sw, - height: 1.sh - ScreenUtil().statusBarHeight * 2, - color: Colors.white, - child: Column( - children: [ - topTip(), - topWidget(), - Expanded(child: bottomWidget()) - ], - ), - )); + barTitle: "演示模式", + haveBack: true, + backgroundColor: AppColors.mainColor, + ), + body: Container( + width: 1.sw, + height: 1.sh - ScreenUtil().statusBarHeight * 2, + color: Colors.white, + child: Column( + children: [topTip(), topWidget(), Expanded(child: bottomWidget())], + ), + )); } - Widget topTip(){ + Widget topTip() { return Container( // height: 120.h, width: 1.sw, @@ -61,7 +55,10 @@ class _DemoModeLockDetailPageState extends State { children: [ Row( children: [ - Expanded(child: Text("提示:当前界面为展示界面,添加设备后才能继续使用", style: TextStyle(fontSize: 24.sp, color: AppColors.mainColor))), + Expanded( + child: Text("提示:当前界面为展示界面,添加设备后才能继续使用", + style: TextStyle( + fontSize: 24.sp, color: AppColors.mainColor))), ], ), ], @@ -82,7 +79,7 @@ class _DemoModeLockDetailPageState extends State { child: Text( "TMH_78f16712781a", style: - TextStyle(fontSize: 22.sp, fontWeight: FontWeight.w400), + TextStyle(fontSize: 22.sp, fontWeight: FontWeight.w400), )), Row( mainAxisAlignment: MainAxisAlignment.end, @@ -112,12 +109,12 @@ class _DemoModeLockDetailPageState extends State { children: [ Center( child: GestureDetector( - onTap: () { - gotoLogin(); - }, - child: Image.asset('images/main/icon_main_openLockBtn.png', - width: 268.w, height: 268.w), - )), + onTap: () { + gotoLogin(); + }, + child: Image.asset('images/main/icon_main_openLockBtn.png', + width: 268.w, height: 268.w), + )), ], ), ), @@ -168,12 +165,13 @@ class _DemoModeLockDetailPageState extends State { Text( '超级管理员', style: - TextStyle(fontSize: 20.sp, color: AppColors.btnDisableColor), + TextStyle(fontSize: 20.sp, color: AppColors.btnDisableColor), ), SizedBox( width: 80.w, ), - Image.asset('images/main/icon_main_remoteUnlocking_grey.png', + Image.asset( + 'images/main/icon_main_remoteUnlocking_grey.png', // state.keyInfos.value.remoteEnable == 1 // ? 'images/main/icon_main_remoteUnlocking.png' // : 'images/main/icon_main_remoteUnlocking_grey.png', @@ -189,7 +187,7 @@ class _DemoModeLockDetailPageState extends State { Text( '网关设备', style: - TextStyle(fontSize: 20.sp, color: AppColors.btnDisableColor), + TextStyle(fontSize: 20.sp, color: AppColors.btnDisableColor), ), ], ), @@ -227,58 +225,57 @@ class _DemoModeLockDetailPageState extends State { // 考勤 // if (state.keyInfos.value.isAttendance == 1) { - showWidgetArr.add(bottomItem('images/main/icon_main_clockingIn.png', - TranslationLoader.lanKeys!.checkingIn!.tr, () { - // gotoLogin(); - Get.toNamed(Routers.checkingInListPage, arguments: KeyInfos()); - })); + showWidgetArr.add(bottomItem('images/main/icon_main_clockingIn.png', + TranslationLoader.lanKeys!.checkingIn!.tr, () { + // gotoLogin(); + Get.toNamed(Routers.checkingInListPage, arguments: KeyInfos()); + })); // } var defaultWidgetArr = [ // 电子钥匙 bottomItem('images/main/icon_main_electronicKey.png', TranslationLoader.lanKeys!.electronicKey!.tr, () { - gotoLogin(); + // gotoLogin(); - // Get.toNamed(Routers.electronicKeyListPage, arguments: { - // "lockMainEntity": widget.lockMainEntity, - // "keyInfo": widget.keyInfo - // }); - }), + Get.toNamed(Routers.electronicKeyListPage, arguments: { + "lockMainEntity": LockMainEntity(), + "keyInfo": KeyInfos() + }); + }), // 密码 bottomItem('images/main/icon_main_password.png', TranslationLoader.lanKeys!.password!.tr, () { - gotoLogin(); - - // Get.toNamed(Routers.passwordKeyListPage, arguments: { - // "lockMainEntity": widget.lockMainEntity, - // "keyInfo": widget.keyInfo - // }); - }), - - // ic卡 - bottomItem('images/main/icon_main_icCard.png', TranslationLoader.lanKeys!.card!.tr, () { // gotoLogin(); - Get.toNamed(Routers.otherTypeKeyListPage, arguments: { - "lockId": 0, - "fromType": 0 + Get.toNamed(Routers.passwordKeyListPage, arguments: { + "lockMainEntity": LockMainEntity(), + "keyInfo": KeyInfos() }); }), + // ic卡 + bottomItem('images/main/icon_main_icCard.png', + TranslationLoader.lanKeys!.card!.tr, () { + // gotoLogin(); + + Get.toNamed(Routers.otherTypeKeyListPage, + arguments: {"lockId": 0, "fromType": 0}); + }), + // 指纹 - bottomItem('images/main/icon_main_fingerprint.png', TranslationLoader.lanKeys!.fingerprint!.tr, () { + bottomItem('images/main/icon_main_fingerprint.png', + TranslationLoader.lanKeys!.fingerprint!.tr, () { // gotoLogin(); - Get.toNamed(Routers.otherTypeKeyListPage, arguments: { - "lockId": 1, - "fromType": 1 - }); + Get.toNamed(Routers.otherTypeKeyListPage, + arguments: {"lockId": 1, "fromType": 1}); }), // 遥控 - bottomItem('images/main/icon_main_remoteControl.png', TranslationLoader.lanKeys!.remoteControl!.tr, () { + bottomItem('images/main/icon_main_remoteControl.png', + TranslationLoader.lanKeys!.remoteControl!.tr, () { gotoLogin(); // Get.toNamed(Routers.otherTypeKeyListPage, arguments: { @@ -315,25 +312,26 @@ class _DemoModeLockDetailPageState extends State { // 授权管理员 bottomItem('images/main/icon_main_authorizedAdmin.png', TranslationLoader.lanKeys!.authorizedAdmin!.tr, () { - gotoLogin(); + // gotoLogin(); - // Get.toNamed(Routers.authorizedAdminListPage, arguments: { - // "keyInfo": KeyInfos() - // }); - }), + Get.toNamed(Routers.authorizedAdminListPage, arguments: { + "lockMainEntity": LockMainEntity(), + "keyInfo": KeyInfos() + }); + }), // 操作记录 bottomItem('images/main/icon_main_operatingRecord.png', TranslationLoader.lanKeys!.operatingRecord!.tr, () { - // gotoLogin(); - Get.toNamed(Routers.lockOperatingRecordPage, arguments: { - "keyInfo": KeyInfos() - }); - }), + // gotoLogin(); + Get.toNamed(Routers.lockOperatingRecordPage, + arguments: {"keyInfo": KeyInfos()}); + }), // 设置 bottomItem( - 'images/main/icon_main_set.png', TranslationLoader.lanKeys!.set!.tr, () { - Get.toNamed(Routers.demoModeLockSetPage); - }), + 'images/main/icon_main_set.png', TranslationLoader.lanKeys!.set!.tr, + () { + Get.toNamed(Routers.demoModeLockSetPage); + }), ]; showWidgetArr.addAll(endWiddget); return showWidgetArr; @@ -345,7 +343,7 @@ class _DemoModeLockDetailPageState extends State { return GestureDetector( onTap: onClick, child: Container( - // height: 300.h, + // height: 300.h, color: Colors.white, child: Column( crossAxisAlignment: CrossAxisAlignment.center, @@ -367,7 +365,7 @@ class _DemoModeLockDetailPageState extends State { ); } - void gotoLogin(){ + void gotoLogin() { // Get.toNamed(Routers.seletLockTypePage); Toast.show(msg: "演示模式"); }