From f0e55ffdb77b0017bb202e9e6d1d573378ee3fb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AD=8F=E5=B0=91=E9=98=B3?= <786612630@qq.com> Date: Fri, 22 Sep 2023 16:06:08 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E8=AF=95=E8=BD=AC=E7=A7=BB=E7=BD=91?= =?UTF-8?q?=E5=85=B3=E3=80=81=E8=BD=AC=E7=A7=BB=E6=99=BA=E8=83=BD=E9=94=81?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xcshareddata/xcschemes/Runner.xcscheme | 2 +- star_lock/lib/appRouters.dart | 6 +- .../selectGetewayList_entity.dart | 111 +++++++ .../selectGetewayList_logic.dart | 45 +++ .../selectGetewayList_page.dart | 79 +++-- .../selectGetewayList_state.dart | 11 + .../recipientInformation_entity.dart | 52 +++ .../recipientInformation_logic.dart | 61 ++++ .../recipientInformation_page.dart | 303 ++++++++++++++++++ .../recipientInformation_state.dart | 18 ++ .../recipientInformation_page.dart | 185 ----------- .../selectBranch/selectBranch_logic.dart | 10 + .../selectBranch/selectBranch_page.dart | 230 +++++++++++++ .../selectBranch/selectBranch_state.dart | 17 + .../transferSmartLock/selectBranch_page.dart | 133 -------- .../transferConfirmationBox_page.dart | 0 .../transferSmartLock_entity.dart | 118 +++++++ .../transferSmartLock_logic.dart | 40 +++ .../transferSmartLock_page.dart | 197 ++++++++++++ .../transferSmartLock_state.dart | 11 + .../transferSmartLock_page.dart | 168 ---------- star_lock/lib/network/api.dart | 6 + star_lock/lib/network/api_provider.dart | 47 +++ star_lock/lib/network/api_repository.dart | 38 +++ 24 files changed, 1378 insertions(+), 510 deletions(-) create mode 100644 star_lock/lib/mine/mineSet/transferGateway/selectGetewayList_entity.dart create mode 100644 star_lock/lib/mine/mineSet/transferGateway/selectGetewayList_logic.dart create mode 100644 star_lock/lib/mine/mineSet/transferGateway/selectGetewayList_state.dart create mode 100644 star_lock/lib/mine/mineSet/transferSmartLock/recipientInformation/recipientInformation_entity.dart create mode 100644 star_lock/lib/mine/mineSet/transferSmartLock/recipientInformation/recipientInformation_logic.dart create mode 100644 star_lock/lib/mine/mineSet/transferSmartLock/recipientInformation/recipientInformation_page.dart create mode 100644 star_lock/lib/mine/mineSet/transferSmartLock/recipientInformation/recipientInformation_state.dart delete mode 100644 star_lock/lib/mine/mineSet/transferSmartLock/recipientInformation_page.dart create mode 100644 star_lock/lib/mine/mineSet/transferSmartLock/selectBranch/selectBranch_logic.dart create mode 100644 star_lock/lib/mine/mineSet/transferSmartLock/selectBranch/selectBranch_page.dart create mode 100644 star_lock/lib/mine/mineSet/transferSmartLock/selectBranch/selectBranch_state.dart delete mode 100644 star_lock/lib/mine/mineSet/transferSmartLock/selectBranch_page.dart create mode 100644 star_lock/lib/mine/mineSet/transferSmartLock/transferConfirmationBox/transferConfirmationBox_page.dart create mode 100644 star_lock/lib/mine/mineSet/transferSmartLock/transferSmartLockList/transferSmartLock_entity.dart create mode 100644 star_lock/lib/mine/mineSet/transferSmartLock/transferSmartLockList/transferSmartLock_logic.dart create mode 100644 star_lock/lib/mine/mineSet/transferSmartLock/transferSmartLockList/transferSmartLock_page.dart create mode 100644 star_lock/lib/mine/mineSet/transferSmartLock/transferSmartLockList/transferSmartLock_state.dart delete mode 100644 star_lock/lib/mine/mineSet/transferSmartLock/transferSmartLock_page.dart diff --git a/star_lock/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/star_lock/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index c87d15a3..f3d88ace 100644 --- a/star_lock/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/star_lock/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -40,7 +40,7 @@ json) { + errorCode = json['errorCode']; + description = json['description']; + errorMsg = json['errorMsg']; + data = json['data'] != null ? GetewayListData.fromJson(json['data']) : null; + } + + Map toJson() { + final Map data = {}; + data['errorCode'] = errorCode; + data['description'] = description; + data['errorMsg'] = errorMsg; + if (this.data != null) { + data['data'] = this.data!.toJson(); + } + return data; + } +} + +class GetewayListData { + List? list; + int? pageNo; + int? pageSize; + int? pages; + int? total; + + GetewayListData({this.list, this.pageNo, this.pageSize, this.pages, this.total}); + + GetewayListData.fromJson(Map json) { + if (json['list'] != null) { + list = []; + json['list'].forEach((v) { + list!.add(GetewayItemData.fromJson(v)); + }); + } + pageNo = json['pageNo']; + pageSize = json['pageSize']; + pages = json['pages']; + total = json['total']; + } + + Map toJson() { + final Map data = {}; + if (list != null) { + data['list'] = list!.map((v) => v.toJson()).toList(); + } + data['pageNo'] = pageNo; + data['pageSize'] = pageSize; + data['pages'] = pages; + data['total'] = total; + return data; + } +} + +class GetewayItemData { + String? serialNumber; + int? plugId; + String? plugName; + String? networkName; + int? lockNum; + String? plugMac; + String? networkMac; + int? isOnline; + String? plugVersion; + int? selet = 0; + GetewayItemData( + {this.serialNumber, + this.plugId, + this.plugName, + this.networkName, + this.lockNum, + this.plugMac, + this.networkMac, + this.isOnline, + this.plugVersion}); + + GetewayItemData.fromJson(Map json) { + serialNumber = json['serialNumber']; + plugId = json['plugId']; + plugName = json['plugName']; + networkName = json['networkName']; + lockNum = json['lockNum']; + plugMac = json['plugMac']; + networkMac = json['networkMac']; + isOnline = json['isOnline']; + plugVersion = json['plugVersion']; + } + + Map toJson() { + final Map data = {}; + data['serialNumber'] = serialNumber; + data['plugId'] = plugId; + data['plugName'] = plugName; + data['networkName'] = networkName; + data['lockNum'] = lockNum; + data['plugMac'] = plugMac; + data['networkMac'] = networkMac; + data['isOnline'] = isOnline; + data['plugVersion'] = plugVersion; + return data; + } +} \ No newline at end of file diff --git a/star_lock/lib/mine/mineSet/transferGateway/selectGetewayList_logic.dart b/star_lock/lib/mine/mineSet/transferGateway/selectGetewayList_logic.dart new file mode 100644 index 00000000..cb7c37d7 --- /dev/null +++ b/star_lock/lib/mine/mineSet/transferGateway/selectGetewayList_logic.dart @@ -0,0 +1,45 @@ + +import 'package:star_lock/tools/baseGetXController.dart'; + +import '../../../network/api_repository.dart'; +import 'selectGetewayList_state.dart'; + +class SelectGetewayListLogic extends BaseGetXController{ + SelectGetewayListState state = SelectGetewayListState(); + + // 获取锁列表 + Future getGetewayListData() async{ + var entity = await ApiRepository.to.getGatewayListData( + pageNo: '1', + pageSize: '20' + ); + if(entity.errorCode!.codeIsSuccessful){ + state.getewayListData.value = entity.data!.list!; + } + } + + @override + void onReady() { + // TODO: implement onReady + super.onReady(); + print("onReady()"); + + getGetewayListData(); + } + + @override + void onInit() { + // TODO: implement onInit + super.onInit(); + print("onInit()"); + + } + + @override + void onClose() { + // TODO: implement onClose + super.onClose(); + + } + +} \ No newline at end of file diff --git a/star_lock/lib/mine/mineSet/transferGateway/selectGetewayList_page.dart b/star_lock/lib/mine/mineSet/transferGateway/selectGetewayList_page.dart index c819482d..d135d883 100644 --- a/star_lock/lib/mine/mineSet/transferGateway/selectGetewayList_page.dart +++ b/star_lock/lib/mine/mineSet/transferGateway/selectGetewayList_page.dart @@ -6,6 +6,10 @@ import '../../../../appRouters.dart'; import '../../../../app_settings/app_colors.dart'; import '../../../../tools/titleAppBar.dart'; import '../../../../translations/trans_lib.dart'; +import '../../../tools/noData.dart'; +import '../../../tools/toast.dart'; +import 'selectGetewayList_entity.dart'; +import 'selectGetewayList_logic.dart'; class SelectGetewayListPage extends StatefulWidget { const SelectGetewayListPage({Key? key}) : super(key: key); @@ -15,6 +19,9 @@ class SelectGetewayListPage extends StatefulWidget { } class _SelectGetewayListPageState extends State { + final logic = Get.put(SelectGetewayListLogic()); + final state = Get.find().state; + @override Widget build(BuildContext context) { return Scaffold( @@ -25,7 +32,19 @@ class _SelectGetewayListPageState extends State { backgroundColor: AppColors.mainColor, actionsList: [ TextButton( - onPressed: () {}, + onPressed: () { + setState(() { + for (var element in state.getewayListData.value) { + if(state.isSeletAll == true){ + state.isSeletAll = false; + element.selet = 0; + }else{ + state.isSeletAll = true; + element.selet = 1; + } + } + }); + }, child: Text( '全选', style: TextStyle(color: Colors.white, fontSize: 24.sp), @@ -48,8 +67,8 @@ class _SelectGetewayListPageState extends State { } Widget _buildMainUI() { - return ListView.separated( - itemCount: 10, + return Obx(() => state.getewayListData.value.isNotEmpty ? ListView.separated( + itemCount: state.getewayListData.value.length, separatorBuilder: (context, index) { return Divider( height: 1, @@ -59,16 +78,22 @@ class _SelectGetewayListPageState extends State { ); }, itemBuilder: (c, index) { - return _electronicKeyItem('images/icon_lock.png', "张三", - "2023.6.21 11.15", "2023.6.21 11.15", () { - Navigator.pushNamed(context, Routers.authorizedAdminDetailPage); + GetewayItemData getewayItemData = state.getewayListData.value[index]; + return _electronicKeyItem(getewayItemData, () { + setState(() { + if(getewayItemData.selet == 1){ + getewayItemData.selet = 0; + }else{ + getewayItemData.selet = 1; + } + }); }); - }); + }):const NoData()); } - Widget _electronicKeyItem(String lockTypeIcon, String lockTypeTitle, - String beginTime, String endTime, Function() action) { + Widget _electronicKeyItem(GetewayItemData getewayItemData, Function() action) { return GestureDetector( + onTap: action, child: Container( color: Colors.white, height: 80.h, @@ -81,9 +106,9 @@ class _SelectGetewayListPageState extends State { ), GestureDetector( child: Image.asset( - 'images/icon_round_unSelet.png', - width: 16, - height: 16, + (getewayItemData.selet == 1) ? 'images/icon_round_selet.png' : 'images/icon_round_unSelet.png', + width: 30.w, + height: 30.w, ), ), SizedBox( @@ -98,26 +123,40 @@ class _SelectGetewayListPageState extends State { SizedBox( width: 16.w, ), - Text( - '星锁网关', - style: TextStyle(fontSize: 24.sp), - ) + Text(getewayItemData.plugName!, style: TextStyle(fontSize: 24.sp),) ], ), ), - onTap: () {}, ); } Widget _buildNextBtn() { return GestureDetector( child: Container( - color: AppColors.btnDisableColor, + color: AppColors.mainColor, width: ScreenUtil().screenWidth, height: 64.h, child: TextButton( - onPressed: () { - Navigator.pushNamed(context, Routers.recipientInformationPage); + onPressed: () async { + bool isCanNext = false; + var idList = []; + for (var element in state.getewayListData.value) { + if(element.selet == 1){ + isCanNext = true; + idList.add(element.plugId); + } + } + if(isCanNext == false){ + Toast.show(msg: "请选择锁"); + return; + } + var data = await Get.toNamed(Routers.recipientInformationPage, arguments: { + "idList":idList, + "isFromType":1, + }); + if(data != null) { + logic.getGetewayListData(); + } }, child: Text( '下一步', diff --git a/star_lock/lib/mine/mineSet/transferGateway/selectGetewayList_state.dart b/star_lock/lib/mine/mineSet/transferGateway/selectGetewayList_state.dart new file mode 100644 index 00000000..ca418a08 --- /dev/null +++ b/star_lock/lib/mine/mineSet/transferGateway/selectGetewayList_state.dart @@ -0,0 +1,11 @@ + + +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'selectGetewayList_entity.dart'; + +class SelectGetewayListState{ + var getewayListData = [].obs; + final TextEditingController searchController = TextEditingController(); + bool isSeletAll = false; +} \ No newline at end of file diff --git a/star_lock/lib/mine/mineSet/transferSmartLock/recipientInformation/recipientInformation_entity.dart b/star_lock/lib/mine/mineSet/transferSmartLock/recipientInformation/recipientInformation_entity.dart new file mode 100644 index 00000000..e2c80eda --- /dev/null +++ b/star_lock/lib/mine/mineSet/transferSmartLock/recipientInformation/recipientInformation_entity.dart @@ -0,0 +1,52 @@ +class RecipientInformationEntity { + int? errorCode; + String? description; + String? errorMsg; + RecipientInformationData? data; + + RecipientInformationEntity( + {this.errorCode, this.description, this.errorMsg, this.data}); + + RecipientInformationEntity.fromJson(Map json) { + errorCode = json['errorCode']; + description = json['description']; + errorMsg = json['errorMsg']; + data = json['data'] != null ? RecipientInformationData.fromJson(json['data']) : null; + } + + Map toJson() { + final Map data = {}; + data['errorCode'] = errorCode; + data['description'] = description; + data['errorMsg'] = errorMsg; + if (this.data != null) { + data['data'] = this.data!.toJson(); + } + return data; + } +} + +class RecipientInformationData { + String? uid; + String? nickname; + String? headUrl; + String? userid; + + RecipientInformationData({this.uid, this.nickname, this.headUrl, this.userid}); + + RecipientInformationData.fromJson(Map json) { + uid = json['uid']; + nickname = json['nickname']; + headUrl = json['headUrl']; + userid = json['userid']; + } + + Map toJson() { + final Map data = {}; + data['uid'] = uid; + data['nickname'] = nickname; + data['headUrl'] = headUrl; + data['userid'] = userid; + return data; + } +} \ No newline at end of file diff --git a/star_lock/lib/mine/mineSet/transferSmartLock/recipientInformation/recipientInformation_logic.dart b/star_lock/lib/mine/mineSet/transferSmartLock/recipientInformation/recipientInformation_logic.dart new file mode 100644 index 00000000..d7ccf401 --- /dev/null +++ b/star_lock/lib/mine/mineSet/transferSmartLock/recipientInformation/recipientInformation_logic.dart @@ -0,0 +1,61 @@ + + +import 'package:get/get.dart'; +import 'package:star_lock/tools/baseGetXController.dart'; +import '../../../../network/api_repository.dart'; +import '../../../../tools/toast.dart'; +import 'recipientInformation_entity.dart'; +import 'recipientInformation_state.dart'; + + +class RecipientInformationLogic extends BaseGetXController{ + RecipientInformationState state = RecipientInformationState(); + + // 转移智能锁确认 + Future transferLockConfirmInfoData(void Function(RecipientInformationData recipientInformationData) action) async{ + var entity = await ApiRepository.to.transferLockConfirmInfoData( + receiverUserid: state.numberController.text, + type: state.type.value.toString(), + countryCode: state.countryCode.value + ); + if(entity.errorCode!.codeIsSuccessful){ + action(entity.data!); + } + } + + // 转移智能锁确认 + Future transferLockInfoData() async{ + var entity = await ApiRepository.to.transferLockInfoData( + receiverUserid: state.numberController.text, + lockIdList: state.idList.value, + countryCode: state.countryCode.value + ); + if(entity.errorCode!.codeIsSuccessful){ + Get.back(result: "scuess"); + } + } + + @override + void onReady() { + // TODO: implement onReady + super.onReady(); + print("onReady()"); + + } + + @override + void onInit() { + // TODO: implement onInit + super.onInit(); + print("onInit()"); + + } + + @override + void onClose() { + // TODO: implement onClose + super.onClose(); + + } + +} \ No newline at end of file diff --git a/star_lock/lib/mine/mineSet/transferSmartLock/recipientInformation/recipientInformation_page.dart b/star_lock/lib/mine/mineSet/transferSmartLock/recipientInformation/recipientInformation_page.dart new file mode 100644 index 00000000..da3c4f45 --- /dev/null +++ b/star_lock/lib/mine/mineSet/transferSmartLock/recipientInformation/recipientInformation_page.dart @@ -0,0 +1,303 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:get/get.dart'; +import 'package:star_lock/mine/mineSet/transferSmartLock/recipientInformation/recipientInformation_logic.dart'; +import 'package:star_lock/tools/submitBtn.dart'; +import 'package:star_lock/tools/toast.dart'; + +import '../../../../../appRouters.dart'; +import '../../../../../app_settings/app_colors.dart'; +import '../../../../../tools/titleAppBar.dart'; +import '../../../../../translations/trans_lib.dart'; +import '../../../../tools/commonItem.dart'; +import 'recipientInformation_entity.dart'; + +class RecipientInformationPage extends StatefulWidget { + const RecipientInformationPage({Key? key}) : super(key: key); + + @override + State createState() => + _RecipientInformationPageState(); +} + +class _RecipientInformationPageState extends State { + final logic = Get.put(RecipientInformationLogic()); + final state = Get.find().state; + + @override + Widget build(BuildContext context) { + return Scaffold( + resizeToAvoidBottomInset: false, + backgroundColor: AppColors.mainBackgroundColor, + appBar: TitleAppBar( + barTitle: TranslationLoader.lanKeys!.recipientInformation!.tr, + haveBack: true, + backgroundColor: AppColors.mainColor, + ), + body: Column( + children: [ + SizedBox(height: 150.h, child: _buildMainUI()), + SizedBox(height: 10.h), + _buildAccoutRow(), + _buildBottomText(), + _buildNextBtn(context), + SizedBox(height: 64.h), + Visibility( + visible: state.isFromType.value == 2 ? true : false, + child: _buildRemoveBadLockBtn()), + SizedBox(height: 64.h,) + ], + ), + ); + } + + Widget _buildMainUI() { + return Obx(() => Column( + children: [ + _electronicKeyItem(state.type.value == 1 ? 'images/select_circle.png' : 'images/normal_circle.png', "个人用户", () { + setState(() { + state.type.value = 1; + }); + }), + _electronicKeyItem(state.type.value == 2 ? 'images/select_circle.png' : 'images/normal_circle.png', "好房管家", () { + setState(() { + state.type.value = 2; + }); + }) + ], + )); + } + + Widget _electronicKeyItem( + String leftIcon, String leftTitle, Function() action) { + return GestureDetector( + onTap: action, + child: Container( + color: Colors.white, + height: 70.h, + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + SizedBox( + width: 40.w, + ), + GestureDetector( + child: Image.asset( + leftIcon, + width: 20.w, + height: 20.w, + ), + ), + SizedBox( + width: 16.w, + ), + Text( + leftTitle, + style: TextStyle(fontSize: 24.sp), + ) + ], + ), + ), + ); + } + + Widget _buildAccoutRow() { + return Container( + // height: 60.h, + color: Colors.white, + child: Column( + children: [ + Row( + children: [ + SizedBox(width: 40.w,), + Text('账号', style: TextStyle(color: AppColors.darkGrayTextColor, fontSize: 22.sp)), + Expanded( + child: TextField( + controller: state.numberController, + textAlign: TextAlign.right, + keyboardType: TextInputType.text, + onChanged: (value) {}, + decoration: InputDecoration( + border: InputBorder.none, + hintText: state.type.value == 1 ? "请输入手机号或email" : "请输入好房管家管理员的账号", + hintStyle: TextStyle( + color: AppColors.placeholderTextColor, + fontSize: ScreenUtil().setSp(22), + textBaseline: TextBaseline.alphabetic), + ), + )), + SizedBox(width: 20.w,), + Image.asset('images/icon_addressBook.png', width: 28.w, height: 28.h,), + SizedBox(width: 40.w,) + ], + ), + Divider( + color: AppColors.greyLineColor, + indent: 20.w, + endIndent: 20.w, + height: 1, + ), + CommonItem( + leftTitel: TranslationLoader.lanKeys!.countryAndRegion!.tr, + rightTitle: "", + isHaveLine: true, + isHaveRightWidget: true, + isHaveDirection: true, + rightWidget: Text( + '${state.countryName.value} +${state.countryCode.value}', + textAlign: TextAlign.end, + style: + TextStyle(fontSize: 22.sp, color: AppColors.darkGrayTextColor), + ), + action: () async { + var result = await Navigator.pushNamed( + context, Routers.seletCountryRegionPage); + result as Map; + state.countryCode.value = result['code']; + state.countryName.value = result['countryName']; + setState(() {}); + }, + ), + ], + ), + ); + } + + Widget _buildBottomText() { + return Padding( + padding: EdgeInsets.only(top: 20.h, bottom: 80.h), + child: Text( + '选中的智能锁将会转移到您输入的账号中,您将失去锁的管理权', + style: + TextStyle(fontSize: 18.sp, color: AppColors.placeholderTextColor), + textAlign: TextAlign.left, + ), + ); + } + + Widget _buildNextBtn(BuildContext context) { + return SubmitBtn(btnName: '下一步', onClick: () { + if(state.numberController.text.isEmpty){ + Toast.show(msg: "请输入手机号或email"); + return; + } + if(state.type.value == 1){ + logic.transferLockConfirmInfoData((v){ + showCupertinoAlertDialog(context, v); + }); + }else{ + Get.toNamed(Routers.selectBranchPage, arguments: { + "idList":state.idList.value, + "countryCode":state.countryCode.value, + "number":state.numberController.text, + }); + } + + }); + } + + Widget _buildRemoveBadLockBtn() { + return Row( + children: [ + const Expanded(child: SizedBox()), + TextButton( + onPressed: () { + + }, + child: Text('移除坏锁', style: TextStyle(fontSize: 22.sp, color: AppColors.darkGrayTextColor), textAlign: TextAlign.end,)), + SizedBox(width: 10.h,) + ], + ); + } + + void showCupertinoAlertDialog(BuildContext context, RecipientInformationData recipientInformationData) { + showGeneralDialog( + context: context, + barrierColor: Colors.black.withOpacity(.5), + barrierDismissible: true, + barrierLabel: '', + transitionDuration: const Duration(milliseconds: 200), + transitionBuilder: (BuildContext context, + Animation animation, + Animation secondaryAnimation, + Widget child) { + return ScaleTransition(scale: animation, child: child); + }, + pageBuilder: (BuildContext context, Animation animation, Animation secondaryAnimation) { + // recipientInformationData.nickname = "张三张三张三"; + return Center( + child: Container( + width: 400.w, + height: 370.h, + color: Colors.white, + child: Column( + children: [ + SizedBox(height: 20.h), + Text("转移确认", style: TextStyle(fontSize: 24.sp)), + SizedBox(height: 20.h), + Image.asset('images/icon_lockGroup_item.png', width: 70.h, height: 70.h, fit: BoxFit.fill), + SizedBox(height: 15.h), + Stack( + alignment: Alignment.center, + clipBehavior: Clip.none, + children: [ + Text(recipientInformationData.nickname!, style: TextStyle(fontSize: 22.sp)), + Positioned( + left: (recipientInformationData.nickname!.length*19.w).w, + child: Container( + width: 80.w, + color: Colors.red, + child: Center(child: Text(state.type.value == 1 ? "个人用户" : "好房管家", style: TextStyle(fontSize: 18.sp, color: Colors.white))), + ), + ) + ], + ), + SizedBox(height: 8.h), + Text(recipientInformationData.userid!, style: TextStyle(fontSize: 22.sp)), + SizedBox(height: 8.h), + Text("本次共转移${state.idList.value.length}把智能锁", style: TextStyle(fontSize: 20.sp)), + SizedBox(height: 20.h), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + ElevatedButton( + onPressed: () { + Get.back(); + }, + style: ElevatedButton.styleFrom( + onPrimary: AppColors.appBarIconColor, + backgroundColor: Colors.grey, + minimumSize: Size(110.w, 45.h), + padding: const EdgeInsets.symmetric(horizontal: 16), + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.all(Radius.circular(2)), + ), + ), + child: Text('取消', style: TextStyle(fontSize: 22.sp)), + ), + ElevatedButton( + onPressed: () { + Get.back(); + logic.transferLockInfoData(); + }, + style: ElevatedButton.styleFrom( + onPrimary: AppColors.appBarIconColor, + backgroundColor: AppColors.mainColor, + minimumSize: Size(110.w, 45.h), + padding: const EdgeInsets.symmetric(horizontal: 16), + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.all(Radius.circular(2)), + ), + ), + child: Text('确认', style: TextStyle(fontSize: 22.sp)), + ), + ], + ) + ], + ), + ), + ); + }); + } +} diff --git a/star_lock/lib/mine/mineSet/transferSmartLock/recipientInformation/recipientInformation_state.dart b/star_lock/lib/mine/mineSet/transferSmartLock/recipientInformation/recipientInformation_state.dart new file mode 100644 index 00000000..5e75faa1 --- /dev/null +++ b/star_lock/lib/mine/mineSet/transferSmartLock/recipientInformation/recipientInformation_state.dart @@ -0,0 +1,18 @@ + +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; + +class RecipientInformationState{ + var type = 1.obs;// 1、个人用户 2、星寓用户 + final TextEditingController numberController = TextEditingController(); + + final countryName = "中国".obs; + final countryCode = "86".obs; + final isFromType = 1.obs; + final idList = [].obs; + RecipientInformationState() { + Map map = Get.arguments; + idList.value = map["idList"]; + isFromType.value = map["isFromType"]; + } +} \ No newline at end of file diff --git a/star_lock/lib/mine/mineSet/transferSmartLock/recipientInformation_page.dart b/star_lock/lib/mine/mineSet/transferSmartLock/recipientInformation_page.dart deleted file mode 100644 index 770654aa..00000000 --- a/star_lock/lib/mine/mineSet/transferSmartLock/recipientInformation_page.dart +++ /dev/null @@ -1,185 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:get/get.dart'; -import 'package:star_lock/tools/submitBtn.dart'; - -import '../../../../appRouters.dart'; -import '../../../../app_settings/app_colors.dart'; -import '../../../../tools/titleAppBar.dart'; -import '../../../../translations/trans_lib.dart'; - -class RecipientInformationPage extends StatefulWidget { - const RecipientInformationPage({Key? key}) : super(key: key); - - @override - State createState() => - _RecipientInformationPageState(); -} - -class _RecipientInformationPageState extends State { - @override - Widget build(BuildContext context) { - return Scaffold( - backgroundColor: AppColors.mainBackgroundColor, - appBar: TitleAppBar( - barTitle: TranslationLoader.lanKeys!.recipientInformation!.tr, - haveBack: true, - backgroundColor: AppColors.mainColor, - ), - body: Column( - children: [ - SizedBox(height: 150.h, child: _buildMainUI()), - SizedBox( - height: 20.h, - ), - _buildAccoutRow(), - _buildBottomText(), - _buildNextBtn(), - Expanded( - child: SizedBox( - height: 64.h, - )), - _buildRemoveBadLockBtn(), - SizedBox( - height: 64.h, - ) - ], - ), - ); - } - - Widget _buildMainUI() { - return ListView.separated( - itemCount: 2, - separatorBuilder: (context, index) { - return Divider( - height: 1, - indent: 20.w, - endIndent: 20.w, - color: AppColors.greyLineColor, - ); - }, - itemBuilder: (c, index) { - if (index == 0) { - return _electronicKeyItem( - 'images/select_circle.png', "个人用户", () {}); - } else { - return _electronicKeyItem( - 'images/normal_circle.png', "好房管家", () {}); - } - }); - } - - Widget _electronicKeyItem( - String leftIcon, String leftTitle, Function() action) { - return GestureDetector( - child: Container( - color: Colors.white, - height: 70.h, - child: Row( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - SizedBox( - width: 40.w, - ), - GestureDetector( - child: Image.asset( - leftIcon, - width: 20.w, - height: 20.w, - ), - ), - SizedBox( - width: 16.w, - ), - Text( - leftTitle, - style: TextStyle(fontSize: 24.sp), - ) - ], - ), - ), - onTap: () {}, - ); - } - - Widget _buildAccoutRow() { - return Container( - height: 60.h, - color: Colors.white, - child: Row( - children: [ - SizedBox( - width: 40.w, - ), - Text( - '账号', - style: - TextStyle(color: AppColors.darkGrayTextColor, fontSize: 22.sp), - ), - Expanded( - child: TextField( - textAlign: TextAlign.right, - keyboardType: TextInputType.text, - onChanged: (value) {}, - decoration: InputDecoration( - border: InputBorder.none, - hintText: '请输入手机号或email', - hintStyle: TextStyle( - color: AppColors.placeholderTextColor, - fontSize: ScreenUtil().setSp(22), - textBaseline: TextBaseline.alphabetic), - ), - )), - SizedBox( - width: 20.w, - ), - Image.asset( - 'images/icon_addressBook.png', - width: 28.w, - height: 28.h, - ), - SizedBox( - width: 40.w, - ) - ], - ), - ); - } - - Widget _buildBottomText() { - return Padding( - padding: EdgeInsets.only(top: 20.h, bottom: 80.h), - child: Text( - '选中的智能锁将会转移到您输入的账号中,您将失去锁的管理权', - style: - TextStyle(fontSize: 18.sp, color: AppColors.placeholderTextColor), - textAlign: TextAlign.left, - ), - ); - } - - Widget _buildNextBtn() { - return SubmitBtn(btnName: '下一步', onClick: () {}); - } - - Widget _buildRemoveBadLockBtn() { - return Row( - children: [ - const Expanded(child: SizedBox()), - TextButton( - onPressed: () {}, - child: Text( - '移除坏锁', - style: TextStyle( - fontSize: 18.sp, color: AppColors.darkGrayTextColor), - textAlign: TextAlign.end, - )), - SizedBox( - width: 10.h, - ) - ], - ); - } -} diff --git a/star_lock/lib/mine/mineSet/transferSmartLock/selectBranch/selectBranch_logic.dart b/star_lock/lib/mine/mineSet/transferSmartLock/selectBranch/selectBranch_logic.dart new file mode 100644 index 00000000..f5198697 --- /dev/null +++ b/star_lock/lib/mine/mineSet/transferSmartLock/selectBranch/selectBranch_logic.dart @@ -0,0 +1,10 @@ + + +import 'package:star_lock/tools/baseGetXController.dart'; +import 'selectBranch_state.dart'; + +class SelectBranchLogic extends BaseGetXController{ + SelectBranchState state = SelectBranchState(); + + +} \ No newline at end of file diff --git a/star_lock/lib/mine/mineSet/transferSmartLock/selectBranch/selectBranch_page.dart b/star_lock/lib/mine/mineSet/transferSmartLock/selectBranch/selectBranch_page.dart new file mode 100644 index 00000000..afe84454 --- /dev/null +++ b/star_lock/lib/mine/mineSet/transferSmartLock/selectBranch/selectBranch_page.dart @@ -0,0 +1,230 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:get/get.dart'; + +import '../../../../../app_settings/app_colors.dart'; +import '../../../../../tools/titleAppBar.dart'; +import '../../../../../translations/trans_lib.dart'; +import '../recipientInformation/recipientInformation_entity.dart'; +import 'selectBranch_logic.dart'; + +class SelectBranchPage extends StatefulWidget { + const SelectBranchPage({Key? key}) : super(key: key); + + @override + State createState() => _SelectBranchPageState(); +} + +class _SelectBranchPageState extends State { + final logic = Get.put(SelectBranchLogic()); + final state = Get.find().state; + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: AppColors.mainBackgroundColor, + appBar: TitleAppBar( + barTitle: TranslationLoader.lanKeys!.recipientInformation!.tr, + haveBack: true, + backgroundColor: AppColors.mainColor, + ), + body: Column( + children: [ + _buildTopView(), + SizedBox( + height: 20.h, + ), + Expanded(child: _buildMainUI()), + _buildNextBtn(), + SizedBox( + height: 64.h, + ) + ], + ), + ); + } + + Widget _buildTopView() { + return Container( + height: 120.h, + width: ScreenUtil().screenWidth, + color: Colors.white, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: EdgeInsets.only(left: 40.w, top: 20.h, bottom: 16.h), + child: Text( + '公寓', + style: TextStyle(fontSize: 28.sp), + ), + ), + Obx(() => Padding( + padding: EdgeInsets.only(left: 40.w), + child: Text('管理员:${state.receiverNumber.value}', + style: TextStyle( + color: AppColors.darkGrayTextColor, fontSize: 24.sp)), + )) + ], + ), + ); + } + + Widget _buildMainUI() { + return ListView.separated( + itemCount: 1, + separatorBuilder: (context, index) { + return Divider( + height: 1, + indent: 20.w, + endIndent: 20.w, + color: AppColors.greyLineColor, + ); + }, + itemBuilder: (c, index) { + return _electronicKeyItem('images/normal_circle.png', "分组一", () {}); + }); + } + + Widget _electronicKeyItem( + String leftIcon, String leftTitle, Function() action) { + return GestureDetector( + child: Container( + color: Colors.white, + height: 70.h, + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + SizedBox( + width: 40.w, + ), + GestureDetector( + child: Image.asset( + leftIcon, + width: 16, + height: 16, + ), + ), + SizedBox( + width: 16.w, + ), + Text( + leftTitle, + style: TextStyle(fontSize: 24.sp), + ) + ], + ), + ), + onTap: () {}, + ); + } + + Widget _buildNextBtn() { + return GestureDetector( + child: Container( + color: AppColors.mainColor, + width: ScreenUtil().screenWidth, + height: 64.h, + child: TextButton( + onPressed: () { + // showCupertinoAlertDialog(context, RecipientInformationData()); + }, + child: Text( + '下一步', + style: TextStyle(fontSize: 28.sp, color: Colors.white), + )), + ), + ); + } + + void showCupertinoAlertDialog(BuildContext context, RecipientInformationData recipientInformationData) { + showGeneralDialog( + context: context, + barrierColor: Colors.black.withOpacity(.5), + barrierDismissible: true, + barrierLabel: '', + transitionDuration: const Duration(milliseconds: 200), + transitionBuilder: (BuildContext context, + Animation animation, + Animation secondaryAnimation, + Widget child) { + return ScaleTransition(scale: animation, child: child); + }, + pageBuilder: (BuildContext context, Animation animation, Animation secondaryAnimation) { + // recipientInformationData.nickname = "张三张三张三"; + return Center( + child: Container( + width: 400.w, + height: 370.h, + color: Colors.white, + child: Column( + children: [ + SizedBox(height: 20.h), + Text("转移确认", style: TextStyle(fontSize: 24.sp)), + SizedBox(height: 20.h), + Image.asset('images/icon_lockGroup_item.png', width: 70.h, height: 70.h, fit: BoxFit.fill), + SizedBox(height: 15.h), + Stack( + alignment: Alignment.center, + clipBehavior: Clip.none, + children: [ + Text(recipientInformationData.nickname!, style: TextStyle(fontSize: 22.sp)), + Positioned( + left: (recipientInformationData.nickname!.length*19.w).w, + child: Container( + width: 80.w, + color: Colors.red, + child: Center(child: Text(state.type.value == 1 ? "个人用户" : "好房管家", style: TextStyle(fontSize: 18.sp, color: Colors.white))), + ), + ) + ], + ), + SizedBox(height: 8.h), + Text(recipientInformationData.userid!, style: TextStyle(fontSize: 22.sp)), + SizedBox(height: 8.h), + Text("本次共转移${state.idList.value.length}把智能锁", style: TextStyle(fontSize: 20.sp)), + SizedBox(height: 20.h), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + ElevatedButton( + onPressed: () { + Get.back(); + }, + style: ElevatedButton.styleFrom( + onPrimary: AppColors.appBarIconColor, + backgroundColor: Colors.grey, + minimumSize: Size(110.w, 45.h), + padding: const EdgeInsets.symmetric(horizontal: 16), + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.all(Radius.circular(2)), + ), + ), + child: Text('取消', style: TextStyle(fontSize: 22.sp)), + ), + ElevatedButton( + onPressed: () { + Get.back(); + // logic.transferLockInfoData(); + }, + style: ElevatedButton.styleFrom( + onPrimary: AppColors.appBarIconColor, + backgroundColor: AppColors.mainColor, + minimumSize: Size(110.w, 45.h), + padding: const EdgeInsets.symmetric(horizontal: 16), + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.all(Radius.circular(2)), + ), + ), + child: Text('确认', style: TextStyle(fontSize: 22.sp)), + ), + ], + ) + ], + ), + ), + ); + }); + } +} diff --git a/star_lock/lib/mine/mineSet/transferSmartLock/selectBranch/selectBranch_state.dart b/star_lock/lib/mine/mineSet/transferSmartLock/selectBranch/selectBranch_state.dart new file mode 100644 index 00000000..ab92bb77 --- /dev/null +++ b/star_lock/lib/mine/mineSet/transferSmartLock/selectBranch/selectBranch_state.dart @@ -0,0 +1,17 @@ + +import 'package:get/get.dart'; + +class SelectBranchState{ + var type = 1.obs;// 1、个人用户 2、星寓用户 + + final receiverNumber = "".obs; + final countryName = "中国".obs; + final countryCode = "86".obs; + final idList = [].obs; + SelectBranchState() { + Map map = Get.arguments; + idList.value = map["idList"]; + countryCode.value = map["countryCode"]; + receiverNumber.value = map["number"]; + } +} \ No newline at end of file diff --git a/star_lock/lib/mine/mineSet/transferSmartLock/selectBranch_page.dart b/star_lock/lib/mine/mineSet/transferSmartLock/selectBranch_page.dart deleted file mode 100644 index 910281c7..00000000 --- a/star_lock/lib/mine/mineSet/transferSmartLock/selectBranch_page.dart +++ /dev/null @@ -1,133 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:get/get.dart'; - -import '../../../../app_settings/app_colors.dart'; -import '../../../../tools/titleAppBar.dart'; -import '../../../../translations/trans_lib.dart'; - -class SelectBranchPage extends StatefulWidget { - const SelectBranchPage({Key? key}) : super(key: key); - - @override - State createState() => _SelectBranchPageState(); -} - -class _SelectBranchPageState extends State { - @override - Widget build(BuildContext context) { - return Scaffold( - backgroundColor: AppColors.mainBackgroundColor, - appBar: TitleAppBar( - barTitle: TranslationLoader.lanKeys!.recipientInformation!.tr, - haveBack: true, - backgroundColor: AppColors.mainColor, - ), - body: Column( - children: [ - _buildTopView(), - SizedBox( - height: 20.h, - ), - Expanded(child: _buildMainUI()), - _buildNextBtn(), - SizedBox( - height: 64.h, - ) - ], - ), - ); - } - - Widget _buildTopView() { - return Container( - height: 120.h, - width: ScreenUtil().screenWidth, - color: Colors.white, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: EdgeInsets.only(left: 40.w, top: 20.h, bottom: 16.h), - child: Text( - '公寓', - style: TextStyle(fontSize: 28.sp), - ), - ), - Padding( - padding: EdgeInsets.only(left: 40.w), - child: Text('管理员:18682150237', - style: TextStyle( - color: AppColors.darkGrayTextColor, fontSize: 24.sp)), - ) - ], - ), - ); - } - - Widget _buildMainUI() { - return ListView.separated( - itemCount: 5, - separatorBuilder: (context, index) { - return Divider( - height: 1, - indent: 20.w, - endIndent: 20.w, - color: AppColors.greyLineColor, - ); - }, - itemBuilder: (c, index) { - return _electronicKeyItem('images/select_circle.png', "分组一", () {}); - }); - } - - Widget _electronicKeyItem( - String leftIcon, String leftTitle, Function() action) { - return GestureDetector( - child: Container( - color: Colors.white, - height: 70.h, - child: Row( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - SizedBox( - width: 40.w, - ), - GestureDetector( - child: Image.asset( - leftIcon, - width: 16, - height: 16, - ), - ), - SizedBox( - width: 16.w, - ), - Text( - leftTitle, - style: TextStyle(fontSize: 28.sp), - ) - ], - ), - ), - onTap: () {}, - ); - } - - Widget _buildNextBtn() { - return GestureDetector( - child: Container( - color: AppColors.mainColor, - width: ScreenUtil().screenWidth, - height: 64.h, - child: TextButton( - onPressed: () {}, - child: Text( - '下一步', - style: TextStyle(fontSize: 28.sp, color: Colors.white), - )), - ), - ); - } -} diff --git a/star_lock/lib/mine/mineSet/transferSmartLock/transferConfirmationBox/transferConfirmationBox_page.dart b/star_lock/lib/mine/mineSet/transferSmartLock/transferConfirmationBox/transferConfirmationBox_page.dart new file mode 100644 index 00000000..e69de29b diff --git a/star_lock/lib/mine/mineSet/transferSmartLock/transferSmartLockList/transferSmartLock_entity.dart b/star_lock/lib/mine/mineSet/transferSmartLock/transferSmartLockList/transferSmartLock_entity.dart new file mode 100644 index 00000000..03ed8ee4 --- /dev/null +++ b/star_lock/lib/mine/mineSet/transferSmartLock/transferSmartLockList/transferSmartLock_entity.dart @@ -0,0 +1,118 @@ +class TransferSmartLockEntity { + int? errorCode; + String? description; + String? errorMsg; + TransferSmartLockListData? data; + + TransferSmartLockEntity( + {this.errorCode, this.description, this.errorMsg, this.data}); + + TransferSmartLockEntity.fromJson(Map json) { + errorCode = json['errorCode']; + description = json['description']; + errorMsg = json['errorMsg']; + data = json['data'] != null ? TransferSmartLockListData.fromJson(json['data']) : null; + } + + Map toJson() { + final Map data = {}; + data['errorCode'] = errorCode; + data['description'] = description; + data['errorMsg'] = errorMsg; + if (this.data != null) { + data['data'] = this.data!.toJson(); + } + return data; + } +} + +class TransferSmartLockListData { + List? list; + + TransferSmartLockListData({this.list}); + + TransferSmartLockListData.fromJson(Map json) { + if (json['list'] != null) { + list = []; + json['list'].forEach((v) { + list!.add(TransferSmartLockItemData.fromJson(v)); + }); + } + } + + Map toJson() { + final Map data = {}; + if (list != null) { + data['list'] = list!.map((v) => v.toJson()).toList(); + } + return data; + } +} + +class TransferSmartLockItemData { + int? lockId; + int? selet = 0; + String? lockAlias; + LockVersion? lockVersion; + + TransferSmartLockItemData({this.lockId, this.lockAlias, this.lockVersion}); + + TransferSmartLockItemData.fromJson(Map json) { + lockId = json['lockId']; + lockAlias = json['lockAlias']; + // lockVersion = json['lockVersion'] != null + // ? LockVersion.fromJson(json['lockVersion']) + // : null; + } + + Map toJson() { + final Map data = {}; + data['lockId'] = lockId; + data['lockAlias'] = lockAlias; + // if (lockVersion != null) { + // data['lockVersion'] = lockVersion!.toJson(); + // } + return data; + } +} + +class LockVersion { + bool? showAdminKbpwdFlag; + int? groupId; + int? protocolVersion; + int? protocolType; + int? orgId; + String? logoUrl; + int? scene; + + LockVersion( + {this.showAdminKbpwdFlag, + this.groupId, + this.protocolVersion, + this.protocolType, + this.orgId, + this.logoUrl, + this.scene}); + + LockVersion.fromJson(Map json) { + showAdminKbpwdFlag = json['showAdminKbpwdFlag']; + groupId = json['groupId']; + protocolVersion = json['protocolVersion']; + protocolType = json['protocolType']; + orgId = json['orgId']; + logoUrl = json['logoUrl']; + scene = json['scene']; + } + + Map toJson() { + final Map data = {}; + data['showAdminKbpwdFlag'] = showAdminKbpwdFlag; + data['groupId'] = groupId; + data['protocolVersion'] = protocolVersion; + data['protocolType'] = protocolType; + data['orgId'] = orgId; + data['logoUrl'] = logoUrl; + data['scene'] = scene; + return data; + } +} diff --git a/star_lock/lib/mine/mineSet/transferSmartLock/transferSmartLockList/transferSmartLock_logic.dart b/star_lock/lib/mine/mineSet/transferSmartLock/transferSmartLockList/transferSmartLock_logic.dart new file mode 100644 index 00000000..a18d022a --- /dev/null +++ b/star_lock/lib/mine/mineSet/transferSmartLock/transferSmartLockList/transferSmartLock_logic.dart @@ -0,0 +1,40 @@ + +import 'package:star_lock/tools/baseGetXController.dart'; +import '../../../../network/api_repository.dart'; +import 'transferSmartLock_state.dart'; + +class TransferSmartLockLogic extends BaseGetXController{ + TransferSmartLockState state = TransferSmartLockState(); + + // 获取锁列表 + Future getTransferLockListData() async{ + var entity = await ApiRepository.to.getTransferLockListData(); + if(entity.errorCode!.codeIsSuccessful){ + state.transferSmartLockListData.value = entity.data!.list!; + } + } + + @override + void onReady() { + // TODO: implement onReady + super.onReady(); + print("onReady()"); + + getTransferLockListData(); + } + + @override + void onInit() { + // TODO: implement onInit + super.onInit(); + print("onInit()"); + + } + + @override + void onClose() { + // TODO: implement onClose + super.onClose(); + + } +} \ No newline at end of file diff --git a/star_lock/lib/mine/mineSet/transferSmartLock/transferSmartLockList/transferSmartLock_page.dart b/star_lock/lib/mine/mineSet/transferSmartLock/transferSmartLockList/transferSmartLock_page.dart new file mode 100644 index 00000000..a2fe3efe --- /dev/null +++ b/star_lock/lib/mine/mineSet/transferSmartLock/transferSmartLockList/transferSmartLock_page.dart @@ -0,0 +1,197 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:get/get.dart'; + +import '../../../../../appRouters.dart'; +import '../../../../../app_settings/app_colors.dart'; +import '../../../../../tools/titleAppBar.dart'; +import '../../../../../translations/trans_lib.dart'; +import '../../../../tools/noData.dart'; +import '../../../../tools/toast.dart'; +import 'transferSmartLock_entity.dart'; +import 'transferSmartLock_logic.dart'; + +class TransferSmartLockPage extends StatefulWidget { + const TransferSmartLockPage({Key? key}) : super(key: key); + + @override + State createState() => _TransferSmartLockPageState(); +} + +class _TransferSmartLockPageState extends State { + final logic = Get.put(TransferSmartLockLogic()); + final state = Get.find().state; + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: AppColors.mainBackgroundColor, + appBar: TitleAppBar( + barTitle: TranslationLoader.lanKeys!.selectiveLock!.tr, + haveBack: true, + backgroundColor: AppColors.mainColor, + actionsList: [ + TextButton( + onPressed: () { + setState(() { + for (var element in state.transferSmartLockListData.value) { + if(state.isSeletAll == true){ + state.isSeletAll = false; + element.selet = 0; + }else{ + state.isSeletAll = true; + element.selet = 1; + } + } + }); + }, + child: Text(state.isSeletAll == true ? TranslationLoader.lanKeys!.checkAll!.tr : TranslationLoader.lanKeys!.cancel!.tr, style: TextStyle(color: Colors.white, fontSize: 24.sp))) + ], + ), + body: Column( + children: [ + _searchWidget(), + SizedBox(height: 10.h), + Expanded(child: _buildMainUI()), + SizedBox(height: 20.h), + _buildNextBtn(), + SizedBox(height: 64.h) + ], + ), + ); + } + + Widget _searchWidget() { + return Container( + height: 60.h, + margin: EdgeInsets.only(top: 20.w, left: 20.w, right: 10.w), + decoration: BoxDecoration( + color: Colors.white, borderRadius: BorderRadius.circular(5)), + child: TextField( + //输入框一行 + maxLines: 1, + controller: state.searchController, + autofocus: false, + onChanged: (value){ + print("onChanged:$value"); + }, + onEditingComplete: (){ + print("onEditingComplete:"); + }, + onSubmitted: (value) async { + FocusScope.of(context).requestFocus(FocusNode()); + await logic.getTransferLockListData(); + if(state.searchController.text.isNotEmpty){ + var contrList = []; + for (var element in state.transferSmartLockListData.value) { + if(element.lockAlias!.contains(state.searchController.text)){ + contrList.add(element); + } + } + state.transferSmartLockListData.value = contrList; + print("contrList:${contrList[0].lockAlias} state.transferSmartLockListData.value:${state.transferSmartLockListData.value[0].lockAlias}"); + } + }, + decoration: InputDecoration( + //输入里面输入文字内边距设置 + contentPadding: const EdgeInsets.only(top: 12.0, left: -19.0, right: -15.0, bottom: 8.0), + hintText: TranslationLoader.lanKeys!.pleaseEnter!.tr, + hintStyle: TextStyle(fontSize: 22.sp, height: 3.0), + //不需要输入框下划线 + border: InputBorder.none, + //左边图标设置 + icon: Padding( + padding: EdgeInsets.only( + top: 20.h, bottom: 20.h, right: 20.w, left: 10.w), + child: Image.asset( + 'images/main/icon_main_search.png', + width: 40.w, + height: 40.w, + ), + ), + ), + ), + ); + } + + Widget _buildMainUI() { + return Obx(() => state.transferSmartLockListData.value.isNotEmpty ? ListView.separated( + itemCount: state.transferSmartLockListData.value.length, + separatorBuilder: (context, index) { + return Divider( + height: 1, + indent: 20.w, + endIndent: 20.w, + color: AppColors.greyLineColor, + ); + }, + itemBuilder: (c, index) { + TransferSmartLockItemData transferSmartLockItemData = state.transferSmartLockListData.value[index]; + return _electronicKeyItem(transferSmartLockItemData, () { + setState(() { + if(transferSmartLockItemData.selet == 1){ + transferSmartLockItemData.selet = 0; + }else{ + transferSmartLockItemData.selet = 1; + } + }); + }); + }):const NoData()); + } + + Widget _electronicKeyItem(TransferSmartLockItemData transferSmartLockItemData, Function() action) { + return GestureDetector( + onTap: action, + child: Container( + color: Colors.white, + height: 90.h, + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + SizedBox(width: 20.w), + Image.asset((transferSmartLockItemData.selet == 1) ? 'images/icon_round_selet.png' : 'images/icon_round_unSelet.png', width: 30.w, height: 30.w), + SizedBox(width: 16.w), + Image.asset('images/icon_lockGroup_item.png', width: 50.h, height: 50.h, fit: BoxFit.fill), + SizedBox(width: 10.w), + Text(transferSmartLockItemData.lockAlias!, style: TextStyle(fontSize: 22.sp, color: AppColors.blackColor)) + ], + ), + ), + ); + } + + Widget _buildNextBtn() { + return GestureDetector( + child: Container( + color: AppColors.mainColor, + width: ScreenUtil().screenWidth, + height: 64.h, + child: TextButton( + onPressed: () async { + bool isCanNext = false; + var idList = []; + for (var element in state.transferSmartLockListData.value) { + if(element.selet == 1){ + isCanNext = true; + idList.add(element.lockId); + } + } + if(isCanNext == false){ + Toast.show(msg: "请选择锁"); + return; + } + var data = await Get.toNamed(Routers.recipientInformationPage, arguments: { + "idList":idList, + "isFromType":2, + }); + if(data != null) { + logic.getTransferLockListData(); + } + }, + child: Text('下一步', style: TextStyle(fontSize: 28.sp, color: Colors.white), + )), + ), + ); + } +} diff --git a/star_lock/lib/mine/mineSet/transferSmartLock/transferSmartLockList/transferSmartLock_state.dart b/star_lock/lib/mine/mineSet/transferSmartLock/transferSmartLockList/transferSmartLock_state.dart new file mode 100644 index 00000000..fb777983 --- /dev/null +++ b/star_lock/lib/mine/mineSet/transferSmartLock/transferSmartLockList/transferSmartLock_state.dart @@ -0,0 +1,11 @@ + +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; + +import 'transferSmartLock_entity.dart'; + +class TransferSmartLockState{ + var transferSmartLockListData = [].obs; + final TextEditingController searchController = TextEditingController(); + bool isSeletAll = false; +} \ No newline at end of file diff --git a/star_lock/lib/mine/mineSet/transferSmartLock/transferSmartLock_page.dart b/star_lock/lib/mine/mineSet/transferSmartLock/transferSmartLock_page.dart deleted file mode 100644 index 736c3201..00000000 --- a/star_lock/lib/mine/mineSet/transferSmartLock/transferSmartLock_page.dart +++ /dev/null @@ -1,168 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:get/get.dart'; - -import '../../../../appRouters.dart'; -import '../../../../app_settings/app_colors.dart'; -import '../../../../tools/titleAppBar.dart'; -import '../../../../translations/trans_lib.dart'; - -class TransferSmartLockPage extends StatefulWidget { - const TransferSmartLockPage({Key? key}) : super(key: key); - - @override - State createState() => _TransferSmartLockPageState(); -} - -class _TransferSmartLockPageState extends State { - @override - Widget build(BuildContext context) { - return Scaffold( - backgroundColor: AppColors.mainBackgroundColor, - appBar: TitleAppBar( - barTitle: TranslationLoader.lanKeys!.selectiveLock!.tr, - haveBack: true, - backgroundColor: AppColors.mainColor, - actionsList: [ - TextButton( - onPressed: () {}, - child: Text( - '全选', - style: TextStyle(color: Colors.white, fontSize: 24.sp), - )) - ], - ), - body: Column( - children: [ - _searchWidget(), - SizedBox( - height: 10.h, - ), - Expanded(child: _buildMainUI()), - SizedBox( - height: 20.h, - ), - _buildNextBtn(), - SizedBox( - height: 64.h, - ) - ], - ), - ); - } - - Widget _searchWidget() { - return Container( - height: 60.h, - margin: EdgeInsets.only(top: 20.w, left: 20.w, right: 10.w), - decoration: BoxDecoration( - color: Colors.white, borderRadius: BorderRadius.circular(5)), - child: TextField( - //输入框一行 - maxLines: 1, - // controller: _controller, - autofocus: false, - - decoration: InputDecoration( - //输入里面输入文字内边距设置 - contentPadding: const EdgeInsets.only( - top: 12.0, left: -19.0, right: -15.0, bottom: 8.0), - hintText: TranslationLoader.lanKeys!.pleaseEnter!.tr, - hintStyle: TextStyle(fontSize: 22.sp, height: 3.0), - //不需要输入框下划线 - border: InputBorder.none, - //左边图标设置 - icon: Padding( - padding: EdgeInsets.only( - top: 20.h, bottom: 20.h, right: 20.w, left: 10.w), - child: Image.asset( - 'images/main/icon_main_search.png', - width: 40.w, - height: 40.w, - ), - ), - ), - ), - ); - } - - Widget _buildMainUI() { - return ListView.separated( - itemCount: 10, - separatorBuilder: (context, index) { - return Divider( - height: 1, - indent: 20.w, - endIndent: 20.w, - color: AppColors.greyLineColor, - ); - }, - itemBuilder: (c, index) { - return _electronicKeyItem('images/icon_lock.png', "张三", - "2023.6.21 11.15", "2023.6.21 11.15", () { - Navigator.pushNamed(context, Routers.authorizedAdminDetailPage); - }); - }); - } - - Widget _electronicKeyItem(String lockTypeIcon, String lockTypeTitle, - String beginTime, String endTime, Function() action) { - return GestureDetector( - child: Container( - color: Colors.white, - height: 90.h, - child: Row( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - SizedBox( - width: 20.w, - ), - GestureDetector( - child: Image.asset( - 'images/icon_round_unSelet.png', - width: 22, - height: 22, - ), - ), - SizedBox( - width: 16.w, - ), - Image.asset( - 'images/icon_lockGroup_item.png', - width: 36, - height: 36, - fit: BoxFit.fill, - ), - SizedBox( - width: 10.w, - ), - Text( - 'Daisy', - style: TextStyle(fontSize: 22.sp, color: AppColors.blackColor), - ) - ], - ), - ), - onTap: () {}, - ); - } - - Widget _buildNextBtn() { - return GestureDetector( - child: Container( - color: Colors.grey, - width: ScreenUtil().screenWidth, - height: 64.h, - child: TextButton( - onPressed: () { - Navigator.pushNamed(context, Routers.recipientInformationPage); - }, - child: Text( - '下一步', - style: TextStyle(fontSize: 28.sp, color: Colors.white), - )), - ), - ); - } -} diff --git a/star_lock/lib/network/api.dart b/star_lock/lib/network/api.dart index b38acbbd..074a2e73 100644 --- a/star_lock/lib/network/api.dart +++ b/star_lock/lib/network/api.dart @@ -89,6 +89,12 @@ abstract class Api { final String deleteICCardURL = '/identityCard/delete'; // 删除IC卡 final String updateICCardUserNoURL = '/identityCard/updatePwdUserNo'; // 更新ic卡用户序号 + final String transferLockListURL = '/room/listForTransfer'; // 转移锁锁列表 + final String transferLockConfirmURL = '/room/transferLockConfirm'; // 转移智能锁确认 + final String transferLockURL = '/room/transfer'; // 转移智能锁 + + final String gatewaykListURL = '/plug/list'; // 转网关列表 + final String getKeyDetailURL = '/key/get'; //获取单把钥匙详情信息 final String lockUserListURL = '/keyUser/listKeyUser'; //锁用户列表 final String canSendKeyURL = '/keyUser/canSendKey'; //群发钥匙检查 diff --git a/star_lock/lib/network/api_provider.dart b/star_lock/lib/network/api_provider.dart index b9e872f2..a87c93b3 100644 --- a/star_lock/lib/network/api_provider.dart +++ b/star_lock/lib/network/api_provider.dart @@ -940,6 +940,53 @@ class ApiProvider extends BaseProvider { }) ); + // 获取转移锁锁列表 + Future getTransferLockListData() => + post( + transferLockListURL.toUrl, + jsonEncode({}) + ); + + // 转移智能锁确认 + Future transferLockConfirmInfoData( + String receiverUserid, + String type, + String countryCode) => + post( + transferLockConfirmURL.toUrl, + jsonEncode({ + 'receiverUserid': receiverUserid, + 'type': type, + 'countryCode': countryCode + }) + ); + + // 转移智能锁 + Future transferLockInfoData( + String receiverUserid, + List lockIdList, + String countryCode) => + post( + transferLockURL.toUrl, + jsonEncode({ + 'receiverUserid': receiverUserid, + 'lockIdList': lockIdList, + 'countryCode': countryCode + }) + ); + + // 获取网关列表 + Future getGatewayListData( + String pageNo, + String pageSize) => + post( + gatewaykListURL.toUrl, + jsonEncode({ + 'pageNo': pageNo, + 'pageSize': pageSize + }) + ); + Future listLockByGroup(String type, String keyGroupId) => post( listLockByGroupURL.toUrl, jsonEncode({'type': type, 'keyGroupId': keyGroupId})); diff --git a/star_lock/lib/network/api_repository.dart b/star_lock/lib/network/api_repository.dart index 05fe2e34..6425f2aa 100644 --- a/star_lock/lib/network/api_repository.dart +++ b/star_lock/lib/network/api_repository.dart @@ -30,6 +30,9 @@ import '../main/lockDetail/lcokSet/normallyOpenMode/GetPassageModeConfigEntity.d import '../main/lockDetail/otherTypeKey/otherTypeKeyList/fingerprintListData_entity.dart'; import '../main/lockMian/entity/lockInfoEntity.dart'; import '../mine/addLock/saveLock/entity/SaveLockEntity.dart'; +import '../mine/mineSet/transferGateway/selectGetewayList_entity.dart'; +import '../mine/mineSet/transferSmartLock/recipientInformation/recipientInformation_entity.dart'; +import '../mine/mineSet/transferSmartLock/transferSmartLockList/transferSmartLock_entity.dart'; import 'api_provider.dart'; class ApiRepository { @@ -1005,4 +1008,39 @@ class ApiRepository { return LoginEntity.fromJson(res.body); } + // 获取转移锁锁列表 + Future getTransferLockListData() async { + final res = await apiProvider.getTransferLockListData(); + return TransferSmartLockEntity.fromJson(res.body); + } + + // 转移智能锁确认 + Future transferLockConfirmInfoData({ + required String receiverUserid, + required String type, + required String countryCode + }) async { + final res = await apiProvider.transferLockConfirmInfoData(receiverUserid, type, countryCode); + return RecipientInformationEntity.fromJson(res.body); + } + + // 转移智能锁 + Future transferLockInfoData({ + required String receiverUserid, + required List lockIdList, + required String countryCode + }) async { + final res = await apiProvider.transferLockInfoData(receiverUserid, lockIdList, countryCode); + return RecipientInformationEntity.fromJson(res.body); + } + + // 获取网关列表 + Future getGatewayListData({ + required String pageNo, + required String pageSize + }) async { + final res = await apiProvider.getGatewayListData(pageNo, pageSize); + return GetewayDataEntity.fromJson(res.body); + } + }