Merge branch 'release' of https://gitee.com/starlock-cn/app-starlock into release

# Conflicts:
#	images/lan/lan_en.json
#	images/lan/lan_keys.json
#	images/lan/lan_zh.json
#	lib/main/lockDetail/lockDetail/lockDetail_page.dart
#	lib/main/lockMian/entity/lockListInfo_entity.dart
This commit is contained in:
魏少阳 2024-06-15 18:20:15 +08:00
commit 5de9d05914
31 changed files with 593 additions and 292 deletions

View File

@ -886,6 +886,7 @@
"加载数据失败": "Failed to load data",
"重试": "Retry",
"升级中,是否退出": "During the upgrade, whether to exit",
"下一步": "Next",
"公寓": "Apartment",
"个人用户": "Personal user",
@ -902,5 +903,6 @@
"把智能锁": "Smart lock",
"确认": "Confirm",
"移除成功": "Remove successfully",
"转移成功": "Transfer success"
"转移成功": "Transfer success",
"该已锁被删除": "The locked is deleted"
}

View File

@ -918,6 +918,7 @@
"加载数据失败": "加载数据失败",
"重试": "重试",
"升级中,是否退出": "升级中,是否退出",
"下一步": "下一步",
"公寓": "公寓",
"个人用户": "个人用户",
@ -934,5 +935,6 @@
"把智能锁": "把智能锁",
"确认": "确认",
"移除成功": "移除成功",
"转移成功": "转移成功"
"转移成功": "转移成功",
"该已锁被删除": "该已锁被删除"
}

View File

@ -900,5 +900,6 @@
"把智能锁": "把智能锁",
"确认": "确认",
"移除成功": "移除成功",
"转移成功": "转移成功"
"转移成功": "转移成功",
"该已锁被删除": "该已锁被删除"
}

View File

@ -9,7 +9,7 @@ import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart';
import 'package:star_lock/login/login/entity/LoginEntity.dart';
import 'package:star_lock/mine/mine/starLockMine_state.dart';
import 'package:star_lock/tools/baseGetXController.dart';
import 'package:star_lock/tools/xs_jPhush.dart';
import 'package:star_lock/tools/push/xs_jPhush.dart';
import '../../mine/mine/starLockMine_logic.dart';
import '../../network/api_repository.dart';
@ -48,7 +48,7 @@ class StarLockLoginLogic extends BaseGetXController {
password: state.pwd.value,
countryCode: state.countryCode.value,
username: state.emailOrPhone.value,
deviceInfo: state.deviceInfoMap.value);
deviceInfo: state.deviceInfoMap);
if (entity.errorCode!.codeIsSuccessful) {
Storage.saveLoginData(entity.data);
Storage.setBool(saveIsVip, entity.data!.isVip == 1);
@ -61,12 +61,13 @@ class StarLockLoginLogic extends BaseGetXController {
}
Future<void> checkIpAction() async {
final CheckIPEntity entity = await ApiRepository.to.checkIpAction(
ip: ''
);
final CheckIPEntity entity = await ApiRepository.to.checkIpAction(ip: '');
if (entity.errorCode!.codeIsSuccessful) {
if(state.countryName.value == entity.data!.name){
ShowTipView().showSureAlertDialog('国家地区的选择将影响数据安全,你当前选择的是阿尔巴尼亚,请确认后再继续'.tr, tipTitle: '确认国家或地区'.tr, sureStr: '我知道了'.tr);
if (state.countryName.value == entity.data!.name) {
ShowTipView().showSureAlertDialog(
'国家地区的选择将影响数据安全,你当前选择的是阿尔巴尼亚,请确认后再继续'.tr,
tipTitle: '确认国家或地区'.tr,
sureStr: '我知道了'.tr);
}
}
}
@ -103,7 +104,7 @@ class StarLockLoginLogic extends BaseGetXController {
}
//
void flushedDeviceInfo(){
void flushedDeviceInfo() {
XSConstantMacro().getDeviceInfoData().then((Map<String, dynamic> data) {
state.deviceInfoMap.value = data;
}).catchError((dynamic error) {
@ -111,5 +112,4 @@ class StarLockLoginLogic extends BaseGetXController {
AppLog.log('获取设备信息时出错: $error');
});
}
}

View File

@ -11,7 +11,7 @@ import 'package:star_lock/login/login/entity/LoginEntity.dart';
import 'package:star_lock/login/register/entity/SendValidationCodeEntity.dart';
import 'package:star_lock/tools/eventBusEventManage.dart';
import 'package:star_lock/tools/storage.dart';
import 'package:star_lock/tools/xs_jPhush.dart';
import 'package:star_lock/tools/push/xs_jPhush.dart';
import '../../network/api_repository.dart';
import '../../tools/baseGetXController.dart';

View File

@ -14,7 +14,7 @@ import 'package:star_lock/tools/device_info_service.dart';
import 'package:star_lock/tools/pay/wx_pay_tool.dart';
import 'package:star_lock/tools/platform_info_services.dart';
import 'package:star_lock/tools/storage.dart';
import 'package:star_lock/tools/xs_jPhush.dart';
import 'package:star_lock/tools/push/xs_jPhush.dart';
import 'package:star_lock/translations/trans_lib.dart';
import 'app.dart';

View File

@ -1,7 +1,6 @@
import 'dart:async';
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
import 'package:star_lock/app_settings/app_settings.dart';
import 'package:star_lock/main/lockDetail/doorLockLog/doorLockLog_entity.dart';
import 'package:star_lock/main/lockDetail/doorLockLog/doorLockLog_state.dart';
@ -58,24 +57,24 @@ class DoorLockLogLogic extends BaseGetXController {
var indexList = getList[i];
// AppLog.log("indexList:$indexList");
var indexMap = {};
indexMap["type"] = indexList[0].toString();
indexMap['type'] = indexList[0].toString();
int operateDate = 0;
if (indexList[0] == 2) {
var passwordData = indexList.sublist(7, 17);
var password = utf8String(passwordData);
indexMap["user"] = password.toString();
}else {
indexMap['user'] = password.toString();
} else {
int userNo = (indexList[1] * 256) + indexList[2];
indexMap["user"] = userNo.toString();
indexMap['user'] = userNo.toString();
}
indexMap["success"] = "1";
indexMap['success'] = '1';
int time = ((0xff & indexList[(3)]) << 24 |
(0xff & indexList[4]) << 16 |
(0xff & indexList[5]) << 8 |
(0xFF & indexList[6]));
indexMap["date"] = "${time * 1000}";
indexMap['date'] = '${time * 1000}';
uploadList.add(indexMap);
if (i == getList.length - 1) {
@ -141,13 +140,13 @@ class DoorLockLogLogic extends BaseGetXController {
}
//
void mockNetworkDataRequest({required bool isRefresh}) async {
Future<void> mockNetworkDataRequest({required bool isRefresh}) async {
//
if (isRefresh) {
state.lockLogItemList.clear();
pageNo = 1;
}
DoorLockLogEntity entity = await ApiRepository.to.lockEventList(
final DoorLockLogEntity entity = await ApiRepository.to.lockEventList(
lockId: state.keyInfos.value.lockId!,
lockEventType: state.dropdownValue.value,
pageNo: pageNo,
@ -165,8 +164,9 @@ class DoorLockLogLogic extends BaseGetXController {
///
StreamSubscription? _getDoorLockLogListRefreshUIEvent;
void _getDoorLockLogListRefreshUIAction() {
_getDoorLockLogListRefreshUIEvent =
eventBus.on<DoorLockLogListRefreshUI>().listen((event) {
_getDoorLockLogListRefreshUIEvent = eventBus
.on<DoorLockLogListRefreshUI>()
.listen((DoorLockLogListRefreshUI event) {
state.currentSelectDate.value = event.getDoorLockLogTime;
// startDate为当天的0点
state.startDate.value = DateTime(
@ -175,11 +175,11 @@ class DoorLockLogLogic extends BaseGetXController {
state.currentSelectDate.value.day)
.millisecondsSinceEpoch;
// endDate为下一天的0点1
state.endDate.value = (DateTime(
state.currentSelectDate.value.year,
state.currentSelectDate.value.month,
state.currentSelectDate.value.day + 1)
.subtract(const Duration(milliseconds: 1)))
state.endDate.value = DateTime(
state.currentSelectDate.value.year,
state.currentSelectDate.value.month,
state.currentSelectDate.value.day + 1)
.subtract(const Duration(milliseconds: 1))
.millisecondsSinceEpoch;
pageNo = 1;
@ -188,9 +188,9 @@ class DoorLockLogLogic extends BaseGetXController {
}
//
void getLockRecordLastUploadDataTime() async {
LockOperatingRecordGetLastRecordTimeEntity entity = await ApiRepository.to
.getLockRecordLastUploadDataTime(
Future<void> getLockRecordLastUploadDataTime() async {
final LockOperatingRecordGetLastRecordTimeEntity entity =
await ApiRepository.to.getLockRecordLastUploadDataTime(
lockId: state.keyInfos.value.lockId.toString());
if (entity.errorCode!.codeIsSuccessful) {
state.operateDate = entity.data!.operateDate! ~/ 1000;
@ -199,8 +199,8 @@ class DoorLockLogLogic extends BaseGetXController {
}
//
void lockRecordUploadData(List list) async {
KeyOperationRecordEntity entity = await ApiRepository.to
Future<void> lockRecordUploadData(List list) async {
final KeyOperationRecordEntity entity = await ApiRepository.to
.lockRecordUploadData(
lockId: state.keyInfos.value.lockId.toString(), records: list);
if (entity.errorCode!.codeIsSuccessful) {
@ -213,12 +213,12 @@ class DoorLockLogLogic extends BaseGetXController {
}
//
void clearOperationRecordRequest() async {
KeyOperationRecordEntity entity = await ApiRepository.to
Future<void> clearOperationRecordRequest() async {
final KeyOperationRecordEntity entity = await ApiRepository.to
.clearOperationRecord(
CommonDataManage().currentKeyInfo.lockId.toString());
if (entity.errorCode!.codeIsSuccessful) {
showToast("清除数据成功", something: () {
showToast('清除数据成功', something: () {
pageNo = 1;
mockNetworkDataRequest(isRefresh: true);
});

View File

@ -5,12 +5,14 @@ import 'package:get/get.dart';
import 'package:star_lock/appRouters.dart';
import 'package:star_lock/main/lockDetail/doorLockLog/doorLockLog_entity.dart';
import 'package:star_lock/main/lockDetail/doorLockLog/doorLockLog_logic.dart';
import 'package:star_lock/main/lockDetail/doorLockLog/doorLockLog_state.dart';
import 'package:star_lock/tools/EasyRefreshTool.dart';
import 'package:star_lock/tools/advancedCalendar/src/widget.dart';
import 'package:star_lock/tools/commonDataManage.dart';
import 'package:star_lock/tools/menuItem/xsDropDownWidget.dart';
import 'package:star_lock/tools/noData.dart';
import 'package:star_lock/tools/showCupertinoAlertView.dart';
import 'package:star_lock/tools/showTipView.dart';
import 'package:timelines/timelines.dart';
import '../../../app_settings/app_colors.dart';
@ -26,8 +28,8 @@ class DoorLockLogPage extends StatefulWidget {
}
class _DoorLockLogPageState extends State<DoorLockLogPage> with RouteAware {
final logic = Get.put(DoorLockLogLogic());
final state = Get.find<DoorLockLogLogic>().state;
final DoorLockLogLogic logic = Get.put(DoorLockLogLogic());
final DoorLockLogState state = Get.find<DoorLockLogLogic>().state;
@override
Widget build(BuildContext context) {
@ -37,22 +39,45 @@ class _DoorLockLogPageState extends State<DoorLockLogPage> with RouteAware {
barTitle: TranslationLoader.lanKeys!.operatingRecord!.tr,
haveBack: true,
backgroundColor: AppColors.mainColor,
actionsList: [
actionsList: <Widget>[
Visibility(
visible: CommonDataManage().currentKeyInfo.isLockOwner == 1
? true
: false,
child: TextButton(
onPressed: () {
ShowCupertinoAlertView().showClearOperationRecordAlert(
clearClick: () {
logic.clearOperationRecordRequest();
});
},
child: Text(
'清空记录'.tr,
style: TextStyle(color: Colors.white, fontSize: 24.sp),
))),
visible: CommonDataManage().currentKeyInfo.isLockOwner == 1,
child: GestureDetector(
child: Image.asset(
'images/icon_tips_Q.png',
width: 34.w,
height: 32.w,
color: Colors.white,
),
onTap: () {
ShowTipView().showSureAlertDialog(
'1.锁没有联网密码、IC卡、指纹等开门记录无法实时上传可以点击右上角按钮然后读取记录。\n2.只能保留一定时间内的记录,如果您需要保留历史记录,可以点击右上角按钮,然后导出记录',
tipTitle: '看不到操作记录,可能原因有',
sureStr: '我知道了');
},
)),
Visibility(
visible: CommonDataManage().currentKeyInfo.isLockOwner == 1,
child: PopupMenuButton<String>(
onSelected: _onMenuItemSelected,
color: Colors.black,
itemBuilder: (BuildContext context) {
return <PopupMenuEntry<String>>[
_buildCustomPopupMenuItem('读取记录'),
const PopupMenuDivider(),
_buildCustomPopupMenuItem('清空记录'),
const PopupMenuDivider(),
_buildCustomPopupMenuItem('导出记录'),
];
},
icon: Image.asset(
'images/icon_bar_more.png',
height: 30.h,
width: 10.w,
),
offset: Offset(0, 70.h), //
),
),
],
),
body: Column(
@ -73,9 +98,47 @@ class _DoorLockLogPageState extends State<DoorLockLogPage> with RouteAware {
);
}
//
PopupMenuItem<String> _buildCustomPopupMenuItem(String value) {
return PopupMenuItem<String>(
value: value,
height: 46.h,
child: SizedBox(
height: 46.h,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(value, style: TextStyle(color: Colors.white, fontSize: 22.sp)),
],
),
),
);
}
void _onMenuItemSelected(String value) {
switch (value) {
case '读取记录':
{
logic.mockNetworkDataRequest(isRefresh: true);
}
break;
case '清空记录':
{
ShowCupertinoAlertView().showClearOperationRecordAlert(
clearClick: () {
logic.clearOperationRecordRequest();
});
}
break;
case '导出记录':
{}
break;
}
}
//
Widget topAdvancedCalendarWidget() {
final theme = Theme.of(context);
final ThemeData theme = Theme.of(context);
return Theme(
data: theme.copyWith(
textTheme: theme.textTheme.copyWith(
@ -134,7 +197,7 @@ class _DoorLockLogPageState extends State<DoorLockLogPage> with RouteAware {
margin: EdgeInsets.only(top: 20.h, left: 30.w, bottom: 10.h, right: 20.w),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
children: <Widget>[
Obx(() => XSDropDownWidget(
items: state.getDropDownItemList,
value: state.dropdownTitle.value,
@ -187,11 +250,11 @@ class _DoorLockLogPageState extends State<DoorLockLogPage> with RouteAware {
return TimelineTileBuilder.fromStyle(
contentsAlign: ContentsAlign.basic,
itemCount: state.lockLogItemList.length,
contentsBuilder: (context, index) {
DoorLockLogDataItem timelineData = state.lockLogItemList[index];
DateTime dateTime =
contentsBuilder: (BuildContext context, int index) {
final DoorLockLogDataItem timelineData = state.lockLogItemList[index];
final DateTime dateTime =
DateTime.fromMillisecondsSinceEpoch(timelineData.operateDate!);
String formattedTime =
final String formattedTime =
'${dateTime.hour.toString().padLeft(2, '0')}:${dateTime.minute.toString().padLeft(2, '0')}';
return Padding(
@ -199,7 +262,7 @@ class _DoorLockLogPageState extends State<DoorLockLogPage> with RouteAware {
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
children: <Widget>[
Text(
'$formattedTime ${timelineData.username!.isNotEmpty ? "${timelineData.username}用" : ""}${timelineData.recordTypeName}',
textAlign: TextAlign.left,
@ -217,14 +280,15 @@ class _DoorLockLogPageState extends State<DoorLockLogPage> with RouteAware {
Get.toNamed(Routers.videoLogDetailPage);
},
child: Stack(
children: [
timelineData.imagesUrl!.isNotEmpty
? Image.network(
timelineData.imagesUrl!,
width: 260.w,
height: 260.h,
)
: Container(),
children: <Widget>[
if (timelineData.imagesUrl!.isNotEmpty)
Image.network(
timelineData.imagesUrl!,
width: 260.w,
height: 260.h,
)
else
Container(),
Positioned(
top: 150.h,
left: 10.w,
@ -293,7 +357,9 @@ class _DoorLockLogPageState extends State<DoorLockLogPage> with RouteAware {
void didPushNext() {
super.didPushNext();
logic.cancelBlueConnetctToastTimer();
if (EasyLoading.isShow) EasyLoading.dismiss(animation: true);
if (EasyLoading.isShow) {
EasyLoading.dismiss(animation: true);
}
state.ifCurrentScreen.value = false;
}
}

View File

@ -9,6 +9,7 @@ import 'package:permission_handler/permission_handler.dart';
import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart';
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart';
import 'package:star_lock/main/lockDetail/lockSet/lockTime/getServerDatetime_entity.dart';
import 'package:star_lock/main/lockMian/entity/lockListInfo_entity.dart';
import 'package:star_lock/tools/throttler.dart';
import 'package:star_lock/widget/permission/permission_dialog.dart';
@ -174,6 +175,66 @@ class LockDetailLogic extends BaseGetXController {
}
}
Future<void> loadData({ required LockListInfoItemEntity lockListInfoItemEntity,required bool isOnlyOneData}) async {
state.keyInfos.value = lockListInfoItemEntity;
CommonDataManage().currentLockUserNo = state.keyInfos.value.lockUserNo!;
CommonDataManage().currentKeyInfo = state.keyInfos.value;
state.lockUserNo = state.keyInfos.value.lockUserNo!;
if (state.keyInfos.value.keyStatus ==
XSConstantMacro.keyStatusWaitIneffective ||
state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusFrozen ||
state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusExpired ||
state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusDeleted ||
state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusReset) {
state.openDoorBtnisUneable.value = false;
state.bottomBtnisEable.value = false;
} else {
state.openDoorBtnisUneable.value = true;
state.bottomBtnisEable.value = true;
}
state.isOnlyOneData = isOnlyOneData;
state.senderUserId = state.keyInfos.value.senderUserId!;
state.isAttendance.value = state.keyInfos.value.lockSetting!.attendance!;
state.isOpenLockNeedOnline.value =
state.keyInfos.value.lockSetting!.appUnlockOnline!;
state.electricQuantity.value = state.keyInfos.value.electricQuantity!;
state.isOpenPassageMode.value = state.keyInfos.value.passageMode!;
state.lockAlias.value = state.keyInfos.value.lockAlias!;
Storage.setString(saveLockAlias, state.lockAlias.value);
BlueManage().connectDeviceName =
state.keyInfos.value.bluetooth!.bluetoothDeviceName!;
final List<int> publicKeyData =
state.keyInfos.value.bluetooth!.publicKey!.cast<int>();
final List<String> saveStrList = changeIntListToStringList(publicKeyData);
Storage.setStringList(saveBluePublicKey, saveStrList);
//
final List<int> privateKeyData =
state.keyInfos.value.bluetooth!.privateKey!.cast<int>();
final List<String> savePrivateKeyList =
changeIntListToStringList(privateKeyData);
Storage.setStringList(saveBluePrivateKey, savePrivateKeyList);
// signKey
final List<int> signKeyData =
state.keyInfos.value.bluetooth!.signKey!.cast<int>();
final List<String> saveSignKeyList = changeIntListToStringList(signKeyData);
Storage.setStringList(saveBlueSignKey, saveSignKeyList);
final bool ifHaveKey = await Storage.ifHaveKey(saveBlueToken);
if (!ifHaveKey) {
final List<String> saveTokenList =
changeIntListToStringList(<int>[0, 0, 0, 0]);
Storage.setStringList(saveBlueToken, saveTokenList);
}
}
//
void openDoorError() {
resetOpenDoorState();
@ -184,7 +245,7 @@ class LockDetailLogic extends BaseGetXController {
//
void closeLuckStatus() {
state.openLockBtnState.value = 0;
state.openDoorBtnisUneable.value = true;
// state.openDoorBtnisUneable.value = true;
state.animationController!.stop(canceled: true);
cancelBlueConnetctToastTimer();
}
@ -350,18 +411,20 @@ class LockDetailLogic extends BaseGetXController {
//
Future<void> getServerDatetime() async {
final GetServerDatetimeEntity entity =
await ApiRepository.to.getServerDatetimeData(isUnShowLoading:true);
await ApiRepository.to.getServerDatetimeData(isUnShowLoading: true);
if (entity.errorCode!.codeIsSuccessful) {
state.differentialTime = entity.data!.date! ~/ 1000 - DateTime.now().millisecondsSinceEpoch ~/ 1000;
}else{
state.differentialTime = entity.data!.date! ~/ 1000 -
DateTime.now().millisecondsSinceEpoch ~/ 1000;
} else {
state.isHaveNetwork = false;
}
}
int getUTCNetTime() {
if(state.isHaveNetwork){
return DateTime.now().millisecondsSinceEpoch ~/ 1000 + state.differentialTime;
}else{
if (state.isHaveNetwork) {
return DateTime.now().millisecondsSinceEpoch ~/ 1000 +
state.differentialTime;
} else {
return 0;
}
}
@ -474,10 +537,10 @@ class LockDetailLogic extends BaseGetXController {
// state.keyInfos.value.electricQuantity = int.parse(event.setResult);
final int electricQuantity =
int.tryParse(event.setResult['electricQuantity']) ?? 0;
state.electricQuantity.value =electricQuantity;
state.electricQuantity.value = electricQuantity;
state.keyInfos.value.electricQuantity = electricQuantity;
state.keyInfos.value.electricQuantityDate =
event.setResult['uploadElectricQuantityDate'];
event.setResult['uploadElectricQuantityDate'];
} else if (event.type == 5) {
// 5
state.keyInfos.value.lockSetting!.remoteUnlock =
@ -516,7 +579,7 @@ class LockDetailLogic extends BaseGetXController {
void resetOpenDoorState() {
state.openLockBtnState.value = 0;
state.openDoorBtnisUneable.value = false;
// state.openDoorBtnisUneable.value = false;
state.animationController?.reset();
state.animationController?.forward();
eventBus.fire(RefreshLockDetailInfoDataEvent());
@ -536,6 +599,13 @@ class LockDetailLogic extends BaseGetXController {
state.LockSetChangeSetRefreshLockDetailWithTypeSubscription = eventBus
.on<LockSetChangeSetRefreshLockDetailWithType>()
.listen((LockSetChangeSetRefreshLockDetailWithType event) {
//
if (event.type == 1) {
state.isOpenLockNeedOnline.value = int.parse(event.setResult);
state.keyInfos.value.lockSetting!.appUnlockOnline =
int.parse(event.setResult);
state.isOpenLockNeedOnline.refresh();
}
if (event.type == 4) {
final int electricQuantity =
int.tryParse(event.setResult['electricQuantity']) ?? 0;

View File

@ -17,7 +17,6 @@ import 'package:star_lock/blue/io_reply.dart';
import 'package:star_lock/blue/io_tool/io_tool.dart';
import 'package:star_lock/blue/io_tool/manager_event_bus.dart';
import 'package:star_lock/blue/sender_manage.dart';
import 'package:star_lock/main/lockDetail/lockSet/lockEscalation/updateLockInfo_entity.dart';
import 'package:star_lock/main/lockDetail/lockSet/lockEscalation/version_entity.dart';
import 'package:star_lock/network/api_repository.dart';
import 'package:star_lock/tools/baseGetXController.dart';
@ -351,10 +350,10 @@ class LockEscalationLogic extends BaseGetXController {
otaIndex++;
processOtaUpgrade();
} else if (reply is ConfirmationOTAUpgradeReply && reply.status == 0x00) {
closeOTADAta();
ApiRepository.to.getLockUpdateLockInfo(
lockId: CommonDataManage().currentKeyInfo.lockId ?? 0,
fwVersion: state.showNewVersion.value);
closeOTADAta();
showToast('固件升级完成'.tr);
} else if (reply is GetStarLockStatuInfoReply) {
_replyGetStarLockStatusInfo(reply);

View File

@ -30,6 +30,7 @@ class Data {
isUpdate = json['isUpdate'];
downloadUrl = json['downloadUrl'];
description = json['description'];
version = json['version'];
}
int? isUpdate;

View File

@ -5,6 +5,7 @@ import 'package:flutter_blue_plus/flutter_blue_plus.dart';
import 'package:get/get.dart';
import 'package:star_lock/login/login/entity/LoginEntity.dart';
import 'package:star_lock/main/lockMian/entity/lockListInfo_entity.dart';
import 'package:star_lock/main/lockMian/lockMain/lockMain_logic.dart';
import 'package:star_lock/tools/showTipView.dart';
import '../../../../blue/blue_manage.dart';
@ -596,7 +597,8 @@ class LockSetLogic extends BaseGetXController {
final bool isXHJ = F.isXHJ;
final bool isOnlyOneData = state.isOnlyOneData.value == true;
await Future<dynamic>.delayed(const Duration(milliseconds: 200)).then((e) {
await Future<dynamic>.delayed(const Duration(milliseconds: 200))
.then((e) {
if (isXHJ) {
Get.close(3);
} else {

View File

@ -144,6 +144,7 @@ class LockListInfoItemEntity {
int? appUnlockOnline;
String? mac;
int? initUserNo;
int? updateDate;
LockListInfoItemEntity({
this.keyId,
@ -182,6 +183,7 @@ class LockListInfoItemEntity {
this.appUnlockOnline,
this.mac,
this.initUserNo,
this.updateDate,
});
LockListInfoItemEntity.fromJson(Map<String, dynamic> json) {
@ -227,6 +229,7 @@ class LockListInfoItemEntity {
appUnlockOnline = json['appUnlockOnline'];
mac = json['mac'];
initUserNo = json['initUserNo'];
updateDate = json['updateDate'];
}
Map<String, dynamic> toJson() {
@ -273,6 +276,7 @@ class LockListInfoItemEntity {
data['appUnlockOnline'] = appUnlockOnline;
data['mac'] = mac;
data['initUserNo'] = initUserNo;
data['updateDate'] = updateDate;
return data;
}

View File

@ -182,7 +182,7 @@ class _LockListXHJPageState extends State<LockListXHJPage> with RouteAware {
isLast = true;
}
list.add(Slidable(
key: ValueKey<int?>(keyInfo.keyId),
key: ValueKey<String?>('${keyInfo.keyId}_${keyInfo.updateDate}'),
endActionPane: ActionPane(
extentRatio: 0.5,
motion: const ScrollMotion(),

View File

@ -1,10 +1,16 @@
import 'dart:async';
import 'dart:io';
import 'package:connectivity_plus/connectivity_plus.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:get/get.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:star_lock/appRouters.dart';
import 'package:star_lock/flavors.dart';
import 'package:star_lock/main/lockDetail/lockDetail/lockDetail_logic.dart';
import 'package:star_lock/main/lockMian/lockList/lockList_logic.dart';
import 'package:star_lock/tools/eventBusEventManage.dart';
import 'package:star_lock/tools/showTipView.dart';
import '../../../app_settings/app_settings.dart';
@ -18,6 +24,8 @@ import 'lockMain_state.dart';
class LockMainLogic extends BaseGetXController {
final LockMainState state = LockMainState();
final List<StreamSubscription<void>> _subscriptions =
<StreamSubscription<void>>[];
Future<LockListInfoEntity> getStarLockInfo(
{bool isUnShowLoading = false}) async {
@ -29,13 +37,14 @@ class LockMainLogic extends BaseGetXController {
);
if (entity.errorCode!.codeIsSuccessful) {
loadMainDataLogic(entity.data!);
Storage.saveMainListData(entity.data!);
}
return entity;
}
void loadMainDataLogic(LockListInfoGroupEntity entity) {
if (entity.groupList!.isEmpty) {
final bool every = entity.groupList!.every((GroupList list) =>
(list.lockList ?? <LockListInfoItemEntity>[]).isEmpty);
if (entity.groupList!.isEmpty || every) {
state.dataLength.value = 0;
} else if (entity.groupList!.length == 1) {
final GroupList groupList = entity.groupList![0];
@ -61,12 +70,13 @@ class LockMainLogic extends BaseGetXController {
}
});
}
Storage.saveMainListData(entity);
}
///
void getConnectType() async {
Future<void> getConnectType() async {
final ConnectivityResult connectResult =
await (Connectivity().checkConnectivity());
await Connectivity().checkConnectivity();
if (connectResult == ConnectivityResult.mobile) {
// _netType = "4G";
state.networkConnectionStatus.value = 1;
@ -133,6 +143,109 @@ class LockMainLogic extends BaseGetXController {
}
}
//
Future<void> flushedStarLockInfo(int keyId, int lockId) async {
final LockListInfoEntity entity = await ApiRepository.to.getStarLockInfo(
keyId: keyId,
);
if (entity.errorCode!.codeIsSuccessful) {
state.lockListInfoGroupEntity.value.groupList ??= <GroupList>[];
final GroupList list = entity.data!.groupList!.first;
final LockListInfoItemEntity listItem =
entity.data!.groupList!.first.lockList!.first;
final int groupIndex = state.lockListInfoGroupEntity.value.groupList
?.indexWhere(
(GroupList group) => group.groupId == list.groupId) ??
-1;
if (groupIndex != -1) {
//
state.lockListInfoGroupEntity.value.groupList![groupIndex].lockList ??=
<LockListInfoItemEntity>[];
final List<LockListInfoItemEntity> lockList = state
.lockListInfoGroupEntity.value.groupList![groupIndex].lockList!;
list.lockList ??= <LockListInfoItemEntity>[];
final int keyIndex = lockList.indexWhere(
(LockListInfoItemEntity lock) => lock.keyId == keyId) ??
-1;
if (keyIndex != -1) {
//
lockList.removeAt(keyIndex);
lockList.insert(keyIndex, listItem);
if (Get.isRegistered<LockDetailLogic>()) {
final bool isOnlyOneData =
F.sw(xhjCall: () => false, skyCall: () => lockList.length > 1);
Get.find<LockDetailLogic>().loadData(
lockListInfoItemEntity: listItem, isOnlyOneData: isOnlyOneData);
}
} else {
//
lockList.insert(0, listItem);
}
} else {
//
state.lockListInfoGroupEntity.value.groupList!.insert(0, list);
}
state.lockListInfoGroupEntity.refresh();
loadMainDataLogic(state.lockListInfoGroupEntity.value);
}
update();
}
//
Future<void> deleteStarLockInfo(int keyId, int lockId) async {
state.lockListInfoGroupEntity.value.groupList
?.forEach((GroupList groupList) {
groupList.lockList
?.removeWhere((LockListInfoItemEntity lock) => lock.keyId == keyId);
});
state.lockListInfoGroupEntity.refresh();
loadMainDataLogic(state.lockListInfoGroupEntity.value);
if (Get.isRegistered<LockDetailLogic>()) {
final bool isKey =
Get.find<LockDetailLogic>().state.keyInfos.value.keyId == keyId;
if (isKey) {
//
EasyLoading.showToast('该已锁被删除'.tr, duration: 3.seconds);
Get.until((Route<dynamic> route) =>
route.settings.name == Routers.starLockMain);
}
}
update();
}
//
void _initSubscription() {
_subscriptions.add(eventBus
.on<RefreshLockInfoDataEvent>()
.listen((RefreshLockInfoDataEvent event) {
//
flushedStarLockInfo(
event.keyId,
event.lockId,
);
}));
_subscriptions.add(eventBus
.on<DeleteLockInfoDataEvent>()
.listen((DeleteLockInfoDataEvent event) {
//
deleteStarLockInfo(
event.keyId,
event.lockId,
);
}));
_subscriptions.add(eventBus
.on<RogerThatLockInfoDataEvent>()
.listen((RogerThatLockInfoDataEvent event) {
//
flushedStarLockInfo(
event.keyId,
event.lockId,
);
}));
}
@override
void onReady() {
super.onReady();
@ -145,10 +258,14 @@ class LockMainLogic extends BaseGetXController {
void onInit() {
super.onInit();
checkWhetherPushIsEnabled();
_initSubscription();
}
@override
void onClose() {
_subscriptions.forEach((StreamSubscription<void> subscription) {
subscription.cancel();
});
super.onClose();
}
}

View File

@ -75,60 +75,62 @@ class _StarLockMainPageState extends State<StarLockMainPage>
@override
Widget build(BuildContext context) {
Widget child = EasyRefreshTool(
onRefresh: () {
SchedulerBinding.instance.addPostFrameCallback((_) {
//
logic.pageNo = 1;
getHttpData();
});
},
// child: getDataReturnUI(state.dataLength.value));
child: getDataReturnUI(state.dataLength.value));
if (widget.showAppBar || widget.showDrawer) {
child = Scaffold(
backgroundColor: const Color(0xFFF5F5F5),
appBar: widget.showAppBar
? TitleAppBar(
barTitle: F.navTitle,
haveBack: false,
haveOtherLeftWidget: true,
leftWidget: Builder(
builder: (BuildContext context) => IconButton(
icon: Image.asset(
'images/main/mainLeft_menu_icon.png',
color: Colors.white,
width: 44.w,
height: 44.w,
),
onPressed: () {
Scaffold.of(context).openDrawer();
},
)),
backgroundColor: AppColors.mainColor,
)
: null,
drawer: widget.showDrawer
? Drawer(
width: 1.sw / 3 * 2,
child: const StarLockMinePage(),
)
: null,
body: child,
);
}
child = F.sw(
skyCall: () => child,
xhjCall: () => Container(
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage('images/xhj_main_bg.jpg'),
fit: BoxFit.cover,
return GetBuilder<LockMainLogic>(builder: (LockMainLogic logic) {
Widget child = EasyRefreshTool(
onRefresh: () {
SchedulerBinding.instance.addPostFrameCallback((_) {
//
logic.pageNo = 1;
getHttpData();
});
},
// child: getDataReturnUI(state.dataLength.value));
child: getDataReturnUI(state.dataLength.value));
if (widget.showAppBar || widget.showDrawer) {
child = Scaffold(
backgroundColor: const Color(0xFFF5F5F5),
appBar: widget.showAppBar
? TitleAppBar(
barTitle: F.navTitle,
haveBack: false,
haveOtherLeftWidget: true,
leftWidget: Builder(
builder: (BuildContext context) => IconButton(
icon: Image.asset(
'images/main/mainLeft_menu_icon.png',
color: Colors.white,
width: 44.w,
height: 44.w,
),
onPressed: () {
Scaffold.of(context).openDrawer();
},
)),
backgroundColor: AppColors.mainColor,
)
: null,
drawer: widget.showDrawer
? Drawer(
width: 1.sw / 3 * 2,
child: const StarLockMinePage(),
)
: null,
body: child,
);
}
child = F.sw(
skyCall: () => child,
xhjCall: () => Container(
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage('images/xhj_main_bg.jpg'),
fit: BoxFit.cover,
),
),
),
child: child,
));
return child;
child: child,
));
return child;
});
}
Widget getDataReturnUI(int type) {
@ -232,10 +234,6 @@ class _StarLockMainPageState extends State<StarLockMainPage>
);
}
void onShow() {}
void onHide() {}
late StreamSubscription _teamEvent;
void _initLoadDataAction() {

View File

@ -1,15 +1,20 @@
import 'package:get/get.dart';
import 'package:star_lock/main/lockDetail/lockDetail/lockDetail_logic.dart';
import 'package:star_lock/main/lockMian/lockMain/lockMain_logic.dart';
import '../../../network/api_repository.dart';
import '../../../tools/baseGetXController.dart';
import 'appUnlockNeedMobileNetworkingLock_state.dart';
import 'selectLockListEntity.dart';
class AppUnlockNeedMobileNetworkingLockLogic extends BaseGetXController{
final AppUnlockNeedMobileNetworkingLockState state = AppUnlockNeedMobileNetworkingLockState();
class AppUnlockNeedMobileNetworkingLockLogic extends BaseGetXController {
final AppUnlockNeedMobileNetworkingLockState state =
AppUnlockNeedMobileNetworkingLockState();
//
Future<SelectLockListEntity> mockNetworkDataRequest() async {
final SelectLockListEntity entity = await ApiRepository.to.selectLockList(searchStr: state.searchController.text);
final SelectLockListEntity entity = await ApiRepository.to
.selectLockList(searchStr: state.searchController.text);
List<LockItemData> dataList = <LockItemData>[];
if (entity.errorCode!.codeIsSuccessful) {
dataList = entity.data!.list!;
@ -27,9 +32,14 @@ class AppUnlockNeedMobileNetworkingLockLogic extends BaseGetXController{
//APP开锁时需手机联网的锁
Future<void> setAppUnlockMustOnlineRequest() async {
final SelectLockListEntity entity =
await ApiRepository.to.setAppUnlockMustOnline(state.selectLockIdList);
await ApiRepository.to.setAppUnlockMustOnline(state.selectLockIdList);
if (entity.errorCode!.codeIsSuccessful) {
showToast('操作成功');
//--
if (Get.isRegistered<LockMainLogic>()) {
Get.find<LockMainLogic>().getStarLockInfo();
}
}
}
@ -44,5 +54,4 @@ class AppUnlockNeedMobileNetworkingLockLogic extends BaseGetXController{
void onInit() {
super.onInit();
}
}
}

View File

@ -9,7 +9,7 @@ import 'package:star_lock/mine/mineSet/mineSet/userSettingInfoEntity.dart';
import 'package:star_lock/mine/mineSet/mineSet/weChatQRCodeEntity.dart';
import 'package:star_lock/tools/showCupertinoAlertView.dart';
import 'package:star_lock/tools/storage.dart';
import 'package:star_lock/tools/xs_jPhush.dart';
import 'package:star_lock/tools/push/xs_jPhush.dart';
import 'package:star_lock/versionUndate/versionUndate_entity.dart';
import '../../../../network/api_repository.dart';
import '../../../../tools/baseGetXController.dart';

View File

@ -1,11 +0,0 @@
import 'package:get/get.dart';
import 'navLogic.dart';
class NavBinding extends Bindings {
@override
void dependencies() {
Get.lazyPut(() => NavLogic());
}
}

View File

@ -1,6 +0,0 @@
import '../tools/baseGetXController.dart';
class NavLogic extends BaseGetXController {
}

View File

@ -1,82 +0,0 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:star_lock/mine/mine/starLockMine_page.dart';
import '../app_settings/app_colors.dart';
import '../main/lockMian/lockMain/lockMain_page.dart';
class NavPages extends StatefulWidget {
const NavPages({Key? key}) : super(key: key);
@override
State<NavPages> createState() => _NavPagesState();
}
class _NavPagesState extends State<NavPages> {
int _currentIndex = 0;
final List<Widget> _listPage = [
StarLockMainPage(),
// StarLockMinePage(key: starLockMineKey),
];
@override
Widget build(BuildContext context) {
var sp;
return Scaffold(
body: IndexedStack(
///
// index: _currentIndex,
children: _listPage,
),
// bottomNavigationBar: BottomNavigationBar(
// elevation: 0.0,
// selectedFontSize: 24.sp,
// unselectedFontSize: 24.sp,
// type: BottomNavigationBarType.fixed,
// selectedItemColor: AppColors.mainColor,
// backgroundColor: Colors.white,
// currentIndex: _currentIndex, ///
// onTap: (index) {
// //bottomNavigationBar的点击事件
// if (_currentIndex == index) {
// return;
// }
// setState(() {
// _currentIndex = index; //
// });
// if (_currentIndex == 0) {
// starLockMainKey.currentState?.onShow();
// starLockMineKey.currentState?.onHide();
// } else if (_currentIndex == 1) {
// starLockMainKey.currentState?.onHide();
// starLockMineKey.currentState?.onShow();
// }
// },
// items: [
// BottomNavigationBarItem(
// icon: SizedBox(
// width: 56.w,
// height: 56.w,
// child: Image.asset(
// _currentIndex == 0
// ? 'images/tabbar/icon_tab_main_select.png'
// : 'images/tabbar/icon_tab_main_unselect.png',
// fit: BoxFit.cover),
// ),
// label: '首页'),
// BottomNavigationBarItem(
// icon: SizedBox(
// width: 56.w,
// height: 56.w,
// child: Image.asset(
// _currentIndex == 1
// ? 'images/tabbar/icon_tab_my_select.png'
// : 'images/tabbar/icon_tab_my_unselect.png',
// fit: BoxFit.cover),
// ),
// label: '我的'),
// ],
// ),
);
}
}

View File

@ -398,12 +398,13 @@ class ApiProvider extends BaseProvider {
//
Future<Response> getStarLockListInfo(int pageNo, int pageSize,
{bool isUnShowLoading = true}) =>
{bool isUnShowLoading = true, int? keyId,}) =>
post(
getStarLockInfoURL.toUrl,
jsonEncode({
jsonEncode(<String, dynamic>{
'pageNo': pageNo,
'pageSize': pageSize,
'keyId': keyId,
}),
isUnShowLoading: isUnShowLoading);

View File

@ -102,7 +102,8 @@ class BaseProvider extends GetConnect with Api {
EasyLoading.showToast('数据不存在', duration: 2000.milliseconds);
break;
case 434: //
ShowTipView().showSureBtnTipsAlert(T['errorMsg']);
ShowTipView()
.showSureBtnTipsAlert(tipsText: T['errorMsg'], sureText: '确定');
break;
}
}

View File

@ -464,6 +464,13 @@ class ApiRepository {
return LockListInfoEntity.fromJson(res.body);
}
//
Future<LockListInfoEntity> getStarLockInfo({required int keyId}) async {
final res = await apiProvider.getStarLockListInfo(1, 20,
isUnShowLoading: true, keyId: keyId);
return LockListInfoEntity.fromJson(res.body);
}
//
Future<LockSetInfoEntity> getLockSettingInfoData(
{required String lockId}) async {

View File

@ -19,7 +19,7 @@ import 'package:star_lock/tools/storage.dart';
import '../versionUndate/versionUndateTool.dart';
import 'bugly/bugly_tool.dart';
import 'xs_jPhush.dart';
import 'push/xs_jPhush.dart';
class AppFirstEnterHandle {
Future<void> getAppFirstEnter(String flagStr) async {

View File

@ -1,4 +1,3 @@
// CommonDataManage的单例使
import 'package:get/get.dart';
@ -6,9 +5,10 @@ import '../main/lockDetail/lockSet/lockSet/lockSetInfo_entity.dart';
import '../main/lockMian/entity/lockListInfo_entity.dart';
class CommonDataManage {
factory CommonDataManage() => shareManager()!;
CommonDataManage._init();
static CommonDataManage? _manager;
static CommonDataManage? shareManager() {
@ -16,18 +16,22 @@ class CommonDataManage {
// _manager!._initBlue();
return _manager;
}
CommonDataManage? get manager => shareManager();
//
final RxInt _mainLockCount = 0.obs;
set setMainLockCount(int v) => _mainLockCount.value = v;
get getMainLockCount => _mainLockCount;
RxInt get getMainLockCount => _mainLockCount;
//
LockListInfoItemEntity currentKeyInfo = LockListInfoItemEntity();
//
int currentLockUserNo = 0;
// set setCurrentLockUserNo(int v) => _currentLockUserNo = v;
// get getCurrentLockUserNo => _currentLockUserNo;
@ -36,10 +40,8 @@ class CommonDataManage {
LockSetInfoData currentLockSetInfoData = LockSetInfoData();
int dayLatestTime = (86400-1)*1000;
int dayLatestTime = (86400 - 1) * 1000;
// 0-1-2-NFC无源锁3-4-5-6-7- 8-
int seletLockType = 0;
}

View File

@ -7,20 +7,20 @@ EventBus eventBus = EventBus();
///
class RefreshLockListInfoDataEvent {
RefreshLockListInfoDataEvent(
{this.clearScanDevices = false, this.isUnShowLoading = false});
//
bool clearScanDevices;
bool isUnShowLoading;
RefreshLockListInfoDataEvent(
{this.clearScanDevices = false, this.isUnShowLoading = false});
}
///
class LockAddUserSucceedEvent {
LockAddUserSucceedEvent(this.dataList, this.type);
int type; // 0 1token失效
List<int> dataList;
LockAddUserSucceedEvent(this.dataList, this.type);
}
///
@ -50,9 +50,9 @@ class RefreshCheckInListEvent {
///
class PassCurrentLockInformationEvent {
LockSetInfoData lockSetInfoData;
PassCurrentLockInformationEvent(this.lockSetInfoData);
LockSetInfoData lockSetInfoData;
}
///
@ -62,16 +62,16 @@ class OtherTypeRefreshListEvent {
/// number
class ChickInAddStaffCardAndFingerprintBlockNumberEvent {
String number;
ChickInAddStaffCardAndFingerprintBlockNumberEvent(this.number);
String number;
}
///
class ChangeLanguageBlockLastLanguageEvent {
String languageTitle;
ChangeLanguageBlockLastLanguageEvent(this.languageTitle);
String languageTitle;
}
///
@ -81,45 +81,45 @@ class LockGroupEditGroupLockRefreshEvent {
///
class LockSetChangeSetRefreshLockDetailWithType {
LockSetChangeSetRefreshLockDetailWithType(this.type, this.setResult);
int type; // 0 1 2 3 4 5
dynamic setResult;
LockSetChangeSetRefreshLockDetailWithType(this.type, this.setResult);
}
///
class GetTVDataRefreshUI {
List<int> tvList;
GetTVDataRefreshUI(this.tvList);
List<int> tvList;
}
/// UDP接收状态然后刷新界面
class GetUDPStatusRefreshUI {
int udpStatus;
GetUDPStatusRefreshUI(this.udpStatus);
int udpStatus;
}
/// UDP接收状态然后刷新监控界面
class GetUDPStatusMonitorUI {
int udpStatus;
GetUDPStatusMonitorUI(this.udpStatus);
int udpStatus;
}
///
class GetFirstFrameGoPush {
bool isFirstFrame;
GetFirstFrameGoPush(this.isFirstFrame);
bool isFirstFrame;
}
/// typeIndex
class GetPasswordTypeUpdateIndex {
int passwordType;
GetPasswordTypeUpdateIndex(this.passwordType);
int passwordType;
}
///
@ -149,9 +149,9 @@ class MineAuthorizedAdminPageRefreshUI {
///
class DoorLockLogListRefreshUI {
DateTime getDoorLockLogTime;
DoorLockLogListRefreshUI(this.getDoorLockLogTime);
DateTime getDoorLockLogTime;
}
///
@ -168,3 +168,27 @@ class AuthorizedAdministratorListPageRefreshUI {
class MineInfoChangeRefreshUI {
MineInfoChangeRefreshUI();
}
///
class RefreshLockInfoDataEvent {
RefreshLockInfoDataEvent({required this.keyId, required this.lockId});
int keyId;
int lockId;
}
///
class DeleteLockInfoDataEvent {
DeleteLockInfoDataEvent({required this.keyId, required this.lockId});
int keyId;
int lockId;
}
///
class RogerThatLockInfoDataEvent {
RogerThatLockInfoDataEvent({required this.keyId, required this.lockId});
int keyId;
int lockId;
}

View File

@ -0,0 +1,10 @@
class MessageConstant {
//
static const int keyStateChange = 10;
//
static const int keyDelete = 20;
//
static const int lockReceive = 30;
//+
static const int keyReceive = 40;
}

View File

@ -0,0 +1,78 @@
import 'dart:convert';
import 'package:get/get.dart';
import 'package:star_lock/app_settings/app_settings.dart';
import 'package:star_lock/tools/eventBusEventManage.dart';
import 'package:star_lock/tools/push/message_constant.dart';
class MessageManagement {
//
static Future<void> shunting(Map<String, dynamic> message) async {
if (message.isEmpty) {
return;
}
Map<String, dynamic> extra = <String, dynamic>{};
if (GetPlatform.isAndroid) {
extra = _androidAnalysis(message);
AppLog.log('MessageManagement.shunting GetPlatform.isAndroid: $extra');
} else if (GetPlatform.isIOS) {
extra = _iosAnalysis(message);
AppLog.log('MessageManagement.shunting GetPlatform.isIos: $extra');
} else {
return;
}
if (extra.isEmpty) {
return;
}
_shuntingBus(extra);
}
//android解析
static Map<String, dynamic> _androidAnalysis(Map<String, dynamic> data) {
// {alert: , extras: {cn.jpush.android.TYPE_PLATFORM: 0, cn.jpush.android.CONTENT_TYPE: , cn.jpush.android.MSG_ID: 18101501949885538, cn.jpush.android.EXTRA: {"eventNo":10,"keyId":530,"lockId":7}}, message: }
final Map<Object?, dynamic> extras = data['extras'];
final Map<String, dynamic> extra =
json.decode(extras['cn.jpush.android.EXTRA'] ?? '{}');
return extra;
}
//ios解析
static Map<String, dynamic> _iosAnalysis(Map<String, dynamic> data) {
// {content: , extras: {eventNo: 20, keyId: 580, lockId: 7}, _j_msgid: 18101504271412025}
final Map<Object?, Object?> extras = data['extras'];
final Map<String, dynamic> extra = <String, dynamic>{};
extras.forEach((Object? key, Object? value) {
extra[key!.toString()] = value;
});
return extra;
}
//
static void _shuntingBus(Map<String, dynamic> data) {
final int eventNo = data['eventNo'] ?? -1;
switch (eventNo) {
case MessageConstant.keyStateChange:
final int keyId = data['keyId'];
final int lockId = data['lockId'];
eventBus.fire(RefreshLockInfoDataEvent(keyId: keyId, lockId: lockId));
break;
case MessageConstant.keyDelete:
final int keyId = data['keyId'];
final int lockId = data['lockId'];
eventBus.fire(DeleteLockInfoDataEvent(keyId: keyId, lockId: lockId));
break;
case MessageConstant.lockReceive:
final int keyId = data['keyId'];
final int lockId = data['lockId'];
eventBus.fire(RogerThatLockInfoDataEvent(keyId: keyId, lockId: lockId));
break;
case MessageConstant.keyReceive:
final int keyId = data['keyId'];
final int lockId = data['lockId'];
eventBus.fire(RogerThatLockInfoDataEvent(keyId: keyId, lockId: lockId));
break;
default:
throw Exception('无法识别eventNo 参数:$eventNo');
}
}
}

View File

@ -7,9 +7,10 @@ import 'package:star_lock/flavors.dart';
import 'package:star_lock/mine/minePersonInfo/minePersonInfoEditAccount/minePersonInfoEditAccount/mineUnbindPhoneOrEmail_entity.dart';
import 'package:star_lock/network/api_repository.dart';
import 'package:star_lock/tools/baseGetXController.dart';
import 'package:star_lock/tools/push/message_management.dart';
import 'package:star_lock/tools/storage.dart';
import '../app_settings/app_settings.dart';
import '../../app_settings/app_settings.dart';
class XSJPushProvider {
final JPush jpush = JPush();
@ -34,7 +35,7 @@ class XSJPushProvider {
appKey: appKey,
channel: 'flutter_channel',
production: false,
debug: true,
debug: false,
);
jpush.applyPushAuthority(
@ -54,6 +55,7 @@ class XSJPushProvider {
}, onReceiveMessage: (Map<String, dynamic> message) async {
AppLog.log('onReceiveMessage: $message');
//
MessageManagement.shunting(message);
}, onReceiveNotificationAuthorization:
(Map<String, dynamic> message) async {
AppLog.log('onReceiveNotificationAuthorization: $message');

View File

@ -23,7 +23,8 @@ class ShowTipView {
content: Text(contentStr),
actions: <Widget>[
CupertinoDialogAction(
child: Text(sureStr ?? TranslationLoader.lanKeys!.sure!.tr),
child: Text(sureStr ?? TranslationLoader.lanKeys!.sure!.tr,
style: TextStyle(color: AppColors.mainColor)),
onPressed: Get.back,
),
],
@ -93,7 +94,9 @@ class ShowTipView {
);
}
void showTFViewAlertDialog(TextEditingController controller, String title, String tipTitle, Function sureClick, {List<TextInputFormatter>? inputFormatters, bool? isShowSuffixIcon}) {
void showTFViewAlertDialog(TextEditingController controller, String title,
String tipTitle, Function sureClick,
{List<TextInputFormatter>? inputFormatters, bool? isShowSuffixIcon}) {
//
showDialog(
context: Get.context!,
@ -122,7 +125,8 @@ class ShowTipView {
}
//
void showSureBtnTipsAlert(String tipsText) {
void showSureBtnTipsAlert(
{required String tipsText, required String sureText}) {
showCupertinoDialog(
context: Get.context!,
builder: (BuildContext context) {