diff --git a/lib/main/lockDetail/lockSet/configuringWifi/configuringWifi/configuringWifi_logic.dart b/lib/main/lockDetail/lockSet/configuringWifi/configuringWifi/configuringWifi_logic.dart index 763d25ca..c350b336 100755 --- a/lib/main/lockDetail/lockSet/configuringWifi/configuringWifi/configuringWifi_logic.dart +++ b/lib/main/lockDetail/lockSet/configuringWifi/configuringWifi/configuringWifi_logic.dart @@ -8,6 +8,7 @@ import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:get/get.dart'; import 'package:network_info_plus/network_info_plus.dart'; import 'package:permission_handler/permission_handler.dart'; +import 'package:star_lock/appRouters.dart'; import 'package:star_lock/app_settings/app_settings.dart'; import 'package:star_lock/blue/io_gateway/io_gateway_configuringWifi.dart'; import 'package:star_lock/blue/io_gateway/io_gateway_getStatus.dart'; @@ -68,7 +69,12 @@ class ConfiguringWifiLogic extends BaseGetXController { secretKey: secretKey, peerId: peerId, ); - Get.close(2); + + if (state.pageName.value == 'lockSet') { + Get.close(2); + } else { + Get.offAllNamed(Routers.starLockMain); + } }); } } diff --git a/lib/main/lockDetail/lockSet/configuringWifi/configuringWifi/configuringWifi_page.dart b/lib/main/lockDetail/lockSet/configuringWifi/configuringWifi/configuringWifi_page.dart index 55a6a02c..89ea1ee1 100755 --- a/lib/main/lockDetail/lockSet/configuringWifi/configuringWifi/configuringWifi_page.dart +++ b/lib/main/lockDetail/lockSet/configuringWifi/configuringWifi/configuringWifi_page.dart @@ -47,7 +47,8 @@ class _ConfiguringWifiPageState extends State SubmitBtn( btnName: '确定'.tr, onClick: () { - logic.senderConfiguringWifiAction(); + FocusScope.of(context).requestFocus(FocusNode()); + logic.senderConfiguringWifiAction(); }, ), ], diff --git a/lib/main/lockDetail/lockSet/configuringWifi/configuringWifi/configuringWifi_state.dart b/lib/main/lockDetail/lockSet/configuringWifi/configuringWifi/configuringWifi_state.dart index 33707851..062ebf51 100755 --- a/lib/main/lockDetail/lockSet/configuringWifi/configuringWifi/configuringWifi_state.dart +++ b/lib/main/lockDetail/lockSet/configuringWifi/configuringWifi/configuringWifi_state.dart @@ -9,6 +9,7 @@ class ConfiguringWifiState{ ConfiguringWifiState() { var map = Get.arguments; lockSetInfoData.value = map['lockSetInfoData']; + pageName.value = map['pageName']; lockBasicInfo.value = lockSetInfoData.value.lockBasicInfo!; if (map['wifiName'] != null) { wifiName.value = map['wifiName']; @@ -20,6 +21,7 @@ class ConfiguringWifiState{ Rx lockBasicInfo = LockBasicInfo().obs; RxString wifiName = ''.obs; + RxString pageName = ''.obs; RxBool ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示 RxInt sureBtnState = 0.obs;// 0普通状态(可用) 1连接中(不可用) diff --git a/lib/main/lockDetail/lockSet/configuringWifi/wifiList/wifiList_page.dart b/lib/main/lockDetail/lockSet/configuringWifi/wifiList/wifiList_page.dart index 937c2e8a..bd976e9d 100755 --- a/lib/main/lockDetail/lockSet/configuringWifi/wifiList/wifiList_page.dart +++ b/lib/main/lockDetail/lockSet/configuringWifi/wifiList/wifiList_page.dart @@ -24,11 +24,18 @@ class _WifiListPageState extends State { @override Widget build(BuildContext context) { - return Scaffold( - backgroundColor: Colors.white, - appBar: TitleAppBar( + return WillPopScope( + onWillPop: () async { + if (state.pageName.value == 'lockSet') { + return true; + } + return false; + }, + child: Scaffold( + backgroundColor: Colors.white, + appBar: TitleAppBar( barTitle: 'WIFI列表'.tr, - haveBack: true, + haveBack: state.pageName.value == 'lockSet', actionsList: [ TextButton( child: Text( @@ -38,45 +45,50 @@ class _WifiListPageState extends State { onPressed: logic.senderGetWifiListWifiAction, ), ], - backgroundColor: AppColors.mainColor), - body: Column( - children: [ - Expanded( - child: Obx(() => state.wifiNameDataList.value.isNotEmpty - ? ListView.builder( - itemCount: state.wifiNameDataList.value.length, - itemBuilder: (BuildContext c, int index) { - Map wifiNameStr = state.wifiNameDataList.value[index]; - return _messageListItem( - wifiNameStr['wifiName'], wifiNameStr['rssi'], () { - Get.toNamed(Routers.configuringWifiPage, arguments: { - 'lockSetInfoData': state.lockSetInfoData.value, - 'wifiName': wifiNameStr['wifiName'], + backgroundColor: AppColors.mainColor, + ), + body: Column( + children: [ + Expanded( + child: Obx(() => state.wifiNameDataList.value.isNotEmpty + ? ListView.builder( + itemCount: state.wifiNameDataList.value.length, + itemBuilder: (BuildContext c, int index) { + Map wifiNameStr = state.wifiNameDataList.value[index]; + return _messageListItem( + wifiNameStr['wifiName'], wifiNameStr['rssi'], () { + Get.toNamed(Routers.configuringWifiPage, + arguments: { + 'lockSetInfoData': + state.lockSetInfoData.value, + 'wifiName': wifiNameStr['wifiName'], + 'pageName': state.pageName.value, + }); }); + }) + : NoData( + noDataHeight: 1.sh - + ScreenUtil().statusBarHeight - + ScreenUtil().bottomBarHeight - + 64.h)), + ), + SubmitBtn( + btnName: '手动配网'.tr, + fontSize: 28.sp, + borderRadius: 20.w, + padding: EdgeInsets.only(top: 25.w, bottom: 25.w), + onClick: () { + Get.toNamed(Routers.configuringWifiPage, + arguments: { + 'lockSetInfoData': state.lockSetInfoData.value }); - }) - : NoData( - noDataHeight: 1.sh - - ScreenUtil().statusBarHeight - - ScreenUtil().bottomBarHeight - - 64.h)), - ), - SubmitBtn( - btnName: '手动配网'.tr, - fontSize: 28.sp, - borderRadius: 20.w, - padding: EdgeInsets.only(top: 25.w, bottom: 25.w), - onClick: () { - Get.toNamed(Routers.configuringWifiPage, - arguments: { - 'lockSetInfoData': state.lockSetInfoData.value - }); - }), - SizedBox( - height: 64.h, - ) - ], - )); + }), + SizedBox( + height: 64.h, + ) + ], + )), + ); } Widget _messageListItem(String wifiName, String rssi, Function() action) { diff --git a/lib/main/lockDetail/lockSet/configuringWifi/wifiList/wifiList_state.dart b/lib/main/lockDetail/lockSet/configuringWifi/wifiList/wifiList_state.dart index ca058136..d640b496 100755 --- a/lib/main/lockDetail/lockSet/configuringWifi/wifiList/wifiList_state.dart +++ b/lib/main/lockDetail/lockSet/configuringWifi/wifiList/wifiList_state.dart @@ -1,18 +1,22 @@ - import 'package:get/get.dart'; import '../../lockSet/lockSetInfo_entity.dart'; -class WifiListState{// 0普通状态(可用) 1连接中(不可用) +class WifiListState { + // 0普通状态(可用) 1连接中(不可用) WifiListState() { final map = Get.arguments; lockSetInfoData.value = map['lockSetInfoData']; + pageName.value = map['pageName']; lockBasicInfo.value = lockSetInfoData.value.lockBasicInfo!; } - final RxList> wifiNameDataList = >[].obs; + + final RxList> wifiNameDataList = + >[].obs; Rx lockSetInfoData = LockSetInfoData().obs; Rx lockBasicInfo = LockBasicInfo().obs; RxBool ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示 RxInt sureBtnState = 0.obs; -} \ No newline at end of file + RxString pageName = ''.obs; +} diff --git a/lib/main/lockDetail/lockSet/lockSet/lockSet_page.dart b/lib/main/lockDetail/lockSet/lockSet/lockSet_page.dart index dbea2c40..a0011308 100755 --- a/lib/main/lockDetail/lockSet/lockSet/lockSet_page.dart +++ b/lib/main/lockDetail/lockSet/lockSet/lockSet_page.dart @@ -595,10 +595,10 @@ class _LockSetPageState extends State isHaveLine: true, isHaveDirection: true, action: () { - Get.toNamed(Routers.wifiListPage, - arguments: { - 'lockSetInfoData': state.lockSetInfoData.value - }); + Get.toNamed(Routers.wifiListPage, arguments: { + 'lockSetInfoData': state.lockSetInfoData.value, + 'pageName': 'lockSet' + }); // Get.toNamed(Routers.configuringWifiPage, arguments: { // 'lockSetInfoData': state.lockSetInfoData.value // }); diff --git a/lib/main/lockMian/entity/lockListInfo_entity.dart b/lib/main/lockMian/entity/lockListInfo_entity.dart index b3b46464..81838ba6 100755 --- a/lib/main/lockMian/entity/lockListInfo_entity.dart +++ b/lib/main/lockMian/entity/lockListInfo_entity.dart @@ -345,6 +345,8 @@ class LockFeature { this.isSupportCatEye, this.isSupportBackupBattery, this.isNoSupportedBlueBroadcast, + this.wifiLockType, + this.wifi, }); LockFeature.fromJson(Map json) { @@ -360,6 +362,8 @@ class LockFeature { isSupportCatEye = json['isSupportCatEye']; isSupportBackupBattery = json['isSupportBackupBattery']; isNoSupportedBlueBroadcast = json['isNoSupportedBlueBroadcast']; + wifiLockType = json['wifiLockType']; + wifi = json['wifi']; } int? password; @@ -374,6 +378,8 @@ class LockFeature { int? isSupportCatEye; int? isSupportBackupBattery; int? isNoSupportedBlueBroadcast; + int? wifiLockType; + int? wifi; Map toJson() { final Map data = {}; @@ -389,6 +395,8 @@ class LockFeature { data['isSupportCatEye'] = isSupportCatEye; data['isSupportBackupBattery'] = isSupportBackupBattery; data['isNoSupportedBlueBroadcast'] = isNoSupportedBlueBroadcast; + data['wifiLockType'] = wifiLockType; + data['wifi'] = wifi; return data; } } diff --git a/lib/mine/addLock/saveLock/saveLock_logic.dart b/lib/mine/addLock/saveLock/saveLock_logic.dart index 7e8ae377..ce1cc799 100755 --- a/lib/mine/addLock/saveLock/saveLock_logic.dart +++ b/lib/mine/addLock/saveLock/saveLock_logic.dart @@ -1,11 +1,12 @@ - import 'dart:async'; import 'package:flutter_blue_plus/flutter_blue_plus.dart'; import 'package:get/get.dart'; import 'package:star_lock/apm/apm_helper.dart'; +import 'package:star_lock/appRouters.dart'; import 'package:star_lock/main/lockDetail/lockDetail/lockDetail_logic.dart'; +import 'package:star_lock/main/lockDetail/lockSet/lockSet/lockSetInfo_entity.dart'; import 'package:star_lock/mine/addLock/saveLock/entity/SaveLockEntity.dart'; import '../../../app_settings/app_settings.dart'; @@ -408,10 +409,11 @@ class SaveLockLogic extends BaseGetXController { final String getMobile = (await Storage.getMobile())!; ApmHelper.instance.trackEvent('save_lock_result', { - 'lock_name':BlueManage().connectDeviceName, - 'account':getMobile.isNotEmpty ? getMobile : (await Storage.getEmail())!, - 'date':DateTool().getNowDateWithType(1), - 'save_lock_result':'成功', + 'lock_name': BlueManage().connectDeviceName, + 'account': + getMobile.isNotEmpty ? getMobile : (await Storage.getEmail())!, + 'date': DateTool().getNowDateWithType(1), + 'save_lock_result': '成功', }); backAction(); // await senderCustomPasswords(); @@ -424,10 +426,11 @@ class SaveLockLogic extends BaseGetXController { final String getMobile = (await Storage.getMobile())!; ApmHelper.instance.trackEvent('save_lock_result', { - 'lock_name':BlueManage().connectDeviceName, - 'account':getMobile.isNotEmpty ? getMobile : (await Storage.getEmail())!, - 'date':DateTool().getNowDateWithType(1), - 'save_lock_result':'${entity.errorCode}--${entity.errorMsg}', + 'lock_name': BlueManage().connectDeviceName, + 'account': + getMobile.isNotEmpty ? getMobile : (await Storage.getEmail())!, + 'date': DateTool().getNowDateWithType(1), + 'save_lock_result': '${entity.errorCode}--${entity.errorMsg}', }); } } @@ -482,20 +485,52 @@ class SaveLockLogic extends BaseGetXController { // ); // } - void backAction() { + void backAction() async { eventBus.fire(RefreshLockListInfoDataEvent(clearScanDevices: true)); BlueManage().disconnect(); - Future.delayed(const Duration(seconds: 1), () { - Get.close(state.isFromMap == 1 ? (CommonDataManage().seletLockType == 0 ? 4 : 5) : (CommonDataManage().seletLockType == 0 ? 5 : 6)); - }); - //刚刚配对完,需要对开锁页锁死 2 秒 - Future.delayed(const Duration(milliseconds: 200), () { - if (Get.isRegistered()) { - Get.find() - .functionBlocker - .countdownProhibited(duration: const Duration(seconds: 2)); + + // 查询锁设置信息 + final LockSetInfoEntity entity = + await ApiRepository.to.getLockSettingInfoDataIsNotLoadingIcon( + lockId: state.lockId.toString(), + ); + if (entity.errorCode!.codeIsSuccessful) { + state.lockSetInfoData.value = entity.data!; + if (state.lockSetInfoData.value.lockFeature?.wifi == 1) { + // await Future.delayed(const Duration(seconds: 1), () {c + // Get.close(state.isFromMap == 1 + // ? (CommonDataManage().seletLockType == 0 ? 4 : 5) + // : (CommonDataManage().seletLockType == 0 ? 5 : 6)); + // }); + // //刚刚配对完,需要对开锁页锁死 2 秒 + // await Future.delayed(const Duration(milliseconds: 200), () { + // if (Get.isRegistered()) { + // Get.find() + // .functionBlocker + // .countdownProhibited(duration: const Duration(seconds: 2)); + // } + // }); + // 如果是wifi锁,需要配置WIFI + Get.toNamed(Routers.wifiListPage, arguments: { + 'lockSetInfoData': state.lockSetInfoData.value, + 'pageName': 'saveLock' + }); + } else { + Future.delayed(const Duration(seconds: 1), () { + Get.close(state.isFromMap == 1 + ? (CommonDataManage().seletLockType == 0 ? 4 : 5) + : (CommonDataManage().seletLockType == 0 ? 5 : 6)); + }); + //刚刚配对完,需要对开锁页锁死 2 秒 + Future.delayed(const Duration(milliseconds: 200), () { + if (Get.isRegistered()) { + Get.find() + .functionBlocker + .countdownProhibited(duration: const Duration(seconds: 2)); + } + }); } - }); + } } @override diff --git a/lib/mine/addLock/saveLock/saveLock_state.dart b/lib/mine/addLock/saveLock/saveLock_state.dart index 564fe3d3..1a14896c 100755 --- a/lib/mine/addLock/saveLock/saveLock_state.dart +++ b/lib/mine/addLock/saveLock/saveLock_state.dart @@ -3,6 +3,7 @@ import 'dart:math'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; +import 'package:star_lock/main/lockDetail/lockSet/lockSet/lockSetInfo_entity.dart'; import '../../../blue/blue_manage.dart'; @@ -25,7 +26,7 @@ class SaveLockState { RxString aliName = ''.obs; RxInt pwdTimestamp = 0.obs; RxMap addressInfo = {}.obs; - + final Rx lockSetInfoData = LockSetInfoData().obs; TextEditingController aliNameController = TextEditingController(); FocusNode focusNode = FocusNode(); diff --git a/lib/network/api_provider.dart b/lib/network/api_provider.dart index a758294c..a8a09668 100755 --- a/lib/network/api_provider.dart +++ b/lib/network/api_provider.dart @@ -423,6 +423,15 @@ class ApiProvider extends BaseProvider { 'lockId': lockId, })); + // 获取所有锁设置信息 + Future getLockSettingInfoDataIsNotLoadingIcon(String lockId) => + post( + getLockSettingURL.toUrl, + jsonEncode({ + 'lockId': lockId, + }), + isUnShowLoading: true); + // 删除锁 Future deletLockInfo(int lockId) => post( deletLockURL.toUrl, diff --git a/lib/network/api_repository.dart b/lib/network/api_repository.dart index 7c97ae82..08bcdd49 100755 --- a/lib/network/api_repository.dart +++ b/lib/network/api_repository.dart @@ -486,6 +486,12 @@ class ApiRepository { final res = await apiProvider.getLockSettingInfoData(lockId); return LockSetInfoEntity.fromJson(res.body); } + // 获取所有锁设置信息(不显示加载框) + Future getLockSettingInfoDataIsNotLoadingIcon( + {required String lockId}) async { + final res = await apiProvider.getLockSettingInfoDataIsNotLoadingIcon(lockId); + return LockSetInfoEntity.fromJson(res.body); + } // 删除锁 Future deletOwnerLockData({required int lockId}) async {