feat:修改电子钥匙页面滑动,子页面不变的问题
This commit is contained in:
parent
421a978ab5
commit
c2cb7218ee
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart';
|
import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart';
|
||||||
import 'package:star_lock/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_state.dart';
|
import 'package:star_lock/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_state.dart';
|
||||||
|
import 'package:star_lock/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_state.dart';
|
||||||
import 'package:star_lock/network/api_repository.dart';
|
import 'package:star_lock/network/api_repository.dart';
|
||||||
import 'package:star_lock/tools/baseGetXController.dart';
|
import 'package:star_lock/tools/baseGetXController.dart';
|
||||||
import 'package:star_lock/tools/commonDataManage.dart';
|
import 'package:star_lock/tools/commonDataManage.dart';
|
||||||
@ -12,220 +12,4 @@ import '../../../../../tools/showTipView.dart';
|
|||||||
|
|
||||||
class SendElectronicKeyLogic extends BaseGetXController {
|
class SendElectronicKeyLogic extends BaseGetXController {
|
||||||
final SendElectronicKeyState state = SendElectronicKeyState();
|
final SendElectronicKeyState state = SendElectronicKeyState();
|
||||||
|
|
||||||
//发送钥匙请求
|
|
||||||
Future<void> sendElectronicKeyRequest() async {
|
|
||||||
if (state.emailOrPhoneController.text.isEmpty) {
|
|
||||||
showToast("请输入接收者账号".tr);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 姓名变为非必填(同通通锁)
|
|
||||||
// if(state.keyNameController.text.isEmpty){
|
|
||||||
// showToast("请输入接收者姓名");
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
//发送钥匙请求
|
|
||||||
var startDate = "0";
|
|
||||||
var endDate = "0";
|
|
||||||
var startTime = "0";
|
|
||||||
var endTime = "0";
|
|
||||||
int typeValue = state.seletType.value;
|
|
||||||
switch (typeValue) {
|
|
||||||
case 0:
|
|
||||||
{
|
|
||||||
// 限时
|
|
||||||
if (state.timeLimitBeginTime.value.isEmpty) {
|
|
||||||
showToast("请选择开始时间".tr);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (state.timeLimitEndTime.value.isEmpty) {
|
|
||||||
showToast("请选择结束时间".tr);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
typeValue = XSConstantMacro.keyTypeTime;
|
|
||||||
startDate = DateTool().dateToTimestamp(state.timeLimitBeginTime.value, 1).toString();
|
|
||||||
endDate = DateTool().dateToTimestamp(state.timeLimitEndTime.value, 1).toString();
|
|
||||||
startTime = "0";
|
|
||||||
endTime = "0";
|
|
||||||
|
|
||||||
// if(DateTime.now().millisecondsSinceEpoch > int.parse(state.beginTimeTimestamp.value)){
|
|
||||||
// Toast.show(msg: "生效时间要大于当前时间");
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
if (int.parse(startDate) >= int.parse(endDate)) {
|
|
||||||
showToast("失效时间要大于生效时间".tr);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
typeValue = XSConstantMacro.keyTypeLong;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
typeValue = XSConstantMacro.keyTypeOnce;
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
typeValue = XSConstantMacro.keyTypeLoop;
|
|
||||||
if (state.cycleBeginTime.value.isEmpty) {
|
|
||||||
showToast("请选择有效期".tr);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
startDate = DateTool().dateToTimestamp(state.cycleBeginTime.value, 1).toString();
|
|
||||||
endDate = DateTool().dateToTimestamp(state.cycleEndTime.value, 1).toString();
|
|
||||||
startTime = DateTool().dateToTimestamp(state.effectiveDateTime.value, 0).toString();
|
|
||||||
endTime = DateTool().dateToTimestamp(state.failureDateTime.value, 0).toString();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
typeValue = XSConstantMacro.keyTypeTime;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
String getKeyType = typeValue.toString();
|
|
||||||
|
|
||||||
var entity = await ApiRepository.to.sendElectronicKey(
|
|
||||||
createUser: state.isCreateUser.value == true ? "1" : "0",
|
|
||||||
countryCode: state.countryCode.value,
|
|
||||||
usernameType: isPhoneNumber(state.emailOrPhoneController.text) == true
|
|
||||||
? '1'
|
|
||||||
: '2',
|
|
||||||
endDate: int.parse(endDate),
|
|
||||||
faceAuthentication: state.isAuthentication.value == true ? '1' : '2',
|
|
||||||
isCameraEnable: '2',
|
|
||||||
isRemoteUnlock: state.isRemoteUnlock.value == true ? '1' : '2',
|
|
||||||
keyNameForAdmin: state.keyNameController.text,
|
|
||||||
keyRight: '0',
|
|
||||||
keyType: getKeyType,
|
|
||||||
lockId: CommonDataManage().currentKeyInfo.lockId.toString(),
|
|
||||||
operatorUid: '',
|
|
||||||
receiverUsername: state.emailOrPhoneController.text,
|
|
||||||
remarks: '',
|
|
||||||
startDate: int.parse(startDate),
|
|
||||||
weekDays: state.weekdaysList.value,
|
|
||||||
startTime: int.parse(startTime),
|
|
||||||
endTime: int.parse(endTime),
|
|
||||||
isOnlyManageSelf: 0);
|
|
||||||
if (entity.errorCode!.codeIsSuccessful) {
|
|
||||||
state.isSendSuccess.value = true;
|
|
||||||
state.sendSucceedType.value = state.seletType.value;
|
|
||||||
resetData();
|
|
||||||
eventBus.fire(ElectronicKeyListRefreshUI());
|
|
||||||
} else {
|
|
||||||
if (entity.errorCode == 425) {
|
|
||||||
//用户未注册
|
|
||||||
state.isCreateUser.value = true;
|
|
||||||
ShowTipView().showIosTipWithContentDialog('${"是否发送电子钥匙给未注册账号".tr}\n${state.emailOrPhoneController.text}', (){
|
|
||||||
sendElectronicKeyRequest();
|
|
||||||
});
|
|
||||||
// if (isPhoneNumber(state.emailOrPhoneController.text) == true) {
|
|
||||||
// _showEmailDialog();
|
|
||||||
// } else {
|
|
||||||
// _showEmailDialog();
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isPhoneNumber(String input) {
|
|
||||||
// 手机号正则表达式,这里简化为11位数字
|
|
||||||
final RegExp phoneRegExp = RegExp(r'^\d{11}$');
|
|
||||||
return phoneRegExp.hasMatch(input);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isEmail(String input) {
|
|
||||||
// 邮箱正则表达式,这里简化为常见格式
|
|
||||||
final RegExp emailRegExp =
|
|
||||||
RegExp(r'^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$');
|
|
||||||
return emailRegExp.hasMatch(input);
|
|
||||||
}
|
|
||||||
|
|
||||||
// //用户未注册确认弹窗
|
|
||||||
// void _showPhoneDialog(widgetContext, String errMsg) {
|
|
||||||
// showCupertinoDialog(
|
|
||||||
// context: widgetContext,
|
|
||||||
// builder: (context) {
|
|
||||||
// return CupertinoAlertDialog(
|
|
||||||
// title: Text('接收者号码未注册,请重新发送'.tr),
|
|
||||||
// actions: [
|
|
||||||
// CupertinoDialogAction(
|
|
||||||
// child: Text(
|
|
||||||
// TranslationLoader.lanKeys!.cancel!.tr,
|
|
||||||
// style: TextStyle(color: AppColors.mainColor),
|
|
||||||
// ),
|
|
||||||
// onPressed: () {
|
|
||||||
// Get.back();
|
|
||||||
// },
|
|
||||||
// ),
|
|
||||||
// CupertinoDialogAction(
|
|
||||||
// child: Text(
|
|
||||||
// TranslationLoader.lanKeys!.sure!.tr,
|
|
||||||
// style: TextStyle(color: AppColors.mainColor),
|
|
||||||
// ),
|
|
||||||
// onPressed: () async {
|
|
||||||
// //选择国家代码
|
|
||||||
// Get.back();
|
|
||||||
//
|
|
||||||
// // var result = await Get.toNamed(Routers.selectCountryRegionPage);
|
|
||||||
// // if (result != null) {
|
|
||||||
// // result as Map<String, dynamic>;
|
|
||||||
// // state.countryCode.value = result['code'];
|
|
||||||
// // state.countryName.value = result['countryName'];
|
|
||||||
// // }
|
|
||||||
// sendElectronicKeyRequest();
|
|
||||||
// },
|
|
||||||
// ),
|
|
||||||
// ],
|
|
||||||
// );
|
|
||||||
// },
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
|
|
||||||
//用户未注册确认弹窗---邮箱
|
|
||||||
// void _showEmailDialog() {
|
|
||||||
// showCupertinoDialog(
|
|
||||||
// context: Get.context!,
|
|
||||||
// builder: (context) {
|
|
||||||
// return CupertinoAlertDialog(
|
|
||||||
// title: Text('${"是否发送电子钥匙给未注册账号".tr}\n${state.emailOrPhoneController.text}'),
|
|
||||||
// actions: [
|
|
||||||
// CupertinoDialogAction(
|
|
||||||
// child: Text(
|
|
||||||
// TranslationLoader.lanKeys!.cancel!.tr,
|
|
||||||
// style: TextStyle(color: AppColors.mainColor),
|
|
||||||
// ),
|
|
||||||
// onPressed: () {
|
|
||||||
// Get.back();
|
|
||||||
// },
|
|
||||||
// ),
|
|
||||||
// CupertinoDialogAction(
|
|
||||||
// child: Text(
|
|
||||||
// TranslationLoader.lanKeys!.sure!.tr,
|
|
||||||
// style: TextStyle(color: AppColors.mainColor),
|
|
||||||
// ),
|
|
||||||
// onPressed: () {
|
|
||||||
// Get.back();
|
|
||||||
//
|
|
||||||
// sendElectronicKeyRequest();
|
|
||||||
// },
|
|
||||||
// ),
|
|
||||||
// ],
|
|
||||||
// );
|
|
||||||
// },
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
|
|
||||||
void resetData() {
|
|
||||||
state.emailOrPhoneController.text = "";
|
|
||||||
state.keyNameController.text = "";
|
|
||||||
|
|
||||||
state.timeLimitBeginTime = DateTool().dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString()).obs;// 限时开始时间
|
|
||||||
state.timeLimitEndTime = DateTool().dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString()).obs;// 限时结束时间
|
|
||||||
state.cycleBeginTime = "".obs;// 循环开始时间
|
|
||||||
state.cycleEndTime = "".obs;// 循环结束时间
|
|
||||||
state.effectiveDateTime = "".obs;// 生效时间
|
|
||||||
state.failureDateTime = "".obs;// 失效时间
|
|
||||||
state.weekdaysList = [].obs;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import 'package:get/get.dart';
|
|||||||
import 'package:star_lock/app_settings/app_colors.dart';
|
import 'package:star_lock/app_settings/app_colors.dart';
|
||||||
import 'package:flutter_native_contact_picker/flutter_native_contact_picker.dart';
|
import 'package:flutter_native_contact_picker/flutter_native_contact_picker.dart';
|
||||||
import 'package:star_lock/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_logic.dart';
|
import 'package:star_lock/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_logic.dart';
|
||||||
|
import 'package:star_lock/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_page.dart';
|
||||||
import 'package:star_lock/network/api_repository.dart';
|
import 'package:star_lock/network/api_repository.dart';
|
||||||
import 'package:star_lock/tools/baseGetXController.dart';
|
import 'package:star_lock/tools/baseGetXController.dart';
|
||||||
import 'package:star_lock/tools/pickers/pickers.dart';
|
import 'package:star_lock/tools/pickers/pickers.dart';
|
||||||
@ -37,28 +38,11 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage>
|
|||||||
final logic = Get.put(SendElectronicKeyLogic());
|
final logic = Get.put(SendElectronicKeyLogic());
|
||||||
final state = Get.find<SendElectronicKeyLogic>().state;
|
final state = Get.find<SendElectronicKeyLogic>().state;
|
||||||
|
|
||||||
Future<void> getDemoMode() async {
|
|
||||||
state.isDemoMode = (await Storage.getBool(ifIsDemoModeOrNot))!;
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
// TODO: implement initState
|
|
||||||
super.initState();
|
super.initState();
|
||||||
|
|
||||||
getDemoMode();
|
|
||||||
|
|
||||||
state.tabController =
|
state.tabController =
|
||||||
TabController(vsync: this, length: _itemTabs.length, initialIndex: 0);
|
TabController(vsync: this, length: _itemTabs.length, initialIndex: 0);
|
||||||
state.tabController.addListener(() {
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
||||||
state.seletType.value = state.tabController.index;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (state.tabController.animation!.value == state.tabController.index) {
|
|
||||||
FocusScope.of(context).requestFocus(FocusNode());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -78,587 +62,6 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage>
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget indexChangeWidget(ItemView item) {
|
|
||||||
if (state.isSendSuccess.value == true &&
|
|
||||||
state.sendSucceedType.value.toString() == item.type) {
|
|
||||||
return sendElectronicKeySucceed();
|
|
||||||
} else {
|
|
||||||
switch (item.type) {
|
|
||||||
case '0':
|
|
||||||
{
|
|
||||||
// 限时
|
|
||||||
return SingleChildScrollView(
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
keyInfoWidget(),
|
|
||||||
keyTimeWidget(),
|
|
||||||
remoteUnlockingWidget(),
|
|
||||||
keyRealNameWidget(),
|
|
||||||
keyBottomWidget(state.timeLimitTips)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
case '1':
|
|
||||||
{
|
|
||||||
// 永久
|
|
||||||
return SingleChildScrollView(
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
keyInfoWidget(),
|
|
||||||
remoteUnlockingWidget(),
|
|
||||||
keyRealNameWidget(),
|
|
||||||
keyBottomWidget(state.permanentTips)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
case '2':
|
|
||||||
{
|
|
||||||
// 单次
|
|
||||||
return SingleChildScrollView(
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
keyInfoWidget(),
|
|
||||||
remoteUnlockingWidget(),
|
|
||||||
keyRealNameWidget(),
|
|
||||||
keyBottomWidget(state.onceLimitTips)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
case '3':
|
|
||||||
{
|
|
||||||
// 循环
|
|
||||||
return SingleChildScrollView(
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
keyInfoWidget(),
|
|
||||||
keyPeriodValidityWidget(),
|
|
||||||
remoteUnlockingWidget(),
|
|
||||||
keyRealNameWidget(),
|
|
||||||
keyBottomWidget(state.cycleLimitTips)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
return Container();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 顶部钥匙信息widget
|
|
||||||
Widget keyInfoWidget() {
|
|
||||||
return Column(
|
|
||||||
children: [
|
|
||||||
// Container(height: 10.h),
|
|
||||||
CommonItem(
|
|
||||||
leftTitel: TranslationLoader.lanKeys!.receiver!.tr,
|
|
||||||
rightTitle: "",
|
|
||||||
isHaveLine: true,
|
|
||||||
isHaveRightWidget: true,
|
|
||||||
rightWidget: getTFWidget(true,
|
|
||||||
TranslationLoader.lanKeys!.pleaseEnterNumberOrEmail!.tr, 1)),
|
|
||||||
CommonItem(
|
|
||||||
leftTitel: TranslationLoader.lanKeys!.countryAndRegion!.tr,
|
|
||||||
rightTitle: "",
|
|
||||||
isHaveLine: true,
|
|
||||||
isHaveRightWidget: true,
|
|
||||||
isHaveDirection: true,
|
|
||||||
rightWidget: Text(
|
|
||||||
'${state.countryName.value} +${state.countryCode.value}',
|
|
||||||
textAlign: TextAlign.end,
|
|
||||||
style:
|
|
||||||
TextStyle(fontSize: 22.sp, color: AppColors.darkGrayTextColor),
|
|
||||||
),
|
|
||||||
action: () async {
|
|
||||||
var result = await Navigator.pushNamed(
|
|
||||||
context, Routers.selectCountryRegionPage);
|
|
||||||
if (result != null) {
|
|
||||||
result as Map<String, dynamic>;
|
|
||||||
state.countryCode.value = result['code'];
|
|
||||||
state.countryName.value = result['countryName'];
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
CommonItem(
|
|
||||||
leftTitel: TranslationLoader.lanKeys!.name!.tr,
|
|
||||||
rightTitle: "",
|
|
||||||
isHaveRightWidget: true,
|
|
||||||
rightWidget: getTFWidget(
|
|
||||||
false, TranslationLoader.lanKeys!.enterYourName!.tr, 2)),
|
|
||||||
Container(height: 10.h),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 生效失效时间
|
|
||||||
Widget keyTimeWidget() {
|
|
||||||
return Column(
|
|
||||||
children: [
|
|
||||||
Obx(() => CommonItem(
|
|
||||||
leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr,
|
|
||||||
rightTitle: state.timeLimitBeginTime.value,
|
|
||||||
isHaveLine: true,
|
|
||||||
isHaveDirection: true,
|
|
||||||
action: () {
|
|
||||||
PDuration selectDate = PDuration.parse(
|
|
||||||
DateTime.parse(state.timeLimitBeginTime.value));
|
|
||||||
Pickers.showDatePicker(context,
|
|
||||||
selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) {
|
|
||||||
state.timeLimitBeginTime.value =
|
|
||||||
DateTool().getYMDHNDateString(p, 1);
|
|
||||||
});
|
|
||||||
})),
|
|
||||||
Obx(() => CommonItem(
|
|
||||||
leftTitel: TranslationLoader.lanKeys!.failureTime!.tr,
|
|
||||||
rightTitle: state.timeLimitEndTime.value,
|
|
||||||
isHaveDirection: true,
|
|
||||||
action: () {
|
|
||||||
PDuration selectDate = PDuration.parse(
|
|
||||||
DateTime.tryParse(state.timeLimitEndTime.value));
|
|
||||||
Pickers.showDatePicker(context,
|
|
||||||
selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) {
|
|
||||||
state.timeLimitEndTime.value =
|
|
||||||
DateTool().getYMDHNDateString(p, 1);
|
|
||||||
});
|
|
||||||
})),
|
|
||||||
Container(height: 10.h),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 实名认证
|
|
||||||
Widget keyRealNameWidget() {
|
|
||||||
return Column(
|
|
||||||
children: [
|
|
||||||
CommonItem(
|
|
||||||
leftTitel: TranslationLoader.lanKeys!.realNameAuthentication!.tr,
|
|
||||||
rightTitle: "",
|
|
||||||
isTipsImg: true,
|
|
||||||
tipsImgAction: () {
|
|
||||||
ShowTipView().showSureAlertDialog(
|
|
||||||
"人脸实名认证指的是用户在使用手机APP开锁时,需要先进行本人人脸验证,验证通过才能开锁。".tr);
|
|
||||||
},
|
|
||||||
isHaveRightWidget: true,
|
|
||||||
rightWidget:
|
|
||||||
SizedBox(width: 60.w, height: 50.h, child: _remoteSwitch(false)),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 循环有效期
|
|
||||||
Widget keyPeriodValidityWidget() {
|
|
||||||
return Column(
|
|
||||||
children: [
|
|
||||||
Obx(() => CommonItem(
|
|
||||||
leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr,
|
|
||||||
rightTitle:
|
|
||||||
"${state.cycleBeginTime.value}\n${state.cycleEndTime.value}",
|
|
||||||
isHaveDirection: true,
|
|
||||||
isHaveLine: true,
|
|
||||||
action: () async {
|
|
||||||
var result =
|
|
||||||
await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: {
|
|
||||||
'validityValue': state.weekdaysList.value,
|
|
||||||
'starDate': state.cycleBeginTime.value,
|
|
||||||
'endDate': state.cycleEndTime.value,
|
|
||||||
'starTime': state.effectiveDateTime.value,
|
|
||||||
'endTime': state.failureDateTime.value
|
|
||||||
});
|
|
||||||
if (result != null && result.isNotEmpty) {
|
|
||||||
state.weekdaysList.value = result['validityValue'];
|
|
||||||
state.cycleBeginTime.value = result['starDate'];
|
|
||||||
state.cycleEndTime.value = result['endDate'];
|
|
||||||
state.effectiveDateTime.value = result['starTime'];
|
|
||||||
state.failureDateTime.value = result['endTime'];
|
|
||||||
}
|
|
||||||
})),
|
|
||||||
Obx(() => Visibility(
|
|
||||||
visible: state.weekdaysList.isNotEmpty ? true : false,
|
|
||||||
child: CommonItem(
|
|
||||||
leftTitel: "有效日".tr,
|
|
||||||
rightTitle: state.weekdaysList.value.join(",").toString(),
|
|
||||||
isHaveDirection: true,
|
|
||||||
isHaveLine: true,
|
|
||||||
action: () async {
|
|
||||||
var result = await Get.toNamed(Routers.seletKeyCyclicDatePage,
|
|
||||||
arguments: {
|
|
||||||
'validityValue': state.weekdaysList.value,
|
|
||||||
'starDate': state.cycleBeginTime.value,
|
|
||||||
'endDate': state.cycleEndTime.value,
|
|
||||||
'starTime': state.effectiveDateTime.value,
|
|
||||||
'endTime': state.failureDateTime.value
|
|
||||||
});
|
|
||||||
if (result != null && result.isNotEmpty) {
|
|
||||||
state.weekdaysList.value = result['validityValue'];
|
|
||||||
state.cycleBeginTime.value = result['starDate'];
|
|
||||||
state.cycleEndTime.value = result['endDate'];
|
|
||||||
state.effectiveDateTime.value = result['starTime'];
|
|
||||||
state.failureDateTime.value = result['endTime'];
|
|
||||||
}
|
|
||||||
}))),
|
|
||||||
Obx(() => Visibility(
|
|
||||||
visible: state.effectiveDateTime.value.isNotEmpty,
|
|
||||||
child: CommonItem(
|
|
||||||
leftTitel: "有效时间".tr,
|
|
||||||
rightTitle:
|
|
||||||
"${state.effectiveDateTime.value}-${state.failureDateTime.value}",
|
|
||||||
isHaveDirection: true,
|
|
||||||
action: () async {
|
|
||||||
var result = await Get.toNamed(Routers.seletKeyCyclicDatePage,
|
|
||||||
arguments: {
|
|
||||||
'validityValue': state.weekdaysList.value,
|
|
||||||
'starDate': state.cycleBeginTime.value,
|
|
||||||
'endDate': state.cycleEndTime.value,
|
|
||||||
'starTime': state.effectiveDateTime.value,
|
|
||||||
'endTime': state.failureDateTime.value
|
|
||||||
});
|
|
||||||
if (result != null && result.isNotEmpty) {
|
|
||||||
state.weekdaysList.value = result['validityValue'];
|
|
||||||
state.cycleBeginTime.value = result['starDate'];
|
|
||||||
state.cycleEndTime.value = result['endDate'];
|
|
||||||
state.effectiveDateTime.value = result['starTime'];
|
|
||||||
state.failureDateTime.value = result['endTime'];
|
|
||||||
}
|
|
||||||
}))),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget keyBottomWidget(String sendElectronicKeyTips) {
|
|
||||||
return Column(
|
|
||||||
children: [
|
|
||||||
Container(
|
|
||||||
padding: EdgeInsets.all(20.w),
|
|
||||||
child: Row(
|
|
||||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: Text(
|
|
||||||
sendElectronicKeyTips,
|
|
||||||
textAlign: TextAlign.start,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 18.sp, color: AppColors.darkGrayTextColor),
|
|
||||||
)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
SubmitBtn(
|
|
||||||
btnName: TranslationLoader.lanKeys!.send!.tr,
|
|
||||||
onClick: () {
|
|
||||||
if (state.isDemoMode == false) {
|
|
||||||
logic.sendElectronicKeyRequest();
|
|
||||||
setState(() {});
|
|
||||||
} else {
|
|
||||||
//演示模式不获取接口
|
|
||||||
logic.showToast("演示模式".tr);
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
Container(
|
|
||||||
padding: EdgeInsets.only(right: 30.w),
|
|
||||||
// color: Colors.red,
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
|
||||||
children: [
|
|
||||||
TextButton(
|
|
||||||
onPressed: () {
|
|
||||||
// 获取是否是演示模式 演示模式不获取接口
|
|
||||||
if (state.isDemoMode == false) {
|
|
||||||
Navigator.pushNamed(
|
|
||||||
context, Routers.massSendElectronicKeyManagePage);
|
|
||||||
} else {
|
|
||||||
logic.showToast("演示模式".tr);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
child: Text(
|
|
||||||
TranslationLoader.lanKeys!.sendGroupKey!.tr,
|
|
||||||
style:
|
|
||||||
TextStyle(color: AppColors.mainColor, fontSize: 22.sp),
|
|
||||||
)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 发送电子钥匙成功
|
|
||||||
Widget sendElectronicKeySucceed() {
|
|
||||||
return Column(
|
|
||||||
children: [
|
|
||||||
Container(
|
|
||||||
height: 250.h,
|
|
||||||
width: 1.sw,
|
|
||||||
color: Colors.white,
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
SizedBox(
|
|
||||||
height: 30.h,
|
|
||||||
),
|
|
||||||
Image.asset(
|
|
||||||
'images/icon_send_success.png',
|
|
||||||
width: 100.w,
|
|
||||||
height: 100.w,
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
height: 20.h,
|
|
||||||
),
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
"发送成功".tr,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 26.sp,
|
|
||||||
color: Colors.black,
|
|
||||||
fontWeight: FontWeight.w500),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
height: 20.h,
|
|
||||||
),
|
|
||||||
SubmitBtn(
|
|
||||||
btnName: '完成'.tr,
|
|
||||||
onClick: () {
|
|
||||||
state.isSendSuccess.value = false;
|
|
||||||
logic.resetData();
|
|
||||||
}),
|
|
||||||
SizedBox(
|
|
||||||
height: 10.h,
|
|
||||||
),
|
|
||||||
OutLineBtn(
|
|
||||||
btnName: '分享'.tr,
|
|
||||||
onClick: () {
|
|
||||||
// Navigator.pushNamed(context, Routers.sendEmailNotificationPage);
|
|
||||||
_openModalBottomSheet();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
height: 10.h,
|
|
||||||
),
|
|
||||||
// OutLineBtn(
|
|
||||||
// btnName: '微信通知',
|
|
||||||
// onClick: () {},
|
|
||||||
// ),
|
|
||||||
// SizedBox(
|
|
||||||
// height: 10.h,
|
|
||||||
// ),
|
|
||||||
//田总说不要标记为已入住
|
|
||||||
// OutLineBtn(
|
|
||||||
// btnName: '标记为已入住',
|
|
||||||
// onClick: () {
|
|
||||||
// updateRoomCheckIn();
|
|
||||||
// },
|
|
||||||
// ),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
//标记房间为已入住 isOn:已入住: 1 空闲:2
|
|
||||||
Future<void> updateRoomCheckIn() async {
|
|
||||||
// var entity = await ApiRepository.to
|
|
||||||
// .updateSetting(state.keyInfo.value.lockId.toString(), '1', '13');
|
|
||||||
// if (entity.errorCode!.codeIsSuccessful) {
|
|
||||||
// Toast.show(msg: "标记成功");
|
|
||||||
// } else {
|
|
||||||
// Toast.show(msg: '操作失败');
|
|
||||||
// }
|
|
||||||
|
|
||||||
var entity = await ApiRepository.to.setRoomStatusData(
|
|
||||||
lockId: CommonDataManage().currentKeyInfo.lockId!,
|
|
||||||
roomStatus: 1,
|
|
||||||
);
|
|
||||||
if (entity.errorCode!.codeIsSuccessful) {
|
|
||||||
logic.showToast("标记成功".tr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 接受者信息输入框
|
|
||||||
Widget getTFWidget(bool isHaveBtn, String tfStr, int lineIndex) {
|
|
||||||
return SizedBox(
|
|
||||||
height: 65.h,
|
|
||||||
width: 320.w,
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: TextField(
|
|
||||||
controller: lineIndex == 1
|
|
||||||
? state.emailOrPhoneController
|
|
||||||
: state.keyNameController,
|
|
||||||
//输入框一行
|
|
||||||
maxLines: 1,
|
|
||||||
inputFormatters: <TextInputFormatter>[
|
|
||||||
FilteringTextInputFormatter.deny('\n'),
|
|
||||||
LengthLimitingTextInputFormatter(30),
|
|
||||||
],
|
|
||||||
// controller: _controller,
|
|
||||||
autofocus: false,
|
|
||||||
textAlign: TextAlign.end,
|
|
||||||
// decoration: InputDecoration(
|
|
||||||
// //输入里面输入文字内边距设置
|
|
||||||
// contentPadding: const EdgeInsets.only(top: 12.0, bottom: 8.0),
|
|
||||||
// hintText: tfStr,
|
|
||||||
// hintStyle: TextStyle(fontSize: 22.sp),
|
|
||||||
// //不需要输入框下划线
|
|
||||||
// border: InputBorder.none,
|
|
||||||
// ),
|
|
||||||
decoration: InputDecoration(
|
|
||||||
//输入里面输入文字内边距设置
|
|
||||||
// contentPadding: const EdgeInsets.only(top: 12.0, bottom: 8.0),
|
|
||||||
hintText: tfStr,
|
|
||||||
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),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
width: 10.w,
|
|
||||||
),
|
|
||||||
isHaveBtn
|
|
||||||
? Container(
|
|
||||||
width: 32.w,
|
|
||||||
height: 32.w,
|
|
||||||
decoration: const BoxDecoration(
|
|
||||||
color: Colors.white,
|
|
||||||
image: DecorationImage(
|
|
||||||
image: AssetImage('images/icon_addressBook.png'),
|
|
||||||
fit: BoxFit.fill),
|
|
||||||
),
|
|
||||||
alignment: Alignment.center,
|
|
||||||
child: InkWell(
|
|
||||||
onTap: () async {
|
|
||||||
Contact? currentContact =
|
|
||||||
await state.contactPicker.selectContact();
|
|
||||||
state.contact = currentContact!;
|
|
||||||
if (currentContact.phoneNumbers!.isNotEmpty) {
|
|
||||||
state.emailOrPhoneController.text = currentContact
|
|
||||||
.phoneNumbers![0]
|
|
||||||
.replaceAll(RegExp(r"\s+\b|\b\s"), "");
|
|
||||||
}
|
|
||||||
if (currentContact.fullName!.isNotEmpty) {
|
|
||||||
state.keyNameController.text = currentContact.fullName!;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: Container()
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 远程开锁
|
|
||||||
Widget remoteUnlockingWidget() {
|
|
||||||
return Visibility(
|
|
||||||
visible: state.isDemoMode
|
|
||||||
? false
|
|
||||||
: (CommonDataManage().currentKeyInfo.lockSetting!.remoteUnlock == 1
|
|
||||||
? true
|
|
||||||
: false),
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
CommonItem(
|
|
||||||
leftTitel: TranslationLoader.lanKeys!.remoteUnlockingAllowed!.tr,
|
|
||||||
rightTitle: "",
|
|
||||||
// isTipsImg: true,
|
|
||||||
// tipsImgAction: () {
|
|
||||||
// ShowTipView().showSureAlertDialog("人脸实名认证指的是用户在使用手机APP或小程序开锁时,需要先进行本人人脸验证,验证通过才能开锁。");
|
|
||||||
// },
|
|
||||||
isHaveRightWidget: true,
|
|
||||||
rightWidget: SizedBox(
|
|
||||||
width: 60.w, height: 50.h, child: _remoteSwitch(true)),
|
|
||||||
action: () {}),
|
|
||||||
Container(height: 10.h),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
//isRemote true:远程开锁 false:实名认证
|
|
||||||
CupertinoSwitch _remoteSwitch(bool isRemote) {
|
|
||||||
return CupertinoSwitch(
|
|
||||||
activeColor: CupertinoColors.activeBlue,
|
|
||||||
trackColor: CupertinoColors.systemGrey5,
|
|
||||||
thumbColor: CupertinoColors.white,
|
|
||||||
value:
|
|
||||||
isRemote ? state.isRemoteUnlock.value : state.isAuthentication.value,
|
|
||||||
onChanged: (value) {
|
|
||||||
if (isRemote) {
|
|
||||||
state.isRemoteUnlock.value = !state.isRemoteUnlock.value;
|
|
||||||
} else {
|
|
||||||
state.isAuthentication.value = !state.isAuthentication.value;
|
|
||||||
if (state.isAuthentication.value) {
|
|
||||||
ShowTipView().showBuyTipWithContentAlert(
|
|
||||||
titleStr: '实名认证为付费功能,请购买后再使用'.tr,
|
|
||||||
sureClick: () {
|
|
||||||
Get.toNamed(Routers.advancedFeaturesWebPage,
|
|
||||||
arguments: {'isShop': false});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future _openModalBottomSheet() async {
|
|
||||||
showModalBottomSheet(
|
|
||||||
context: context,
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadiusDirectional.circular(10)),
|
|
||||||
constraints: BoxConstraints(maxHeight: 270.h),
|
|
||||||
builder: (BuildContext context) {
|
|
||||||
return Column(
|
|
||||||
children: [
|
|
||||||
SizedBox(
|
|
||||||
width: ScreenUtil().screenWidth,
|
|
||||||
height: 180.h,
|
|
||||||
child: ListView(
|
|
||||||
scrollDirection: Axis.horizontal, //横向滚动
|
|
||||||
children: initBottomSheetList()),
|
|
||||||
),
|
|
||||||
Container(
|
|
||||||
height: 8.h,
|
|
||||||
color: AppColors.greyBackgroundColor,
|
|
||||||
),
|
|
||||||
TextButton(
|
|
||||||
style: ButtonStyle(
|
|
||||||
overlayColor:
|
|
||||||
MaterialStateProperty.all<Color>(Colors.white)),
|
|
||||||
child: Text(
|
|
||||||
'取消'.tr,
|
|
||||||
style: TextStyle(
|
|
||||||
color: Colors.black, fontSize: ScreenUtil().setSp(24)),
|
|
||||||
),
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.pop(context);
|
|
||||||
},
|
|
||||||
)
|
|
||||||
],
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
TabBar _tabBar() {
|
TabBar _tabBar() {
|
||||||
return TabBar(
|
return TabBar(
|
||||||
controller: state.tabController,
|
controller: state.tabController,
|
||||||
@ -688,11 +91,8 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage>
|
|||||||
|
|
||||||
Tab _tab(ItemView item) {
|
Tab _tab(ItemView item) {
|
||||||
return Tab(
|
return Tab(
|
||||||
// text: item.title,
|
|
||||||
child: Container(
|
child: Container(
|
||||||
// width: 1.sw / 8,
|
|
||||||
margin: EdgeInsets.all(10.w),
|
margin: EdgeInsets.all(10.w),
|
||||||
// color: Colors.red,
|
|
||||||
child: Text(
|
child: Text(
|
||||||
item.title,
|
item.title,
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
@ -706,7 +106,9 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage>
|
|||||||
child: TabBarView(
|
child: TabBarView(
|
||||||
controller: state.tabController,
|
controller: state.tabController,
|
||||||
children: _itemTabs
|
children: _itemTabs
|
||||||
.map((ItemView item) => Obx(() => indexChangeWidget(item)))
|
.map((ItemView item) => SendElectronicKeyView(
|
||||||
|
type: item.type,
|
||||||
|
))
|
||||||
.toList()),
|
.toList()),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -718,81 +120,6 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage>
|
|||||||
ItemView(title: TranslationLoader.lanKeys!.circulation!.tr, type: "3"),
|
ItemView(title: TranslationLoader.lanKeys!.circulation!.tr, type: "3"),
|
||||||
];
|
];
|
||||||
|
|
||||||
List<Widget> initBottomSheetList() {
|
|
||||||
List<Widget> widgetList = [];
|
|
||||||
|
|
||||||
widgetList.add(buildCenter3('images/icon_wechat.png', '微信好友'.tr, 0));
|
|
||||||
widgetList.add(buildCenter3('images/icon_message.png', '短信'.tr, 1));
|
|
||||||
widgetList.add(buildCenter3('images/icon_email.png', '邮件'.tr, 2));
|
|
||||||
widgetList.add(buildCenter3('images/icon_more.png', '更多'.tr, 3));
|
|
||||||
|
|
||||||
return widgetList;
|
|
||||||
}
|
|
||||||
|
|
||||||
GestureDetector buildCenter3(
|
|
||||||
String imageName, String titleStr, int itemIndex) {
|
|
||||||
return GestureDetector(
|
|
||||||
child: Container(
|
|
||||||
width: 120.w,
|
|
||||||
// height: 64.h,
|
|
||||||
margin:
|
|
||||||
EdgeInsets.only(top: 20.w, bottom: 20.w, left: 10.w, right: 10.w),
|
|
||||||
child: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
Image.asset(
|
|
||||||
imageName,
|
|
||||||
width: 50.w,
|
|
||||||
height: 50.h,
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
height: 16.w,
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
titleStr,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: ScreenUtil().setSp(20), color: Colors.black),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
onTap: () => _jumpSmartDeviceRoute(itemIndex),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
_jumpSmartDeviceRoute(int itemIndex) {
|
|
||||||
Get.back();
|
|
||||||
switch (itemIndex) {
|
|
||||||
case 0:
|
|
||||||
//微信好友
|
|
||||||
{
|
|
||||||
String pwdShareStr = '您好,您的电子钥匙生成成功'.tr;
|
|
||||||
NativeInteractionTool().loadNativeShare(shareText: pwdShareStr);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
//短信
|
|
||||||
{
|
|
||||||
String pwdShareStr = '您好,您的电子钥匙生成成功'.tr;
|
|
||||||
NativeInteractionTool().loadNativeShare(shareText: pwdShareStr);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
//邮件
|
|
||||||
{
|
|
||||||
Get.toNamed(Routers.sendEmailNotificationPage);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
//更多
|
|
||||||
{
|
|
||||||
String pwdShareStr = '您好,您的电子钥匙生成成功'.tr;
|
|
||||||
NativeInteractionTool().loadNativeShare(shareText: pwdShareStr);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class ItemView {
|
class ItemView {
|
||||||
|
|||||||
@ -6,34 +6,12 @@ import '../../../../../tools/dateTool.dart';
|
|||||||
import '../../../../lockMian/entity/lockListInfo_entity.dart';
|
import '../../../../lockMian/entity/lockListInfo_entity.dart';
|
||||||
|
|
||||||
class SendElectronicKeyState {
|
class SendElectronicKeyState {
|
||||||
TextEditingController emailOrPhoneController = TextEditingController(); //邮箱/手机号输入框
|
|
||||||
TextEditingController keyNameController = TextEditingController(); //钥匙名输入框
|
|
||||||
|
|
||||||
late TabController tabController;
|
late TabController tabController;
|
||||||
|
|
||||||
final FlutterContactPicker contactPicker = FlutterContactPicker();
|
final FlutterContactPicker contactPicker = FlutterContactPicker();
|
||||||
late Contact contact;
|
late Contact contact;
|
||||||
// final keyInfo = LockListInfoItemEntity().obs;
|
|
||||||
|
|
||||||
final isRemoteUnlock = false.obs; //是否允许远程开锁
|
|
||||||
final isAuthentication = false.obs; //是否可以实名认证
|
|
||||||
|
|
||||||
var timeLimitBeginTime = DateTool().dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString()).obs;// 限时开始时间
|
|
||||||
var timeLimitEndTime = DateTool().dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString()).obs;// 限时结束时间
|
|
||||||
var cycleBeginTime = "".obs;// 循环开始时间
|
|
||||||
var cycleEndTime = "".obs;// 循环结束时间
|
|
||||||
var effectiveDateTime = "".obs;// 生效时间
|
|
||||||
var failureDateTime = "".obs;// 失效时间
|
|
||||||
var weekdaysList = [].obs;
|
|
||||||
|
|
||||||
var seletType = 0.obs;// 限时、永久、单次、循环
|
|
||||||
var isSendSuccess = false.obs;
|
|
||||||
var countryName = '中国'.tr.obs;
|
|
||||||
var countryCode = '86'.obs;
|
|
||||||
var isCreateUser = false.obs; //用户未注册时传1 已注册传0
|
|
||||||
|
|
||||||
var isDemoMode = false;
|
|
||||||
final sendSucceedType = 0.obs;
|
|
||||||
|
|
||||||
final timeLimitTips = '接收者在有效期内可以不限次数使用'; //限时
|
final timeLimitTips = '接收者在有效期内可以不限次数使用'; //限时
|
||||||
final permanentTips = '接收者可以使用此App开关锁'; //永久
|
final permanentTips = '接收者可以使用此App开关锁'; //永久
|
||||||
|
|||||||
@ -0,0 +1,164 @@
|
|||||||
|
import 'package:get/get.dart';
|
||||||
|
import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart';
|
||||||
|
import 'package:star_lock/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_state.dart';
|
||||||
|
import 'package:star_lock/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_state.dart';
|
||||||
|
import 'package:star_lock/network/api_repository.dart';
|
||||||
|
import 'package:star_lock/tools/baseGetXController.dart';
|
||||||
|
import 'package:star_lock/tools/commonDataManage.dart';
|
||||||
|
import 'package:star_lock/tools/dateTool.dart';
|
||||||
|
import 'package:star_lock/tools/eventBusEventManage.dart';
|
||||||
|
import 'package:star_lock/tools/showTipView.dart';
|
||||||
|
import 'package:star_lock/tools/storage.dart';
|
||||||
|
|
||||||
|
class SendElectronicKeyViewLogic extends BaseGetXController {
|
||||||
|
String type;
|
||||||
|
final SendElectronicKeyViewState state = SendElectronicKeyViewState();
|
||||||
|
|
||||||
|
SendElectronicKeyViewLogic(this.type);
|
||||||
|
|
||||||
|
@override
|
||||||
|
void onInit() {
|
||||||
|
super.onInit();
|
||||||
|
|
||||||
|
Storage.getBool(ifIsDemoModeOrNot)
|
||||||
|
.then((value) => state.isDemoMode = value ?? false);
|
||||||
|
}
|
||||||
|
|
||||||
|
//发送钥匙请求
|
||||||
|
Future<void> sendElectronicKeyRequest() async {
|
||||||
|
if (state.emailOrPhoneController.text.isEmpty) {
|
||||||
|
showToast("请输入接收者账号".tr);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//发送钥匙请求
|
||||||
|
var startDate = "0";
|
||||||
|
var endDate = "0";
|
||||||
|
var startTime = "0";
|
||||||
|
var endTime = "0";
|
||||||
|
int typeValue;
|
||||||
|
switch (type) {
|
||||||
|
case '0':
|
||||||
|
// 限时
|
||||||
|
if (state.timeLimitBeginTime.value.isEmpty) {
|
||||||
|
showToast("请选择开始时间".tr);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (state.timeLimitEndTime.value.isEmpty) {
|
||||||
|
showToast("请选择结束时间".tr);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
typeValue = XSConstantMacro.keyTypeTime;
|
||||||
|
startDate = DateTool()
|
||||||
|
.dateToTimestamp(state.timeLimitBeginTime.value, 1)
|
||||||
|
.toString();
|
||||||
|
endDate = DateTool()
|
||||||
|
.dateToTimestamp(state.timeLimitEndTime.value, 1)
|
||||||
|
.toString();
|
||||||
|
startTime = "0";
|
||||||
|
endTime = "0";
|
||||||
|
|
||||||
|
if (int.parse(startDate) >= int.parse(endDate)) {
|
||||||
|
showToast("失效时间要大于生效时间".tr);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case '1':
|
||||||
|
typeValue = XSConstantMacro.keyTypeLong;
|
||||||
|
break;
|
||||||
|
case '2':
|
||||||
|
typeValue = XSConstantMacro.keyTypeOnce;
|
||||||
|
break;
|
||||||
|
case '3':
|
||||||
|
typeValue = XSConstantMacro.keyTypeLoop;
|
||||||
|
if (state.cycleBeginTime.value.isEmpty) {
|
||||||
|
showToast("请选择有效期".tr);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
startDate = DateTool()
|
||||||
|
.dateToTimestamp(state.cycleBeginTime.value, 1)
|
||||||
|
.toString();
|
||||||
|
endDate =
|
||||||
|
DateTool().dateToTimestamp(state.cycleEndTime.value, 1).toString();
|
||||||
|
startTime = DateTool()
|
||||||
|
.dateToTimestamp(state.effectiveDateTime.value, 0)
|
||||||
|
.toString();
|
||||||
|
endTime = DateTool()
|
||||||
|
.dateToTimestamp(state.failureDateTime.value, 0)
|
||||||
|
.toString();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
typeValue = XSConstantMacro.keyTypeTime;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
String getKeyType = typeValue.toString();
|
||||||
|
|
||||||
|
var entity = await ApiRepository.to.sendElectronicKey(
|
||||||
|
createUser: state.isCreateUser.value == true ? "1" : "0",
|
||||||
|
countryCode: state.countryCode.value,
|
||||||
|
usernameType: isPhoneNumber(state.emailOrPhoneController.text) == true
|
||||||
|
? '1'
|
||||||
|
: '2',
|
||||||
|
endDate: int.parse(endDate),
|
||||||
|
faceAuthentication: state.isAuthentication.value == true ? '1' : '2',
|
||||||
|
isCameraEnable: '2',
|
||||||
|
isRemoteUnlock: state.isRemoteUnlock.value == true ? '1' : '2',
|
||||||
|
keyNameForAdmin: state.keyNameController.text,
|
||||||
|
keyRight: '0',
|
||||||
|
keyType: getKeyType,
|
||||||
|
lockId: CommonDataManage().currentKeyInfo.lockId.toString(),
|
||||||
|
operatorUid: '',
|
||||||
|
receiverUsername: state.emailOrPhoneController.text,
|
||||||
|
remarks: '',
|
||||||
|
startDate: int.parse(startDate),
|
||||||
|
weekDays: state.weekdaysList,
|
||||||
|
startTime: int.parse(startTime),
|
||||||
|
endTime: int.parse(endTime),
|
||||||
|
isOnlyManageSelf: 0);
|
||||||
|
if (entity.errorCode!.codeIsSuccessful) {
|
||||||
|
state.isSendSuccess.value = true;
|
||||||
|
resetData();
|
||||||
|
eventBus.fire(ElectronicKeyListRefreshUI());
|
||||||
|
} else {
|
||||||
|
if (entity.errorCode == 425) {
|
||||||
|
//用户未注册
|
||||||
|
state.isCreateUser.value = true;
|
||||||
|
ShowTipView().showIosTipWithContentDialog(
|
||||||
|
'${"是否发送电子钥匙给未注册账号".tr}\n${state.emailOrPhoneController.text}', () {
|
||||||
|
sendElectronicKeyRequest();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isPhoneNumber(String input) {
|
||||||
|
// 手机号正则表达式,这里简化为11位数字
|
||||||
|
final RegExp phoneRegExp = RegExp(r'^\d{11}$');
|
||||||
|
return phoneRegExp.hasMatch(input);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isEmail(String input) {
|
||||||
|
// 邮箱正则表达式,这里简化为常见格式
|
||||||
|
final RegExp emailRegExp =
|
||||||
|
RegExp(r'^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$');
|
||||||
|
return emailRegExp.hasMatch(input);
|
||||||
|
}
|
||||||
|
|
||||||
|
void resetData() {
|
||||||
|
state.emailOrPhoneController.text = "";
|
||||||
|
state.keyNameController.text = "";
|
||||||
|
state.timeLimitBeginTime = DateTool()
|
||||||
|
.dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString())
|
||||||
|
.obs; // 限时开始时间
|
||||||
|
state.timeLimitEndTime = DateTool()
|
||||||
|
.dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString())
|
||||||
|
.obs; // 限时结束时间
|
||||||
|
state.cycleBeginTime = "".obs; // 循环开始时间
|
||||||
|
state.cycleEndTime = "".obs; // 循环结束时间
|
||||||
|
state.effectiveDateTime = "".obs; // 生效时间
|
||||||
|
state.failureDateTime = "".obs; // 失效时间
|
||||||
|
state.weekdaysList = [].obs;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,656 @@
|
|||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
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/app_settings/app_colors.dart';
|
||||||
|
import 'package:flutter_native_contact_picker/flutter_native_contact_picker.dart';
|
||||||
|
import 'package:star_lock/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_logic.dart';
|
||||||
|
import 'package:star_lock/network/api_repository.dart';
|
||||||
|
import 'package:star_lock/tools/NativeInteractionTool.dart';
|
||||||
|
import 'package:star_lock/tools/baseGetXController.dart';
|
||||||
|
import 'package:star_lock/tools/commonDataManage.dart';
|
||||||
|
import 'package:star_lock/tools/commonItem.dart';
|
||||||
|
import 'package:star_lock/tools/dateTool.dart';
|
||||||
|
import 'package:star_lock/tools/pickers/pickers.dart';
|
||||||
|
import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart';
|
||||||
|
import 'package:star_lock/tools/pickers/time_picker/model/pduration.dart';
|
||||||
|
import 'package:star_lock/tools/showTipView.dart';
|
||||||
|
import 'package:star_lock/tools/storage.dart';
|
||||||
|
import 'package:star_lock/tools/submitBtn.dart';
|
||||||
|
import 'package:star_lock/translations/trans_lib.dart';
|
||||||
|
|
||||||
|
class SendElectronicKeyView extends StatefulWidget {
|
||||||
|
String type;
|
||||||
|
|
||||||
|
SendElectronicKeyView({required this.type, Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<SendElectronicKeyView> createState() => _SendElectronicKeyViewState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _SendElectronicKeyViewState extends State<SendElectronicKeyView>
|
||||||
|
with AutomaticKeepAliveClientMixin {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return GetBuilder<SendElectronicKeyViewLogic>(
|
||||||
|
tag: widget.type,
|
||||||
|
init: SendElectronicKeyViewLogic(widget.type),
|
||||||
|
builder: (SendElectronicKeyViewLogic logic) {
|
||||||
|
return Obx(() {
|
||||||
|
if (logic.state.isSendSuccess.value == true) {
|
||||||
|
return sendElectronicKeySucceed(logic);
|
||||||
|
} else {
|
||||||
|
switch (widget.type) {
|
||||||
|
case '0':
|
||||||
|
// 限时
|
||||||
|
return SingleChildScrollView(
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
keyInfoWidget(logic),
|
||||||
|
keyTimeWidget(logic),
|
||||||
|
remoteUnlockingWidget(logic),
|
||||||
|
keyRealNameWidget(logic),
|
||||||
|
keyBottomWidget(logic.state.timeLimitTips, logic)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
case '1':
|
||||||
|
// 永久
|
||||||
|
return SingleChildScrollView(
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
keyInfoWidget(logic),
|
||||||
|
remoteUnlockingWidget(logic),
|
||||||
|
keyRealNameWidget(logic),
|
||||||
|
keyBottomWidget(logic.state.permanentTips, logic)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
case '2':
|
||||||
|
// 单次
|
||||||
|
return SingleChildScrollView(
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
keyInfoWidget(logic),
|
||||||
|
remoteUnlockingWidget(logic),
|
||||||
|
keyRealNameWidget(logic),
|
||||||
|
keyBottomWidget(logic.state.onceLimitTips, logic)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
case '3':
|
||||||
|
// 循环
|
||||||
|
return SingleChildScrollView(
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
keyInfoWidget(logic),
|
||||||
|
keyPeriodValidityWidget(logic),
|
||||||
|
remoteUnlockingWidget(logic),
|
||||||
|
keyRealNameWidget(logic),
|
||||||
|
keyBottomWidget(logic.state.cycleLimitTips, logic)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
default:
|
||||||
|
return Container();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 顶部钥匙信息widget
|
||||||
|
Widget keyInfoWidget(SendElectronicKeyViewLogic logic) {
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
// Container(height: 10.h),
|
||||||
|
CommonItem(
|
||||||
|
leftTitel: TranslationLoader.lanKeys!.receiver!.tr,
|
||||||
|
rightTitle: "",
|
||||||
|
isHaveLine: true,
|
||||||
|
isHaveRightWidget: true,
|
||||||
|
rightWidget: getTFWidget(
|
||||||
|
true,
|
||||||
|
TranslationLoader.lanKeys!.pleaseEnterNumberOrEmail!.tr,
|
||||||
|
1,
|
||||||
|
logic)),
|
||||||
|
CommonItem(
|
||||||
|
leftTitel: TranslationLoader.lanKeys!.countryAndRegion!.tr,
|
||||||
|
rightTitle: "",
|
||||||
|
isHaveLine: true,
|
||||||
|
isHaveRightWidget: true,
|
||||||
|
isHaveDirection: true,
|
||||||
|
rightWidget: Text(
|
||||||
|
'${logic.state.countryName.value} +${logic.state.countryCode.value}',
|
||||||
|
textAlign: TextAlign.end,
|
||||||
|
style:
|
||||||
|
TextStyle(fontSize: 22.sp, color: AppColors.darkGrayTextColor),
|
||||||
|
),
|
||||||
|
action: () async {
|
||||||
|
var result = await Navigator.pushNamed(
|
||||||
|
context, Routers.selectCountryRegionPage);
|
||||||
|
if (result != null) {
|
||||||
|
result as Map<String, dynamic>;
|
||||||
|
logic.state.countryCode.value = result['code'];
|
||||||
|
logic.state.countryName.value = result['countryName'];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
CommonItem(
|
||||||
|
leftTitel: TranslationLoader.lanKeys!.name!.tr,
|
||||||
|
rightTitle: "",
|
||||||
|
isHaveRightWidget: true,
|
||||||
|
rightWidget: getTFWidget(
|
||||||
|
false, TranslationLoader.lanKeys!.enterYourName!.tr, 2, logic)),
|
||||||
|
Container(height: 10.h),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 生效失效时间
|
||||||
|
Widget keyTimeWidget(SendElectronicKeyViewLogic logic) {
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
Obx(() => CommonItem(
|
||||||
|
leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr,
|
||||||
|
rightTitle: logic.state.timeLimitBeginTime.value,
|
||||||
|
isHaveLine: true,
|
||||||
|
isHaveDirection: true,
|
||||||
|
action: () {
|
||||||
|
PDuration selectDate = PDuration.parse(
|
||||||
|
DateTime.parse(logic.state.timeLimitBeginTime.value));
|
||||||
|
Pickers.showDatePicker(context,
|
||||||
|
selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) {
|
||||||
|
logic.state.timeLimitBeginTime.value =
|
||||||
|
DateTool().getYMDHNDateString(p, 1);
|
||||||
|
});
|
||||||
|
})),
|
||||||
|
Obx(() => CommonItem(
|
||||||
|
leftTitel: TranslationLoader.lanKeys!.failureTime!.tr,
|
||||||
|
rightTitle: logic.state.timeLimitEndTime.value,
|
||||||
|
isHaveDirection: true,
|
||||||
|
action: () {
|
||||||
|
PDuration selectDate = PDuration.parse(
|
||||||
|
DateTime.tryParse(logic.state.timeLimitEndTime.value));
|
||||||
|
Pickers.showDatePicker(context,
|
||||||
|
selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) {
|
||||||
|
logic.state.timeLimitEndTime.value =
|
||||||
|
DateTool().getYMDHNDateString(p, 1);
|
||||||
|
});
|
||||||
|
})),
|
||||||
|
Container(height: 10.h),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 实名认证
|
||||||
|
Widget keyRealNameWidget(SendElectronicKeyViewLogic logic) {
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
CommonItem(
|
||||||
|
leftTitel: TranslationLoader.lanKeys!.realNameAuthentication!.tr,
|
||||||
|
rightTitle: "",
|
||||||
|
isTipsImg: true,
|
||||||
|
tipsImgAction: () {
|
||||||
|
ShowTipView().showSureAlertDialog(
|
||||||
|
"人脸实名认证指的是用户在使用手机APP开锁时,需要先进行本人人脸验证,验证通过才能开锁。".tr);
|
||||||
|
},
|
||||||
|
isHaveRightWidget: true,
|
||||||
|
rightWidget: SizedBox(
|
||||||
|
width: 60.w, height: 50.h, child: _remoteSwitch(false, logic)),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 循环有效期
|
||||||
|
Widget keyPeriodValidityWidget(SendElectronicKeyViewLogic logic) {
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
Obx(() => CommonItem(
|
||||||
|
leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr,
|
||||||
|
rightTitle:
|
||||||
|
"${logic.state.cycleBeginTime.value}\n${logic.state.cycleEndTime.value}",
|
||||||
|
isHaveDirection: true,
|
||||||
|
isHaveLine: true,
|
||||||
|
action: () async {
|
||||||
|
var result =
|
||||||
|
await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: {
|
||||||
|
'validityValue': logic.state.weekdaysList,
|
||||||
|
'starDate': logic.state.cycleBeginTime.value,
|
||||||
|
'endDate': logic.state.cycleEndTime.value,
|
||||||
|
'starTime': logic.state.effectiveDateTime.value,
|
||||||
|
'endTime': logic.state.failureDateTime.value
|
||||||
|
});
|
||||||
|
if (result != null && result.isNotEmpty) {
|
||||||
|
logic.state.weekdaysList.value = result['validityValue'];
|
||||||
|
logic.state.cycleBeginTime.value = result['starDate'];
|
||||||
|
logic.state.cycleEndTime.value = result['endDate'];
|
||||||
|
logic.state.effectiveDateTime.value = result['starTime'];
|
||||||
|
logic.state.failureDateTime.value = result['endTime'];
|
||||||
|
}
|
||||||
|
})),
|
||||||
|
Obx(() => Visibility(
|
||||||
|
visible: logic.state.weekdaysList.isNotEmpty ? true : false,
|
||||||
|
child: CommonItem(
|
||||||
|
leftTitel: "有效日".tr,
|
||||||
|
rightTitle: logic.state.weekdaysList.join(",").toString(),
|
||||||
|
isHaveDirection: true,
|
||||||
|
isHaveLine: true,
|
||||||
|
action: () async {
|
||||||
|
var result = await Get.toNamed(Routers.seletKeyCyclicDatePage,
|
||||||
|
arguments: {
|
||||||
|
'validityValue': logic.state.weekdaysList,
|
||||||
|
'starDate': logic.state.cycleBeginTime.value,
|
||||||
|
'endDate': logic.state.cycleEndTime.value,
|
||||||
|
'starTime': logic.state.effectiveDateTime.value,
|
||||||
|
'endTime': logic.state.failureDateTime.value
|
||||||
|
});
|
||||||
|
if (result != null && result.isNotEmpty) {
|
||||||
|
logic.state.weekdaysList.value = result['validityValue'];
|
||||||
|
logic.state.cycleBeginTime.value = result['starDate'];
|
||||||
|
logic.state.cycleEndTime.value = result['endDate'];
|
||||||
|
logic.state.effectiveDateTime.value = result['starTime'];
|
||||||
|
logic.state.failureDateTime.value = result['endTime'];
|
||||||
|
}
|
||||||
|
}))),
|
||||||
|
Obx(() => Visibility(
|
||||||
|
visible: logic.state.effectiveDateTime.value.isNotEmpty,
|
||||||
|
child: CommonItem(
|
||||||
|
leftTitel: "有效时间".tr,
|
||||||
|
rightTitle:
|
||||||
|
"${logic.state.effectiveDateTime.value}-${logic.state.failureDateTime.value}",
|
||||||
|
isHaveDirection: true,
|
||||||
|
action: () async {
|
||||||
|
var result = await Get.toNamed(Routers.seletKeyCyclicDatePage,
|
||||||
|
arguments: {
|
||||||
|
'validityValue': logic.state.weekdaysList,
|
||||||
|
'starDate': logic.state.cycleBeginTime.value,
|
||||||
|
'endDate': logic.state.cycleEndTime.value,
|
||||||
|
'starTime': logic.state.effectiveDateTime.value,
|
||||||
|
'endTime': logic.state.failureDateTime.value
|
||||||
|
});
|
||||||
|
if (result != null && result.isNotEmpty) {
|
||||||
|
logic.state.weekdaysList.value = result['validityValue'];
|
||||||
|
logic.state.cycleBeginTime.value = result['starDate'];
|
||||||
|
logic.state.cycleEndTime.value = result['endDate'];
|
||||||
|
logic.state.effectiveDateTime.value = result['starTime'];
|
||||||
|
logic.state.failureDateTime.value = result['endTime'];
|
||||||
|
}
|
||||||
|
}))),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget keyBottomWidget(
|
||||||
|
String sendElectronicKeyTips, SendElectronicKeyViewLogic logic) {
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
padding: EdgeInsets.all(20.w),
|
||||||
|
child: Row(
|
||||||
|
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: Text(
|
||||||
|
sendElectronicKeyTips,
|
||||||
|
textAlign: TextAlign.start,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 18.sp, color: AppColors.darkGrayTextColor),
|
||||||
|
)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SubmitBtn(
|
||||||
|
btnName: TranslationLoader.lanKeys!.send!.tr,
|
||||||
|
onClick: () {
|
||||||
|
if (logic.state.isDemoMode == false) {
|
||||||
|
logic.sendElectronicKeyRequest();
|
||||||
|
setState(() {});
|
||||||
|
} else {
|
||||||
|
//演示模式不获取接口
|
||||||
|
logic.showToast("演示模式".tr);
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
Container(
|
||||||
|
padding: EdgeInsets.only(right: 30.w),
|
||||||
|
// color: Colors.red,
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: () {
|
||||||
|
// 获取是否是演示模式 演示模式不获取接口
|
||||||
|
if (logic.state.isDemoMode == false) {
|
||||||
|
Navigator.pushNamed(
|
||||||
|
context, Routers.massSendElectronicKeyManagePage);
|
||||||
|
} else {
|
||||||
|
logic.showToast("演示模式".tr);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: Text(
|
||||||
|
TranslationLoader.lanKeys!.sendGroupKey!.tr,
|
||||||
|
style:
|
||||||
|
TextStyle(color: AppColors.mainColor, fontSize: 22.sp),
|
||||||
|
)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 发送电子钥匙成功
|
||||||
|
Widget sendElectronicKeySucceed(SendElectronicKeyViewLogic logic) {
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
height: 250.h,
|
||||||
|
width: 1.sw,
|
||||||
|
color: Colors.white,
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
SizedBox(
|
||||||
|
height: 30.h,
|
||||||
|
),
|
||||||
|
Image.asset(
|
||||||
|
'images/icon_send_success.png',
|
||||||
|
width: 100.w,
|
||||||
|
height: 100.w,
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 20.h,
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
"发送成功".tr,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 26.sp,
|
||||||
|
color: Colors.black,
|
||||||
|
fontWeight: FontWeight.w500),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 20.h,
|
||||||
|
),
|
||||||
|
SubmitBtn(
|
||||||
|
btnName: '完成'.tr,
|
||||||
|
onClick: () {
|
||||||
|
logic.state.isSendSuccess.value = false;
|
||||||
|
logic.resetData();
|
||||||
|
}),
|
||||||
|
SizedBox(
|
||||||
|
height: 10.h,
|
||||||
|
),
|
||||||
|
OutLineBtn(
|
||||||
|
btnName: '分享'.tr,
|
||||||
|
onClick: () {
|
||||||
|
_openModalBottomSheet();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 10.h,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//标记房间为已入住 isOn:已入住: 1 空闲:2
|
||||||
|
Future<void> updateRoomCheckIn(SendElectronicKeyViewLogic logic) async {
|
||||||
|
var entity = await ApiRepository.to.setRoomStatusData(
|
||||||
|
lockId: CommonDataManage().currentKeyInfo.lockId!,
|
||||||
|
roomStatus: 1,
|
||||||
|
);
|
||||||
|
if (entity.errorCode!.codeIsSuccessful) {
|
||||||
|
logic.showToast("标记成功".tr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 接受者信息输入框
|
||||||
|
Widget getTFWidget(bool isHaveBtn, String tfStr, int lineIndex,
|
||||||
|
SendElectronicKeyViewLogic logic) {
|
||||||
|
return SizedBox(
|
||||||
|
height: 65.h,
|
||||||
|
width: 320.w,
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: TextField(
|
||||||
|
controller: lineIndex == 1
|
||||||
|
? logic.state.emailOrPhoneController
|
||||||
|
: logic.state.keyNameController,
|
||||||
|
//输入框一行
|
||||||
|
maxLines: 1,
|
||||||
|
inputFormatters: <TextInputFormatter>[
|
||||||
|
FilteringTextInputFormatter.deny('\n'),
|
||||||
|
LengthLimitingTextInputFormatter(30),
|
||||||
|
],
|
||||||
|
// controller: _controller,
|
||||||
|
autofocus: false,
|
||||||
|
textAlign: TextAlign.end,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
//输入里面输入文字内边距设置
|
||||||
|
hintText: tfStr,
|
||||||
|
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),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
width: 10.w,
|
||||||
|
),
|
||||||
|
isHaveBtn
|
||||||
|
? Container(
|
||||||
|
width: 32.w,
|
||||||
|
height: 32.w,
|
||||||
|
decoration: const BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
image: DecorationImage(
|
||||||
|
image: AssetImage('images/icon_addressBook.png'),
|
||||||
|
fit: BoxFit.fill),
|
||||||
|
),
|
||||||
|
alignment: Alignment.center,
|
||||||
|
child: InkWell(
|
||||||
|
onTap: () async {
|
||||||
|
Contact? currentContact =
|
||||||
|
await logic.state.contactPicker.selectContact();
|
||||||
|
logic.state.contact = currentContact!;
|
||||||
|
if (currentContact.phoneNumbers!.isNotEmpty) {
|
||||||
|
logic.state.emailOrPhoneController.text = currentContact
|
||||||
|
.phoneNumbers![0]
|
||||||
|
.replaceAll(RegExp(r"\s+\b|\b\s"), "");
|
||||||
|
}
|
||||||
|
if (currentContact.fullName!.isNotEmpty) {
|
||||||
|
logic.state.keyNameController.text =
|
||||||
|
currentContact.fullName!;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: Container()
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 远程开锁
|
||||||
|
Widget remoteUnlockingWidget(SendElectronicKeyViewLogic logic) {
|
||||||
|
return Visibility(
|
||||||
|
visible: logic.state.isDemoMode
|
||||||
|
? false
|
||||||
|
: (CommonDataManage().currentKeyInfo.lockSetting!.remoteUnlock == 1
|
||||||
|
? true
|
||||||
|
: false),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
CommonItem(
|
||||||
|
leftTitel: TranslationLoader.lanKeys!.remoteUnlockingAllowed!.tr,
|
||||||
|
rightTitle: "",
|
||||||
|
isHaveRightWidget: true,
|
||||||
|
rightWidget: SizedBox(
|
||||||
|
width: 60.w, height: 50.h, child: _remoteSwitch(true, logic)),
|
||||||
|
action: () {}),
|
||||||
|
Container(height: 10.h),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//isRemote true:远程开锁 false:实名认证
|
||||||
|
CupertinoSwitch _remoteSwitch(
|
||||||
|
bool isRemote, SendElectronicKeyViewLogic logic) {
|
||||||
|
return CupertinoSwitch(
|
||||||
|
activeColor: CupertinoColors.activeBlue,
|
||||||
|
trackColor: CupertinoColors.systemGrey5,
|
||||||
|
thumbColor: CupertinoColors.white,
|
||||||
|
value: isRemote
|
||||||
|
? logic.state.isRemoteUnlock.value
|
||||||
|
: logic.state.isAuthentication.value,
|
||||||
|
onChanged: (value) {
|
||||||
|
if (isRemote) {
|
||||||
|
logic.state.isRemoteUnlock.value = !logic.state.isRemoteUnlock.value;
|
||||||
|
} else {
|
||||||
|
logic.state.isAuthentication.value =
|
||||||
|
!logic.state.isAuthentication.value;
|
||||||
|
if (logic.state.isAuthentication.value) {
|
||||||
|
ShowTipView().showBuyTipWithContentAlert(
|
||||||
|
titleStr: '实名认证为付费功能,请购买后再使用'.tr,
|
||||||
|
sureClick: () {
|
||||||
|
Get.toNamed(Routers.advancedFeaturesWebPage,
|
||||||
|
arguments: {'isShop': false});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future _openModalBottomSheet() async {
|
||||||
|
showModalBottomSheet(
|
||||||
|
context: context,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadiusDirectional.circular(10)),
|
||||||
|
constraints: BoxConstraints(maxHeight: 270.h),
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
SizedBox(
|
||||||
|
width: ScreenUtil().screenWidth,
|
||||||
|
height: 180.h,
|
||||||
|
child: ListView(
|
||||||
|
scrollDirection: Axis.horizontal, //横向滚动
|
||||||
|
children: initBottomSheetList()),
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
height: 8.h,
|
||||||
|
color: AppColors.greyBackgroundColor,
|
||||||
|
),
|
||||||
|
TextButton(
|
||||||
|
style: ButtonStyle(
|
||||||
|
overlayColor:
|
||||||
|
MaterialStateProperty.all<Color>(Colors.white)),
|
||||||
|
child: Text(
|
||||||
|
'取消'.tr,
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.black, fontSize: ScreenUtil().setSp(24)),
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.pop(context);
|
||||||
|
},
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Widget> initBottomSheetList() {
|
||||||
|
List<Widget> widgetList = [];
|
||||||
|
widgetList.add(buildCenter3('images/icon_wechat.png', '微信好友'.tr, 0));
|
||||||
|
widgetList.add(buildCenter3('images/icon_message.png', '短信'.tr, 1));
|
||||||
|
widgetList.add(buildCenter3('images/icon_email.png', '邮件'.tr, 2));
|
||||||
|
widgetList.add(buildCenter3('images/icon_more.png', '更多'.tr, 3));
|
||||||
|
return widgetList;
|
||||||
|
}
|
||||||
|
|
||||||
|
GestureDetector buildCenter3(
|
||||||
|
String imageName, String titleStr, int itemIndex) {
|
||||||
|
return GestureDetector(
|
||||||
|
child: Container(
|
||||||
|
width: 120.w,
|
||||||
|
// height: 64.h,
|
||||||
|
margin:
|
||||||
|
EdgeInsets.only(top: 20.w, bottom: 20.w, left: 10.w, right: 10.w),
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Image.asset(
|
||||||
|
imageName,
|
||||||
|
width: 50.w,
|
||||||
|
height: 50.h,
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 16.w,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
titleStr,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: ScreenUtil().setSp(20), color: Colors.black),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onTap: () => _jumpSmartDeviceRoute(itemIndex),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
_jumpSmartDeviceRoute(int itemIndex) {
|
||||||
|
Get.back();
|
||||||
|
switch (itemIndex) {
|
||||||
|
case 0:
|
||||||
|
//微信好友
|
||||||
|
String pwdShareStr = '您好,您的电子钥匙生成成功'.tr;
|
||||||
|
NativeInteractionTool().loadNativeShare(shareText: pwdShareStr);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
//短信
|
||||||
|
String pwdShareStr = '您好,您的电子钥匙生成成功'.tr;
|
||||||
|
NativeInteractionTool().loadNativeShare(shareText: pwdShareStr);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
//邮件
|
||||||
|
Get.toNamed(Routers.sendEmailNotificationPage);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
//更多
|
||||||
|
String pwdShareStr = '您好,您的电子钥匙生成成功'.tr;
|
||||||
|
NativeInteractionTool().loadNativeShare(shareText: pwdShareStr);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool get wantKeepAlive => true;
|
||||||
|
}
|
||||||
@ -0,0 +1,36 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_native_contact_picker/flutter_native_contact_picker.dart';
|
||||||
|
import 'package:get/get.dart';
|
||||||
|
import 'package:star_lock/tools/dateTool.dart';
|
||||||
|
|
||||||
|
|
||||||
|
class SendElectronicKeyViewState {
|
||||||
|
TextEditingController emailOrPhoneController = TextEditingController(); //邮箱/手机号输入框
|
||||||
|
TextEditingController keyNameController = TextEditingController(); //钥匙名输入框
|
||||||
|
|
||||||
|
final FlutterContactPicker contactPicker = FlutterContactPicker();
|
||||||
|
late Contact contact;
|
||||||
|
|
||||||
|
final isRemoteUnlock = false.obs; //是否允许远程开锁
|
||||||
|
final isAuthentication = false.obs; //是否可以实名认证
|
||||||
|
|
||||||
|
var timeLimitBeginTime = DateTool().dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString()).obs;// 限时开始时间
|
||||||
|
var timeLimitEndTime = DateTool().dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString()).obs;// 限时结束时间
|
||||||
|
var cycleBeginTime = "".obs;// 循环开始时间
|
||||||
|
var cycleEndTime = "".obs;// 循环结束时间
|
||||||
|
var effectiveDateTime = "".obs;// 生效时间
|
||||||
|
var failureDateTime = "".obs;// 失效时间
|
||||||
|
var weekdaysList = [].obs;
|
||||||
|
|
||||||
|
var isSendSuccess = false.obs;
|
||||||
|
var countryName = '中国'.tr.obs;
|
||||||
|
var countryCode = '86'.obs;
|
||||||
|
var isCreateUser = false.obs; //用户未注册时传1 已注册传0
|
||||||
|
var isDemoMode = false;
|
||||||
|
|
||||||
|
final timeLimitTips = '接收者在有效期内可以不限次数使用'; //限时
|
||||||
|
final permanentTips = '接收者可以使用此App开关锁'; //永久
|
||||||
|
final onceLimitTips = '单次钥匙有效期为1小时,只能使用一次'; //单次
|
||||||
|
final cycleLimitTips = '接收者可以在有效期内的固定时间段里,不限次数使用'; //循环
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user