diff --git a/images/lan/lan_en.json b/images/lan/lan_en.json index 1438df9e..f902422b 100755 --- a/images/lan/lan_en.json +++ b/images/lan/lan_en.json @@ -883,4 +883,7 @@ "账号格式错误": "The account format is incorrect", "接收者信息为空": "The recipient information is empty", "请输入时间(秒)": "Please enter the time (seconds)", + "加载数据失败": "Failed to load data", + "重试": "Retry", + "升级中,是否退出": "During the upgrade, whether to exit" } diff --git a/images/lan/lan_keys.json b/images/lan/lan_keys.json index 3b8af6e6..8f5845a0 100755 --- a/images/lan/lan_keys.json +++ b/images/lan/lan_keys.json @@ -914,5 +914,8 @@ "新增": "新增", "账号格式错误": "账号格式错误", "接收者信息为空": "接收者信息为空", - "请输入时间(秒)": "请输入时间(秒)" + "请输入时间(秒)": "请输入时间(秒)", + "加载数据失败": "加载数据失败", + "重试": "重试", + "升级中,是否退出": "升级中,是否退出" } diff --git a/images/lan/lan_zh.json b/images/lan/lan_zh.json index 827c2850..12c79ae2 100755 --- a/images/lan/lan_zh.json +++ b/images/lan/lan_zh.json @@ -862,14 +862,12 @@ "五": "五", "六": "六", "日": "日", - "无考勤记录": "无考勤记录", "大家干劲十足": "大家干劲十足", "工作时长未出炉": "工作时长未出炉", "国家地区的选择将影响数据安全,你当前选择的是阿尔巴尼亚,请确认后再继续": "国家地区的选择将影响数据安全,你当前选择的是阿尔巴尼亚,请确认后再继续", "确认国家或地区": "确认国家或地区", "我知道了": "我知道了", - "新建短信模版": "新建短信模版", "新建邮件模版": "新建邮件模版", "自定义短信模版": "自定义短信模版", @@ -877,10 +875,13 @@ "名称": "名称", "星星锁": "星星锁", "为了让您及时收到重要通知和更新,我们需要获取通知权限。请点击“确定”按钮,然后在设置页面中启用通知权限。": "为了让您及时收到重要通知和更新,我们需要获取通知权限。请点击“确定”按钮,然后在设置页面中启用通知权限。", - "开启后,可通过长按锁上的设置键重新上电,用APP重新添加":"开启后,可通过长按锁上的设置键重新上电,用APP重新添加", + "开启后,可通过长按锁上的设置键重新上电,用APP重新添加": "开启后,可通过长按锁上的设置键重新上电,用APP重新添加", "已有": "已有", "新增": "新增", "账号格式错误": "账号格式错误", "接收者信息为空": "接收者信息为空", - "请输入时间(秒)": "请输入时间(秒)" + "请输入时间(秒)": "请输入时间(秒)", + "加载数据失败": "加载数据失败", + "重试": "重试", + "升级中,是否退出": "升级中,是否退出" } diff --git a/lib/blue/io_protocol/io_getStarLockStatusInfo.dart b/lib/blue/io_protocol/io_getStarLockStatusInfo.dart index acdc977b..e527836f 100755 --- a/lib/blue/io_protocol/io_getStarLockStatusInfo.dart +++ b/lib/blue/io_protocol/io_getStarLockStatusInfo.dart @@ -9,12 +9,6 @@ import '../io_type.dart'; import '../sm4Encipher/sm4.dart'; class GetStarLockStatuInfoCommand extends SenderProtocol { - - String? lockID; - String? userID; - int? utcTimeStamp; - int? unixTimeStamp; - List? privateKey; GetStarLockStatuInfoCommand({ this.lockID, this.userID, @@ -23,6 +17,12 @@ class GetStarLockStatuInfoCommand extends SenderProtocol { this.privateKey }) : super(CommandType.readStarLockStatusInfo); + String? lockID; + String? userID; + int? utcTimeStamp; + int? unixTimeStamp; + List? privateKey; + @override String toString() { return 'GetStarLockStatuInfoCommand{lockID: $lockID, ' @@ -32,24 +32,24 @@ class GetStarLockStatuInfoCommand extends SenderProtocol { @override List messageDetail() { - List data = []; - List ebcData = []; + List data = []; + List ebcData = []; // 指令类型 - int type = commandType!.typeValue; - double typeDouble = type / 256; - int type1 = typeDouble.toInt(); - int type2 = type % 256; + final int type = commandType!.typeValue; + final double typeDouble = type / 256; + final int type1 = typeDouble.toInt(); + final int type2 = type % 256; data.add(type1); data.add(type2); // 锁id 40 - int lockIDLength = utf8.encode(lockID!).length; + final int lockIDLength = utf8.encode(lockID!).length; data.addAll(utf8.encode(lockID!)); data = getFixedLengthList(data, 40 - lockIDLength); //userID 要接受钥匙的用户的useid 20 - int userIDLength = utf8.encode(userID!).length; + final int userIDLength = utf8.encode(userID!).length; data.addAll(utf8.encode(userID!)); data = getFixedLengthList(data, 20 - userIDLength); @@ -57,16 +57,16 @@ class GetStarLockStatuInfoCommand extends SenderProtocol { data.add((utcTimeStamp! & 0xff000000) >> 24); data.add((utcTimeStamp! & 0xff0000) >> 16); data.add((utcTimeStamp! & 0xff00) >> 8); - data.add((utcTimeStamp! & 0xff)); + data.add(utcTimeStamp! & 0xff); // endDate 4 data.add((unixTimeStamp! & 0xff000000) >> 24); data.add((unixTimeStamp! & 0xff0000) >> 16); data.add((unixTimeStamp! & 0xff00) >> 8); - data.add((unixTimeStamp! & 0xff)); + data.add(unixTimeStamp! & 0xff); if ((data.length % 16) != 0) { - int add = (16 - data.length % 16); + final int add = 16 - data.length % 16; for (int i = 0; i < add; i++) { data.add(0); } @@ -84,7 +84,7 @@ class GetStarLockStatuInfoReply extends Reply { : super.parseData(commandType, dataDetail) { data = dataDetail; - int status = data[2]; + final int status = data[2]; errorWithStstus(status); } } \ No newline at end of file diff --git a/lib/blue/io_tool/io_tool.dart b/lib/blue/io_tool/io_tool.dart index f8dcc00a..698e33d3 100755 --- a/lib/blue/io_tool/io_tool.dart +++ b/lib/blue/io_tool/io_tool.dart @@ -5,22 +5,22 @@ import 'package:crypto/crypto.dart'; import 'package:flutter/services.dart'; int listChangInt(List list){ - int dataLen = (list[0] << 8) + list[1]; + final int dataLen = (list[0] << 8) + list[1]; return dataLen; } List intChangList(int count){ - List intList = []; - double typeDouble = count / 256; - int type1 = typeDouble.toInt(); - int type2 = count % 256; + final List intList = []; + final double typeDouble = count / 256; + final int type1 = typeDouble.toInt(); + final int type2 = count % 256; intList.add(type1); intList.add(type2); return intList; } List changeIntListToStringList(List list){ - List strList = []; + final List strList = []; for(int i = 0; i changeIntListToStringList(List list){ } List changeStringListToIntList(List list){ - List intList = []; + final List intList = []; for(int i = 0; i changeStringListToIntList(List list){ int _hexToInt(String hex) { int val = 0; - int len = hex.length; + final int len = hex.length; for (int i = 0; i < len; i++) { - int hexDigit = hex.codeUnitAt(i); + final int hexDigit = hex.codeUnitAt(i); if (hexDigit >= 48 && hexDigit <= 57) { val += (hexDigit - 48) * (1 << (4 * (len - 1 - i))); } else if (hexDigit >= 65 && hexDigit <= 70) { @@ -58,8 +58,8 @@ int _hexToInt(String hex) { } String md5Crypto(List data) { - final dig = md5.convert(data); - var keyStr = dig.toString(); + final Digest dig = md5.convert(data); + final String keyStr = dig.toString(); return keyStr.substring(0, 16).toLowerCase(); } @@ -73,8 +73,8 @@ List getFixedLengthList(List data, int length) { //int ---> 指定长度的hex (如指定长度为6的情况,0x000001 0x001234, 0xefab23) String intToFormatHex(int num, int length) { - String hexString = num.toRadixString(16); - String formatString = hexString.padLeft(length, "0"); + final String hexString = num.toRadixString(16); + final String formatString = hexString.padLeft(length, "0"); return formatString; } @@ -82,8 +82,8 @@ String uint8ToHex(Uint8List byteArr) { if (byteArr.isEmpty) { return ""; } - Uint8List result = Uint8List(byteArr.length << 1); - var hexTable = [ + final Uint8List result = Uint8List(byteArr.length << 1); + final List hexTable = [ '0', '1', '2', @@ -101,10 +101,10 @@ String uint8ToHex(Uint8List byteArr) { 'E', 'F' ]; //16进制字符表 - for (var i = 0; i < byteArr.length; i++) { - var bit = byteArr[i]; //取传入的byteArr的每一位 - var index = bit >> 4 & 15; //右移4位,取剩下四位 - var i2 = i << 1; //byteArr的每一位对应结果的两位,所以对于结果的操作位数要乘2 + for (int i = 0; i < byteArr.length; i++) { + final int bit = byteArr[i]; //取传入的byteArr的每一位 + int index = bit >> 4 & 15; //右移4位,取剩下四位 + final int i2 = i << 1; //byteArr的每一位对应结果的两位,所以对于结果的操作位数要乘2 result[i2] = hexTable[index].codeUnitAt(0); //左边的值取字符表,转为Unicode放进resut数组 index = bit & 15; //取右边四位 result[i2 + 1] = @@ -117,8 +117,8 @@ String uint8ToHex(Uint8List byteArr) { int byteInt8(List dataDetail, int index) => _toInt8(dataDetail[index]); int _toInt8(int value) { - var buffer = Int8List(4).buffer; - var bData = ByteData.view(buffer); + final ByteBuffer buffer = Int8List(4).buffer; + final ByteData bData = ByteData.view(buffer); bData.setInt8(0, value); return bData.getInt8(0); } @@ -129,15 +129,15 @@ int _byteInt16(List dataDetail, int index) { return 0; } - int value = (dataDetail[index + 1] & 0xff) << 8 | (dataDetail[index] & 0xff); + final int value = (dataDetail[index + 1] & 0xff) << 8 | (dataDetail[index] & 0xff); return _toInt16(value); } int _toInt16(int value) { - var buffer = Int16List(1).buffer; - var bData = ByteData.view(buffer); + final ByteBuffer buffer = Int16List(1).buffer; + final ByteData bData = ByteData.view(buffer); bData.setInt16(0, value); - int outputValue = bData.getInt16(0); + final int outputValue = bData.getInt16(0); return outputValue; } @@ -146,50 +146,50 @@ int _byteInt32(List dataDetail, int index) { if (checkListIndex(dataDetail, index, 4)) { return 0; } - int value = ((0xFF & dataDetail[(index + 3)]) << 24 | + final int value = (0xFF & dataDetail[(index + 3)]) << 24 | (0xFF & dataDetail[index + 2]) << 16 | (0xFF & dataDetail[index + 1]) << 8 | - 0xFF & dataDetail[index]); + 0xFF & dataDetail[index]; return _toInt32(value); } int _toInt32(int value) { - var buffer = Int32List(2).buffer; - var bData = ByteData.view(buffer); + final ByteBuffer buffer = Int32List(2).buffer; + final ByteData bData = ByteData.view(buffer); bData.setInt32(0, value); - int outputValue = bData.getInt32(0); + final int outputValue = bData.getInt32(0); return outputValue; } -List intToInt8List(int value) => [value]; +List intToInt8List(int value) => [value]; -List intToByte2ListHigh(int value) => [value, value >> 8]; +List intToByte2ListHigh(int value) => [value, value >> 8]; //TODO:int->4个字节List 低字节在前,高字节在后(大端存储) 1byte = 8bit List intToByte4ListHigh(int value) => - [value, value >> 8, value >> 16, value >> 24]; + [value, value >> 8, value >> 16, value >> 24]; int byteUInt8(List dataDetail, int index) => _toUInt8(dataDetail[index]); int _toUInt8(int value) { - var buffer = Int8List(1).buffer; - var bData = ByteData.view(buffer); + final ByteBuffer buffer = Int8List(1).buffer; + final ByteData bData = ByteData.view(buffer); bData.setInt8(0, value); return bData.getUint8(0); } int byteUInt16(List dataDetail, int index) => _byteUInt16(dataDetail, index); -_byteUInt16(List dataDetail, int index) { +int _byteUInt16(List dataDetail, int index) { if (checkListIndex(dataDetail, index, 2)) { return 0; } - int value = (dataDetail[index + 1]) << 8 | dataDetail[index]; + final int value = (dataDetail[index + 1]) << 8 | dataDetail[index]; return _toUInt16(value); } int _toUInt16(int value) { - var buffer = Uint16List(2).buffer; - var bData = ByteData.view(buffer); + final ByteBuffer buffer = Uint16List(2).buffer; + final ByteData bData = ByteData.view(buffer); bData.setInt16(0, value); return bData.getUint16(0); } @@ -201,18 +201,18 @@ int _byteUInt32(List dataDetail, int index) { if (checkListIndex(dataDetail, index, 4)) { return 0; } - int value = ((0xFF & dataDetail[(index + 3)]) << 24 | + final int value = (0xFF & dataDetail[(index + 3)]) << 24 | (0xFF & dataDetail[index + 2]) << 16 | (0xFF & dataDetail[index + 1]) << 8 | - 0xFF & dataDetail[index]); + 0xFF & dataDetail[index]; return _toUInt32(value); } int _toUInt32(int value) { - var buffer = Int32List(2).buffer; - var bData = ByteData.view(buffer); + final ByteBuffer buffer = Int32List(2).buffer; + final ByteData bData = ByteData.view(buffer); bData.setInt32(0, value); - int outputValue = bData.getUint32(0); + final int outputValue = bData.getUint32(0); return outputValue; } @@ -220,42 +220,42 @@ bool checkListIndex(List dataDetail, int index, int offsetLength) { if (dataDetail == null) { return true; } - var len = dataDetail.length; - bool result = index + offsetLength > len; + final int len = dataDetail.length; + final bool result = index + offsetLength > len; if (result) {} return result; } int checkSum(List data) { int sum = 0; - for (int v in data) { + for (final int v in data) { sum ^= v; } return sum; } Future> loadAssetsFile(String assetsPath) async { - var byteData = await rootBundle.load(assetsPath); + final ByteData byteData = await rootBundle.load(assetsPath); return byteData.buffer.asUint8List().toList(); } //获取截取后的数组 List> splitList(List list, int len) { if (len <= 1) { - return [list]; + return >[list]; } - List> result = []; + final List> result = >[]; int index = 1; while (true) { if (index * len < list.length) { - List temp = list.skip((index - 1) * len).take(len).toList(); + final List temp = list.skip((index - 1) * len).take(len).toList(); result.add(temp); index++; continue; } - List temp = list.skip((index - 1) * len).toList(); + final List temp = list.skip((index - 1) * len).toList(); result.add(temp); break; } @@ -263,11 +263,11 @@ List> splitList(List list, int len) { } //TODO:int->两个字节 List 高字节在前,低字节在后(小端存储) 本工程只有配置 WiFi用到的!!!! -List intToByte2ListLow(int value) => [value >> 8, value]; +List intToByte2ListLow(int value) => [value >> 8, value]; String radixHex16String(List codeUnits) { String result = ''; - for (var value in codeUnits) { + for (final int value in codeUnits) { result += value.toRadixString(16).padLeft(2, '0'); } return result; @@ -275,7 +275,7 @@ String radixHex16String(List codeUnits) { String radixHex16StringTo2String(List codeUnits) { String result = ''; - codeUnits.forEach((value) { + codeUnits.forEach((int value) { result += int.parse(value.toRadixString(16).padLeft(2, '0'),radix: 16).toRadixString(2); }); return result; @@ -283,7 +283,7 @@ String radixHex16StringTo2String(List codeUnits) { String asciiString(List codeUnits) { String result = ''; - for (var value in codeUnits) { + for (final int value in codeUnits) { result += String.fromCharCode(value); } return result; @@ -291,7 +291,7 @@ String asciiString(List codeUnits) { String utf8String(List codeUnits) { codeUnits.reversed; - List uniqueList = []; + final List uniqueList = []; for (int i = 0; i < codeUnits.length; i++) { if (codeUnits[i] != 0) { uniqueList.add(codeUnits[i]); @@ -302,11 +302,13 @@ String utf8String(List codeUnits) { } bool compareTwoList({List? list1, List? list2}) { - if (list1!.length != list2!.length) return false; - int ctn = list1.length; + if (list1!.length != list2!.length) { + return false; + } + final int ctn = list1.length; for (int i = 0; i < ctn; i++) { - int v1 = list1[i]; - int v2 = list2[i]; + final int v1 = list1[i]; + final int v2 = list2[i]; if (v1 != v2) { return false; } diff --git a/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_page.dart b/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_page.dart index 1303fc90..c0a7a24c 100755 --- a/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_page.dart +++ b/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_page.dart @@ -426,12 +426,12 @@ class _SendElectronicKeyViewState extends State OutLineBtn( btnName: logic.state.userNameType.value == 1 ? '短信通知' : '邮件通知', onClick: () { - if (logic.state.userNameType.value == 2) { - Get.toNamed(Routers.sendEmailNotificationPage, - arguments: {'email': logic.emailOrPhone}); - } else { - logic.sendMsg(isPhone: true); - } + Get.toNamed(Routers.sendEmailNotificationPage, + arguments: { + 'receiver': logic.emailOrPhone, + 'channelType': logic.state.userNameType.value, + 'keyId': logic.keyId + }); }, ), SizedBox( diff --git a/lib/main/lockDetail/electronicKey/sendEmailNotification/sendEmailNotification_logic.dart b/lib/main/lockDetail/electronicKey/sendEmailNotification/sendEmailNotification_logic.dart index 475d09bb..b050ced5 100644 --- a/lib/main/lockDetail/electronicKey/sendEmailNotification/sendEmailNotification_logic.dart +++ b/lib/main/lockDetail/electronicKey/sendEmailNotification/sendEmailNotification_logic.dart @@ -1,4 +1,4 @@ -import 'package:get_storage/get_storage.dart'; +import 'package:get/get.dart'; import 'package:star_lock/main/lockDetail/electronicKey/sendEmailNotification/sendEmailNotification_entity.dart'; import 'package:star_lock/main/lockDetail/electronicKey/sendEmailNotification/sendEmailNotification_state.dart'; import 'package:star_lock/network/api_repository.dart'; @@ -13,13 +13,41 @@ class SendEmailNotificationLogic extends BaseGetXController { final SendEmailNotificationEntity entity = await ApiRepository.to.getKeyNoticeTemplate( lockId: CommonDataManage().currentKeyInfo.lockId ?? 0, - keyId: CommonDataManage().currentKeyInfo.keyId ?? 0, - channelType: 2, + keyId: state.getKeyId.value, + channelType: state.channelType.value, ); if (entity.errorCode!.codeIsSuccessful) { state.emailTemplateList.value = entity.data?.list ?? []; + state.currentNotifyItem.value = state.emailTemplateList.first; + state.templateContentController.text = + state.currentNotifyItem.value.template ?? ''; state.emailTemplateList.refresh(); + state.currentNotifyItem.refresh(); + } + } + + //发送短信、邮件通知 channelType--1短信 2邮件 opisAPKFileName + Future keyNoticeSubmitRequest() async { + if (state.receiverController.text.isEmpty && + state.getReceiver.value.isEmpty) { + showToast('请输入接收者'); + return; + } + final SendEmailNotificationEntity entity = + await ApiRepository.to.keyNoticeSubmit( + receiverName: state.getReceiver.value.isEmpty + ? state.receiverController.text + : state.getReceiver.value, + lockId: CommonDataManage().currentKeyInfo.lockId ?? 0, + keyId: state.getKeyId.value, + channelType: state.channelType.value, + openDoorType: 1, + templateType: state.currentNotifyItem.value.type ?? '', + ); + if (entity.errorCode!.codeIsSuccessful) { + showToast('发送成功'); + Get.back(); } } } diff --git a/lib/main/lockDetail/electronicKey/sendEmailNotification/sendEmailNotification_page.dart b/lib/main/lockDetail/electronicKey/sendEmailNotification/sendEmailNotification_page.dart index 40b89831..c11e0960 100755 --- a/lib/main/lockDetail/electronicKey/sendEmailNotification/sendEmailNotification_page.dart +++ b/lib/main/lockDetail/electronicKey/sendEmailNotification/sendEmailNotification_page.dart @@ -1,12 +1,14 @@ import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; +import 'package:star_lock/appRouters.dart'; import 'package:star_lock/main/lockDetail/electronicKey/sendEmailNotification/SendEmailNotification_logic.dart'; +import 'package:star_lock/main/lockDetail/electronicKey/sendEmailNotification/sendEmailNotification_entity.dart'; import 'package:star_lock/main/lockDetail/electronicKey/sendEmailNotification/sendEmailNotification_state.dart'; import 'package:star_lock/tools/emailNotifyTypeSelectAlert.dart'; import 'package:star_lock/tools/pickers/pickers.dart'; import 'package:star_lock/tools/pickers/style/default_style.dart'; -import 'package:star_lock/translations/trans_lib.dart'; import '../../../../app_settings/app_colors.dart'; import '../../../../tools/commonItem.dart'; @@ -39,33 +41,40 @@ class _SendEmailNotificationPageState extends State { return Scaffold( backgroundColor: AppColors.mainBackgroundColor, appBar: TitleAppBar( - barTitle: '邮件通知', + barTitle: state.channelType.value == 1 ? '短信通知' : '邮件通知', haveBack: true, backgroundColor: AppColors.mainColor), body: SingleChildScrollView( child: Column( children: [ - Obx(() => CommonItem( - leftTitel: TranslationLoader.lanKeys!.receiver!.tr, - rightTitle: state.getEmail.value, - isHaveLine: true, - )), + Obx(() => state.getReceiver.value.isNotEmpty + ? CommonItem( + leftTitel: '接收者'.tr, + rightTitle: state.getReceiver.value, + isHaveLine: true, + ) + : CommonItem( + leftTitel: '接收者'.tr, + isHaveLine: true, + isHaveRightWidget: true, + rightWidget: _buildReceiverItemWidget())), Obx(() => CommonItem( leftTitel: '类型', - rightTitle: - state.emailNotifyType.value == 1 ? '系统邮件' : '个人邮件', + rightTitle: state.getNotifyTypeText.value, isHaveDirection: true, action: () { EmailNotifyTypeSelectAlert.showEmailNotifyTypeSelectAlert( - context, (int value) { - state.emailNotifyType.value = value; - }); + isEmail: state.channelType.value == 2, + onSelected: (int value) { + state.notifyTypeSelect.value = value; + state.updateNotifyTypeText(); + }); }, )), Container(height: 10.h), Obx(() => CommonItem( leftTitel: '模板', - rightTitle: state.selectEmailTemplate.value, + rightTitle: state.currentNotifyItem.value.name ?? '', isHaveDirection: true, isHaveLine: true, action: () { @@ -81,7 +90,7 @@ class _SendEmailNotificationPageState extends State { maxLines: 8, maxLength: 1000, textAlign: TextAlign.start, - controller: state.emailController, + controller: state.templateContentController, style: TextStyle( color: Colors.black, fontSize: 22.sp, @@ -125,22 +134,125 @@ class _SendEmailNotificationPageState extends State { borderRadius: 20.w, margin: EdgeInsets.only(left: 30.w, right: 30.w, top: 30.w), padding: EdgeInsets.only(top: 25.w, bottom: 25.w), - onClick: () {}), + onClick: () { + if (state.notifyTypeSelect.value == 1) { + logic.keyNoticeSubmitRequest(); + } else {} + }), ], ), ), + ); } + + Widget _buildReceiverItemWidget() { + return Container( + constraints: BoxConstraints(maxWidth: 400.w), // 设置父组件的宽度约束 + child: Row( + mainAxisSize: MainAxisSize.min, // 设置 Row 的 mainAxisSize 属性 + children: [ + Flexible( + fit: FlexFit.loose, // 使用 Flexible 并设置ting fit 属性 + child: SizedBox(width: 10.w), + ), + if (state.channelType.value == 1) + GestureDetector( + child: Container( + width: 90.w, + color: Colors.white, + child: Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Obx(() => Text( + '+${state.countryCode.value}', + style: TextStyle( + color: AppColors.darkGrayTextColor, + fontSize: 20.sp), + )), + Image.asset( + 'images/icon_grayPullDown.png', + width: 20.w, + height: 20.w, + ), + ], + ), + ), + onTap: () async { + final result = + await Get.toNamed(Routers.selectCountryRegionPage); + if (result != null) { + result as Map; + state.countryCode.value = result['code']; + state.countryName.value = result['countryName']; + } + }, + ) + else + Container(), + getReceiverTFWidget(), + ], + ), + ); + } + + // 接受者信息输入框 + Widget getReceiverTFWidget() { + return SizedBox( + height: 65.h, + width: 200.w, + child: Row( + children: [ + Expanded( + child: TextField( + controller: state.receiverController, + //输入框一行 + maxLines: 1, + inputFormatters: [ + FilteringTextInputFormatter.deny('\n'), + LengthLimitingTextInputFormatter(30), + ], + autofocus: false, + textAlign: TextAlign.end, + decoration: InputDecoration( + hintText: '请输入'.tr, + hintStyle: TextStyle(fontSize: 22.sp), + focusedBorder: const OutlineInputBorder( + borderSide: + BorderSide(width: 0, color: Colors.transparent)), + disabledBorder: const OutlineInputBorder( + borderSide: + BorderSide(width: 0, color: Colors.transparent)), + enabledBorder: const OutlineInputBorder( + borderSide: + BorderSide(width: 0, color: Colors.transparent)), + border: const OutlineInputBorder( + borderSide: + BorderSide(width: 0, color: Colors.transparent)), + contentPadding: const EdgeInsets.symmetric(vertical: 0), + ), + style: TextStyle( + fontSize: 22.sp, textBaseline: TextBaseline.alphabetic), + onChanged: (String value) { + // 处理接收者输入改变事件 + }, + ), + ), + ], + ), ); } // 底部选择pickerView void openBottomItemSheet(BuildContext context) { - final List nameList = - state.emailTemplateList.map((item) => item.name!).toList(); + final List nameList = state.emailTemplateList + .map((EmailNotificationItem item) => item.name!) + .toList(); Pickers.showSinglePicker(context, data: nameList, pickerStyle: DefaultPickerStyle(), onConfirm: (p, int position) { - state.selectEmailTemplate.value = nameList[position]; + state.currentNotifyItem.value = state.emailTemplateList[position]; + state.templateContentController.text = + state.emailTemplateList[position].template!; }); } } diff --git a/lib/main/lockDetail/electronicKey/sendEmailNotification/sendEmailNotification_state.dart b/lib/main/lockDetail/electronicKey/sendEmailNotification/sendEmailNotification_state.dart index bbe0e2fe..954be4dc 100644 --- a/lib/main/lockDetail/electronicKey/sendEmailNotification/sendEmailNotification_state.dart +++ b/lib/main/lockDetail/electronicKey/sendEmailNotification/sendEmailNotification_state.dart @@ -4,14 +4,60 @@ import 'package:star_lock/main/lockDetail/electronicKey/sendEmailNotification/se class SendEmailNotificationState { SendEmailNotificationState() { - if (Get.arguments['email'] != null) { - getEmail.value = Get.arguments['email']; + if (Get.arguments['receiver'] != null) { + getReceiver.value = Get.arguments['receiver']; + } + + if (Get.arguments['keyId'] != null) { + getKeyId.value = Get.arguments['keyId']; + } + + if (Get.arguments['channelType'] != null) { + channelType.value = Get.arguments['channelType']; + updateNotifyTypeText(); + // if (channelType.value == 1) { + // if (notifyTypeSelect.value == 1) { + // getNotifyTypeText.value = '系统短信'; + // } else { + // getNotifyTypeText.value = '个人短信'; + // } + // } else { + // if (notifyTypeSelect.value == 1) { + // getNotifyTypeText.value = '系统邮件'; + // } else { + // getNotifyTypeText.value = '个人邮件'; + // } + // } } } - RxString getEmail = ''.obs; - final TextEditingController emailController = TextEditingController(); - RxInt emailNotifyType = 1.obs; //1 代表系统邮件,2 代表个人邮件 - RxList emailTemplateList = [].obs; - RxString selectEmailTemplate = '默认模版'.obs; + RxString getReceiver = ''.obs; + final TextEditingController templateContentController = + TextEditingController(); + final TextEditingController receiverController = TextEditingController(); + RxInt notifyTypeSelect = 1.obs; //1 代表系统,2 代表个人 + RxInt channelType = 0.obs; //1 代表短信,2 代表邮件 + RxString getNotifyTypeText = ''.obs; + RxList emailTemplateList = + [].obs; + Rx currentNotifyItem = EmailNotificationItem().obs; + RxInt getKeyId = 0.obs; //获取钥匙成功得到的keyId + RxString countryCode = '86'.obs; + RxString countryName = '中国'.obs; + + Future updateNotifyTypeText() async { + if (channelType.value == 1) { + if (notifyTypeSelect.value == 1) { + getNotifyTypeText.value = '系统短信'; + } else { + getNotifyTypeText.value = '个人短信'; + } + } else { + if (notifyTypeSelect.value == 1) { + getNotifyTypeText.value = '系统邮件'; + } else { + getNotifyTypeText.value = '个人邮件'; + } + } + } } diff --git a/lib/main/lockDetail/lockSet/lockEscalation/lockEscalation_logic.dart b/lib/main/lockDetail/lockSet/lockEscalation/lockEscalation_logic.dart index 4a34e67a..563c9d9e 100755 --- a/lib/main/lockDetail/lockSet/lockEscalation/lockEscalation_logic.dart +++ b/lib/main/lockDetail/lockSet/lockEscalation/lockEscalation_logic.dart @@ -10,11 +10,14 @@ import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:get/get.dart'; import 'package:http/http.dart' as http; import 'package:star_lock/blue/blue_manage.dart'; +import 'package:star_lock/blue/io_protocol/io_getStarLockStatusInfo.dart'; import 'package:star_lock/blue/io_protocol/io_otaUpgrade.dart'; import 'package:star_lock/blue/io_protocol/io_processOtaUpgrade.dart'; 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'; @@ -36,6 +39,8 @@ class LockEscalationLogic extends BaseGetXController { int startSecond = 0; Map? headJson; FwVersionEntity? entity; + String model = ''; + String currentVersion = ''; //手动升级 Future otaUpdate() async { @@ -157,7 +162,10 @@ class LockEscalationLogic extends BaseGetXController { // 拦截返回事件 void getBack() { if (state.otaUpdateIng.value) { - closeOTADAta(); + ShowTipView().showIosTipWithContentDialog('升级中,是否退出'.tr, () { + closeOTADAta(); + Get.back(); + }); } else { Get.back(); } @@ -236,20 +244,11 @@ class LockEscalationLogic extends BaseGetXController { //检查最新版本 Future checkUpData() async { - final String model = CommonDataManage().currentKeyInfo.model ?? ''; - String currentVersion = CommonDataManage().currentKeyInfo.fwVersion ?? ''; - if (currentVersion.split('.').length >= 3) { - currentVersion = currentVersion.split('.')[0] + - '.' + - currentVersion.split('.')[1] + - '.' + - currentVersion.split('.')[2]; - } state.showVersion.value = currentVersion; entity = await ApiRepository.to .getFwVersion(model: model, currentVersion: currentVersion); state.isShowUpDataBtn.value = entity?.data?.isUpdate == 1; - state.showNewVersion.value = entity?.data?.version??''; + state.showNewVersion.value = entity?.data?.version ?? ''; } //下载升级 @@ -264,10 +263,75 @@ class LockEscalationLogic extends BaseGetXController { } } + // 获取锁状态 + Future getStarLockStatus() async { + state.loading.value = true; + showBlueConnetctToastTimer(action: () { + state.loading.value = false; + }); + BlueManage().blueSendData(BlueManage().connectDeviceName, + (BluetoothConnectionState deviceConnectionState) async { + if (deviceConnectionState == BluetoothConnectionState.connected) { + final List? privateKey = + await Storage.getStringList(saveBluePrivateKey); + final List getPrivateKeyList = + changeStringListToIntList(privateKey!); + IoSenderManage.senderGetStarLockStatuInfo( + lockID: BlueManage().connectDeviceName, + userID: await Storage.getUid(), + utcTimeStamp: 0, + unixTimeStamp: 0, + isBeforeAddUser: false, + privateKey: getPrivateKeyList); + } else if (deviceConnectionState == + BluetoothConnectionState.disconnected) { + cancelBlueConnetctToastTimer(); + state.loading.value = false; + } + }); + } + + // 获取星锁状态 + Future _replyGetStarLockStatusInfo(Reply reply) async { + final int status = reply.data[2]; + state.loading.value = false; + switch (status) { + case 0x00: + //成功 + dismissEasyLoading(); + cancelBlueConnetctToastTimer(); + // 设备型号 + final List modelList = reply.data.sublist(24, 43); + // 设备型号 + final List fwVersion = reply.data.sublist(44, 63); + model = utf8String(modelList); + currentVersion = utf8String(fwVersion); + checkUpData(); + break; + case 0x06: + //无权限 + final List? privateKey = + await Storage.getStringList(saveBluePrivateKey); + final List getPrivateKeyList = + changeStringListToIntList(privateKey!); + IoSenderManage.senderGetStarLockStatuInfo( + lockID: BlueManage().connectDeviceName, + userID: await Storage.getUid(), + utcTimeStamp: 0, + unixTimeStamp: 0, + isBeforeAddUser: false, + privateKey: getPrivateKeyList, + ); + break; + default: + //失败 + break; + } + } + @override void onReady() { super.onReady(); - checkUpData(); } @override @@ -288,9 +352,15 @@ class LockEscalationLogic extends BaseGetXController { processOtaUpgrade(); } else if (reply is ConfirmationOTAUpgradeReply && reply.status == 0x00) { closeOTADAta(); + ApiRepository.to.getLockUpdateLockInfo( + lockId: CommonDataManage().currentKeyInfo.lockId ?? 0, + fwVersion: state.showNewVersion.value); showToast('固件升级完成'.tr); + } else if (reply is GetStarLockStatuInfoReply) { + _replyGetStarLockStatusInfo(reply); } }); + getStarLockStatus(); } @override diff --git a/lib/main/lockDetail/lockSet/lockEscalation/lockEscalation_page.dart b/lib/main/lockDetail/lockSet/lockEscalation/lockEscalation_page.dart index 949a7e3d..cb8ffcb9 100755 --- a/lib/main/lockDetail/lockSet/lockEscalation/lockEscalation_page.dart +++ b/lib/main/lockDetail/lockSet/lockEscalation/lockEscalation_page.dart @@ -40,22 +40,65 @@ class _LockEscalationPageState extends State { } Widget updateView(LockEscalationLogic logic) { + if (logic.state.loading.value) { + return Padding( + padding: EdgeInsets.only(top: 60.h), + child: Align( + alignment: Alignment.topCenter, + child: Column( + children: [ + Text( + '加载数据中'.tr, + style: TextStyle(fontSize: 24.sp, fontWeight: FontWeight.w600), + ), + SizedBox( + height: 40.h, + ), + CircularProgressIndicator( + color: AppColors.mainColor, + ), + ], + ), + ), + ); + } if (logic.state.otaUpdateIng.value) { return otaUpdate(logic); } + if (logic.model == '') { + return Padding( + padding: EdgeInsets.only(top: 60.h), + child: Column( + children: [ + Text( + '加载数据失败'.tr, + style: TextStyle(fontSize: 24.sp, fontWeight: FontWeight.w600), + ), + SizedBox( + height: 40.h, + ), + SubmitBtn( + btnName: '重试'.tr, + onClick: () { + logic.getStarLockStatus(); + }), + ], + ), + ); + } return defaultUpdate(logic); } //升级 Widget defaultUpdate(LockEscalationLogic logic) { return Column( - children: [ + children: [ SizedBox( height: 60.h, ), Row( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ Image.asset( 'images/main/icon_main_lockSet_lockEscalation.png', width: 36.w, @@ -67,7 +110,8 @@ class _LockEscalationPageState extends State { Obx(() { if (logic.state.isShowUpDataBtn.value) { return Text( - TranslationLoader.lanKeys!.haveNewVersion!.tr + logic.state.showNewVersion.value, + TranslationLoader.lanKeys!.haveNewVersion!.tr + + logic.state.showNewVersion.value, style: TextStyle(fontSize: 24.sp, fontWeight: FontWeight.w600), ); @@ -133,7 +177,7 @@ class _LockEscalationPageState extends State { //ota升级 Widget otaUpdate(LockEscalationLogic logic) { return Column( - children: [ + children: [ SizedBox( height: 20.h, ), @@ -178,7 +222,7 @@ class _LockEscalationPageState extends State { padding: EdgeInsets.symmetric(horizontal: 50.w, vertical: 15.h), child: Row( mainAxisSize: MainAxisSize.min, - children: [ + children: [ Text( '固件传输中', style: TextStyle( diff --git a/lib/main/lockDetail/lockSet/lockEscalation/lockEscalation_state.dart b/lib/main/lockDetail/lockSet/lockEscalation/lockEscalation_state.dart index a182c23a..0bda3bce 100755 --- a/lib/main/lockDetail/lockSet/lockEscalation/lockEscalation_state.dart +++ b/lib/main/lockDetail/lockSet/lockEscalation/lockEscalation_state.dart @@ -4,6 +4,7 @@ class LockEscalationState { RxBool otaUpdateIng = false.obs; RxDouble otaProgress = 0.00.obs; RxBool isShowUpDataBtn = false.obs; - RxString showVersion = '1.0.0'.obs; - RxString showNewVersion = '1.0.0'.obs; + RxString showVersion = ''.obs; + RxString showNewVersion = ''.obs; + RxBool loading = true.obs; } diff --git a/lib/main/lockDetail/lockSet/lockEscalation/updateLockInfo_entity.dart b/lib/main/lockDetail/lockSet/lockEscalation/updateLockInfo_entity.dart new file mode 100644 index 00000000..6809967d --- /dev/null +++ b/lib/main/lockDetail/lockSet/lockEscalation/updateLockInfo_entity.dart @@ -0,0 +1,25 @@ +class UpdateLockInfoEntity { + UpdateLockInfoEntity( + {this.errorCode, this.description, this.errorMsg, this.data}); + + UpdateLockInfoEntity.fromJson(Map json) { + errorCode = json['errorCode']; + description = json['description']; + errorMsg = json['errorMsg']; + data = json['data']; + } + + int? errorCode; + String? description; + String? errorMsg; + dynamic data; + + Map toJson() { + final Map data = {}; + data['errorCode'] = errorCode; + data['description'] = description; + data['errorMsg'] = errorMsg; + data['data'] = this.data; + return data; + } +} diff --git a/lib/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_page.dart b/lib/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_page.dart index 4a0692e7..39cdf279 100755 --- a/lib/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_page.dart +++ b/lib/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_page.dart @@ -6,6 +6,7 @@ import 'package:get/get.dart'; import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_logic.dart'; import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_state.dart'; import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyListEntity.dart'; +import 'package:star_lock/tools/commonDataManage.dart'; import 'package:star_lock/tools/showTFView.dart'; import 'package:star_lock/tools/showTipView.dart'; @@ -25,7 +26,8 @@ class PasswordKeyDetailPage extends StatefulWidget { State createState() => _PasswordKeyDetailPageState(); } -class _PasswordKeyDetailPageState extends State with RouteAware { +class _PasswordKeyDetailPageState extends State + with RouteAware { final PasswordKeyDetailLogic logic = Get.put(PasswordKeyDetailLogic()); final PasswordKeyDetailState state = Get.find().state; @@ -44,7 +46,7 @@ class _PasswordKeyDetailPageState extends State with Rout height: 30.h, width: 30.w, ), - onPressed: _openModalBottomSheet, + onPressed: openModalBottomSheet, ), ], ), @@ -52,13 +54,14 @@ class _PasswordKeyDetailPageState extends State with Rout child: Column( children: [ Obx(() => Visibility( - visible: state.itemData.value.isCustom! == 1, - child: CommonItem( - leftTitel: "${"密码".tr}${TranslationLoader.lanKeys!.number!.tr}", - rightTitle: state.itemData.value.pwdUserNo.toString(), - isHaveDirection: false, - isHaveLine: true), - )), + visible: state.itemData.value.isCustom! == 1, + child: CommonItem( + leftTitel: + "${"密码".tr}${TranslationLoader.lanKeys!.number!.tr}", + rightTitle: state.itemData.value.pwdUserNo.toString(), + isHaveDirection: false, + isHaveLine: true), + )), Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.password!.tr, rightTitle: state.keyboardPwd.value, @@ -148,16 +151,18 @@ class _PasswordKeyDetailPageState extends State with Rout rightTitle: '', isHaveDirection: true, action: () { - Get.toNamed(Routers.lockOperatingRecordPage, arguments: { + Get.toNamed(Routers.lockOperatingRecordPage, + arguments: { 'type': 1, - 'id': state.itemData.value.keyboardPwdId.toString(), + 'id': state.itemData.value.keyboardPwdId.toString(), 'recordName': state.itemData.value.keyboardPwdName }); }), Visibility( - visible: state.itemData.value.isCustom == 0 && state.itemData.value.keyboardPwdType != 1 && state.itemData.value.keyboardPwdType != 4, - child:bottomTip() - ), + visible: state.itemData.value.isCustom == 0 && + state.itemData.value.keyboardPwdType != 1 && + state.itemData.value.keyboardPwdType != 4, + child: bottomTip()), Container(height: 40.h), SizedBox( width: ScreenUtil().screenWidth - 40.w, @@ -244,7 +249,7 @@ class _PasswordKeyDetailPageState extends State with Rout )); } - Widget bottomTip(){ + Widget bottomTip() { return Column( children: [ Container( @@ -254,10 +259,10 @@ class _PasswordKeyDetailPageState extends State with Rout children: [ Expanded( child: Text( - '密码生成后,请在当日23:59前使用一次进行激活,否则过0点后未激活则失效。'.tr, - textAlign: TextAlign.start, - style: TextStyle(fontSize: 20.sp), - )), + '密码生成后,请在当日23:59前使用一次进行激活,否则过0点后未激活则失效。'.tr, + textAlign: TextAlign.start, + style: TextStyle(fontSize: 20.sp), + )), ], ), ), @@ -317,13 +322,14 @@ class _PasswordKeyDetailPageState extends State with Rout //发送时间 String getSenderDate(PasswordKeyListItem indexEntity) { String senderDate = ''; - DateTime dateStr = + final DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.sendDate!); senderDate = dateStr.toLocal().toString().substring(0, 16); return senderDate; } - void showCupertinoAlertDialog(BuildContext context, TextEditingController inputController) { + void showCupertinoAlertDialog( + BuildContext context, TextEditingController inputController) { showDialog( context: context, builder: (BuildContext context) { @@ -371,7 +377,7 @@ class _PasswordKeyDetailPageState extends State with Rout ); } - Future _openModalBottomSheet() async { + Future openModalBottomSheet() async { showModalBottomSheet( context: context, shape: RoundedRectangleBorder( @@ -382,7 +388,7 @@ class _PasswordKeyDetailPageState extends State with Rout children: [ SizedBox( width: ScreenUtil().screenWidth, - height: 180.h, + height: 160.h, child: ListView( scrollDirection: Axis.horizontal, //横向滚动 children: initBottomSheetList()), @@ -410,7 +416,7 @@ class _PasswordKeyDetailPageState extends State with Rout } List initBottomSheetList() { - List widgetList = []; + final List widgetList = []; widgetList.add(buildCenter3('images/icon_wechat.png', '微信好友', 0)); widgetList.add(buildCenter3('images/icon_message.png', '短信', 1)); @@ -447,37 +453,28 @@ class _PasswordKeyDetailPageState extends State with Rout ], ), ), - onTap: () => _jumpSmartDeviceRoute(itemIndex), + onTap: () => jumpSmartDeviceRoute(itemIndex), ); } - _jumpSmartDeviceRoute(int itemIndex) { + Future jumpSmartDeviceRoute(int itemIndex) async { Get.back(); - String pwdShareStr = logic.getShareContentStr(); + final String pwdShareStr = logic.getShareContentStr(); switch (itemIndex) { - case 0: - //微信好友 - { - NativeInteractionTool().loadNativeShare(shareText: pwdShareStr); - } + case 0: //微信好友 + NativeInteractionTool().loadNativeShare(shareText: pwdShareStr); break; - case 1: - //短信 - { - NativeInteractionTool().loadNativeShare(shareText: pwdShareStr); - } + case 1: //短信 + case 2: //邮件 + Get.toNamed(Routers.sendEmailNotificationPage, + arguments: { + 'receiver': '', + 'channelType': itemIndex == 1 ? 1 : 2, + 'keyId': CommonDataManage().currentKeyInfo.keyId, + }); break; - case 2: - //邮件 - { - Get.toNamed(Routers.sendEmailNotificationPage); - } - break; - case 3: - //更多 - { - NativeInteractionTool().loadNativeShare(shareText: pwdShareStr); - } + case 3: //更多 + NativeInteractionTool().loadNativeShare(shareText: pwdShareStr); break; default: } diff --git a/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart b/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart index 917bae6a..0bd4700a 100755 --- a/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart +++ b/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart @@ -1,4 +1,3 @@ - import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; @@ -39,7 +38,8 @@ class PasswordKeyPerpetualPage extends StatefulWidget { class _PasswordKeyPerpetualPageState extends State with RouteAware, SingleTickerProviderStateMixin { final PasswordKeyPerpetualLogic logic = Get.put(PasswordKeyPerpetualLogic()); - final PasswordKeyPerpetualState state = Get.find().state; + final PasswordKeyPerpetualState state = + Get.find().state; @override void initState() { @@ -93,7 +93,8 @@ class _PasswordKeyPerpetualPageState extends State TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr, state.nameController), keyBottomWidget( - '密码生成后,请在当日23:59前使用一次进行激活,否则过0点后未激活则失效。密码激活后,有效期内不限次数使用。'.tr) + '密码生成后,请在当日23:59前使用一次进行激活,否则过0点后未激活则失效。密码激活后,有效期内不限次数使用。' + .tr) ], ), ); @@ -141,7 +142,10 @@ class _PasswordKeyPerpetualPageState extends State child: Column( children: [ keyIfPerpetualWidget(), - if (state.isPermanent.value == false) keyCustomTimeLimitWidget() else Container(), + if (state.isPermanent.value == false) + keyCustomTimeLimitWidget() + else + Container(), perpetualKeyWidget( false, TranslationLoader.lanKeys!.name!.tr, @@ -189,8 +193,7 @@ class _PasswordKeyPerpetualPageState extends State TranslationLoader.lanKeys!.name!.tr, TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr, state.nameController), - keyBottomWidget( - '清空密码底部提示'.tr) + keyBottomWidget('清空密码底部提示'.tr) ], ), ); @@ -322,7 +325,10 @@ class _PasswordKeyPerpetualPageState extends State rightTitle: '', isHaveRightWidget: true, rightWidget: SizedBox(width: 60.w, height: 50.h, child: _switch())), - if (state.isPermanent.value == true) Container(height: 10.h) else Container(height: 1.h), + if (state.isPermanent.value == true) + Container(height: 10.h) + else + Container(height: 1.h), ], ); } @@ -330,8 +336,7 @@ class _PasswordKeyPerpetualPageState extends State // 自定义是管理员密码 Widget keyIfAdministratorWidget() { return Visibility( - visible: - CommonDataManage().currentKeyInfo.isLockOwner == 1, + visible: CommonDataManage().currentKeyInfo.isLockOwner == 1, child: Column( children: [ // SizedBox(height: 10.h), @@ -374,11 +379,11 @@ class _PasswordKeyPerpetualPageState extends State }), Visibility( visible: CommonDataManage().currentKeyInfo.vendor == - IoModelVendor.vendor_XL && - (CommonDataManage().currentKeyInfo.model == - IoModelVendor.model_XL_BLE || - CommonDataManage().currentKeyInfo.model == - IoModelVendor.model_XL_WIFI), + IoModelVendor.vendor_XL && + (CommonDataManage().currentKeyInfo.model == + IoModelVendor.model_XL_BLE || + CommonDataManage().currentKeyInfo.model == + IoModelVendor.model_XL_WIFI), child: CommonItem( leftTitel: '结束日期', rightTitle: state.endTime.value, @@ -403,7 +408,8 @@ class _PasswordKeyPerpetualPageState extends State final PDuration selectDate = PDuration.parse( DateTool().dateToDateTime(state.loopEffectiveDate.value, 0)); Pickers.showDatePicker(context, - selectDate: selectDate, mode: DateMode.H, onConfirm: (PDuration p) { + selectDate: selectDate, + mode: DateMode.H, onConfirm: (PDuration p) { state.loopEffectiveDate.value = DateTool().getYMDHNDateString(p, 5); state.loopStartHours.value = p.hour!; @@ -417,7 +423,8 @@ class _PasswordKeyPerpetualPageState extends State final PDuration selectDate = PDuration.parse( DateTool().dateToDateTime(state.loopFailureDate.value, 0)); Pickers.showDatePicker(context, - selectDate: selectDate, mode: DateMode.H, onConfirm: (PDuration p) { + selectDate: selectDate, + mode: DateMode.H, onConfirm: (PDuration p) { state.loopFailureDate.value = DateTool().getYMDHNDateString(p, 5); state.loopEndHours.value = p.hour!; @@ -563,14 +570,16 @@ class _PasswordKeyPerpetualPageState extends State child: TextField( //输入框一行 maxLines: 1, - inputFormatters: editController == state.pwdController ? [ - FilteringTextInputFormatter.deny('\n'), - LengthLimitingTextInputFormatter(9), - FilteringTextInputFormatter.allow(RegExp(r'[0-9]')), - ]:[ - FilteringTextInputFormatter.deny('\n'), - LengthLimitingTextInputFormatter(50), - ], + inputFormatters: editController == state.pwdController + ? [ + FilteringTextInputFormatter.deny('\n'), + LengthLimitingTextInputFormatter(9), + FilteringTextInputFormatter.allow(RegExp(r'[0-9]')), + ] + : [ + FilteringTextInputFormatter.deny('\n'), + LengthLimitingTextInputFormatter(50), + ], keyboardType: editController == state.nameController ? TextInputType.text : TextInputType.number, @@ -657,7 +666,7 @@ class _PasswordKeyPerpetualPageState extends State children: [ SizedBox( width: ScreenUtil().screenWidth, - height: 180.h, + height: 160.h, child: ListView( scrollDirection: Axis.horizontal, //横向滚动 children: initBottomSheetList()), @@ -725,9 +734,8 @@ class _PasswordKeyPerpetualPageState extends State return Expanded( child: TabBarView( controller: state.tabController, - children: _itemTabs - .map((ItemView item) => Obx(indexChangeWidget)) - .toList(), + children: + _itemTabs.map((ItemView item) => Obx(indexChangeWidget)).toList(), ), ); } @@ -779,38 +787,29 @@ class _PasswordKeyPerpetualPageState extends State ], ), ), - onTap: () => _jumpSmartDeviceRoute(itemIndex), + onTap: () => jumpSmartDeviceRoute(itemIndex), ); } //\n生效时间:${itemData.startDate}\n类型:永久\n锁名:${itemData.keyboardPwdName} - _jumpSmartDeviceRoute(int itemIndex) { + Future jumpSmartDeviceRoute(int itemIndex) async { Get.back(); final String pwdShareStr = logic.getShareContentStr(); switch (itemIndex) { - case 0: - //微信好友 - { - NativeInteractionTool().loadNativeShare(shareText: pwdShareStr); - } + case 0: //微信好友 + NativeInteractionTool().loadNativeShare(shareText: pwdShareStr); break; - case 1: - //短信 - { - NativeInteractionTool().loadNativeShare(shareText: pwdShareStr); - } + case 1: //短信 + case 2: //邮件 + Get.toNamed(Routers.sendEmailNotificationPage, + arguments: { + 'receiver': '', + 'channelType': itemIndex == 1 ? 1 : 2, + 'keyId': CommonDataManage().currentKeyInfo.keyId, + }); break; - case 2: - //邮件 - { - Navigator.pushNamed(context, Routers.sendEmailNotificationPage); - } - break; - case 3: - //更多 - { - NativeInteractionTool().loadNativeShare(shareText: pwdShareStr); - } + case 3: //更多 + NativeInteractionTool().loadNativeShare(shareText: pwdShareStr); break; default: } diff --git a/lib/mine/valueAddedServices/advancedFeaturesWeb/advancedFeaturesWeb_logic.dart b/lib/mine/valueAddedServices/advancedFeaturesWeb/advancedFeaturesWeb_logic.dart index b9f550a4..41bebc90 100755 --- a/lib/mine/valueAddedServices/advancedFeaturesWeb/advancedFeaturesWeb_logic.dart +++ b/lib/mine/valueAddedServices/advancedFeaturesWeb/advancedFeaturesWeb_logic.dart @@ -77,7 +77,6 @@ class AdvancedFeaturesWebLogic extends BaseGetXController { //监听webview的调用 Future flutterBridge(JavaScriptMessage message) async { final dynamic obj = jsonDecode(message.message); - AppLog.log(obj); if (obj is! Map && obj['action'] is String) { return; } diff --git a/lib/network/api.dart b/lib/network/api.dart index ea17749e..b9ff02c2 100755 --- a/lib/network/api.dart +++ b/lib/network/api.dart @@ -255,4 +255,6 @@ abstract class Api { final String checkIpURL = '/checkIp/ip'; final String keyNoticeTemplateURL = '/key/getNoticeTemplate'; //获取电子钥匙通知模板 + final String keyNoticeSubmitURL = '/key/noticeSubmit'; //发送短信、邮件通知 + final String lockUpdateLockInfo = '/lock/updateLockInfo'; //更新锁固件版本 } diff --git a/lib/network/api_provider.dart b/lib/network/api_provider.dart index 19035f57..6bf76bb6 100755 --- a/lib/network/api_provider.dart +++ b/lib/network/api_provider.dart @@ -2245,6 +2245,33 @@ class ApiProvider extends BaseProvider { }), isUnShowLoading: true, ); + + Future> keyNoticeSubmit(String receiverName, int lockId, + int keyId, int channelType, int openDoorType, String templateType) => + post( + keyNoticeSubmitURL.toUrl, + jsonEncode({ + 'receiverName': receiverName, + 'lockId': lockId, + 'keyId': keyId, + 'channelType': channelType, + 'openDoorType': openDoorType, + 'templateType': templateType, + }), + isUnShowLoading: true, + ); + + Future> getLockUpdateLockInfo( + int lockId, + String fwVersion, + ) => + post( + lockUpdateLockInfo.toUrl, + jsonEncode({ + 'lockId': lockId, + 'fwVersion': fwVersion, + }), + ); } extension ExtensionString on String { diff --git a/lib/network/api_repository.dart b/lib/network/api_repository.dart index 542b08f6..b7a46ad1 100755 --- a/lib/network/api_repository.dart +++ b/lib/network/api_repository.dart @@ -12,6 +12,7 @@ import 'package:star_lock/main/lockDetail/electronicKey/sendEmailNotification/se import 'package:star_lock/main/lockDetail/face/addFace/addFace_entity.dart'; import 'package:star_lock/main/lockDetail/fingerprint/fingerprintList/fingerprint_entity.dart'; import 'package:star_lock/main/lockDetail/lockSet/basicInformation/basicInformation/KeyDetailEntity.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/main/lockDetail/messageWarn/lockUser/lockUser_entity.dart'; import 'package:star_lock/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceFingerprintList/coerceFingerprintList_entity.dart'; @@ -2259,4 +2260,28 @@ class ApiRepository { await apiProvider.getKeyNoticeTemplate(lockId, keyId, channelType); return SendEmailNotificationEntity.fromJson(res.body); } + + // 发送短信、邮件通知 + Future keyNoticeSubmit({ + required String receiverName, + required int lockId, + required int keyId, + required int channelType, + required int openDoorType, + required String templateType, + }) async { + final Response res = await apiProvider.keyNoticeSubmit( + receiverName, lockId, keyId, channelType, openDoorType, templateType); + return SendEmailNotificationEntity.fromJson(res.body); + } + + // 获取电子钥匙通知模板 + Future getLockUpdateLockInfo({ + required int lockId, + required String fwVersion, + }) async { + final Response res = + await apiProvider.getLockUpdateLockInfo(lockId, fwVersion); + return UpdateLockInfoEntity.fromJson(res.body); + } } diff --git a/lib/tools/emailNotifyTypeSelectAlert.dart b/lib/tools/emailNotifyTypeSelectAlert.dart index 693ab04e..c7c1afec 100644 --- a/lib/tools/emailNotifyTypeSelectAlert.dart +++ b/lib/tools/emailNotifyTypeSelectAlert.dart @@ -14,10 +14,10 @@ class EmailNotifyTypeSelectAlert extends StatelessWidget { } static void showEmailNotifyTypeSelectAlert( - BuildContext context, Function(int) onSelected) { + {required bool isEmail, required Function(int) onSelected}) { bool isSystemEmailSelected = true; // 默认选中系统邮件 showCupertinoDialog( - context: context, + context: Get.context!, builder: (BuildContext context) { return StatefulBuilder( builder: (BuildContext context, StateSetter setState) { @@ -54,7 +54,7 @@ class EmailNotifyTypeSelectAlert extends StatelessWidget { Padding( padding: EdgeInsets.only(left: 10.w), child: Text( - '系统邮件(推荐)', + isEmail ? '系统邮件(推荐)' : '系统短信(推荐)', style: TextStyle( fontSize: 22.sp, fontWeight: FontWeight.bold), ), @@ -67,7 +67,9 @@ class EmailNotifyTypeSelectAlert extends StatelessWidget { child: Align( alignment: Alignment.centerLeft, child: Text( - '邮件将从软件平台直接发给用户,请根据需要在软件那里购买邮件数量', + isEmail + ? '邮件将从软件平台直接发给用户,请根据需要在软件那里购买邮件数量' + : '短信将从软件平台直接发给用户,请根据需要在软件那里购买短信数量', style: TextStyle(fontSize: 18.sp), textAlign: TextAlign.left, ), @@ -93,7 +95,7 @@ class EmailNotifyTypeSelectAlert extends StatelessWidget { Padding( padding: EdgeInsets.only(left: 10.w), child: Text( - '个人邮件', + isEmail ? '个人邮件' : '个人短信', style: TextStyle( fontSize: 22.sp, fontWeight: FontWeight.bold), ), @@ -106,8 +108,11 @@ class EmailNotifyTypeSelectAlert extends StatelessWidget { child: Align( alignment: Alignment.centerLeft, child: Text( - '邮件将从你的个人邮箱发给用户', + isEmail + ? '邮件将从你的个人邮箱发给用户' + : '短信将从你的个人手机号发给用户,费用由运营商从你的手机号扣除', style: TextStyle(fontSize: 18.sp), + textAlign: TextAlign.left, ), ), ),