1,密码钥匙重置接口增加
2,新增删除账号入口及安全验证页面 3,新增删除账号接口调试 4,新增刷新库 5,部分页面状态刷新重构
This commit is contained in:
parent
073a7ad38b
commit
eca37e7588
@ -415,5 +415,7 @@
|
||||
"seletFingerprint":"Selet Fingerprint",
|
||||
"getKey":"Get Key",
|
||||
"getCard":"Get Card",
|
||||
"getFingerprint":"Get Fingerprint"
|
||||
"getFingerprint":"Get Fingerprint",
|
||||
"safeVerify":"Security verification",
|
||||
"deleteAccountTips": "After deleting the account, all your information and related records will be completely deleted from the platform, and can not be recovered, delete or not"
|
||||
}
|
||||
|
||||
@ -415,5 +415,7 @@
|
||||
"seletFingerprint":"seletFingerprint",
|
||||
"getKey":"getKey",
|
||||
"getCard":"getCard",
|
||||
"getFingerprint":"getFingerprint"
|
||||
"getFingerprint":"getFingerprint",
|
||||
"safeVerify":"safeVerify",
|
||||
"deleteAccountTips":"deleteAccountTips"
|
||||
}
|
||||
@ -418,5 +418,7 @@
|
||||
"seletFingerprint":"选择指纹",
|
||||
"getKey":"获取钥匙",
|
||||
"getCard":"获取卡",
|
||||
"getFingerprint":"获取指纹"
|
||||
"getFingerprint":"获取指纹",
|
||||
"safeVerify":"安全验证",
|
||||
"deleteAccountTips":"删除账号后,你的所有信息及相关记录都会从平台彻底删除,且不可恢复,是否删除?"
|
||||
}
|
||||
@ -8,6 +8,7 @@ import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/ma
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupList_page.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendReceiver/massSendReceiver_page.dart';
|
||||
import 'package:star_lock/main/lockDetail/lockDetail/lockDetail_main_page.dart';
|
||||
import 'package:star_lock/mine/mine/safeVerify/safeVerify_page.dart';
|
||||
import 'package:star_lock/mine/minePersonInfo/minePersonInfoEmail/minePersonInfoEmail_page.dart';
|
||||
import 'package:star_lock/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator_page.dart';
|
||||
import 'package:star_lock/mine/mineSet/authorizedAdministrator/administratorDetails/adminDetailChangeDate_page.dart';
|
||||
@ -323,6 +324,7 @@ abstract class Routers {
|
||||
static const adminLockListPage = '/adminLockListPage'; //管理员详情的锁列表
|
||||
static const expireLockChangeDatePage =
|
||||
'/expireLockChangeDatePage'; //即将到期列表有效期修改
|
||||
static const safeVerifyPage = '/safeVerifyPage'; //删除账号安全验证
|
||||
}
|
||||
|
||||
abstract class AppRouters {
|
||||
@ -807,6 +809,7 @@ abstract class AppRouters {
|
||||
page: () => const AdminDetailChangeDatePage()),
|
||||
GetPage(
|
||||
name: Routers.expireLockChangeDatePage,
|
||||
page: () => const ExpireLockChangeDatePage())
|
||||
page: () => const ExpireLockChangeDatePage()),
|
||||
GetPage(name: Routers.safeVerifyPage, page: () => const SafeVerifyPage())
|
||||
];
|
||||
}
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/appRouters.dart';
|
||||
@ -9,18 +8,14 @@ import '../../network/api_repository.dart';
|
||||
import '../../tools/store_service.dart';
|
||||
import 'starLock_login_state.dart';
|
||||
|
||||
class StarLockLoginLogic extends BaseGetXController{
|
||||
class StarLockLoginLogic extends BaseGetXController {
|
||||
final StarLockLoginState state = StarLockLoginState();
|
||||
final stateMyLogic = Get.put(StarLockMineLogic()).state;
|
||||
|
||||
void login() async{
|
||||
var entity = await ApiRepository.to.login(
|
||||
"1",
|
||||
state.pwd.value,
|
||||
"+86",
|
||||
state.emailOrPhone.value
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
void login() async {
|
||||
var entity = await ApiRepository.to
|
||||
.login("1", state.pwd.value, "+86", state.emailOrPhone.value);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
// await StoreService.to.saveLogInInfo(entity);
|
||||
stateMyLogic.saveLoginData(entity.data);
|
||||
// Get.back();
|
||||
@ -32,24 +27,26 @@ class StarLockLoginLogic extends BaseGetXController{
|
||||
_resetCanNext();
|
||||
}
|
||||
|
||||
void exchangeFistShow() => state.passwordShow.value = !state.passwordShow.value;
|
||||
void exchangeFistShow() =>
|
||||
state.passwordShow.value = !state.passwordShow.value;
|
||||
|
||||
void checkNext(TextEditingController controller) {
|
||||
changeInput(controller);
|
||||
}
|
||||
|
||||
void changeInput(TextEditingController controller) {
|
||||
if(controller == state.emailOrPhoneController){
|
||||
if (controller == state.emailOrPhoneController) {
|
||||
state.emailOrPhone.value = controller.text;
|
||||
}
|
||||
if(controller == state.pwdController) {
|
||||
if (controller == state.pwdController) {
|
||||
state.pwd.value = controller.text;
|
||||
}
|
||||
_resetCanNext();
|
||||
}
|
||||
|
||||
void _resetCanNext(){
|
||||
state.canNext.value = state.pwdIsOK && state.isEmailOrPhone && state.agree.value;
|
||||
void _resetCanNext() {
|
||||
state.canNext.value =
|
||||
state.pwdIsOK && state.isEmailOrPhone && state.agree.value;
|
||||
}
|
||||
|
||||
@override
|
||||
@ -57,5 +54,4 @@ class StarLockLoginLogic extends BaseGetXController{
|
||||
state.onClose();
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -142,10 +142,12 @@ class _StarLockRegisterPageState extends State<StarLockRegisterPage> {
|
||||
onTap: () async {
|
||||
var result = await Navigator.pushNamed(
|
||||
context, Routers.seletCountryRegionPage);
|
||||
result as Map<String, dynamic>;
|
||||
logic.state.countryCode.value = result['code'];
|
||||
logic.state.countryId.value = result["countryId"];
|
||||
logic.state.countryName.value = result['countryName'];
|
||||
if (result != null) {
|
||||
result as Map<String, dynamic>;
|
||||
logic.state.countryCode.value = result['code'];
|
||||
logic.state.countryId.value = result["countryId"];
|
||||
logic.state.countryName.value = result['countryName'];
|
||||
}
|
||||
print(
|
||||
"路由返回值: ${result}, countryCode:${logic.state.countryCode} ,countryId:${logic.state.countryId}");
|
||||
},
|
||||
|
||||
@ -27,7 +27,7 @@ class AuthorizedAdminSendEntity {
|
||||
}
|
||||
|
||||
class Data {
|
||||
int? receiverUid;
|
||||
String? receiverUid;
|
||||
ReceiverUser? receiverUser;
|
||||
int? keyId;
|
||||
|
||||
@ -64,13 +64,13 @@ class ReceiverUser {
|
||||
|
||||
ReceiverUser(
|
||||
{this.email,
|
||||
this.name,
|
||||
this.updatedAt,
|
||||
this.createdAt,
|
||||
this.id,
|
||||
this.profilePhotoUrl,
|
||||
this.phone,
|
||||
this.cloud});
|
||||
this.name,
|
||||
this.updatedAt,
|
||||
this.createdAt,
|
||||
this.id,
|
||||
this.profilePhotoUrl,
|
||||
this.phone,
|
||||
this.cloud});
|
||||
|
||||
ReceiverUser.fromJson(Map<String, dynamic> json) {
|
||||
email = json['email'];
|
||||
@ -113,13 +113,13 @@ class Phone {
|
||||
|
||||
Phone(
|
||||
{this.userId,
|
||||
this.phoneNumberHash,
|
||||
this.phoneNumberEncrypt,
|
||||
this.countryCode,
|
||||
this.phoneNumberVerifiedAt,
|
||||
this.updatedAt,
|
||||
this.createdAt,
|
||||
this.id});
|
||||
this.phoneNumberHash,
|
||||
this.phoneNumberEncrypt,
|
||||
this.countryCode,
|
||||
this.phoneNumberVerifiedAt,
|
||||
this.updatedAt,
|
||||
this.createdAt,
|
||||
this.id});
|
||||
|
||||
Phone.fromJson(Map<String, dynamic> json) {
|
||||
userId = json['user_id'];
|
||||
@ -149,7 +149,7 @@ class Phone {
|
||||
class Cloud {
|
||||
String? username;
|
||||
String? password;
|
||||
int? cloudUid;
|
||||
String? cloudUid;
|
||||
int? userId;
|
||||
String? updatedAt;
|
||||
String? createdAt;
|
||||
@ -157,12 +157,12 @@ class Cloud {
|
||||
|
||||
Cloud(
|
||||
{this.username,
|
||||
this.password,
|
||||
this.cloudUid,
|
||||
this.userId,
|
||||
this.updatedAt,
|
||||
this.createdAt,
|
||||
this.id});
|
||||
this.password,
|
||||
this.cloudUid,
|
||||
this.userId,
|
||||
this.updatedAt,
|
||||
this.createdAt,
|
||||
this.id});
|
||||
|
||||
Cloud.fromJson(Map<String, dynamic> json) {
|
||||
username = json['username'];
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
import 'package:date_format/date_format.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_native_contact_picker/flutter_native_contact_picker.dart';
|
||||
@ -6,7 +5,6 @@ import 'package:flutter_pickers/pickers.dart';
|
||||
import 'package:flutter_pickers/time_picker/model/date_mode.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/main/lockMian/entity/lockInfoEntity.dart';
|
||||
import 'package:star_lock/network/api_repository.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import 'package:star_lock/tools/toast.dart';
|
||||
@ -30,48 +28,13 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage> {
|
||||
final logic = Get.put(AuthorizedAdminLogic());
|
||||
final state = Get.find<AuthorizedAdminLogic>().state;
|
||||
|
||||
// final FlutterContactPicker _contactPicker = FlutterContactPicker();
|
||||
// late Contact _contact;
|
||||
// late KeyInfos keyInfo;
|
||||
// late LockMainEntity lockMainEntity;
|
||||
// bool _isAuthentication = false; //是否可以实名认证
|
||||
// var _selectEffectiveDate = ''; //生效时间
|
||||
// var _selectFailureDate = ''; //失效时间
|
||||
// late DateTime _effectiveDateTime;
|
||||
// late DateTime _failureDateTime;
|
||||
// final TextEditingController _emailOrPhoneController =
|
||||
// TextEditingController(); //邮箱/手机号输入框
|
||||
// final TextEditingController _keyNameController =
|
||||
// TextEditingController(); //钥匙名输入框
|
||||
// late bool _isSendSuccess;
|
||||
// String countryName = '中国';
|
||||
// String countryCode = '86';
|
||||
// List weekdaysList = [];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
// DateTime dateTime = DateTime.now();
|
||||
// _effectiveDateTime = dateTime;
|
||||
// _failureDateTime = dateTime;
|
||||
// _selectEffectiveDate =
|
||||
// '${dateTime.year}-${dateTime.month}-${dateTime.day} ${dateTime.hour}:${dateTime.minute}'; //默认为当前时间
|
||||
// _selectFailureDate =
|
||||
// '${dateTime.year}-${dateTime.month}-${dateTime.day} ${dateTime.hour}:${dateTime.minute}'; //默认为当前时间
|
||||
// _isSendSuccess = false;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// dynamic obj = ModalRoute.of(context)?.settings.arguments;
|
||||
// if (obj != null && (obj["lockMainEntity"] != null)) {
|
||||
// lockMainEntity = obj["lockMainEntity"];
|
||||
// }
|
||||
// if (obj != null && (obj["keyInfo"] != null)) {
|
||||
// keyInfo = obj["keyInfo"];
|
||||
// }
|
||||
|
||||
state.type.value = widget.type;
|
||||
|
||||
return SingleChildScrollView(
|
||||
@ -137,10 +100,12 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage> {
|
||||
action: () async {
|
||||
var result = await Navigator.pushNamed(
|
||||
context, Routers.seletCountryRegionPage);
|
||||
result as Map<String, dynamic>;
|
||||
state.countryCode.value = result['code'];
|
||||
state.countryName.value = result['countryName'];
|
||||
setState(() {});
|
||||
if (result != null) {
|
||||
result as Map<String, dynamic>;
|
||||
state.countryCode.value = result['code'];
|
||||
state.countryName.value = result['countryName'];
|
||||
setState(() {});
|
||||
}
|
||||
},
|
||||
),
|
||||
CommonItem(
|
||||
@ -169,7 +134,8 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage> {
|
||||
setState(() {
|
||||
state.selectEffectiveDate.value =
|
||||
'${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}';
|
||||
state.effectiveDateTime.value = DateTime.parse(state.selectEffectiveDate.value);
|
||||
state.effectiveDateTime.value =
|
||||
DateTime.parse(state.selectEffectiveDate.value);
|
||||
});
|
||||
});
|
||||
}),
|
||||
@ -183,7 +149,8 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage> {
|
||||
setState(() {
|
||||
state.selectFailureDate.value =
|
||||
'${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}';
|
||||
state.failureDateTime.value = DateTime.parse(state.selectFailureDate.value);
|
||||
state.failureDateTime.value =
|
||||
DateTime.parse(state.selectFailureDate.value);
|
||||
});
|
||||
});
|
||||
}),
|
||||
@ -232,7 +199,8 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage> {
|
||||
btnName: TranslationLoader.lanKeys!.send!.tr,
|
||||
onClick: () {
|
||||
//发送钥匙请求
|
||||
if (state.emailOrPhoneController.text.isNotEmpty && state.keyNameController.value.text.isNotEmpty) {
|
||||
if (state.emailOrPhoneController.text.isNotEmpty &&
|
||||
state.keyNameController.value.text.isNotEmpty) {
|
||||
// logic.addUserConnectBlue();
|
||||
logic.sendElectronicKeyRequest();
|
||||
}
|
||||
@ -358,8 +326,9 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage> {
|
||||
child: TextField(
|
||||
//输入框一行
|
||||
maxLines: 1,
|
||||
controller:
|
||||
lineIndex == 1 ? state.emailOrPhoneController : state.keyNameController,
|
||||
controller: lineIndex == 1
|
||||
? state.emailOrPhoneController
|
||||
: state.keyNameController,
|
||||
autofocus: false,
|
||||
textAlign: TextAlign.end,
|
||||
decoration: InputDecoration(
|
||||
@ -389,7 +358,8 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage> {
|
||||
alignment: Alignment.center,
|
||||
child: InkWell(
|
||||
onTap: () async {
|
||||
Contact? contact = await state.contactPicker.selectContact();
|
||||
Contact? contact =
|
||||
await state.contactPicker.selectContact();
|
||||
setState(() {
|
||||
state.contact = contact!;
|
||||
// print("object111111111111 ${_contact.fullName} ${_contact.phoneNumbers}");
|
||||
@ -403,48 +373,6 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage> {
|
||||
);
|
||||
}
|
||||
|
||||
//发送授权管理员列表请求
|
||||
// Future<void> sendElectronicKeyRequest() async {
|
||||
// String getFailureDateTime = '0';
|
||||
// String getEffectiveDateTime = '0';
|
||||
// String lockID = state.keyInfo.value.lockId.toString();
|
||||
// String getKeyType = (int.parse(widget.type) + 1).toString();
|
||||
// if (widget.type == '0') {
|
||||
// getFailureDateTime = state.failureDateTime.value.millisecondsSinceEpoch.toString();
|
||||
// getEffectiveDateTime =
|
||||
// state.effectiveDateTime.value.millisecondsSinceEpoch.toString();
|
||||
// }
|
||||
// var entity = await ApiRepository.to.sendElectronicKey(
|
||||
// state.isCreateUser.value ? "1" : "0",
|
||||
// state.countryCode.value,
|
||||
// '1',
|
||||
// getFailureDateTime,
|
||||
// state.isAuthentication.value == true ? '1' : '2',
|
||||
// '2',
|
||||
// '2',
|
||||
// state.keyNameController.text,
|
||||
// '1',
|
||||
// getKeyType,
|
||||
// lockID,
|
||||
// '',
|
||||
// state.emailOrPhoneController.text,
|
||||
// '',
|
||||
// getEffectiveDateTime,
|
||||
// state.weekdaysList);
|
||||
// if (entity.errorCode!.codeIsSuccessful) {
|
||||
// print('发送电子钥匙成功');
|
||||
// state.isSendSuccess.value = true;
|
||||
// setState(() {});
|
||||
// } else {
|
||||
// Toast.show(msg: '${entity.errorMsg}');
|
||||
// if (entity.errorCode == 425) {
|
||||
// //用户未注册
|
||||
// state.isCreateUser.value = true;
|
||||
// sendElectronicKeyRequest();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
//实名认证
|
||||
CupertinoSwitch _switch() {
|
||||
return CupertinoSwitch(
|
||||
|
||||
@ -134,10 +134,12 @@ class _VolumeAuthorizationLockPageState
|
||||
action: () async {
|
||||
var result = await Navigator.pushNamed(
|
||||
context, Routers.seletCountryRegionPage);
|
||||
result as Map<String, dynamic>;
|
||||
countryCode = result['code'];
|
||||
countryName = result['countryName'];
|
||||
setState(() {});
|
||||
if (result != null) {
|
||||
result as Map<String, dynamic>;
|
||||
countryCode = result['code'];
|
||||
countryName = result['countryName'];
|
||||
setState(() {});
|
||||
}
|
||||
},
|
||||
),
|
||||
CommonItem(
|
||||
|
||||
@ -39,8 +39,9 @@ class _CheckingInAddStaffPageState extends State<CheckingInAddStaffPage> {
|
||||
rightTitle: "",
|
||||
isHaveLine: true,
|
||||
isHaveRightWidget: true,
|
||||
rightWidget:
|
||||
getTFWidget(TranslationLoader.lanKeys!.pleaseEnter!.tr, state.staffNameController)),
|
||||
rightWidget: getTFWidget(
|
||||
TranslationLoader.lanKeys!.pleaseEnter!.tr,
|
||||
state.staffNameController)),
|
||||
Obx(() => CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.punchingMode!.tr,
|
||||
rightTitle: state.seletPrintingMethodStr.value,
|
||||
@ -50,22 +51,28 @@ class _CheckingInAddStaffPageState extends State<CheckingInAddStaffPage> {
|
||||
var list = ["APP", "密码", "卡", "指纹"];
|
||||
_showSeletClockInType(list, "1");
|
||||
})),
|
||||
SizedBox(height: 10.h,),
|
||||
SizedBox(
|
||||
height: 10.h,
|
||||
),
|
||||
//员工是否有App、卡、钥匙、指纹必须显示
|
||||
Obx(() => CommonItem(
|
||||
leftTitel:addStaffGetIfHaveKey(),
|
||||
leftTitel: addStaffGetIfHaveKey(),
|
||||
rightTitle: "",
|
||||
isHaveLine: true,
|
||||
isHaveRightWidget: true,
|
||||
rightWidget: Row(
|
||||
children: [
|
||||
whetherTheEmployeeHasAKeyWidget("无", state.appUnHaveAccount.value, () {
|
||||
whetherTheEmployeeHasAKeyWidget(
|
||||
"无", state.appUnHaveAccount.value, () {
|
||||
setState(() {
|
||||
state.appUnHaveAccount.value = true;
|
||||
});
|
||||
}),
|
||||
SizedBox(width: 30.w,),
|
||||
whetherTheEmployeeHasAKeyWidget("有", !state.appUnHaveAccount.value, () {
|
||||
SizedBox(
|
||||
width: 30.w,
|
||||
),
|
||||
whetherTheEmployeeHasAKeyWidget(
|
||||
"有", !state.appUnHaveAccount.value, () {
|
||||
setState(() {
|
||||
state.appUnHaveAccount.value = false;
|
||||
});
|
||||
@ -74,125 +81,149 @@ class _CheckingInAddStaffPageState extends State<CheckingInAddStaffPage> {
|
||||
))),
|
||||
// 当选择App时显示 其他隐藏
|
||||
Obx(() => Visibility(
|
||||
visible: (state.appUnHaveAccount.value && state.seletPrintingMethodType.value == "1") ? true : false,
|
||||
child: Column(
|
||||
children: [
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.accountNumber!.tr,
|
||||
rightTitle: "",
|
||||
isHaveLine: true,
|
||||
isHaveRightWidget: true,
|
||||
rightWidget:
|
||||
getTFWidget(TranslationLoader.lanKeys!.pleaseEnter!.tr, state.staffAccountController)),
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.countryAndRegion!.tr,
|
||||
rightTitle: "",
|
||||
isHaveLine: true,
|
||||
isHaveRightWidget: true,
|
||||
isHaveDirection: true,
|
||||
rightWidget: Text(
|
||||
'${state.countryName.value} +${state.countryCode.value}',
|
||||
textAlign: TextAlign.end,
|
||||
style:
|
||||
TextStyle(fontSize: 22.sp, color: AppColors.darkGrayTextColor),
|
||||
),
|
||||
action: () async {
|
||||
var result = await Navigator.pushNamed(
|
||||
context, Routers.seletCountryRegionPage);
|
||||
result as Map<String, dynamic>;
|
||||
state.countryCode.value = result['code'];
|
||||
state.countryName.value = result['countryName'];
|
||||
setState(() {});
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
)),
|
||||
// 当选择密码、卡、指纹时显示
|
||||
Obx(() => Visibility(
|
||||
visible: (state.seletPrintingMethodType.value != "1" && state.appUnHaveAccount.value) ? true : false,
|
||||
child: CommonItem(
|
||||
leftTitel: addStaffGetKeyType(),
|
||||
isHaveLine: false,
|
||||
isHaveRightWidget: true,
|
||||
rightWidget: Row(
|
||||
visible: (state.appUnHaveAccount.value &&
|
||||
state.seletPrintingMethodType.value == "1")
|
||||
? true
|
||||
: false,
|
||||
child: Column(
|
||||
children: [
|
||||
Obx(() => Text(state.getDataPassword.value, style: TextStyle(fontSize: 24.sp))),
|
||||
SizedBox(width: 30.w,),
|
||||
SizedBox(
|
||||
width: 130.w,
|
||||
height: 40.h,
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(backgroundColor: AppColors.mainColor,),
|
||||
child: Text(addStaffSeletKeyType(), style: TextStyle(color: Colors.white, fontSize: 22.sp)),
|
||||
onPressed: () async {
|
||||
switch(int.parse(state.seletPrintingMethodType.value)){
|
||||
case 2:
|
||||
// 获取密码
|
||||
logic.getKeyboardPwdRequest();
|
||||
break;
|
||||
case 3:
|
||||
// 卡
|
||||
if(state.staffNameController.text.isEmpty){
|
||||
Toast.show(msg: "请输入姓名");
|
||||
return;
|
||||
}
|
||||
|
||||
var data = await Get.toNamed(Routers.otherTypeKeyManagePage, arguments: {
|
||||
"lockId": state.getKeyInfosData.value.lockId,
|
||||
"keyType": 0,
|
||||
"fromType": 2, // 1从添加钥匙列表进入 2从考勤添加员工入口进入
|
||||
"fromTypeTwoStaffName" :state.staffNameController.text
|
||||
});
|
||||
if(data != null) {
|
||||
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
// 指纹
|
||||
if(state.staffNameController.text.isEmpty){
|
||||
Toast.show(msg: "请输入姓名");
|
||||
return;
|
||||
}
|
||||
|
||||
var data = await Get.toNamed(Routers.otherTypeKeyManagePage, arguments: {
|
||||
"lockId": state.getKeyInfosData.value.lockId,
|
||||
"keyType": 1,
|
||||
"fromType": 2, // 1从添加钥匙列表进入 2从考勤添加员工入口进入
|
||||
"fromTypeTwoStaffName" :state.staffNameController.text
|
||||
});
|
||||
if(data != null) {
|
||||
|
||||
}
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.accountNumber!.tr,
|
||||
rightTitle: "",
|
||||
isHaveLine: true,
|
||||
isHaveRightWidget: true,
|
||||
rightWidget: getTFWidget(
|
||||
TranslationLoader.lanKeys!.pleaseEnter!.tr,
|
||||
state.staffAccountController)),
|
||||
CommonItem(
|
||||
leftTitel:
|
||||
TranslationLoader.lanKeys!.countryAndRegion!.tr,
|
||||
rightTitle: "",
|
||||
isHaveLine: true,
|
||||
isHaveRightWidget: true,
|
||||
isHaveDirection: true,
|
||||
rightWidget: Text(
|
||||
'${state.countryName.value} +${state.countryCode.value}',
|
||||
textAlign: TextAlign.end,
|
||||
style: TextStyle(
|
||||
fontSize: 22.sp,
|
||||
color: AppColors.darkGrayTextColor),
|
||||
),
|
||||
action: () async {
|
||||
var result = await Navigator.pushNamed(
|
||||
context, Routers.seletCountryRegionPage);
|
||||
if (result != null) {
|
||||
result as Map<String, dynamic>;
|
||||
state.countryCode.value = result['code'];
|
||||
state.countryName.value = result['countryName'];
|
||||
setState(() {});
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
)),
|
||||
)),
|
||||
),
|
||||
)),
|
||||
// 当选择密码、卡、指纹时显示
|
||||
Obx(() => Visibility(
|
||||
visible: (state.seletPrintingMethodType.value != "1" &&
|
||||
state.appUnHaveAccount.value)
|
||||
? true
|
||||
: false,
|
||||
child: CommonItem(
|
||||
leftTitel: addStaffGetKeyType(),
|
||||
isHaveLine: false,
|
||||
isHaveRightWidget: true,
|
||||
rightWidget: Row(
|
||||
children: [
|
||||
Obx(() => Text(state.getDataPassword.value,
|
||||
style: TextStyle(fontSize: 24.sp))),
|
||||
SizedBox(
|
||||
width: 30.w,
|
||||
),
|
||||
SizedBox(
|
||||
width: 130.w,
|
||||
height: 40.h,
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: AppColors.mainColor,
|
||||
),
|
||||
child: Text(addStaffSeletKeyType(),
|
||||
style: TextStyle(
|
||||
color: Colors.white, fontSize: 22.sp)),
|
||||
onPressed: () async {
|
||||
switch (int.parse(
|
||||
state.seletPrintingMethodType.value)) {
|
||||
case 2:
|
||||
// 获取密码
|
||||
logic.getKeyboardPwdRequest();
|
||||
break;
|
||||
case 3:
|
||||
// 卡
|
||||
if (state
|
||||
.staffNameController.text.isEmpty) {
|
||||
Toast.show(msg: "请输入姓名");
|
||||
return;
|
||||
}
|
||||
|
||||
var data = await Get.toNamed(
|
||||
Routers.otherTypeKeyManagePage,
|
||||
arguments: {
|
||||
"lockId": state
|
||||
.getKeyInfosData.value.lockId,
|
||||
"keyType": 0,
|
||||
"fromType":
|
||||
2, // 1从添加钥匙列表进入 2从考勤添加员工入口进入
|
||||
"fromTypeTwoStaffName":
|
||||
state.staffNameController.text
|
||||
});
|
||||
if (data != null) {}
|
||||
break;
|
||||
case 4:
|
||||
// 指纹
|
||||
if (state
|
||||
.staffNameController.text.isEmpty) {
|
||||
Toast.show(msg: "请输入姓名");
|
||||
return;
|
||||
}
|
||||
|
||||
var data = await Get.toNamed(
|
||||
Routers.otherTypeKeyManagePage,
|
||||
arguments: {
|
||||
"lockId": state
|
||||
.getKeyInfosData.value.lockId,
|
||||
"keyType": 1,
|
||||
"fromType":
|
||||
2, // 1从添加钥匙列表进入 2从考勤添加员工入口进入
|
||||
"fromTypeTwoStaffName":
|
||||
state.staffNameController.text
|
||||
});
|
||||
if (data != null) {}
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}),
|
||||
),
|
||||
],
|
||||
)),
|
||||
)),
|
||||
// 当选择钥匙类型为有时 必显示
|
||||
Obx(() => Visibility(
|
||||
visible: !state.appUnHaveAccount.value,
|
||||
child: CommonItem(
|
||||
leftTitel: addStaffGetKeyType(),
|
||||
rightTitle: state.seletKey.value,
|
||||
isHaveLine: false,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
logic.addStaffSeletKey((v){
|
||||
var list = [];
|
||||
for (var element in v) {
|
||||
list.add(element.attendanceWay);
|
||||
}
|
||||
_showSeletClockInType(list, "2");
|
||||
});
|
||||
|
||||
}),
|
||||
)),
|
||||
visible: !state.appUnHaveAccount.value,
|
||||
child: CommonItem(
|
||||
leftTitel: addStaffGetKeyType(),
|
||||
rightTitle: state.seletKey.value,
|
||||
isHaveLine: false,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
logic.addStaffSeletKey((v) {
|
||||
var list = [];
|
||||
for (var element in v) {
|
||||
list.add(element.attendanceWay);
|
||||
}
|
||||
_showSeletClockInType(list, "2");
|
||||
});
|
||||
}),
|
||||
)),
|
||||
SizedBox(height: 50.w),
|
||||
SubmitBtn(
|
||||
btnName: TranslationLoader.lanKeys!.sure!.tr,
|
||||
@ -200,14 +231,14 @@ class _CheckingInAddStaffPageState extends State<CheckingInAddStaffPage> {
|
||||
margin: EdgeInsets.only(left: 30.w, right: 30.w, top: 30.w),
|
||||
padding: EdgeInsets.only(top: 25.w, bottom: 25.w),
|
||||
onClick: () {
|
||||
if(state.staffNameController.text.isEmpty){
|
||||
if (state.staffNameController.text.isEmpty) {
|
||||
Toast.show(msg: "请输入姓名");
|
||||
return;
|
||||
}
|
||||
|
||||
if(state.isAdd.value == "2"){
|
||||
if (state.isAdd.value == "2") {
|
||||
logic.editStaffLoadData();
|
||||
}else{
|
||||
} else {
|
||||
logic.addStaffLoadData();
|
||||
}
|
||||
}),
|
||||
@ -261,26 +292,30 @@ class _CheckingInAddStaffPageState extends State<CheckingInAddStaffPage> {
|
||||
data: list,
|
||||
//选择事件的回调
|
||||
clickCallBack: (int index, var str) {
|
||||
setState(() {
|
||||
if(type == "1"){
|
||||
state.seletPrintingMethodType.value = (index+1).toString();
|
||||
state.seletPrintingMethodStr.value = str.toString();
|
||||
state.getDataPassword.value = "";
|
||||
}else{
|
||||
state.seletKey.value = str.toString();
|
||||
}
|
||||
print("object:$index str:$str type:$type state.seletPrintingMethodType.value:${state.seletPrintingMethodType.value}");
|
||||
});
|
||||
});
|
||||
setState(() {
|
||||
if (type == "1") {
|
||||
state.seletPrintingMethodType.value = (index + 1).toString();
|
||||
state.seletPrintingMethodStr.value = str.toString();
|
||||
state.getDataPassword.value = "";
|
||||
} else {
|
||||
state.seletKey.value = str.toString();
|
||||
}
|
||||
print(
|
||||
"object:$index str:$str type:$type state.seletPrintingMethodType.value:${state.seletPrintingMethodType.value}");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Widget whetherTheEmployeeHasAKeyWidget(String title, bool appUnHaveAccount, Function() action) {
|
||||
Widget whetherTheEmployeeHasAKeyWidget(
|
||||
String title, bool appUnHaveAccount, Function() action) {
|
||||
return GestureDetector(
|
||||
onTap: action,
|
||||
child: Row(
|
||||
children: [
|
||||
Image.asset(
|
||||
appUnHaveAccount ? 'images/icon_round_selet.png' : 'images/icon_round_unSelet.png',
|
||||
appUnHaveAccount
|
||||
? 'images/icon_round_selet.png'
|
||||
: 'images/icon_round_unSelet.png',
|
||||
width: 26.w,
|
||||
height: 26.w,
|
||||
),
|
||||
@ -298,9 +333,9 @@ class _CheckingInAddStaffPageState extends State<CheckingInAddStaffPage> {
|
||||
);
|
||||
}
|
||||
|
||||
String addStaffGetIfHaveKey(){
|
||||
String addStaffGetIfHaveKey() {
|
||||
String title = "";
|
||||
switch(int.parse(state.seletPrintingMethodType.value)){
|
||||
switch (int.parse(state.seletPrintingMethodType.value)) {
|
||||
case 1:
|
||||
title = TranslationLoader.lanKeys!.whetherTheEmployeeHasAKey!.tr;
|
||||
break;
|
||||
@ -317,9 +352,9 @@ class _CheckingInAddStaffPageState extends State<CheckingInAddStaffPage> {
|
||||
return title;
|
||||
}
|
||||
|
||||
String addStaffGetKeyType(){
|
||||
String addStaffGetKeyType() {
|
||||
String title = "";
|
||||
switch(int.parse(state.seletPrintingMethodType.value)){
|
||||
switch (int.parse(state.seletPrintingMethodType.value)) {
|
||||
case 1:
|
||||
title = TranslationLoader.lanKeys!.accountNumber!.tr;
|
||||
break;
|
||||
@ -336,9 +371,9 @@ class _CheckingInAddStaffPageState extends State<CheckingInAddStaffPage> {
|
||||
return title;
|
||||
}
|
||||
|
||||
String addStaffSeletKeyType(){
|
||||
String addStaffSeletKeyType() {
|
||||
String title = "";
|
||||
switch(int.parse(state.seletPrintingMethodType.value)){
|
||||
switch (int.parse(state.seletPrintingMethodType.value)) {
|
||||
case 1:
|
||||
title = TranslationLoader.lanKeys!.getKey!.tr;
|
||||
break;
|
||||
@ -354,5 +389,4 @@ class _CheckingInAddStaffPageState extends State<CheckingInAddStaffPage> {
|
||||
}
|
||||
return title;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -7,6 +7,7 @@ import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity
|
||||
import 'package:star_lock/network/api_repository.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import 'package:star_lock/tools/jh_pop_menus.dart';
|
||||
import 'package:star_lock/tools/showCupertinoAlert.dart';
|
||||
import 'package:star_lock/tools/toast.dart';
|
||||
|
||||
import '../../../../../appRouters.dart';
|
||||
@ -271,7 +272,7 @@ class _ElectronicKeyDetailPageState extends State<ElectronicKeyDetailPage> {
|
||||
print("删除电子钥匙成功");
|
||||
Toast.show(msg: "删除成功");
|
||||
setState(() {
|
||||
Navigator.pop(context);
|
||||
Navigator.pop(context, true);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,9 +0,0 @@
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_logic.dart';
|
||||
|
||||
class ElectronicKeyListBinding extends Bindings {
|
||||
@override
|
||||
void dependencies() {
|
||||
Get.lazyPut(() => ElectronicKeyListLogic());
|
||||
}
|
||||
}
|
||||
@ -1,16 +1,60 @@
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_state.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart';
|
||||
import 'package:star_lock/network/api_repository.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import 'package:star_lock/tools/toast.dart';
|
||||
|
||||
class ElectronicKeyListLogic {
|
||||
late ElectronicKeyListEntity dataEntity = ElectronicKeyListEntity();
|
||||
void electronicKeyList() async {
|
||||
var entity = await ApiRepository.to
|
||||
.electronicKeyList('0', '63', '0', '28', '1', '1', '20', '0', '0');
|
||||
class ElectronicKeyListLogic extends BaseGetXController {
|
||||
final ElectronicKeyListState state = ElectronicKeyListState();
|
||||
|
||||
//请求电子钥匙列表
|
||||
Future<List<ElectronicKeyListItem>> mockNetworkDataRequest() async {
|
||||
ElectronicKeyListEntity entity = await ApiRepository.to.electronicKeyList(
|
||||
'0',
|
||||
state.keyInfo.value.keyId.toString(),
|
||||
'',
|
||||
state.keyInfo.value.lockId.toString(),
|
||||
'',
|
||||
state.pageNum.toString(),
|
||||
state.pageSize.toString(),
|
||||
'0',
|
||||
'0');
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
print("电子钥匙列表成功:${entity.data?.itemList}");
|
||||
dataEntity = entity;
|
||||
}
|
||||
if (entity.data != null) {
|
||||
return entity.data!.itemList;
|
||||
} else {
|
||||
List<ElectronicKeyListItem> dataList = [];
|
||||
return dataList;
|
||||
}
|
||||
}
|
||||
|
||||
//电子钥匙重置请求
|
||||
Future<void> resetElectronicKeyListRequest() async {
|
||||
ElectronicKeyListEntity entity = await ApiRepository.to
|
||||
.resetElectronicKey(state.keyInfo.value.lockId.toString(), '0');
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
print("重置电子钥匙成功啦啦啦啦啦");
|
||||
Toast.show(msg: "重置成功");
|
||||
mockNetworkDataRequest();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
// TODO: implement onReady
|
||||
super.onReady();
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
// TODO: implement onInit
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
// TODO: implement onClose
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,13 +1,10 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:pull_to_refresh/pull_to_refresh.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_logic.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart';
|
||||
import 'package:star_lock/main/lockMian/entity/lockInfoEntity.dart';
|
||||
import 'package:star_lock/network/api_repository.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import 'package:star_lock/tools/toast.dart';
|
||||
|
||||
import 'package:star_lock/tools/noData.dart';
|
||||
import '../../../../appRouters.dart';
|
||||
import '../../../../app_settings/app_colors.dart';
|
||||
import '../../../../tools/submitBtn.dart';
|
||||
@ -23,19 +20,18 @@ class ElectronicKeyListPage extends StatefulWidget {
|
||||
|
||||
class _ElectronicKeyListPageState extends State<ElectronicKeyListPage> {
|
||||
final logic = Get.put(ElectronicKeyListLogic());
|
||||
late KeyInfos keyInfo;
|
||||
late LockMainEntity lockMainEntity;
|
||||
final state = Get.find<ElectronicKeyListLogic>().state;
|
||||
late RefreshController _refreshController;
|
||||
late List<ElectronicKeyListItem> itemDataList = [];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_refreshController = RefreshController(initialRefresh: true);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
dynamic obj = ModalRoute.of(context)?.settings.arguments;
|
||||
if (obj != null && (obj["lockMainEntity"] != null)) {
|
||||
lockMainEntity = obj["lockMainEntity"];
|
||||
}
|
||||
if (obj != null && (obj["keyInfo"] != null)) {
|
||||
keyInfo = obj["keyInfo"];
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.mainBackgroundColor,
|
||||
appBar: TitleAppBar(
|
||||
@ -49,13 +45,14 @@ class _ElectronicKeyListPageState extends State<ElectronicKeyListPage> {
|
||||
style: TextStyle(color: Colors.white, fontSize: 24.sp),
|
||||
),
|
||||
onPressed: () {
|
||||
resetElectronicKeyListRequest();
|
||||
logic.resetElectronicKeyListRequest();
|
||||
setState(() {});
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
body: FutureBuilder<List<ElectronicKeyListItem>>(
|
||||
future: mockNetworkDataRequest(),
|
||||
future: logic.mockNetworkDataRequest(),
|
||||
builder: (BuildContext context,
|
||||
AsyncSnapshot<List<ElectronicKeyListItem>> snapshot) {
|
||||
//请求结束
|
||||
@ -65,7 +62,7 @@ class _ElectronicKeyListPageState extends State<ElectronicKeyListPage> {
|
||||
return const Text('请求失败');
|
||||
} else {
|
||||
//请求成功
|
||||
final List<ElectronicKeyListItem> itemData = snapshot.data!;
|
||||
itemDataList = snapshot.data!;
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
@ -73,18 +70,34 @@ class _ElectronicKeyListPageState extends State<ElectronicKeyListPage> {
|
||||
SizedBox(
|
||||
height: 20.h,
|
||||
),
|
||||
Expanded(child: _buildMainUI(itemData)),
|
||||
Expanded(
|
||||
child: itemDataList.isEmpty
|
||||
? const NoData()
|
||||
: SmartRefresher(
|
||||
controller: _refreshController,
|
||||
onRefresh: _refresh,
|
||||
onLoading: _loadMore,
|
||||
header: ClassicHeader(
|
||||
height: 45.h,
|
||||
releaseText: '松开手刷新',
|
||||
refreshingText: '刷新中',
|
||||
completeText: '刷新完成',
|
||||
failedText: '刷新失败',
|
||||
idleText: '下拉刷新',
|
||||
),
|
||||
child: _buildMainUI(itemDataList),
|
||||
)),
|
||||
AddBottomWhiteBtn(
|
||||
btnName: TranslationLoader.lanKeys!.sendKey!.tr,
|
||||
onClick: () {
|
||||
Navigator.pushNamed(
|
||||
context, Routers.sendElectronicKeyManagePage,
|
||||
arguments: {
|
||||
"lockMainEntity": lockMainEntity,
|
||||
"keyInfo": keyInfo
|
||||
"lockMainEntity": state.lockMainEntity.value,
|
||||
"keyInfo": state.keyInfo.value
|
||||
}).then((val) {
|
||||
if (val != null) {
|
||||
mockNetworkDataRequest();
|
||||
logic.mockNetworkDataRequest();
|
||||
setState(() {});
|
||||
}
|
||||
});
|
||||
@ -104,6 +117,30 @@ class _ElectronicKeyListPageState extends State<ElectronicKeyListPage> {
|
||||
);
|
||||
}
|
||||
|
||||
///加载更多函数
|
||||
Future<void> _loadMore() async {
|
||||
if (state.pageNum.value == 1) {
|
||||
if (itemDataList.length < 10) {
|
||||
_refreshController.loadComplete();
|
||||
} else {
|
||||
state.pageNum.value++;
|
||||
await logic.mockNetworkDataRequest();
|
||||
_refreshController.loadComplete();
|
||||
}
|
||||
} else {
|
||||
state.pageNum.value++;
|
||||
await logic.mockNetworkDataRequest();
|
||||
_refreshController.loadComplete();
|
||||
}
|
||||
}
|
||||
|
||||
///刷新函数
|
||||
Future<void> _refresh() async {
|
||||
state.pageNum.value = 1;
|
||||
await logic.mockNetworkDataRequest();
|
||||
_refreshController.refreshCompleted();
|
||||
}
|
||||
|
||||
Widget _searchWidget() {
|
||||
return Container(
|
||||
height: 60.h,
|
||||
@ -142,6 +179,7 @@ class _ElectronicKeyListPageState extends State<ElectronicKeyListPage> {
|
||||
Widget _buildMainUI(itemData) {
|
||||
List<ElectronicKeyListItem> getItemData = itemData;
|
||||
return ListView.separated(
|
||||
shrinkWrap: true,
|
||||
itemCount: getItemData.length,
|
||||
itemBuilder: (c, index) {
|
||||
ElectronicKeyListItem indexEntity = getItemData[index];
|
||||
@ -164,7 +202,13 @@ class _ElectronicKeyListPageState extends State<ElectronicKeyListPage> {
|
||||
return _electronicKeyItem('images/controls_user.png',
|
||||
indexEntity.keyName!, useDateStr, keyStatus, isAdminKey, () {
|
||||
Navigator.pushNamed(context, Routers.electronicKeyDetailPage,
|
||||
arguments: {"itemData": indexEntity});
|
||||
arguments: {"itemData": indexEntity}).then((val) {
|
||||
if (val != null) {
|
||||
logic.mockNetworkDataRequest();
|
||||
setState(() {});
|
||||
}
|
||||
});
|
||||
;
|
||||
});
|
||||
},
|
||||
separatorBuilder: (BuildContext context, int index) {
|
||||
@ -176,41 +220,6 @@ class _ElectronicKeyListPageState extends State<ElectronicKeyListPage> {
|
||||
);
|
||||
}
|
||||
|
||||
//请求电子钥匙列表
|
||||
Future<List<ElectronicKeyListItem>> mockNetworkDataRequest() async {
|
||||
ElectronicKeyListEntity entity = await ApiRepository.to.electronicKeyList(
|
||||
'0',
|
||||
keyInfo.keyId.toString(),
|
||||
'',
|
||||
keyInfo.lockId.toString(),
|
||||
'',
|
||||
'1',
|
||||
'20',
|
||||
'0',
|
||||
'0');
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
print("电子钥匙列表成功:${entity.data?.itemList}");
|
||||
}
|
||||
if (entity.data != null) {
|
||||
return entity.data!.itemList;
|
||||
} else {
|
||||
List<ElectronicKeyListItem> dataList = [];
|
||||
return dataList;
|
||||
}
|
||||
}
|
||||
|
||||
//电子钥匙重置请求
|
||||
Future<void> resetElectronicKeyListRequest() async {
|
||||
ElectronicKeyListEntity entity = await ApiRepository.to
|
||||
.resetElectronicKey(keyInfo.lockId.toString(), '0');
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
print("重置电子钥匙成功啦啦啦啦啦");
|
||||
Toast.show(msg: "重置成功");
|
||||
mockNetworkDataRequest();
|
||||
setState(() {});
|
||||
}
|
||||
}
|
||||
|
||||
//使用期限
|
||||
String getUseDateStr(ElectronicKeyListItem indexEntity) {
|
||||
String useDateStr = '';
|
||||
|
||||
@ -0,0 +1,16 @@
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/main/lockMian/entity/lockInfoEntity.dart';
|
||||
import 'package:star_lock/mine/mineSet/mineSet/userSettingInfoEntity.dart';
|
||||
|
||||
class ElectronicKeyListState {
|
||||
final keyInfo = KeyInfos().obs;
|
||||
final lockMainEntity = LockMainEntity().obs;
|
||||
var pageNum = 1.obs; //请求页码
|
||||
final pageSize = 20.obs; //请求每页数据条数
|
||||
|
||||
ElectronicKeyListState() {
|
||||
Map map = Get.arguments;
|
||||
lockMainEntity.value = map["lockMainEntity"];
|
||||
keyInfo.value = map["keyInfo"];
|
||||
}
|
||||
}
|
||||
@ -249,10 +249,12 @@ class _MassSendElectronicKeyPageState extends State<MassSendElectronicKeyPage> {
|
||||
action: () async {
|
||||
var result = await Navigator.pushNamed(
|
||||
context, Routers.seletCountryRegionPage);
|
||||
result as Map<String, dynamic>;
|
||||
countryCode = result['code'];
|
||||
countryName = result['countryName'];
|
||||
setState(() {});
|
||||
if (result != null) {
|
||||
result as Map<String, dynamic>;
|
||||
countryCode = result['code'];
|
||||
countryName = result['countryName'];
|
||||
setState(() {});
|
||||
}
|
||||
},
|
||||
),
|
||||
CommonItem(
|
||||
|
||||
@ -81,10 +81,12 @@ class _MassSendReceiverPageState extends State<MassSendReceiverPage> {
|
||||
action: () async {
|
||||
var result = await Navigator.pushNamed(
|
||||
context, Routers.seletCountryRegionPage);
|
||||
result as Map<String, dynamic>;
|
||||
countryCode = result['code'];
|
||||
countryName = result['countryName'];
|
||||
setState(() {});
|
||||
if (result != null) {
|
||||
result as Map<String, dynamic>;
|
||||
countryCode = result['code'];
|
||||
countryName = result['countryName'];
|
||||
setState(() {});
|
||||
}
|
||||
},
|
||||
),
|
||||
Row(
|
||||
|
||||
@ -1,9 +0,0 @@
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_logic.dart';
|
||||
|
||||
class SendElectronicKeyBinding extends Bindings {
|
||||
@override
|
||||
void dependencies() {
|
||||
Get.lazyPut(() => SendElectronicKeyLogic());
|
||||
}
|
||||
}
|
||||
@ -1,90 +1,50 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_state.dart';
|
||||
import 'package:star_lock/network/api_repository.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import 'package:star_lock/tools/toast.dart';
|
||||
|
||||
class SendElectronicKeyLogic extends BaseGetXController {
|
||||
final SendElectronicKeyState state = SendElectronicKeyState();
|
||||
final stateMyLogic = Get.put(SendElectronicKeyLogic()).state;
|
||||
|
||||
void sendElectronicKey() async {
|
||||
// String getFailureDateTime = '0';
|
||||
// String getEffectiveDateTime = '0';
|
||||
// String getKeyType = (int.parse(state.keyType) + 1).toString();
|
||||
|
||||
// if (state.keyType == '1') {
|
||||
// getFailureDateTime = DateTime.fromMillisecondsSinceEpoch(
|
||||
// int.parse(state.failureDate.value) * 1000)
|
||||
// .toString()
|
||||
// .substring(0, 19);
|
||||
// getEffectiveDateTime = DateTime.fromMillisecondsSinceEpoch(
|
||||
// int.parse(state.effectiveDate.value) * 1000)
|
||||
// .toString()
|
||||
// .substring(0, 19);
|
||||
// }
|
||||
// var entity = await ApiRepository.to.sendElectronicKey(
|
||||
// '0',
|
||||
// '0',
|
||||
// '1',
|
||||
// getFailureDateTime,
|
||||
// state.isRealName == true ? '1' : '2',
|
||||
// '2',
|
||||
// state.isRemoteUnlock == true ? '1' : '2',
|
||||
// state.keyNameController.text,
|
||||
// '1',
|
||||
// getKeyType,
|
||||
// '28',
|
||||
// '小吴副号',
|
||||
// emailOrPhoneController.text,
|
||||
// '0',
|
||||
// getEffectiveDateTime, []);
|
||||
// if (entity.errorCode!.codeIsSuccessful) {
|
||||
// // print('发送电子钥匙成功');
|
||||
// }
|
||||
// var entity = await ApiRepository.to.sendElectronicKey(
|
||||
// '0',
|
||||
// '0',
|
||||
// '1',
|
||||
// state.failureDate,
|
||||
// state.isRealName == true ? '1' : '2',
|
||||
// '2',
|
||||
// state.isRemoteUnlock == true ? '1' : '2',
|
||||
// state.emailOrPhoneController.text,
|
||||
// '1',
|
||||
// '0',
|
||||
// '28',
|
||||
// '小吴副号',
|
||||
// '18682150237',
|
||||
// '0',
|
||||
// '0', []);
|
||||
// if (entity.errorCode!.codeIsSuccessful) {
|
||||
// print('发送电子钥匙成功');
|
||||
// Get.back();
|
||||
// }
|
||||
//发送钥匙请求
|
||||
Future<void> sendElectronicKeyRequest() async {
|
||||
String getFailureDateTime = '0';
|
||||
String getEffectiveDateTime = '0';
|
||||
String lockID = state.keyInfo.value.lockId.toString();
|
||||
String getKeyType = (int.parse(state.type.value) + 1).toString();
|
||||
if (state.type.value == '0') {
|
||||
getFailureDateTime =
|
||||
state.failureDateTime.value.millisecondsSinceEpoch.toString();
|
||||
getEffectiveDateTime =
|
||||
state.effectiveDateTime.value.millisecondsSinceEpoch.toString();
|
||||
}
|
||||
var entity = await ApiRepository.to.sendElectronicKey(
|
||||
state.isCreateUser.value ? "1" : "0",
|
||||
state.countryCode.value,
|
||||
'1',
|
||||
getFailureDateTime,
|
||||
state.isAuthentication.value == true ? '1' : '2',
|
||||
'2',
|
||||
state.isRemoteUnlock.value == true ? '1' : '2',
|
||||
state.keyNameController.text,
|
||||
'0',
|
||||
getKeyType,
|
||||
lockID,
|
||||
'',
|
||||
state.emailOrPhoneController.text,
|
||||
'',
|
||||
getEffectiveDateTime,
|
||||
state.weekdaysList);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
print('发送电子钥匙成功');
|
||||
state.isSendSuccess.value = true;
|
||||
} else {
|
||||
Toast.show(msg: '${entity.errorMsg}');
|
||||
if (entity.errorCode == 425) {
|
||||
//用户未注册
|
||||
state.isCreateUser.value = true;
|
||||
sendElectronicKeyRequest();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// void checkNext(TextEditingController controller) {
|
||||
// changeInput(controller);
|
||||
// }
|
||||
|
||||
// void changeInput(TextEditingController controller) {
|
||||
// if (controller == state.emailOrPhoneController) {
|
||||
// state.emailOrPhone.value = controller.text;
|
||||
// }
|
||||
// if (controller == state.keyNameController) {
|
||||
// state.keyName.value = controller.text;
|
||||
// }
|
||||
// _resetCanNext();
|
||||
// }
|
||||
|
||||
// void _resetCanNext() {
|
||||
// state.canNext.value = state.isEmailOrPhoneOK && state.isKeyNameOK;
|
||||
// }
|
||||
|
||||
// @override
|
||||
// void onClose() {
|
||||
// state.onClose();
|
||||
// super.onClose();
|
||||
// }
|
||||
}
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
import 'package:date_format/date_format.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_pickers/pickers.dart';
|
||||
@ -7,7 +6,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.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/lockMian/entity/lockInfoEntity.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_logic.dart';
|
||||
import 'package:star_lock/network/api_repository.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import 'package:star_lock/tools/toast.dart';
|
||||
@ -27,60 +26,25 @@ class SendElectronicKeyPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> {
|
||||
final FlutterContactPicker _contactPicker = FlutterContactPicker();
|
||||
late Contact _contact;
|
||||
late KeyInfos keyInfo;
|
||||
late LockMainEntity lockMainEntity;
|
||||
|
||||
// final logic = Get.put(SendElectronicKeyLogic());
|
||||
// final state = Get.find<SendElectronicKeyLogic>().state;
|
||||
|
||||
bool _isRemoteUnlock = false; //是否允许远程开锁
|
||||
bool _isAuthentication = false; //是否可以实名认证
|
||||
String _selectEffectiveDate = ''; //生效时间
|
||||
String _selectFailureDate = ''; //失效时间
|
||||
late DateTime _effectiveDateTime;
|
||||
late DateTime _failureDateTime;
|
||||
TextEditingController emailOrPhoneController =
|
||||
TextEditingController(); //邮箱/手机号输入框
|
||||
TextEditingController keyNameController = TextEditingController(); //钥匙名输入框
|
||||
late bool _isSendSuccess;
|
||||
String countryName = '中国';
|
||||
String countryCode = '86';
|
||||
List weekdaysList = [];
|
||||
bool _isCreateUser = false; //用户未注册时传1 已注册传0
|
||||
final logic = Get.put(SendElectronicKeyLogic());
|
||||
final state = Get.find<SendElectronicKeyLogic>().state;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
DateTime dateTime = DateTime.now();
|
||||
_effectiveDateTime = dateTime;
|
||||
_failureDateTime = dateTime;
|
||||
_selectEffectiveDate = formatDate(
|
||||
dateTime, [yyyy, '-', mm, '-', dd, ' ', HH, ':', nn]); //默认为当前时间
|
||||
_selectFailureDate = formatDate(
|
||||
dateTime, [yyyy, '-', mm, '-', dd, ' ', HH, ':', nn]); //默认为当前时间
|
||||
_isSendSuccess = false;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
dynamic obj = ModalRoute.of(context)?.settings.arguments;
|
||||
if (obj != null && (obj["lockMainEntity"] != null)) {
|
||||
lockMainEntity = obj["lockMainEntity"];
|
||||
}
|
||||
if (obj != null && (obj["keyInfo"] != null)) {
|
||||
keyInfo = obj["keyInfo"];
|
||||
}
|
||||
state.type.value = widget.type;
|
||||
|
||||
return SingleChildScrollView(
|
||||
child: indexChangeWidget(),
|
||||
child: Obx(() => indexChangeWidget()),
|
||||
);
|
||||
}
|
||||
|
||||
Widget indexChangeWidget() {
|
||||
if (_isSendSuccess) {
|
||||
if (state.isSendSuccess.value == true) {
|
||||
return sendElectronicKeySucceed();
|
||||
} else {
|
||||
switch (int.parse(widget.type)) {
|
||||
@ -159,7 +123,7 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> {
|
||||
isHaveRightWidget: true,
|
||||
isHaveDirection: true,
|
||||
rightWidget: Text(
|
||||
'$countryName +$countryCode',
|
||||
'${state.countryName.value} +${state.countryCode.value}',
|
||||
textAlign: TextAlign.end,
|
||||
style:
|
||||
TextStyle(fontSize: 22.sp, color: AppColors.darkGrayTextColor),
|
||||
@ -167,10 +131,12 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> {
|
||||
action: () async {
|
||||
var result = await Navigator.pushNamed(
|
||||
context, Routers.seletCountryRegionPage);
|
||||
result as Map<String, dynamic>;
|
||||
countryCode = result['code'];
|
||||
countryName = result['countryName'];
|
||||
setState(() {});
|
||||
if (result != null) {
|
||||
result as Map<String, dynamic>;
|
||||
state.countryCode.value = result['code'];
|
||||
state.countryName.value = result['countryName'];
|
||||
setState(() {});
|
||||
}
|
||||
},
|
||||
),
|
||||
CommonItem(
|
||||
@ -190,30 +156,32 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> {
|
||||
children: [
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr,
|
||||
rightTitle: _selectEffectiveDate,
|
||||
rightTitle: state.selectEffectiveDate.value,
|
||||
isHaveLine: true,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
||||
onConfirm: (p) {
|
||||
setState(() {
|
||||
_selectEffectiveDate =
|
||||
state.selectEffectiveDate.value =
|
||||
'${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}';
|
||||
_effectiveDateTime = DateTime.parse(_selectEffectiveDate);
|
||||
state.effectiveDateTime.value =
|
||||
DateTime.parse(state.selectEffectiveDate.value);
|
||||
});
|
||||
});
|
||||
}),
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.failureTime!.tr,
|
||||
rightTitle: _selectFailureDate,
|
||||
rightTitle: state.selectFailureDate.value,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
||||
onConfirm: (p) {
|
||||
setState(() {
|
||||
_selectFailureDate =
|
||||
state.selectFailureDate.value =
|
||||
'${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}';
|
||||
_failureDateTime = DateTime.parse(_selectFailureDate);
|
||||
state.failureDateTime.value =
|
||||
DateTime.parse(state.selectFailureDate.value);
|
||||
});
|
||||
});
|
||||
}),
|
||||
@ -249,12 +217,12 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> {
|
||||
action: () async {
|
||||
var result = await Navigator.pushNamed(
|
||||
context, Routers.electronicKeyPeriodValidityPage);
|
||||
result as Map<String, dynamic>;
|
||||
weekdaysList = result['validityValue'];
|
||||
_effectiveDateTime = result['starDate'];
|
||||
_failureDateTime = result['endDate'];
|
||||
print(
|
||||
'得到的有效期数据:$weekdaysList $_effectiveDateTime $_failureDateTime');
|
||||
if (result != null) {
|
||||
result as Map<String, dynamic>;
|
||||
state.weekdaysList.value = result['validityValue'];
|
||||
state.effectiveDateTime.value = result['starDate'];
|
||||
state.failureDateTime.value = result['endDate'];
|
||||
}
|
||||
}),
|
||||
SizedBox(
|
||||
height: 10.h,
|
||||
@ -285,17 +253,19 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> {
|
||||
btnName: TranslationLoader.lanKeys!.send!.tr,
|
||||
onClick: () {
|
||||
//发送钥匙请求
|
||||
if (emailOrPhoneController.text.isNotEmpty &&
|
||||
keyNameController.text.isNotEmpty) {
|
||||
if (state.emailOrPhoneController.text.isNotEmpty &&
|
||||
state.keyNameController.text.isNotEmpty) {
|
||||
if (int.parse(widget.type) == 0) {
|
||||
//失效时间大于生效时间
|
||||
if (_failureDateTime.compareTo(_effectiveDateTime) == 1) {
|
||||
sendElectronicKeyRequest();
|
||||
if (state.failureDateTime.value
|
||||
.compareTo(state.effectiveDateTime.value) ==
|
||||
1) {
|
||||
logic.sendElectronicKeyRequest();
|
||||
} else {
|
||||
Toast.show(msg: '失效时间需大于生效时间');
|
||||
}
|
||||
} else {
|
||||
sendElectronicKeyRequest();
|
||||
logic.sendElectronicKeyRequest();
|
||||
}
|
||||
} else {
|
||||
Toast.show(msg: '请完善信息');
|
||||
@ -324,48 +294,6 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> {
|
||||
);
|
||||
}
|
||||
|
||||
//发送钥匙请求
|
||||
Future<void> sendElectronicKeyRequest() async {
|
||||
String getFailureDateTime = '0';
|
||||
String getEffectiveDateTime = '0';
|
||||
String lockID = keyInfo.lockId.toString();
|
||||
String getKeyType = (int.parse(widget.type) + 1).toString();
|
||||
if (widget.type == '0') {
|
||||
getFailureDateTime = _failureDateTime.millisecondsSinceEpoch.toString();
|
||||
getEffectiveDateTime =
|
||||
_effectiveDateTime.millisecondsSinceEpoch.toString();
|
||||
}
|
||||
var entity = await ApiRepository.to.sendElectronicKey(
|
||||
_isCreateUser ? "1" : "0",
|
||||
countryCode,
|
||||
'1',
|
||||
getFailureDateTime,
|
||||
_isAuthentication == true ? '1' : '2',
|
||||
'2',
|
||||
_isRemoteUnlock == true ? '1' : '2',
|
||||
keyNameController.text,
|
||||
'0',
|
||||
getKeyType,
|
||||
lockID,
|
||||
'',
|
||||
emailOrPhoneController.text,
|
||||
'',
|
||||
getEffectiveDateTime,
|
||||
weekdaysList);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
print('发送电子钥匙成功');
|
||||
_isSendSuccess = true;
|
||||
setState(() {});
|
||||
} else {
|
||||
Toast.show(msg: '${entity.errorMsg}');
|
||||
if (entity.errorCode == 425) {
|
||||
//用户未注册
|
||||
_isCreateUser = true;
|
||||
sendElectronicKeyRequest();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 发送电子钥匙成功
|
||||
Widget sendElectronicKeySucceed() {
|
||||
return Column(
|
||||
@ -408,7 +336,7 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> {
|
||||
SubmitBtn(
|
||||
btnName: '完成',
|
||||
onClick: () {
|
||||
_isSendSuccess = false;
|
||||
state.isSendSuccess.value = false;
|
||||
Navigator.pop(context, true);
|
||||
}),
|
||||
SizedBox(
|
||||
@ -443,7 +371,7 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> {
|
||||
//标记房间为已入住 isOn:已入住: 1 空闲:2
|
||||
Future<void> updateRoomCheckIn() async {
|
||||
var entity = await ApiRepository.to
|
||||
.updateSetting(keyInfo.lockId.toString(), '1', '13');
|
||||
.updateSetting(state.keyInfo.value.lockId.toString(), '1', '13');
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
print("标记为已入住成功啦啦啦啦啦");
|
||||
Toast.show(msg: "标记成功");
|
||||
@ -462,8 +390,9 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> {
|
||||
children: [
|
||||
Expanded(
|
||||
child: TextField(
|
||||
controller:
|
||||
lineIndex == 1 ? emailOrPhoneController : keyNameController,
|
||||
controller: lineIndex == 1
|
||||
? state.emailOrPhoneController
|
||||
: state.keyNameController,
|
||||
//输入框一行
|
||||
maxLines: 1,
|
||||
// controller: _controller,
|
||||
@ -496,9 +425,9 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> {
|
||||
child: InkWell(
|
||||
onTap: () async {
|
||||
Contact? currentContact =
|
||||
await _contactPicker.selectContact();
|
||||
await state.contactPicker.selectContact();
|
||||
setState(() {
|
||||
_contact = currentContact!;
|
||||
state.contact = currentContact!;
|
||||
// print("object111111111111 ${_contact.fullName} ${_contact.phoneNumbers}");
|
||||
});
|
||||
},
|
||||
@ -532,13 +461,14 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> {
|
||||
activeColor: CupertinoColors.activeBlue,
|
||||
trackColor: CupertinoColors.systemGrey5,
|
||||
thumbColor: CupertinoColors.white,
|
||||
value: isRemote ? _isRemoteUnlock : _isAuthentication,
|
||||
value:
|
||||
isRemote ? state.isRemoteUnlock.value : state.isAuthentication.value,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
if (isRemote) {
|
||||
_isRemoteUnlock = value;
|
||||
state.isRemoteUnlock.value = !state.isRemoteUnlock.value;
|
||||
} else {
|
||||
_isAuthentication = value;
|
||||
state.isAuthentication.value = !state.isAuthentication.value;
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
@ -1,29 +1,41 @@
|
||||
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/main/lockMian/entity/lockInfoEntity.dart';
|
||||
|
||||
class SendElectronicKeyState {
|
||||
// var emailOrPhone = ''.obs;
|
||||
// var keyName = ''.obs;
|
||||
// var effectiveDate = ''.obs; //生效时间
|
||||
// var failureDate = ''.obs; //失效时间
|
||||
// var isRemoteUnlock = false; //远程开锁
|
||||
// var isRealName = false; //实名认证
|
||||
// var keyType = '1'; //钥匙类型 限期1,永久2,单次3,循环4
|
||||
// var canNext = false.obs;
|
||||
TextEditingController emailOrPhoneController =
|
||||
TextEditingController(); //邮箱/手机号输入框
|
||||
TextEditingController keyNameController = TextEditingController(); //钥匙名输入框
|
||||
|
||||
// bool get isEmailOrPhoneOK => emailOrPhone.value.isNotEmpty;
|
||||
// bool get isKeyNameOK => keyName.value.isNotEmpty;
|
||||
final FlutterContactPicker contactPicker = FlutterContactPicker();
|
||||
late Contact contact;
|
||||
final keyInfo = KeyInfos().obs;
|
||||
final lockMainEntity = LockMainEntity().obs;
|
||||
|
||||
// TextEditingController emailOrPhoneController =
|
||||
// TextEditingController(); //邮箱/手机号输入框
|
||||
// TextEditingController keyNameController = TextEditingController(); //钥匙名输入框
|
||||
// SendElectronicKeyState() {
|
||||
// emailOrPhoneController.text = emailOrPhone.value;
|
||||
// keyNameController.text = keyName.value;
|
||||
// }
|
||||
final isRemoteUnlock = false.obs; //是否允许远程开锁
|
||||
final isAuthentication = false.obs; //是否可以实名认证
|
||||
DateTime dateTime = DateTime.now();
|
||||
final effectiveDateTime = DateTime.now().obs;
|
||||
final failureDateTime = DateTime.now().obs;
|
||||
|
||||
// void onClose() {
|
||||
// emailOrPhoneController.dispose();
|
||||
// keyNameController.dispose();
|
||||
// }
|
||||
var selectEffectiveDate =
|
||||
'${DateTime.now().year}-${DateTime.now().month}-${DateTime.now().day} ${DateTime.now().hour}:${DateTime.now().minute}'
|
||||
.obs; //默认为当前时间
|
||||
var selectFailureDate =
|
||||
'${DateTime.now().year}-${DateTime.now().month}-${DateTime.now().day} ${DateTime.now().hour}:${DateTime.now().minute}'
|
||||
.obs; //默认为当前时间
|
||||
|
||||
var type = ''.obs;
|
||||
var isSendSuccess = false.obs;
|
||||
var countryName = '中国'.obs;
|
||||
var countryCode = '86'.obs;
|
||||
var weekdaysList = [].obs;
|
||||
var isCreateUser = false.obs; //用户未注册时传1 已注册传0
|
||||
|
||||
SendElectronicKeyState() {
|
||||
Map map = Get.arguments;
|
||||
lockMainEntity.value = map["lockMainEntity"];
|
||||
keyInfo.value = map["keyInfo"];
|
||||
}
|
||||
}
|
||||
|
||||
@ -199,6 +199,7 @@ class _PasswordKeyDetailPageState extends State<PasswordKeyDetailPage> {
|
||||
padding: EdgeInsets.only(top: 25.w, bottom: 25.w),
|
||||
onClick: () {
|
||||
deletePwdRequest();
|
||||
Navigator.pop(context, true);
|
||||
}),
|
||||
],
|
||||
),
|
||||
@ -280,13 +281,9 @@ class _PasswordKeyDetailPageState extends State<PasswordKeyDetailPage> {
|
||||
//删除密码请求 deleteType:1-蓝牙 2-网关
|
||||
Future<void> deletePwdRequest() async {
|
||||
PasswordKeyEntity entity = await ApiRepository.to.deleteKeyboardPwd(
|
||||
itemData.lockId.toString(), itemData.keyboardPwdId.toString(), '1');
|
||||
itemData.lockId.toString(), itemData.keyboardPwdId.toString(), 1);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
print("删除密码成功");
|
||||
Toast.show(msg: "删除成功");
|
||||
setState(() {
|
||||
Navigator.pop(context);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -314,8 +311,9 @@ class _PasswordKeyDetailPageState extends State<PasswordKeyDetailPage> {
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return ShowTFView(
|
||||
title:
|
||||
"${TranslationLoader.lanKeys!.amend!.tr}${TranslationLoader.lanKeys!.name!.tr}",
|
||||
title: inputController == _inputNameController
|
||||
? "${TranslationLoader.lanKeys!.amend!.tr}${TranslationLoader.lanKeys!.name!.tr}"
|
||||
: "${TranslationLoader.lanKeys!.amend!.tr}${TranslationLoader.lanKeys!.password!.tr}",
|
||||
tipTitle: "请输入",
|
||||
controller: inputController,
|
||||
sureClick: () {
|
||||
@ -331,81 +329,4 @@ class _PasswordKeyDetailPageState extends State<PasswordKeyDetailPage> {
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
void showCupertinoAlertDialog(
|
||||
BuildContext context, TextEditingController inputController) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return Card(
|
||||
color: const Color(0x00FFFFFF),
|
||||
child: CupertinoAlertDialog(
|
||||
title: Text(
|
||||
"${TranslationLoader.lanKeys!.amend!.tr} ${TranslationLoader.lanKeys!.password!.tr}"),
|
||||
content: Column(
|
||||
children: <Widget>[
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Container(
|
||||
height: 80.h,
|
||||
// color: Colors.white,
|
||||
margin: EdgeInsets.all(10.w),
|
||||
child: TextField(
|
||||
controller: inputController,
|
||||
//输入框一行
|
||||
maxLines: 1,
|
||||
// controller: _controller,
|
||||
autofocus: false,
|
||||
decoration: InputDecoration(
|
||||
//输入里面输入文字内边距设置
|
||||
// contentPadding: const EdgeInsets.only(
|
||||
// top: 12.0, left: -19.0, right: -15.0, bottom: 8.0),
|
||||
hintText: TranslationLoader.lanKeys!.pleaseEnter!.tr,
|
||||
//不需要输入框下划线
|
||||
border: InputBorder.none,
|
||||
//左边图标设置
|
||||
// icon: Padding(
|
||||
// padding: EdgeInsets.only(top:30.w, bottom: 20.w, right: 20.w, left: 20.w),
|
||||
// child: Image.asset('images/main/icon_main_search.png', width: 40.w, height: 40.w,),
|
||||
// ),
|
||||
// //右边图标设置
|
||||
// suffixIcon: GestureDetector(
|
||||
// onTap: () {
|
||||
// //addPostFrameCallback是 StatefulWidge 渲染结束的回调,只会被调用一次
|
||||
// // SchedulerBinding.instance.addPostFrameCallback((_) {
|
||||
// // _controller.text = "";
|
||||
// // });
|
||||
// },
|
||||
// child: Padding(
|
||||
// padding: EdgeInsets.all(8),
|
||||
// child: Image.asset('images/main/icon_main_cell.png', width: 50.w, height: 50.w,),
|
||||
// ),
|
||||
// )
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
actions: <Widget>[
|
||||
CupertinoDialogAction(
|
||||
child: Text(TranslationLoader.lanKeys!.cancel!.tr),
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
child: Text(TranslationLoader.lanKeys!.sure!.tr),
|
||||
onPressed: () {
|
||||
updatePwdRequest();
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
@ -0,0 +1,56 @@
|
||||
import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyListEntity.dart';
|
||||
import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_state.dart';
|
||||
import 'package:star_lock/network/api_repository.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import 'package:star_lock/tools/toast.dart';
|
||||
|
||||
class PasswordKeyListLogic extends BaseGetXController {
|
||||
final PasswordKeyListState state = PasswordKeyListState();
|
||||
|
||||
//请求密码钥匙列表
|
||||
Future<List<PasswordKeyListItem>> mockNetworkDataRequest() async {
|
||||
PasswordKeyListEntity entity = await ApiRepository.to.passwordKeyList(
|
||||
'0',
|
||||
state.keyInfo.value.lockId.toString(),
|
||||
'0',
|
||||
state.pageNum.toString(),
|
||||
state.pageSize.toString());
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
print("密码钥匙列表成功:${entity.data?.itemList}");
|
||||
}
|
||||
if (entity.data != null) {
|
||||
return entity.data!.itemList!;
|
||||
} else {
|
||||
List<PasswordKeyListItem> dataList = [];
|
||||
return dataList;
|
||||
}
|
||||
}
|
||||
|
||||
//密码钥匙重置请求
|
||||
Future<void> resetPasswordKeyListRequest() async {
|
||||
PasswordKeyListEntity entity = await ApiRepository.to
|
||||
.keyboardPwdReset(state.keyInfo.value.lockId.toString());
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
print("重置电子钥匙成功啦啦啦啦啦");
|
||||
Toast.show(msg: "重置成功");
|
||||
mockNetworkDataRequest();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
// TODO: implement onReady
|
||||
super.onReady();
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
// TODO: implement onInit
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
// TODO: implement onClose
|
||||
}
|
||||
}
|
||||
@ -1,12 +1,11 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:pull_to_refresh/pull_to_refresh.dart';
|
||||
import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyListEntity.dart';
|
||||
import 'package:star_lock/main/lockMian/entity/lockInfoEntity.dart';
|
||||
import 'package:star_lock/network/api_repository.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import 'package:star_lock/tools/toast.dart';
|
||||
|
||||
import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_logic.dart';
|
||||
import 'package:star_lock/tools/noData.dart';
|
||||
import '../../../../appRouters.dart';
|
||||
import '../../../../app_settings/app_colors.dart';
|
||||
import '../../../../tools/submitBtn.dart';
|
||||
@ -21,18 +20,20 @@ class PasswordKeyListPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _PasswordKeyListPageState extends State<PasswordKeyListPage> {
|
||||
late KeyInfos keyInfo;
|
||||
late LockMainEntity lockMainEntity;
|
||||
final logic = Get.put(PasswordKeyListLogic());
|
||||
final state = Get.find<PasswordKeyListLogic>().state;
|
||||
late List<PasswordKeyListItem> _itemDataList = [];
|
||||
|
||||
late RefreshController _refreshController;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_refreshController = RefreshController(initialRefresh: true);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
dynamic obj = ModalRoute.of(context)?.settings.arguments;
|
||||
if (obj != null && (obj["lockMainEntity"] != null)) {
|
||||
lockMainEntity = obj["lockMainEntity"];
|
||||
}
|
||||
if (obj != null && (obj["keyInfo"] != null)) {
|
||||
keyInfo = obj["keyInfo"];
|
||||
}
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.mainBackgroundColor,
|
||||
appBar: TitleAppBar(
|
||||
@ -46,13 +47,13 @@ class _PasswordKeyListPageState extends State<PasswordKeyListPage> {
|
||||
style: TextStyle(color: Colors.white, fontSize: 24.sp),
|
||||
),
|
||||
onPressed: () {
|
||||
resetPasswordKeyListRequest();
|
||||
showCupertinoDialogStyle();
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
body: FutureBuilder<List<PasswordKeyListItem>>(
|
||||
future: mockNetworkDataRequest(),
|
||||
future: logic.mockNetworkDataRequest(),
|
||||
builder: (BuildContext context,
|
||||
AsyncSnapshot<List<PasswordKeyListItem>> snapshot) {
|
||||
//请求结束
|
||||
@ -62,7 +63,7 @@ class _PasswordKeyListPageState extends State<PasswordKeyListPage> {
|
||||
return const Text('请求失败');
|
||||
} else {
|
||||
//请求成功
|
||||
final List<PasswordKeyListItem> itemData = snapshot.data!;
|
||||
_itemDataList = snapshot.data!;
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
@ -70,7 +71,25 @@ class _PasswordKeyListPageState extends State<PasswordKeyListPage> {
|
||||
SizedBox(
|
||||
height: 20.h,
|
||||
),
|
||||
Expanded(child: _buildMainUI(itemData)),
|
||||
Expanded(
|
||||
child: _itemDataList.isEmpty
|
||||
? const NoData()
|
||||
: SmartRefresher(
|
||||
controller: _refreshController,
|
||||
onRefresh: _refresh,
|
||||
onLoading: _loadMore,
|
||||
enablePullUp: true,
|
||||
enablePullDown: true,
|
||||
header: ClassicHeader(
|
||||
height: 45.h,
|
||||
releaseText: '松开手刷新',
|
||||
refreshingText: '刷新中',
|
||||
completeText: '刷新完成',
|
||||
failedText: '刷新失败',
|
||||
idleText: '下拉刷新',
|
||||
),
|
||||
child: _buildMainUI(_itemDataList),
|
||||
)),
|
||||
SizedBox(
|
||||
height: 20.h,
|
||||
),
|
||||
@ -80,11 +99,11 @@ class _PasswordKeyListPageState extends State<PasswordKeyListPage> {
|
||||
Navigator.pushNamed(
|
||||
context, Routers.passwordKeyManagePage,
|
||||
arguments: {
|
||||
"lockMainEntity": lockMainEntity,
|
||||
"keyInfo": keyInfo
|
||||
"lockMainEntity": state.lockMainEntity.value,
|
||||
"keyInfo": state.keyInfo.value
|
||||
}).then((val) {
|
||||
if (val != null) {
|
||||
mockNetworkDataRequest();
|
||||
logic.mockNetworkDataRequest();
|
||||
setState(() {});
|
||||
}
|
||||
});
|
||||
@ -103,31 +122,28 @@ class _PasswordKeyListPageState extends State<PasswordKeyListPage> {
|
||||
);
|
||||
}
|
||||
|
||||
//请求密码钥匙列表
|
||||
Future<List<PasswordKeyListItem>> mockNetworkDataRequest() async {
|
||||
PasswordKeyListEntity entity = await ApiRepository.to
|
||||
.passwordKeyList('0', keyInfo.lockId.toString(), '0', '1', '20');
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
print("密码钥匙列表成功:${entity.data?.itemList}");
|
||||
}
|
||||
if (entity.data != null) {
|
||||
return entity.data!.itemList!;
|
||||
///加载更多函数
|
||||
Future<void> _loadMore() async {
|
||||
if (state.pageNum.value == 1) {
|
||||
if (_itemDataList.length < 10) {
|
||||
_refreshController.loadComplete();
|
||||
} else {
|
||||
state.pageNum.value++;
|
||||
await logic.mockNetworkDataRequest();
|
||||
_refreshController.loadComplete();
|
||||
}
|
||||
} else {
|
||||
List<PasswordKeyListItem> dataList = [];
|
||||
return dataList;
|
||||
state.pageNum.value++;
|
||||
await logic.mockNetworkDataRequest();
|
||||
_refreshController.loadComplete();
|
||||
}
|
||||
}
|
||||
|
||||
//密码钥匙重置请求
|
||||
Future<void> resetPasswordKeyListRequest() async {
|
||||
PasswordKeyListEntity entity =
|
||||
await ApiRepository.to.resetPasswordKey(keyInfo.lockId.toString(), '0');
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
print("重置电子钥匙成功啦啦啦啦啦");
|
||||
Toast.show(msg: "重置成功");
|
||||
mockNetworkDataRequest();
|
||||
setState(() {});
|
||||
}
|
||||
///刷新函数
|
||||
Future<void> _refresh() async {
|
||||
state.pageNum.value = 1;
|
||||
await logic.mockNetworkDataRequest();
|
||||
_refreshController.refreshCompleted();
|
||||
}
|
||||
|
||||
Widget _searchWidget() {
|
||||
@ -300,4 +316,47 @@ class _PasswordKeyListPageState extends State<PasswordKeyListPage> {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void showCupertinoDialogStyle() async {
|
||||
var result = await showCupertinoDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return CupertinoAlertDialog(
|
||||
title: const Text(''),
|
||||
content: Text(
|
||||
"该锁的密码钥匙都将被删除",
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 24.sp,
|
||||
fontWeight: FontWeight.w700),
|
||||
),
|
||||
actions: <Widget>[
|
||||
CupertinoButton(
|
||||
child: Text(
|
||||
"取消",
|
||||
style: TextStyle(
|
||||
color: Colors.blue,
|
||||
fontSize: 24.sp,
|
||||
fontWeight: FontWeight.w600),
|
||||
),
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
CupertinoButton(
|
||||
child: Text(
|
||||
"重置",
|
||||
style: TextStyle(
|
||||
color: Colors.blue,
|
||||
fontSize: 24.sp,
|
||||
fontWeight: FontWeight.w600),
|
||||
),
|
||||
onPressed: () {
|
||||
logic.resetPasswordKeyListRequest();
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,15 @@
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/main/lockMian/entity/lockInfoEntity.dart';
|
||||
|
||||
class PasswordKeyListState {
|
||||
final keyInfo = KeyInfos().obs;
|
||||
final lockMainEntity = LockMainEntity().obs;
|
||||
var pageNum = 1.obs; //请求页码
|
||||
final pageSize = 20.obs; //请求每页数据条数
|
||||
|
||||
PasswordKeyListState() {
|
||||
Map map = Get.arguments;
|
||||
lockMainEntity.value = map["lockMainEntity"];
|
||||
keyInfo.value = map["keyInfo"];
|
||||
}
|
||||
}
|
||||
@ -353,7 +353,7 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> {
|
||||
btnName: TranslationLoader.lanKeys!.getPassword!.tr,
|
||||
onClick: () {
|
||||
// logic.senderCustomPasswords();
|
||||
|
||||
|
||||
/*
|
||||
int getWidgetNumber = int.parse(widget.type);
|
||||
|
||||
@ -429,7 +429,7 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> {
|
||||
//清空码
|
||||
getKeyType = '4';
|
||||
}
|
||||
if (widget.type != '0' || widget.type != '2' || widget.type != '5') {
|
||||
if (widget.type != '0' && widget.type != '2' && widget.type != '5') {
|
||||
getFailureDateTime =
|
||||
DateTime.parse(_selectFailureDate).millisecondsSinceEpoch.toString();
|
||||
getEffectiveDateTime = DateTime.parse(_selectEffectiveDate)
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
@ -26,13 +25,11 @@ class StarLockMainPage extends StatefulWidget {
|
||||
|
||||
// GlobalKey<_StarLockMainPageState> starLockMainKey = GlobalKey();
|
||||
class _StarLockMainPageState extends State<StarLockMainPage> with BaseWidget {
|
||||
|
||||
final logic = Get.put(LockMainLogic());
|
||||
final state = Get.find<LockMainLogic>().state;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: const Color(0xFFF5F5F5),
|
||||
appBar: TitleAppBar(
|
||||
@ -77,17 +74,21 @@ class _StarLockMainPageState extends State<StarLockMainPage> with BaseWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget getDataReturnUI(int type){
|
||||
Widget getDataReturnUI(int type) {
|
||||
Widget returnWidget;
|
||||
switch(type){
|
||||
switch (type) {
|
||||
case 0:
|
||||
returnWidget = unHaveData();
|
||||
break;
|
||||
break;
|
||||
case 1:
|
||||
returnWidget = LockDetailPage(lockMainEntity: logic.state.lockMainEntity.value, isFrist: true, keyInfo:logic.state.lockMainEntity.value.data!.keyInfos![0]);
|
||||
returnWidget = LockDetailPage(
|
||||
lockMainEntity: logic.state.lockMainEntity.value,
|
||||
isFrist: true,
|
||||
keyInfo: logic.state.lockMainEntity.value.data!.keyInfos![0]);
|
||||
break;
|
||||
case 2:
|
||||
returnWidget = LockListPage(lockMainEntity:logic.state.lockMainEntity.value);
|
||||
returnWidget =
|
||||
LockListPage(lockMainEntity: logic.state.lockMainEntity.value);
|
||||
break;
|
||||
default:
|
||||
returnWidget = unHaveData();
|
||||
@ -104,7 +105,7 @@ class _StarLockMainPageState extends State<StarLockMainPage> with BaseWidget {
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
width: 330.w,
|
||||
width: 330.w,
|
||||
height: 330.w,
|
||||
// decoration: BoxDecoration(
|
||||
// border: Border.all(width: 4.w, color: AppColors.mainColor),
|
||||
|
||||
@ -265,7 +265,7 @@ class SaveLockLogic extends BaseGetXController {
|
||||
deviceNo:"123456",
|
||||
// lockUserNo:userNo.toString(),
|
||||
lockUserNo:"1234",
|
||||
pwdTimestamp:"11223344"
|
||||
pwdTimestamp:DateTime.now().millisecondsSinceEpoch.toString()
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
eventBus.fire(RefreshLockListInfoDataEvent());
|
||||
|
||||
88
star_lock/lib/mine/mine/safeVerify/safeVerify_logic.dart
Normal file
88
star_lock/lib/mine/mine/safeVerify/safeVerify_logic.dart
Normal file
@ -0,0 +1,88 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:get/get_core/src/get_main.dart';
|
||||
import 'package:get/get_navigation/src/extension_navigation.dart';
|
||||
import 'package:get/get_utils/get_utils.dart';
|
||||
import 'package:star_lock/appRouters.dart';
|
||||
import 'package:star_lock/login/login/entity/LoginEntity.dart';
|
||||
import 'package:star_lock/mine/mine/safeVerify/safeVerify_state.dart';
|
||||
import 'package:star_lock/network/api_repository.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import 'package:star_lock/tools/toast.dart';
|
||||
|
||||
class SafeVerifyLogic extends BaseGetXController {
|
||||
final SafeVerifyState state = SafeVerifyState();
|
||||
|
||||
late Timer _timer;
|
||||
void _startTimer() {
|
||||
_timer = Timer.periodic(1.seconds, (timer) {
|
||||
if (state.currentSecond > 1) {
|
||||
state.currentSecond--;
|
||||
} else {
|
||||
_cancelTimer();
|
||||
state.currentSecond = state.totalSeconds;
|
||||
}
|
||||
state.resetResend();
|
||||
});
|
||||
}
|
||||
|
||||
void _cancelTimer() {
|
||||
_timer.cancel();
|
||||
}
|
||||
|
||||
//获取验证码请求
|
||||
void sendValidationCode() async {
|
||||
var entity = await ApiRepository.to.sendValidationCode(
|
||||
"+86",
|
||||
state.loginData.value.mobile!,
|
||||
'1',
|
||||
state.codeType.value,
|
||||
"B748F838-94EE-4BDB-A0E6-7B2D16849792",
|
||||
state.xWidth.value.toString());
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
_startTimer();
|
||||
} else {}
|
||||
}
|
||||
|
||||
//删除账号请求
|
||||
Future<void> userLogoutRequest() async {
|
||||
LoginEntity entity = await ApiRepository.to.userLogout();
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
Toast.show(msg: '验证成功,账号已删除');
|
||||
//删除账号成功,
|
||||
Get.offNamedUntil(Routers.starLockLoginPage, (route) => false);
|
||||
}
|
||||
}
|
||||
|
||||
void checkNext(TextEditingController controller) {
|
||||
changeInput(controller);
|
||||
}
|
||||
|
||||
void changeInput(TextEditingController controller) {
|
||||
if (controller == state.codeController) {
|
||||
state.verificationCode.value = controller.text;
|
||||
}
|
||||
_resetCanSub();
|
||||
}
|
||||
|
||||
void _resetCanSub() {
|
||||
state.canSub.value = state.codeIsOK;
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
super.onReady();
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
state.initLoginData();
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
super.onClose();
|
||||
}
|
||||
}
|
||||
101
star_lock/lib/mine/mine/safeVerify/safeVerify_page.dart
Normal file
101
star_lock/lib/mine/mine/safeVerify/safeVerify_page.dart
Normal file
@ -0,0 +1,101 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/app_settings/app_colors.dart';
|
||||
import 'package:star_lock/mine/mine/safeVerify/safeVerify_logic.dart';
|
||||
import 'package:star_lock/tools/submitBtn.dart';
|
||||
import 'package:star_lock/tools/titleAppBar.dart';
|
||||
import 'package:star_lock/translations/trans_lib.dart';
|
||||
|
||||
class SafeVerifyPage extends StatefulWidget {
|
||||
const SafeVerifyPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<SafeVerifyPage> createState() => _SafeVerifyPageState();
|
||||
}
|
||||
|
||||
class _SafeVerifyPageState extends State<SafeVerifyPage> {
|
||||
final logic = Get.put(SafeVerifyLogic());
|
||||
final state = Get.find<SafeVerifyLogic>().state;
|
||||
String mobilePhone = '';
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
backgroundColor: const Color(0xFFFFFFFF),
|
||||
appBar: TitleAppBar(
|
||||
barTitle: TranslationLoader.lanKeys!.safeVerify!.tr,
|
||||
haveBack: true,
|
||||
backgroundColor: AppColors.mainColor),
|
||||
body: safeVerifyColumn());
|
||||
}
|
||||
|
||||
Widget safeVerifyColumn() {
|
||||
return Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 60.h,
|
||||
),
|
||||
Container(
|
||||
margin: EdgeInsets.only(left: 60.w, right: 60.w),
|
||||
height: 60.h,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white, borderRadius: BorderRadius.circular(30.w)),
|
||||
child: TextField(
|
||||
//输入框一行
|
||||
maxLines: 1,
|
||||
controller: state.codeController,
|
||||
autofocus: false,
|
||||
decoration: InputDecoration(
|
||||
contentPadding:
|
||||
const EdgeInsets.only(left: 5, top: -8, bottom: 6),
|
||||
hintText: TranslationLoader.lanKeys!.pleaseEnter!.tr,
|
||||
hintStyle: TextStyle(fontSize: 22.sp, height: 1.0),
|
||||
//不需要输入框下划线
|
||||
border: const OutlineInputBorder(),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 30.h,
|
||||
),
|
||||
SizedBox(
|
||||
width: 200.w,
|
||||
child: SubmitBtn(
|
||||
btnName: TranslationLoader.lanKeys!.getVerificationCode!.tr,
|
||||
onClick: () {
|
||||
logic.sendValidationCode();
|
||||
},
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 60.h,
|
||||
),
|
||||
Obx(() => Padding(
|
||||
padding: EdgeInsets.only(left: 60.w, right: 60.w),
|
||||
child: Text(
|
||||
'请点击获取验证码,验证码将发送到${state.loginData.value.mobile}',
|
||||
style: TextStyle(
|
||||
color: AppColors.darkGrayTextColor, fontSize: 22.sp),
|
||||
),
|
||||
)),
|
||||
SizedBox(
|
||||
height: 120.h,
|
||||
),
|
||||
Obx(() => SubmitBtn(
|
||||
btnName: '验证',
|
||||
isDisabled: state.canSub.value,
|
||||
onClick: () {
|
||||
logic.userLogoutRequest();
|
||||
},
|
||||
))
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
60
star_lock/lib/mine/mine/safeVerify/safeVerify_state.dart
Normal file
60
star_lock/lib/mine/mine/safeVerify/safeVerify_state.dart
Normal file
@ -0,0 +1,60 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/login/login/entity/LoginData.dart';
|
||||
import 'package:star_lock/login/seletCountryRegion/common/index.dart';
|
||||
import 'package:star_lock/tools/storage.dart';
|
||||
import 'package:star_lock/translations/trans_lib.dart';
|
||||
|
||||
class SafeVerifyState {
|
||||
final TextEditingController codeController = TextEditingController();
|
||||
|
||||
static int currentTimeMillis() {
|
||||
return DateTime.now().millisecondsSinceEpoch;
|
||||
}
|
||||
|
||||
var countryCode = '+86'.obs;
|
||||
var countryId = '9'.obs;
|
||||
var codeType = '5'.obs;
|
||||
var verificationCode = ''.obs;
|
||||
var xWidth = ''.obs; // 滑动验证码滑动位置
|
||||
var canSub = false.obs;
|
||||
var date = currentTimeMillis().toString().obs;
|
||||
|
||||
bool get codeIsOK => verificationCode.value.isNotEmpty;
|
||||
|
||||
var canResend = false.obs;
|
||||
var btnText = ''.obs;
|
||||
var totalSeconds = 120;
|
||||
var currentSecond = 120;
|
||||
|
||||
final loginData = LoginData().obs;
|
||||
|
||||
///本地存储 登录信息
|
||||
void saveLoginData(LoginData? data) async {
|
||||
print("saveLoginData:${data!.mobile}");
|
||||
await Storage.setString('userLoginData', jsonEncode(data));
|
||||
loginData.value = data;
|
||||
}
|
||||
|
||||
///初始化本地数据
|
||||
void initLoginData() async {
|
||||
final data = await Storage.getString('userLoginData');
|
||||
print("getLoginData:$data");
|
||||
if (data != null && data.isNotEmpty) {
|
||||
loginData.value = LoginData.fromJson(jsonDecode(data));
|
||||
}
|
||||
}
|
||||
|
||||
SafeVerifyState() {
|
||||
resetResend();
|
||||
}
|
||||
|
||||
void resetResend() {
|
||||
canResend.value = totalSeconds == currentSecond;
|
||||
btnText.value = !canResend.value
|
||||
? '$currentSecond s'
|
||||
: btnText.value = TranslationLoader.lanKeys!.getVerificationCode!.tr;
|
||||
}
|
||||
|
||||
void onClose() {}
|
||||
}
|
||||
@ -1,9 +1,18 @@
|
||||
import 'package:star_lock/login/login/entity/LoginEntity.dart';
|
||||
import 'package:star_lock/network/api_repository.dart';
|
||||
|
||||
import '../../tools/baseGetXController.dart';
|
||||
import 'starLockMine_state.dart';
|
||||
|
||||
class StarLockMineLogic extends BaseGetXController {
|
||||
final StarLockMineState state = StarLockMineState();
|
||||
|
||||
//删除账号请求
|
||||
Future<void> userLogoutRequest() async {
|
||||
LoginEntity entity = await ApiRepository.to.userLogout();
|
||||
if (entity.errorCode!.codeIsSuccessful) {}
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
print("ready home");
|
||||
@ -23,5 +32,4 @@ class StarLockMineLogic extends BaseGetXController {
|
||||
print("close home");
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -272,10 +272,12 @@ class _AddAuthorizedAdministratorPageState
|
||||
action: () async {
|
||||
var result = await Navigator.pushNamed(
|
||||
context, Routers.seletCountryRegionPage);
|
||||
result as Map<String, dynamic>;
|
||||
countryCode = result['code'];
|
||||
countryName = result['countryName'];
|
||||
setState(() {});
|
||||
if (result != null) {
|
||||
result as Map<String, dynamic>;
|
||||
countryCode = result['code'];
|
||||
countryName = result['countryName'];
|
||||
setState(() {});
|
||||
}
|
||||
},
|
||||
),
|
||||
CommonItem(
|
||||
|
||||
@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/mine/mineSet/mineSet/mineSet_logic.dart';
|
||||
import 'package:star_lock/tools/showIosTipView.dart';
|
||||
import '../../../appRouters.dart';
|
||||
import '../../../app_settings/app_colors.dart';
|
||||
import '../../../tools/commonItem.dart';
|
||||
@ -240,7 +241,9 @@ class _MineSetPageState extends State<MineSetPage> {
|
||||
style: TextStyle(
|
||||
color: AppColors.darkGrayTextColor, fontSize: 18.sp),
|
||||
),
|
||||
onPressed: () {},
|
||||
onPressed: () {
|
||||
showCupertinoAlertDialog(context);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
@ -252,6 +255,25 @@ class _MineSetPageState extends State<MineSetPage> {
|
||||
);
|
||||
}
|
||||
|
||||
void showCupertinoAlertDialog(BuildContext context) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return ShowIosTipView(
|
||||
title: "",
|
||||
tipTitle: TranslationLoader.lanKeys!.deleteAccountTips!.tr,
|
||||
sureClick: () {
|
||||
//安全验证
|
||||
Navigator.pushNamed(context, Routers.safeVerifyPage);
|
||||
},
|
||||
cancelClick: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
CupertinoSwitch _isPrompToneSwitch() {
|
||||
return CupertinoSwitch(
|
||||
activeColor: CupertinoColors.activeBlue,
|
||||
|
||||
@ -45,7 +45,9 @@ class _RecipientInformationPageState extends State<RecipientInformationPage> {
|
||||
Visibility(
|
||||
visible: state.isFromType.value == 2 ? true : false,
|
||||
child: _buildRemoveBadLockBtn()),
|
||||
SizedBox(height: 64.h,)
|
||||
SizedBox(
|
||||
height: 64.h,
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
@ -53,19 +55,27 @@ class _RecipientInformationPageState extends State<RecipientInformationPage> {
|
||||
|
||||
Widget _buildMainUI() {
|
||||
return Obx(() => Column(
|
||||
children: [
|
||||
_electronicKeyItem(state.type.value == 1 ? 'images/select_circle.png' : 'images/normal_circle.png', "个人用户", () {
|
||||
setState(() {
|
||||
state.type.value = 1;
|
||||
});
|
||||
}),
|
||||
_electronicKeyItem(state.type.value == 2 ? 'images/select_circle.png' : 'images/normal_circle.png', "星寓", () {
|
||||
setState(() {
|
||||
state.type.value = 2;
|
||||
});
|
||||
})
|
||||
],
|
||||
));
|
||||
children: [
|
||||
_electronicKeyItem(
|
||||
state.type.value == 1
|
||||
? 'images/select_circle.png'
|
||||
: 'images/normal_circle.png',
|
||||
"个人用户", () {
|
||||
setState(() {
|
||||
state.type.value = 1;
|
||||
});
|
||||
}),
|
||||
_electronicKeyItem(
|
||||
state.type.value == 2
|
||||
? 'images/select_circle.png'
|
||||
: 'images/normal_circle.png',
|
||||
"星寓", () {
|
||||
setState(() {
|
||||
state.type.value = 2;
|
||||
});
|
||||
})
|
||||
],
|
||||
));
|
||||
}
|
||||
|
||||
Widget _electronicKeyItem(
|
||||
@ -110,26 +120,39 @@ class _RecipientInformationPageState extends State<RecipientInformationPage> {
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
SizedBox(width: 40.w,),
|
||||
Text('账号', style: TextStyle(color: AppColors.darkGrayTextColor, fontSize: 22.sp)),
|
||||
SizedBox(
|
||||
width: 40.w,
|
||||
),
|
||||
Text('账号',
|
||||
style: TextStyle(
|
||||
color: AppColors.darkGrayTextColor, fontSize: 22.sp)),
|
||||
Expanded(
|
||||
child: TextField(
|
||||
controller: state.numberController,
|
||||
textAlign: TextAlign.right,
|
||||
keyboardType: TextInputType.text,
|
||||
onChanged: (value) {},
|
||||
decoration: InputDecoration(
|
||||
border: InputBorder.none,
|
||||
hintText: state.type.value == 1 ? "请输入手机号或email" : "请输入星寓管理员的账号",
|
||||
hintStyle: TextStyle(
|
||||
color: AppColors.placeholderTextColor,
|
||||
fontSize: ScreenUtil().setSp(22),
|
||||
textBaseline: TextBaseline.alphabetic),
|
||||
),
|
||||
controller: state.numberController,
|
||||
textAlign: TextAlign.right,
|
||||
keyboardType: TextInputType.text,
|
||||
onChanged: (value) {},
|
||||
decoration: InputDecoration(
|
||||
border: InputBorder.none,
|
||||
hintText:
|
||||
state.type.value == 1 ? "请输入手机号或email" : "请输入星寓管理员的账号",
|
||||
hintStyle: TextStyle(
|
||||
color: AppColors.placeholderTextColor,
|
||||
fontSize: ScreenUtil().setSp(22),
|
||||
textBaseline: TextBaseline.alphabetic),
|
||||
),
|
||||
)),
|
||||
SizedBox(width: 20.w,),
|
||||
Image.asset('images/icon_addressBook.png', width: 28.w, height: 28.h,),
|
||||
SizedBox(width: 40.w,)
|
||||
SizedBox(
|
||||
width: 20.w,
|
||||
),
|
||||
Image.asset(
|
||||
'images/icon_addressBook.png',
|
||||
width: 28.w,
|
||||
height: 28.h,
|
||||
),
|
||||
SizedBox(
|
||||
width: 40.w,
|
||||
)
|
||||
],
|
||||
),
|
||||
Divider(
|
||||
@ -147,16 +170,18 @@ class _RecipientInformationPageState extends State<RecipientInformationPage> {
|
||||
rightWidget: Text(
|
||||
'${state.countryName.value} +${state.countryCode.value}',
|
||||
textAlign: TextAlign.end,
|
||||
style:
|
||||
TextStyle(fontSize: 22.sp, color: AppColors.darkGrayTextColor),
|
||||
style: TextStyle(
|
||||
fontSize: 22.sp, color: AppColors.darkGrayTextColor),
|
||||
),
|
||||
action: () async {
|
||||
var result = await Navigator.pushNamed(
|
||||
context, Routers.seletCountryRegionPage);
|
||||
result as Map<String, dynamic>;
|
||||
state.countryCode.value = result['code'];
|
||||
state.countryName.value = result['countryName'];
|
||||
setState(() {});
|
||||
if (result != null) {
|
||||
result as Map<String, dynamic>;
|
||||
state.countryCode.value = result['code'];
|
||||
state.countryName.value = result['countryName'];
|
||||
setState(() {});
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
@ -177,41 +202,43 @@ class _RecipientInformationPageState extends State<RecipientInformationPage> {
|
||||
}
|
||||
|
||||
Widget _buildNextBtn(BuildContext context) {
|
||||
return SubmitBtn(btnName: '下一步', onClick: () {
|
||||
if(state.numberController.text.isEmpty){
|
||||
Toast.show(msg: "请输入手机号或email");
|
||||
return;
|
||||
}
|
||||
if(state.isFromType.value == 1){
|
||||
// 转移智能锁
|
||||
if(state.type.value == 1){
|
||||
logic.transferLockConfirmInfoData((v){
|
||||
showCupertinoAlertDialog(context, v);
|
||||
});
|
||||
}else{
|
||||
Get.toNamed(Routers.selectBranchPage, arguments: {
|
||||
"idList":state.idList.value,
|
||||
"countryCode":state.countryCode.value,
|
||||
"number":state.numberController.text,
|
||||
"isFromType":state.isFromType.value,
|
||||
});
|
||||
}
|
||||
}else{
|
||||
// 转移网关
|
||||
if(state.type.value == 1){
|
||||
logic.transferGateWayConfirmInfoData((v){
|
||||
showCupertinoAlertDialog(context, v);
|
||||
});
|
||||
}else{
|
||||
Get.toNamed(Routers.selectBranchPage, arguments: {
|
||||
"idList":state.idList.value,
|
||||
"countryCode":state.countryCode.value,
|
||||
"number":state.numberController.text,
|
||||
"isFromType":state.isFromType.value
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
return SubmitBtn(
|
||||
btnName: '下一步',
|
||||
onClick: () {
|
||||
if (state.numberController.text.isEmpty) {
|
||||
Toast.show(msg: "请输入手机号或email");
|
||||
return;
|
||||
}
|
||||
if (state.isFromType.value == 1) {
|
||||
// 转移智能锁
|
||||
if (state.type.value == 1) {
|
||||
logic.transferLockConfirmInfoData((v) {
|
||||
showCupertinoAlertDialog(context, v);
|
||||
});
|
||||
} else {
|
||||
Get.toNamed(Routers.selectBranchPage, arguments: {
|
||||
"idList": state.idList.value,
|
||||
"countryCode": state.countryCode.value,
|
||||
"number": state.numberController.text,
|
||||
"isFromType": state.isFromType.value,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// 转移网关
|
||||
if (state.type.value == 1) {
|
||||
logic.transferGateWayConfirmInfoData((v) {
|
||||
showCupertinoAlertDialog(context, v);
|
||||
});
|
||||
} else {
|
||||
Get.toNamed(Routers.selectBranchPage, arguments: {
|
||||
"idList": state.idList.value,
|
||||
"countryCode": state.countryCode.value,
|
||||
"number": state.numberController.text,
|
||||
"isFromType": state.isFromType.value
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Widget _buildRemoveBadLockBtn() {
|
||||
@ -219,30 +246,35 @@ class _RecipientInformationPageState extends State<RecipientInformationPage> {
|
||||
children: [
|
||||
const Expanded(child: SizedBox()),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
|
||||
},
|
||||
child: Text('移除坏锁', style: TextStyle(fontSize: 22.sp, color: AppColors.darkGrayTextColor), textAlign: TextAlign.end,)),
|
||||
SizedBox(width: 10.h,)
|
||||
onPressed: () {},
|
||||
child: Text(
|
||||
'移除坏锁',
|
||||
style: TextStyle(
|
||||
fontSize: 22.sp, color: AppColors.darkGrayTextColor),
|
||||
textAlign: TextAlign.end,
|
||||
)),
|
||||
SizedBox(
|
||||
width: 10.h,
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
// 点击确认
|
||||
void showCupertinoAlertDialog(BuildContext context, RecipientInformationData recipientInformationData) {
|
||||
void showCupertinoAlertDialog(
|
||||
BuildContext context, RecipientInformationData recipientInformationData) {
|
||||
showGeneralDialog(
|
||||
context: context,
|
||||
barrierColor: Colors.black.withOpacity(.5),
|
||||
barrierDismissible: true,
|
||||
barrierLabel: '',
|
||||
transitionDuration: const Duration(milliseconds: 200),
|
||||
transitionBuilder: (BuildContext context,
|
||||
Animation<double> animation,
|
||||
Animation<double> secondaryAnimation,
|
||||
Widget child) {
|
||||
transitionBuilder: (BuildContext context, Animation<double> animation,
|
||||
Animation<double> secondaryAnimation, Widget child) {
|
||||
return ScaleTransition(scale: animation, child: child);
|
||||
},
|
||||
pageBuilder: (BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation) {
|
||||
pageBuilder: (BuildContext context, Animation<double> animation,
|
||||
Animation<double> secondaryAnimation) {
|
||||
// recipientInformationData.nickname = "张三张三张三";
|
||||
return Center(
|
||||
child: Container(
|
||||
@ -254,27 +286,35 @@ class _RecipientInformationPageState extends State<RecipientInformationPage> {
|
||||
SizedBox(height: 20.h),
|
||||
Text("转移确认", style: TextStyle(fontSize: 24.sp)),
|
||||
SizedBox(height: 20.h),
|
||||
Image.asset('images/icon_lockGroup_item.png', width: 70.h, height: 70.h, fit: BoxFit.fill),
|
||||
Image.asset('images/icon_lockGroup_item.png',
|
||||
width: 70.h, height: 70.h, fit: BoxFit.fill),
|
||||
SizedBox(height: 15.h),
|
||||
Stack(
|
||||
alignment: Alignment.center,
|
||||
clipBehavior: Clip.none,
|
||||
children: <Widget>[
|
||||
Text(recipientInformationData.nickname!, style: TextStyle(fontSize: 22.sp)),
|
||||
Positioned(
|
||||
left: (recipientInformationData.nickname!.length*19.w).w,
|
||||
child: Container(
|
||||
width: 80.w,
|
||||
color: Colors.red,
|
||||
child: Center(child: Text(state.type.value == 1 ? "个人用户" : "星寓", style: TextStyle(fontSize: 18.sp, color: Colors.white))),
|
||||
),
|
||||
)
|
||||
],
|
||||
alignment: Alignment.center,
|
||||
clipBehavior: Clip.none,
|
||||
children: <Widget>[
|
||||
Text(recipientInformationData.nickname!,
|
||||
style: TextStyle(fontSize: 22.sp)),
|
||||
Positioned(
|
||||
left: (recipientInformationData.nickname!.length * 19.w)
|
||||
.w,
|
||||
child: Container(
|
||||
width: 80.w,
|
||||
color: Colors.red,
|
||||
child: Center(
|
||||
child: Text(state.type.value == 1 ? "个人用户" : "星寓",
|
||||
style: TextStyle(
|
||||
fontSize: 18.sp, color: Colors.white))),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
SizedBox(height: 8.h),
|
||||
Text(recipientInformationData.userid!, style: TextStyle(fontSize: 22.sp)),
|
||||
Text(recipientInformationData.userid!,
|
||||
style: TextStyle(fontSize: 22.sp)),
|
||||
SizedBox(height: 8.h),
|
||||
Text("本次共转移${state.idList.value.length}把智能锁", style: TextStyle(fontSize: 20.sp)),
|
||||
Text("本次共转移${state.idList.value.length}把智能锁",
|
||||
style: TextStyle(fontSize: 20.sp)),
|
||||
SizedBox(height: 20.h),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
@ -297,10 +337,10 @@ class _RecipientInformationPageState extends State<RecipientInformationPage> {
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
if(state.isFromType.value == 1){
|
||||
if (state.isFromType.value == 1) {
|
||||
// 转移智能锁 transferGatewayInfoData
|
||||
logic.transferLockInfoData();
|
||||
}else{
|
||||
} else {
|
||||
// 转移网关
|
||||
logic.transferGatewayInfoData();
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@ abstract class Api {
|
||||
// final String baseUrl = "https://lock.star-lock.cn/api"; // 测试环境
|
||||
// final String baseUrl = "http://wenlin.lock.star-lock.cn/api"; //曾工
|
||||
final String baseUrl = "http://192.168.56.101:8099/api"; //曾工本地
|
||||
// final String baseUrl = "http://192.168.1.14:8099/api"; //葛工开发环境地址
|
||||
|
||||
// 登录注册
|
||||
final String getVerificationCodeUrl = '/user/sendValidationCode';
|
||||
@ -25,7 +26,7 @@ abstract class Api {
|
||||
'/key/modifyKeyNameForAdmin'; //编辑电子钥匙名字
|
||||
final String updateKeyDateURL = '/key/updateKeyDate'; //编辑电子钥匙的有效期、有效时间、有效日
|
||||
final String passwordKeyListURL = '/keyboardPwd/listSendRecords'; //密码钥匙列表
|
||||
final String passwordKeyResetURL = '/keyboardPwd/reset'; //密码钥匙重置
|
||||
final String keyboardPwdResetURL = '/keyboardPwd/reset'; //密码钥匙重置
|
||||
final String deleteElectronicKeyURL = '/key/delete'; //删除电子钥匙
|
||||
final String deleteKeyboardPwdURL = '/keyboardPwd/delete'; //删除密码
|
||||
final String getLockInfoURL = '/lock/syncDataPage'; // 获取锁信息
|
||||
@ -117,4 +118,6 @@ abstract class Api {
|
||||
final String setAppUnlockMustOnlineURL =
|
||||
'/room/setAppUnlockMustOnline'; //APP开锁时需手机联网的锁
|
||||
final String userLogoutURL = '/user/logout'; //退出登录
|
||||
final String deleteAccountURL = '/user/delete'; //删除账号
|
||||
final String getUserInfoURL = '/user/getUserInfo'; //获取个人信息
|
||||
}
|
||||
|
||||
@ -439,7 +439,7 @@ class ApiProvider extends BaseProvider {
|
||||
}));
|
||||
|
||||
Future<Response> deleteKeyboardPwd(
|
||||
String lockId, String keyboardPwdId, String deleteType) =>
|
||||
String lockId, String keyboardPwdId, int deleteType) =>
|
||||
post(
|
||||
deleteKeyboardPwdURL.toUrl,
|
||||
jsonEncode({
|
||||
@ -943,78 +943,56 @@ class ApiProvider extends BaseProvider {
|
||||
|
||||
// 获取转移锁锁列表
|
||||
Future<Response> getTransferLockListData() =>
|
||||
post(
|
||||
transferLockListURL.toUrl,
|
||||
jsonEncode({})
|
||||
);
|
||||
post(transferLockListURL.toUrl, jsonEncode({}));
|
||||
|
||||
// 转移智能锁确认
|
||||
Future<Response> transferLockConfirmInfoData(
|
||||
String receiverUserid,
|
||||
String type,
|
||||
String countryCode) =>
|
||||
String receiverUserid, String type, String countryCode) =>
|
||||
post(
|
||||
transferLockConfirmURL.toUrl,
|
||||
jsonEncode({
|
||||
'receiverUserid': receiverUserid,
|
||||
'type': type,
|
||||
'countryCode': countryCode
|
||||
})
|
||||
);
|
||||
}));
|
||||
|
||||
// 转移智能锁
|
||||
Future<Response> transferLockInfoData(
|
||||
String receiverUserid,
|
||||
List lockIdList,
|
||||
String countryCode) =>
|
||||
String receiverUserid, List lockIdList, String countryCode) =>
|
||||
post(
|
||||
transferLockURL.toUrl,
|
||||
jsonEncode({
|
||||
'receiverUserid': receiverUserid,
|
||||
'lockIdList': lockIdList,
|
||||
'countryCode': countryCode
|
||||
})
|
||||
);
|
||||
}));
|
||||
|
||||
// 获取网关列表
|
||||
Future<Response> getGatewayListData(
|
||||
String pageNo,
|
||||
String pageSize) =>
|
||||
post(
|
||||
gatewaykListURL.toUrl,
|
||||
jsonEncode({
|
||||
'pageNo': pageNo,
|
||||
'pageSize': pageSize
|
||||
})
|
||||
);
|
||||
Future<Response> getGatewayListData(String pageNo, String pageSize) => post(
|
||||
gatewaykListURL.toUrl,
|
||||
jsonEncode({'pageNo': pageNo, 'pageSize': pageSize}));
|
||||
|
||||
// 转移网关确认
|
||||
Future<Response> transferGatewayConfirmInfoData(
|
||||
String receiverUserid,
|
||||
String type,
|
||||
String countryCode) =>
|
||||
String receiverUserid, String type, String countryCode) =>
|
||||
post(
|
||||
transferGatewayConfirmURL.toUrl,
|
||||
jsonEncode({
|
||||
'receiverUserid': receiverUserid,
|
||||
'type': type,
|
||||
'countryCode': countryCode
|
||||
})
|
||||
);
|
||||
}));
|
||||
|
||||
// 转移网关
|
||||
Future<Response> transferGatewayInfoData(
|
||||
String receiverUserid,
|
||||
List plugIdList,
|
||||
String countryCode) =>
|
||||
String receiverUserid, List plugIdList, String countryCode) =>
|
||||
post(
|
||||
transferGatewayURL.toUrl,
|
||||
jsonEncode({
|
||||
'receiverUserid': receiverUserid,
|
||||
'plugIdList': plugIdList,
|
||||
'countryCode': countryCode
|
||||
})
|
||||
);
|
||||
}));
|
||||
|
||||
Future<Response> listLockByGroup(String type, String keyGroupId) => post(
|
||||
listLockByGroupURL.toUrl,
|
||||
@ -1140,6 +1118,25 @@ class ApiProvider extends BaseProvider {
|
||||
|
||||
//退出登录
|
||||
Future<Response> userLogout() => get(userLogoutURL.toUrl);
|
||||
|
||||
//删除账号
|
||||
Future<Response> deleteAccount(
|
||||
String operatorUid, String uniqueid, String verificationCode) =>
|
||||
post(
|
||||
deleteAccountURL.toUrl,
|
||||
jsonEncode({
|
||||
'operatorUid': operatorUid,
|
||||
'uniqueid': uniqueid,
|
||||
'verificationCode': verificationCode
|
||||
}));
|
||||
|
||||
// 获取个人信息
|
||||
Future<Response> getUserInfo(String operatorUid) =>
|
||||
post(getUserInfoURL.toUrl, jsonEncode({'operatorUid': operatorUid}));
|
||||
|
||||
// 重置密码钥匙
|
||||
Future<Response> keyboardPwdReset(String lockId) =>
|
||||
post(keyboardPwdResetURL.toUrl, jsonEncode({'lockId': lockId}));
|
||||
}
|
||||
|
||||
extension ExtensionString on String {
|
||||
|
||||
@ -28,9 +28,9 @@ class BaseProvider extends GetConnect with Api {
|
||||
Map<String, dynamic>? query,
|
||||
Decoder<T>? decoder,
|
||||
Progress? uploadProgress,
|
||||
bool? isUnShowLoading = false}) async {
|
||||
bool? isUnShowLoading = false}) async {
|
||||
// print("post: url:${url} body:${body} contentType:${contentType} headers:${headers} query:${query}");
|
||||
if(isUnShowLoading == false) EasyLoading.show();
|
||||
if (isUnShowLoading == false) EasyLoading.show();
|
||||
|
||||
print('哈喽请求body体为:${body}');
|
||||
var res = await super.post(url, body,
|
||||
|
||||
@ -440,7 +440,7 @@ class ApiRepository {
|
||||
|
||||
//删除密码
|
||||
Future<PasswordKeyEntity> deleteKeyboardPwd(
|
||||
String lockId, String keyboardPwdId, String deleteType) async {
|
||||
String lockId, String keyboardPwdId, int deleteType) async {
|
||||
final res =
|
||||
await apiProvider.deleteKeyboardPwd(lockId, keyboardPwdId, deleteType);
|
||||
return PasswordKeyEntity.fromJson(res.body);
|
||||
@ -449,7 +449,7 @@ class ApiRepository {
|
||||
//标记房态
|
||||
Future<PasswordKeyEntity> updateSetting(
|
||||
String lockId, String isOn, String type) async {
|
||||
final res = await apiProvider.deleteKeyboardPwd(lockId, isOn, type);
|
||||
final res = await apiProvider.updateSetting(lockId, isOn, type);
|
||||
return PasswordKeyEntity.fromJson(res.body);
|
||||
}
|
||||
|
||||
@ -1109,4 +1109,24 @@ class ApiRepository {
|
||||
receiverUserid, plugIdList, countryCode);
|
||||
return RecipientInformationEntity.fromJson(res.body);
|
||||
}
|
||||
|
||||
//删除账号
|
||||
Future<AuthorizedAdminListEntity> deleteAccount(
|
||||
String operatorUid, String uniqueid, String verificationCode) async {
|
||||
final res = await apiProvider.deleteAccount(
|
||||
operatorUid, uniqueid, verificationCode);
|
||||
return AuthorizedAdminListEntity.fromJson(res.body);
|
||||
}
|
||||
|
||||
//获取个人信息
|
||||
Future<AuthorizedAdminListEntity> getUserInfo(String operatorUid) async {
|
||||
final res = await apiProvider.getUserInfo(operatorUid);
|
||||
return AuthorizedAdminListEntity.fromJson(res.body);
|
||||
}
|
||||
|
||||
//重置密码钥匙
|
||||
Future<PasswordKeyListEntity> keyboardPwdReset(String lockId) async {
|
||||
final res = await apiProvider.keyboardPwdReset(lockId);
|
||||
return PasswordKeyListEntity.fromJson(res.body);
|
||||
}
|
||||
}
|
||||
|
||||
56
star_lock/lib/tools/showCupertinoAlert.dart
Normal file
56
star_lock/lib/tools/showCupertinoAlert.dart
Normal file
@ -0,0 +1,56 @@
|
||||
import 'dart:async';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
|
||||
//封装一个适合我们项目的,结果返回一个 future
|
||||
//颜色等受系统默认的值影响,这里面就不填写属性了,primaryColor 更新会影响到所有的默认效果
|
||||
Future<bool> showCupertinoAlert({
|
||||
BuildContext? context, //如果没设置全局,需要传递自己的context
|
||||
String title = '',
|
||||
String message = '',
|
||||
confirmText = '确定',
|
||||
cancelText = '取消',
|
||||
isShowCancel = true,
|
||||
isDestructiveConfirm = false,
|
||||
isDestructiveCancel = false,
|
||||
}) {
|
||||
// context = context ?? DialogConfig.context;
|
||||
final completer = Completer<bool>();
|
||||
final actions = <CupertinoDialogAction>[
|
||||
CupertinoDialogAction(
|
||||
isDestructiveAction: isDestructiveConfirm,
|
||||
onPressed: () {
|
||||
completer.complete(true);
|
||||
Navigator.of(context!).pop();
|
||||
},
|
||||
child: Text(confirmText),
|
||||
),
|
||||
];
|
||||
if (isShowCancel) {
|
||||
actions.insert(
|
||||
0,
|
||||
CupertinoDialogAction(
|
||||
isDestructiveAction: isDestructiveCancel,
|
||||
onPressed: () {
|
||||
completer.complete(false);
|
||||
Navigator.of(context!).pop();
|
||||
},
|
||||
child: Text(
|
||||
cancelText,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
// showCupertinoModalPopup<void>(
|
||||
// context: context,
|
||||
// barrierDismissible: false,
|
||||
// builder: (BuildContext context) => CupertinoAlertDialog(
|
||||
// title: Text(title),
|
||||
// content: Padding(
|
||||
// padding: const EdgeInsets.only(top: 10),
|
||||
// child: Text(message),
|
||||
// ),
|
||||
// actions: actions,
|
||||
// ),
|
||||
// );
|
||||
return completer.future;
|
||||
}
|
||||
@ -185,7 +185,8 @@ class LanKeyEntity {
|
||||
this.workingHoursWereNotReleased,
|
||||
this.beLate,
|
||||
this.leaveEarly,
|
||||
this.noCardPunched, this.holidayInfo,
|
||||
this.noCardPunched,
|
||||
this.holidayInfo,
|
||||
this.lanEnglish,
|
||||
this.lanChinese,
|
||||
this.multilingual,
|
||||
@ -400,7 +401,8 @@ class LanKeyEntity {
|
||||
this.getKey,
|
||||
this.getCard,
|
||||
this.getFingerprint,
|
||||
});
|
||||
this.safeVerify,
|
||||
this.deleteAccountTips});
|
||||
|
||||
LanKeyEntity.fromJson(dynamic json) {
|
||||
starLock = json['starLock'];
|
||||
@ -833,6 +835,8 @@ class LanKeyEntity {
|
||||
getKey = json['getKey'];
|
||||
getCard = json['getCard'];
|
||||
getFingerprint = json['getFingerprint'];
|
||||
safeVerify = json['safeVerify'];
|
||||
deleteAccountTips = json['deleteAccountTips'];
|
||||
}
|
||||
String? starLock;
|
||||
String? clickUnlockAndHoldDownClose;
|
||||
@ -1252,6 +1256,8 @@ class LanKeyEntity {
|
||||
String? getKey;
|
||||
String? getCard;
|
||||
String? getFingerprint;
|
||||
String? safeVerify;
|
||||
String? deleteAccountTips;
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final map = <String, dynamic>{};
|
||||
@ -1682,6 +1688,8 @@ class LanKeyEntity {
|
||||
map['getKey'] = getKey;
|
||||
map['getCard'] = getCard;
|
||||
map['getFingerprint'] = getFingerprint;
|
||||
map['safeVerify'] = safeVerify;
|
||||
map['deleteAccountTips'] = deleteAccountTips;
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user