# Conflicts:
#	star_lock/lib/network/api.dart
#	star_lock/lib/network/api_provider.dart
#	star_lock/lib/network/api_repository.dart
This commit is contained in:
魏少阳 2023-08-24 14:29:31 +08:00
commit db10bd561b
29 changed files with 1218 additions and 2141 deletions

File diff suppressed because it is too large Load Diff

View File

@ -77,7 +77,8 @@ class _StarLockRegisterPageState extends State<StarLockRegisterPage> {
// color: Colors.red,
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(30.h)),
border: Border.all(width: 1.0, color: AppColors.greyLineColor)),
border:
Border.all(width: 1.0, color: AppColors.greyLineColor)),
child: Row(
children: [
GestureDetector(
@ -87,16 +88,22 @@ class _StarLockRegisterPageState extends State<StarLockRegisterPage> {
child: Obx(() => Container(
width: 170.w,
height: 60.h,
decoration: state.isIphoneType.value ? BoxDecoration(
color: AppColors.mainColor,
borderRadius:
BorderRadius.all(Radius.circular(30.h)),
border: Border.all(width: 1.0, color: AppColors.greyLineColor)):null,
decoration: state.isIphoneType.value
? BoxDecoration(
color: AppColors.mainColor,
borderRadius:
BorderRadius.all(Radius.circular(30.h)),
border: Border.all(
width: 1.0, color: AppColors.greyLineColor))
: null,
child: Center(
child: Text(
TranslationLoader.lanKeys!.iphone!.tr,
style: TextStyle(color: state.isIphoneType.value ? Colors.white : Colors.black),
)))),
TranslationLoader.lanKeys!.iphone!.tr,
style: TextStyle(
color: state.isIphoneType.value
? Colors.white
: Colors.black),
)))),
),
Expanded(
child: GestureDetector(
@ -106,13 +113,23 @@ class _StarLockRegisterPageState extends State<StarLockRegisterPage> {
child: Obx(() => Container(
height: 60.h,
// color: Colors.red,
decoration: state.isIphoneType.value ? null : BoxDecoration(
color: AppColors.mainColor,
borderRadius:
BorderRadius.all(Radius.circular(30.h)),
border: Border.all(width: 1.0, color: AppColors.greyLineColor)),
decoration: state.isIphoneType.value
? null
: BoxDecoration(
color: AppColors.mainColor,
borderRadius:
BorderRadius.all(Radius.circular(30.h)),
border: Border.all(
width: 1.0,
color: AppColors.greyLineColor)),
child: Center(
child: Text(TranslationLoader.lanKeys!.email!.tr, style: TextStyle(color: state.isIphoneType.value ? Colors.black : Colors.white),)))),
child: Text(
TranslationLoader.lanKeys!.email!.tr,
style: TextStyle(
color: state.isIphoneType.value
? Colors.black
: Colors.white),
)))),
),
),
],
@ -123,31 +140,43 @@ class _StarLockRegisterPageState extends State<StarLockRegisterPage> {
SizedBox(height: 60.h),
GestureDetector(
onTap: () async {
// Navigator.pushNamed(context, Routers.seletCountryRegionPage);
var result = await Navigator.pushNamed(context, Routers.seletCountryRegionPage);
// logic.state.countryCode.value = (result as Map<String, dynamic>)['code'];
// logic.state.countryId.value = result["countryId"];
logic.state.countryCode.value = "+86";
logic.state.countryId.value = "9";
// print("路由返回值: ${result}, countryCode:${logic.state.countryCode} ,countryId:${logic.state.countryId}");
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'];
print(
"路由返回值: ${result}, countryCode:${logic.state.countryCode} ,countryId:${logic.state.countryId}");
},
child: Container(
child: SizedBox(
height: 70.h,
child: Row(
children: [
SizedBox(width: 5.w),
Expanded(
child: Text(TranslationLoader.lanKeys!.countryAndRegion!.tr, style: TextStyle(fontSize: 26.sp, color: AppColors.blackColor))),
child: Text(TranslationLoader.lanKeys!.countryAndRegion!.tr,
style: TextStyle(
fontSize: 26.sp, color: AppColors.blackColor))),
SizedBox(width: 20.w),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Obx(() => Text(state.isIphoneType.value ? "中国+86" : "中国", textAlign: TextAlign.end, style: TextStyle(fontSize: 26.sp, color: AppColors.blackColor),))
Obx(() => Text(
state.isIphoneType.value
? '${logic.state.countryName} +${logic.state.countryCode}'
: "${logic.state.countryName}",
textAlign: TextAlign.end,
style: TextStyle(
fontSize: 26.sp, color: AppColors.blackColor),
))
],
),
SizedBox(width: 5.w),
Image.asset('images/icon_right.png', width: 50.w, height: 50.w,
Image.asset(
'images/icon_right.png',
width: 50.w,
height: 50.w,
),
],
),
@ -171,10 +200,14 @@ class _StarLockRegisterPageState extends State<StarLockRegisterPage> {
logic.checkNext(state.phoneOrEmailController);
},
leftWidget:
// Image.asset('images/icon_login_account.png', width: 30.w, height: 30.w,),
Padding(
// Image.asset('images/icon_login_account.png', width: 30.w, height: 30.w,),
Padding(
padding: EdgeInsets.only(right: 10.w, left: 5.w),
child: Image.asset('images/icon_login_account.png', width: 30.w, height: 30.w,),
child: Image.asset(
'images/icon_login_account.png',
width: 30.w,
height: 30.w,
),
),
hintText: TranslationLoader.lanKeys!.pleaseEnterNumberOrEmail!.tr,
keyboardType: TextInputType.number,
@ -191,7 +224,11 @@ class _StarLockRegisterPageState extends State<StarLockRegisterPage> {
isPwd: true,
leftWidget: Padding(
padding: EdgeInsets.only(right: 10.w, left: 5.w),
child: Image.asset('images/icon_login_password.png', width: 30.w, height: 30.w,),
child: Image.asset(
'images/icon_login_password.png',
width: 30.w,
height: 30.w,
),
),
hintText:
"${TranslationLoader.lanKeys!.pleaseEnter!.tr}${TranslationLoader.lanKeys!.password!.tr}",
@ -213,7 +250,11 @@ class _StarLockRegisterPageState extends State<StarLockRegisterPage> {
isPwd: true,
leftWidget: Padding(
padding: EdgeInsets.only(right: 10.w, left: 5.w),
child: Image.asset('images/icon_login_password.png', width: 30.w, height: 30.w,),
child: Image.asset(
'images/icon_login_password.png',
width: 30.w,
height: 30.w,
),
),
hintText:
"${TranslationLoader.lanKeys!.sure!.tr}${TranslationLoader.lanKeys!.password!.tr}",
@ -236,7 +277,8 @@ class _StarLockRegisterPageState extends State<StarLockRegisterPage> {
height: 30.w,
),
),
hintText: "${TranslationLoader.lanKeys!.pleaseEnter!.tr}${TranslationLoader.lanKeys!.verificationCode!.tr}",
hintText:
"${TranslationLoader.lanKeys!.pleaseEnter!.tr}${TranslationLoader.lanKeys!.verificationCode!.tr}",
inputFormatters: [
LengthLimitingTextInputFormatter(20),
]),
@ -245,27 +287,39 @@ class _StarLockRegisterPageState extends State<StarLockRegisterPage> {
width: 20.w,
),
Obx(() => GestureDetector(
onTap: state.phoneOrEmailStrIsOK.value ? () async {
// Navigator.pushNamed(context, Routers.safetyVerificationPage, arguments: {"countryCode":"+86", "account":state.phoneOrEmailStr.value});
var result = await Navigator.pushNamed(context, Routers.safetyVerificationPage, arguments: {"countryCode":"+86", "account":state.phoneOrEmailStr.value});
logic.state.xWidth.value = (result as Map<String, dynamic>)['xWidth'];
logic.sendValidationCode();
}:null,
child: Container(
width: 180.w,
height: 60.h,
padding: EdgeInsets.all(5.h),
decoration: BoxDecoration(
color: state.phoneOrEmailStrIsOK.value ? AppColors.mainColor : Colors.grey,
borderRadius: BorderRadius.circular(5)),
child: Center(
child: Text(
state.btnText.value,
textAlign: TextAlign.center,
style: TextStyle(color: Colors.white, fontSize: 26.sp,)),
),
),
))
onTap: state.phoneOrEmailStrIsOK.value
? () async {
// Navigator.pushNamed(context, Routers.safetyVerificationPage, arguments: {"countryCode":"+86", "account":state.phoneOrEmailStr.value});
var result = await Navigator.pushNamed(
context, Routers.safetyVerificationPage,
arguments: {
"countryCode": state.countryCode,
"account": state.phoneOrEmailStr.value
});
logic.state.xWidth.value =
(result as Map<String, dynamic>)['xWidth'];
logic.sendValidationCode();
}
: null,
child: Container(
width: 180.w,
height: 60.h,
padding: EdgeInsets.all(5.h),
decoration: BoxDecoration(
color: state.phoneOrEmailStrIsOK.value
? AppColors.mainColor
: Colors.grey,
borderRadius: BorderRadius.circular(5)),
child: Center(
child: Text(state.btnText.value,
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
fontSize: 26.sp,
)),
),
),
))
],
),
SizedBox(height: 50.w),

View File

@ -10,8 +10,9 @@ class StarLockRegisterState {
final TextEditingController sureController = TextEditingController();
final TextEditingController codeController = TextEditingController();
var countryCode = '+86'.obs;
var countryId = '9'.obs;
var countryCode = '86'.obs;
var countryId = '1'.obs;
var countryName = '中国'.obs;
var phoneOrEmailStr = ''.obs;
var phoneOrEmailStrIsOK = false.obs;
var pwd = ''.obs;

View File

@ -1,54 +0,0 @@
import 'package:azlistview/azlistview.dart';
import 'index.dart';
class CountriesModel extends ISuspensionBean {
String? short;
late String name;
String? en;
late String tel;
String? pinyin;
String? tagIndex;
CountriesModel(
{this.short,
required this.name,
this.en,
required this.tel,
this.pinyin,
this.tagIndex});
CountriesModel.fromJson(Map<String, dynamic> json) {
if (json["short"] is String) {
short = json["short"];
}
if (json["name"] is String) {
name = json["name"];
}
if (json["en"] is String) {
en = json["en"];
}
if (json["tel"] is String) {
tel = json["tel"];
}
if (json["pinyin"] is String) {
pinyin = json["pinyin"];
}
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data["short"] = short;
data["name"] = name;
data["en"] = en;
data["tel"] = tel;
data["pinyin"] = pinyin;
return data;
}
@override
String getSuspensionTag() => tagIndex!;
@override
String toString() => json.encode(this);
}

View File

@ -0,0 +1,81 @@
import 'dart:convert';
import 'package:azlistview/azlistview.dart';
class CountryRegionEntity {
int? errorCode;
String? description;
String? errorMsg;
List<CountryRegionModel>? dataList;
CountryRegionEntity(
{this.errorCode, this.description, this.errorMsg, this.dataList});
CountryRegionEntity.fromJson(Map<String, dynamic> json) {
errorCode = json['errorCode'];
description = json['description'];
errorMsg = json['errorMsg'];
if (json['data'] != null) {
dataList = <CountryRegionModel>[];
json['data'].forEach((v) {
dataList!.add(CountryRegionModel.fromJson(v));
});
}
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['errorCode'] = errorCode;
data['description'] = description;
data['errorMsg'] = errorMsg;
if (dataList != null) {
data['data'] = dataList!.map((v) => v.toJson()).toList();
}
return data;
}
}
class CountryRegionModel extends ISuspensionBean {
int? countryId;
String? name;
String? code;
String? flag;
String? abbreviation;
String? group;
String? tagIndex;
CountryRegionModel(
{this.countryId,
this.name,
this.code,
this.flag,
this.abbreviation,
this.group,
this.tagIndex});
CountryRegionModel.fromJson(Map<String, dynamic> json) {
countryId = json['countryId'];
name = json['name'];
code = json['code'];
flag = json['flag'];
abbreviation = json['abbreviation'];
group = json['group'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['countryId'] = countryId;
data['name'] = name;
data['code'] = code;
data['flag'] = flag;
data['abbreviation'] = abbreviation;
data['group'] = group;
return data;
}
@override
String getSuspensionTag() => tagIndex!;
@override
String toString() => json.encode(this);
}

View File

@ -1,108 +0,0 @@
import 'dart:convert';
import 'package:azlistview/azlistview.dart';
import 'package:flutter/material.dart';
class CityModel extends ISuspensionBean {
String name;
String? tagIndex;
String? namePinyin;
CityModel({
required this.name,
this.tagIndex,
this.namePinyin,
});
CityModel.fromJson(Map<String, dynamic> json) : name = json['name'];
Map<String, dynamic> toJson() => {
'name': name,
// 'tagIndex': tagIndex,
// 'namePinyin': namePinyin,
// 'isShowSuspension': isShowSuspension
};
@override
String getSuspensionTag() => tagIndex!;
@override
String toString() => json.encode(this);
}
class ContactInfo extends ISuspensionBean {
String name;
String? tagIndex;
String? namePinyin;
Color? bgColor;
IconData? iconData;
String? img;
String? id;
String? firstletter;
ContactInfo({
required this.name,
this.tagIndex,
this.namePinyin,
this.bgColor,
this.iconData,
this.img,
this.id,
this.firstletter,
});
ContactInfo.fromJson(Map<String, dynamic> json)
: name = json['name'],
img = json['img'],
id = json['id']?.toString(),
firstletter = json['firstletter'];
Map<String, dynamic> toJson() => {
// 'id': id,
'name': name,
'img': img,
// 'firstletter': firstletter,
// 'tagIndex': tagIndex,
// 'namePinyin': namePinyin,
// 'isShowSuspension': isShowSuspension
};
@override
String getSuspensionTag() => tagIndex!;
@override
String toString() => json.encode(this);
}
// class Languages extends GithubLanguage with ISuspensionBean {
// String? tagIndex;
// String? pinyin;
// String? shortPinyin;
// Languages.fromJson(Map<String, dynamic> json) : super.fromJson(json);
// @override
// Map<String, dynamic> toJson() {
// final Map<String, dynamic> map = super.toJson();
// void addIfNonNull(String fieldName, dynamic value) {
// if (value != null) {
// map[fieldName] = value;
// }
// }
// // addIfNonNull('tagIndex', tagIndex);
// return map;
// }
// @override
// String getSuspensionTag() {
// return tagIndex!;
// }
// @override
// String toString() {
// return json.encode(this);
// }
// }

View File

@ -1,13 +1,10 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:star_lock/app_settings/app_colors.dart';
import 'package:star_lock/login/seletCountryRegion/common/countries_model.dart';
import 'package:star_lock/login/seletCountryRegion/common/models.dart';
import 'index.dart';
import 'package:star_lock/login/seletCountryRegion/common/countryRegionEntity.dart';
class Utils {
static String getImgPath(String name, {String format: 'png'}) {
static String getImgPath(String name, {String format = 'png'}) {
return 'assets/images/$name.$format';
}
@ -15,7 +12,7 @@ class Utils {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(msg),
duration: Duration(seconds: 2),
duration: const Duration(seconds: 2),
),
);
}
@ -42,7 +39,8 @@ class Utils {
);
}
static Widget getListItem(BuildContext context, CountriesModel model,
static Widget getListItem(
BuildContext context, CountryRegionModel model, Function() onClick,
{double susHeight = 40}) {
return GestureDetector(
child: SizedBox(
@ -54,7 +52,7 @@ class Utils {
width: 20.w,
),
Text(
model.name,
model.name!,
style: TextStyle(
color: AppColors.darkGrayTextColor, fontSize: 24.sp),
),
@ -63,7 +61,7 @@ class Utils {
width: 30.w,
)),
Text(
'+${model.tel}',
'+${model.code}',
style: TextStyle(color: AppColors.blackColor, fontSize: 22.sp),
),
SizedBox(
@ -71,99 +69,11 @@ class Utils {
)
],
),
// Divider(
// height: 1,
// color: AppColors.greyLineColor,
// endIndent: 0,
// indent: 20.w,
// )
),
onTap: () {
LogUtil.e("onItemClick : $model");
Utils.showSnackBar(context, 'onItemClick : ${model.name}');
},
);
// return ListTile(
// title: Text('${model.name} +${model.tel}'),
// onTap: () {
// LogUtil.e("onItemClick : $model");
// Utils.showSnackBar(context, 'onItemClick : ${model.name}');
// },
// );
// return Column(
// mainAxisSize: MainAxisSize.min,
// children: <Widget>[
// Offstage(
// offstage: !(model.isShowSuspension == true),
// child: getSusItem(context, model.getSuspensionTag(),
// susHeight: susHeight),
// ),
// ListTile(
// title: Text(model.name),
// onTap: () {
// LogUtil.e("onItemClick : $model");
// Utils.showSnackBar(context, 'onItemClick : ${model.name}');
// },
// )
// ],
// );
}
static Widget getWeChatListItem(
BuildContext context,
ContactInfo model, {
double susHeight = 40,
Color? defHeaderBgColor,
}) {
return getWeChatItem(context, model, defHeaderBgColor: defHeaderBgColor);
// return Column(
// mainAxisSize: MainAxisSize.min,
// children: <Widget>[
// Offstage(
// offstage: !(model.isShowSuspension == true),
// child: getSusItem(context, model.getSuspensionTag(),
// susHeight: susHeight),
// ),
// getWeChatItem(context, model, defHeaderBgColor: defHeaderBgColor),
// ],
// );
}
static Widget getWeChatItem(
BuildContext context,
ContactInfo model, {
Color? defHeaderBgColor,
}) {
DecorationImage? image;
// if (model.img != null && model.img.isNotEmpty) {
// image = DecorationImage(
// image: CachedNetworkImageProvider(model.img),
// fit: BoxFit.contain,
// );
// }
return ListTile(
leading: Container(
width: 36,
height: 36,
decoration: BoxDecoration(
shape: BoxShape.rectangle,
borderRadius: BorderRadius.circular(4.0),
color: model.bgColor ?? defHeaderBgColor,
image: image,
),
child: model.iconData == null
? null
: Icon(
model.iconData,
color: Colors.white,
size: 20,
),
),
title: Text(model.name),
onTap: () {
LogUtil.e("onItemClick : $model");
Utils.showSnackBar(context, 'onItemClick : ${model.name}');
onClick();
// LogUtil.e("onItemClick : $model");
// Utils.showSnackBar(context, 'onItemClick : ${model.name}');
},
);
}

View File

@ -2,11 +2,13 @@ import 'package:azlistview/azlistview.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:star_lock/login/seletCountryRegion/common/countryRegionEntity.dart';
import 'package:star_lock/network/api_repository.dart';
import 'package:star_lock/tools/baseGetXController.dart';
import '../../app_settings/app_colors.dart';
import '../../tools/titleAppBar.dart';
import '../../translations/trans_lib.dart';
import 'common/countries_model.dart';
import 'common/index.dart';
class SeletCountryRegionPage extends StatefulWidget {
@ -17,7 +19,7 @@ class SeletCountryRegionPage extends StatefulWidget {
}
class _SeletCountryRegionPageState extends State<SeletCountryRegionPage> {
List<CountriesModel> countriesList = [];
List<CountryRegionModel> countriesList = [];
@override
void initState() {
@ -25,34 +27,30 @@ class _SeletCountryRegionPageState extends State<SeletCountryRegionPage> {
SuspensionUtil.setShowSuspensionStatus(
countriesList.cast<ISuspensionBean>());
Future.delayed(const Duration(milliseconds: 500), () {
loadData();
Future.delayed(const Duration(milliseconds: 20), () {
getCountriesListRequest();
});
}
///json文件
Future<void> getCountriesListRequest() async {
CountryRegionEntity entity = await ApiRepository.to.getCountryRegion('1');
countriesList.clear();
if (entity.errorCode!.codeIsSuccessful) {
countriesList.addAll(entity.dataList!);
_handleList(countriesList);
}
}
Future<String> loadJsonFromAssets(String assetsPath) async {
return await rootBundle.loadString(assetsPath);
}
void loadData() async {
//
String jsonData = await loadJsonFromAssets('assets/countries.json');
countriesList.clear();
List list = json.decode(jsonData);
for (var v in list) {
countriesList.add(CountriesModel.fromJson(v));
}
_handleList(countriesList);
}
void _handleList(List<CountriesModel> list) {
void _handleList(List<CountryRegionModel> list) {
if (list.isEmpty) return;
for (int i = 0, length = list.length; i < length; i++) {
CountriesModel countryModel = list[i];
// String pinyin = PinyinHelper.getPinyinE(list[i].name);
String tag = countryModel.pinyin!.substring(0, 1).toUpperCase();
// list[i].pinyin = pinyin;
CountryRegionModel countryModel = list[i];
String tag = countryModel.group!;
if (RegExp('[A-Z]').hasMatch(tag)) {
list[i].tagIndex = tag;
} else {
@ -82,16 +80,22 @@ class _SeletCountryRegionPageState extends State<SeletCountryRegionPage> {
data: countriesList,
itemCount: countriesList.length,
itemBuilder: (BuildContext context, int index) {
CountriesModel model = countriesList[index];
return Utils.getListItem(context, model);
CountryRegionModel model = countriesList[index];
return Utils.getListItem(context, model, () {
Map<String, dynamic> resultMap = {};
resultMap['code'] = model.code;
resultMap['countryId'] = model.countryId.toString();
resultMap['countryName'] = model.name;
Navigator.pop(context, resultMap);
});
},
padding: EdgeInsets.zero,
susItemBuilder: (BuildContext context, int index) {
CountriesModel model = countriesList[index];
CountryRegionModel model = countriesList[index];
String tag = model.getSuspensionTag();
return Utils.getSusItem(context, tag);
},
indexBarData: ['', ...kIndexBarData],
indexBarData: const ['', ...kIndexBarData],
),
);
}

View File

@ -1,8 +1,12 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_native_contact_picker/flutter_native_contact_picker.dart';
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/network/api_repository.dart';
import 'package:star_lock/tools/baseGetXController.dart';
import '../../../../appRouters.dart';
import '../../../../app_settings/app_colors.dart';
@ -22,15 +26,31 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage> {
final FlutterContactPicker _contactPicker = FlutterContactPicker();
late Contact _contact;
@override
Widget build(BuildContext context) {
return indexChangeWidget();
}
// bool _isRemoteUnlock = false; //
bool _isAuthentication = false; //
var _selectEffectiveDate = ''; //
var _selectFailureDate = ''; //
final TextEditingController _emailOrPhoneController =
TextEditingController(); ///
final TextEditingController _keyNameController =
TextEditingController(); //
late bool _isSendSuccess;
@override
void initState() {
// TODO: implement initState
super.initState();
DateTime dateTime = DateTime.now();
_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) {
return indexChangeWidget();
}
Widget indexChangeWidget() {
@ -70,14 +90,14 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage> {
rightTitle: "",
isHaveLine: true,
isHaveRightWidget: true,
rightWidget: getTFWidget(
true, TranslationLoader.lanKeys!.pleaseEnterNumberOrEmail!.tr)),
rightWidget: getTFWidget(true,
TranslationLoader.lanKeys!.pleaseEnterNumberOrEmail!.tr, 1)),
CommonItem(
leftTitel: TranslationLoader.lanKeys!.name!.tr,
rightTitle: "",
isHaveRightWidget: true,
rightWidget:
getTFWidget(false, TranslationLoader.lanKeys!.pleaseEnter!.tr)),
rightWidget: getTFWidget(
false, TranslationLoader.lanKeys!.pleaseEnter!.tr, 2)),
Container(height: 10.h),
],
);
@ -89,18 +109,30 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage> {
children: [
CommonItem(
leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr,
rightTitle: "2020.06.20 11:49",
rightTitle: _selectEffectiveDate,
isHaveLine: true,
isHaveDirection: true,
action: () {
// _showDatePicker();
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
onConfirm: (p) {
setState(() {
_selectEffectiveDate =
'${p.year}-${p.month}-${p.day} ${p.hour}:${p.minute}';
});
});
}),
CommonItem(
leftTitel: TranslationLoader.lanKeys!.failureTime!.tr,
rightTitle: "2020.06.20 11:49",
rightTitle: _selectFailureDate,
isHaveDirection: true,
action: () {
// _showDatePicker();
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
onConfirm: (p) {
setState(() {
_selectFailureDate =
'${p.year}-${p.month}-${p.day} ${p.hour}:${p.minute}';
});
});
}),
Container(height: 10.h),
],
@ -143,7 +175,15 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage> {
SizedBox(
height: 20.h,
),
SubmitBtn(btnName: TranslationLoader.lanKeys!.send!.tr, onClick: () {}),
SubmitBtn(
btnName: TranslationLoader.lanKeys!.send!.tr,
onClick: () {
//
if (_emailOrPhoneController.text.isNotEmpty &&
_keyNameController.text.isNotEmpty) {
sendElectronicKeyRequest();
}
}),
Container(
padding: EdgeInsets.only(right: 30.w),
// color: Colors.red,
@ -241,8 +281,8 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage> {
}
//
Widget getTFWidget(bool isHaveBtn, String tfStr) {
return Container(
Widget getTFWidget(bool isHaveBtn, String tfStr, int lineIndex) {
return SizedBox(
height: 50.h,
width: 300.w,
child: Row(
@ -251,7 +291,8 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage> {
child: TextField(
//
maxLines: 1,
// controller: _controller,
controller:
lineIndex == 1 ? _emailOrPhoneController : _keyNameController,
autofocus: false,
textAlign: TextAlign.end,
decoration: InputDecoration(
@ -295,27 +336,52 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage> {
);
}
CupertinoSwitch _switch() {
/*
return Switch(
value: false,
onChanged: (value){
// switchValue = !switchValue;
setState(() {
//
Future<void> sendElectronicKeyRequest() async {
String getFailureDateTime = '0';
String getEffectiveDateTime = '0';
String deviceID = '28';
String getKeyType = (int.parse(widget.type) + 1).toString();
if (widget.type == '0') {
getFailureDateTime =
DateTime.parse(_selectFailureDate).millisecondsSinceEpoch.toString();
getEffectiveDateTime = DateTime.parse(_selectEffectiveDate)
.millisecondsSinceEpoch
.toString();
}
var entity = await ApiRepository.to.sendElectronicKey(
'0',
'0',
'1',
getFailureDateTime,
_isAuthentication == true ? '1' : '2',
'2',
'2',
_keyNameController.text,
'1',
getKeyType,
deviceID,
'小吴副号',
_emailOrPhoneController.text,
'0',
getEffectiveDateTime, []);
if (entity.errorCode!.codeIsSuccessful) {
print('发送电子钥匙成功');
_isSendSuccess = true;
setState(() {});
}
}
});
}
);
*/
bool _isOn = false;
//
CupertinoSwitch _switch() {
return CupertinoSwitch(
activeColor: CupertinoColors.activeBlue,
trackColor: CupertinoColors.systemGrey5,
thumbColor: CupertinoColors.white,
value: _isOn,
value: _isAuthentication,
onChanged: (value) {
setState(() {
_isOn = value;
_isAuthentication = value;
});
},
);

View File

@ -1,6 +1,9 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.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 '../../../../appRouters.dart';
import '../../../../app_settings/app_colors.dart';
@ -25,50 +28,146 @@ class _AuthorizedAdminListPageState extends State<AuthorizedAdminListPage> {
barTitle: TranslationLoader.lanKeys!.authorizedAdmin!.tr,
haveBack: true,
backgroundColor: AppColors.mainColor,
// actionsList: [
// TextButton(
// child: Text(
// TranslationLoader.lanKeys!.reset!.tr,
// style: TextStyle(color: Colors.white, fontSize: 24.sp),
// ),
// onPressed: () {},
// ),
// ],
),
body: Column(
children: [
Expanded(child: _buildMainUI()),
SizedBox(
height: 20.h,
),
AddBottomWhiteBtn(
btnName: TranslationLoader.lanKeys!.addAuthorizedAdmin!.tr,
onClick: () {
Navigator.pushNamed(context, Routers.authorizedAdminManagePage);
},
),
SizedBox(
height: 64.h,
)
],
),
body: FutureBuilder<List<ElectronicKeyListItem>>(
future: mockNetworkDataRequest(),
builder: (BuildContext context,
AsyncSnapshot<List<ElectronicKeyListItem>> snapshot) {
//
if (snapshot.connectionState == ConnectionState.done) {
if (snapshot.hasError) {
//
return const Text('请求失败');
} else {
//
final List<ElectronicKeyListItem> itemData = snapshot.data!;
return Column(
children: [
Expanded(child: _buildMainUI(itemData)),
SizedBox(
height: 20.h,
),
AddBottomWhiteBtn(
btnName:
TranslationLoader.lanKeys!.addAuthorizedAdmin!.tr,
onClick: () {
Navigator.pushNamed(
context, Routers.authorizedAdminManagePage);
},
),
SizedBox(
height: 64.h,
)
],
);
}
} else {
// loading
return Container();
}
}),
);
}
Widget _buildMainUI() {
// keyRight=1
Future<List<ElectronicKeyListItem>> mockNetworkDataRequest() async {
ElectronicKeyListEntity entity = await ApiRepository.to
.electronicKeyList('0', '63', '0', '28', '1', '1', '20', '0', '1');
if (entity.errorCode!.codeIsSuccessful) {
print("电子钥匙列表成功:${entity.data?.itemList}");
}
if (entity.data != null) {
return entity.data!.itemList;
} else {
List<ElectronicKeyListItem> dataList = [];
return dataList;
}
}
Widget _buildMainUI(itemData) {
List<ElectronicKeyListItem> getItemData = itemData;
return ListView.builder(
itemCount: 5,
itemCount: getItemData.length,
itemBuilder: (c, index) {
return _electronicKeyItem('images/controls_user.png', "张三",
"2023.6.21 11.15", "2023.6.21 11.15", () {
ElectronicKeyListItem indexEntity = getItemData[index];
String useDateStr = ''; //使
String keyStatus = ''; //
//使
useDateStr = getUseDateStr(indexEntity);
//
keyStatus = getKeyStatus(indexEntity.keyStatus);
//
bool isAdminKey = false;
if (indexEntity.keyRight == 1) {
isAdminKey = true;
} else {
isAdminKey = false;
}
return _electronicKeyItem('images/controls_user.png',
indexEntity.keyName!, useDateStr, keyStatus, isAdminKey, () {
// Navigator.pushNamed(context, Routers.authorizedAdminDetailPage);
Navigator.pushNamed(context, Routers.electronicKeyDetailPage);
});
});
}
Widget _electronicKeyItem(String lockTypeIcon, String lockTypeTitle,
String beginTime, String endTime, Function() action) {
//使
String getUseDateStr(ElectronicKeyListItem indexEntity) {
String useDateStr = '';
if (indexEntity.keyType == 1) {
//
DateTime startDateStr =
DateTime.fromMillisecondsSinceEpoch(indexEntity.startDate!);
DateTime endDateStr =
DateTime.fromMillisecondsSinceEpoch(indexEntity.endDate!);
useDateStr =
'${startDateStr.toLocal().toString().substring(0, 16)}-${endDateStr.toLocal().toString().substring(0, 16)}';
} else if (indexEntity.keyType == 2) {
//
DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.date!);
useDateStr = '${dateStr.toLocal().toString().substring(0, 16)} 永久';
} else if (indexEntity.keyType == 3) {
//
DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.date!);
useDateStr = '${dateStr.toLocal().toString().substring(0, 16)} 单次';
} else if (indexEntity.keyType == 4) {
//
useDateStr = '循环';
}
return useDateStr;
}
//
String getKeyStatus(int? keyStatusFlag) {
String keyStatus = '';
if (keyStatusFlag == 110401) {
//使
keyStatus = '';
} else if (keyStatusFlag == 110402) {
//
keyStatus = '待接收';
} else if (keyStatusFlag == 110405) {
//
keyStatus = '已冻结';
} else if (keyStatusFlag == 110408) {
//
keyStatus = '已删除';
} else if (keyStatusFlag == 110410) {
//
keyStatus = '已重置';
}
return keyStatus;
}
Widget _electronicKeyItem(String avatarURL, String receiveUser,
String useDate, String keyStatus, bool isAdminKey, Function() action) {
return GestureDetector(
onTap: action,
child: Container(
@ -84,7 +183,7 @@ class _AuthorizedAdminListPageState extends State<AuthorizedAdminListPage> {
width: 30.w,
),
Image.asset(
lockTypeIcon,
avatarURL,
width: 60.w,
height: 60.w,
),
@ -99,7 +198,7 @@ class _AuthorizedAdminListPageState extends State<AuthorizedAdminListPage> {
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
lockTypeTitle,
receiveUser,
style: TextStyle(
fontSize: 24.sp, color: AppColors.blackColor),
),
@ -114,7 +213,7 @@ class _AuthorizedAdminListPageState extends State<AuthorizedAdminListPage> {
borderRadius: BorderRadius.circular(5.0),
),
child: Text(
'待接收',
keyStatus,
style: TextStyle(color: Colors.red, fontSize: 16.sp),
),
)
@ -125,7 +224,7 @@ class _AuthorizedAdminListPageState extends State<AuthorizedAdminListPage> {
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
"2023.6.21 11.15 永久",
useDate,
style: TextStyle(
fontSize: 18.sp,
color: AppColors.placeholderTextColor),

View File

@ -2,8 +2,12 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecordEntity.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/jh_pop_menus.dart';
import 'package:star_lock/tools/toast.dart';
import '../../../../../appRouters.dart';
import '../../../../../app_settings/app_colors.dart';
@ -23,11 +27,10 @@ class ElectronicKeyDetailPage extends StatefulWidget {
class _ElectronicKeyDetailPageState extends State<ElectronicKeyDetailPage> {
final TextEditingController _changeNameController = TextEditingController();
ElectronicKeyListItem itemData = ElectronicKeyListItem();
@override
Widget build(BuildContext context) {
ElectronicKeyListItem itemData = ElectronicKeyListItem();
dynamic obj = ModalRoute.of(context)?.settings.arguments;
if (obj != null && (obj["itemData"] != null)) {
itemData = obj["itemData"];
@ -63,7 +66,9 @@ class _ElectronicKeyDetailPageState extends State<ElectronicKeyDetailPage> {
children: [
CommonItem(
leftTitel: TranslationLoader.lanKeys!.name!.tr,
rightTitle: itemData.keyName,
rightTitle: _changeNameController.text.isNotEmpty
? _changeNameController.text
: itemData.keyName,
isHaveDirection: true,
isHaveLine: true,
action: () {
@ -140,11 +145,11 @@ class _ElectronicKeyDetailPageState extends State<ElectronicKeyDetailPage> {
} else if (indexEntity.keyType == 2) {
//
DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.date!);
useDateStr = '${dateStr.toLocal().toString()} 永久';
useDateStr = '${dateStr.toLocal().toString().substring(0, 16)} 永久';
} else if (indexEntity.keyType == 3) {
//
DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.date!);
useDateStr = '${dateStr.toLocal().toString()} 单次';
useDateStr = '${dateStr.toLocal().toString().substring(0, 16)} 单次';
} else if (indexEntity.keyType == 4) {
//
useDateStr = '循环';
@ -230,15 +235,42 @@ class _ElectronicKeyDetailPageState extends State<ElectronicKeyDetailPage> {
);
}
void showCupertinoAlertDialog(BuildContext context) {
//
Future<void> modifyKeyNameRequest() async {
KeyOperationRecordEntity entity = await ApiRepository.to
.modifyKeyNameForAdmin(
itemData.keyId.toString(), _changeNameController.text, '0');
if (entity.errorCode!.codeIsSuccessful) {
print("修改要是名称成功啦啦啦啦啦");
Toast.show(msg: "修改成功");
setState(() {
Navigator.pop(context);
});
}
}
void showCupertinoAlertDialog(
BuildContext context,
) {
showDialog(
context: context,
builder: (BuildContext context) {
return ShowTFView(
title:
"${TranslationLoader.lanKeys!.amend!.tr} ${TranslationLoader.lanKeys!.name!.tr}",
tipTitle: "请输入",
controller: _changeNameController);
});
context: context,
builder: (BuildContext context) {
return ShowTFView(
title:
"${TranslationLoader.lanKeys!.amend!.tr} ${TranslationLoader.lanKeys!.name!.tr}",
tipTitle: "请输入",
controller: _changeNameController,
sureClick: () {
//
if (_changeNameController.text.isNotEmpty) {
modifyKeyNameRequest();
}
},
cancelClick: () {
Navigator.pop(context);
},
);
},
);
}
}

View File

@ -30,53 +30,59 @@ class _KeyOperationRecordPageState extends State<KeyOperationRecordPage> {
backgroundColor: AppColors.mainColor,
),
body: FutureBuilder<List<KeyRecordDataItem>>(
// future: mockNetworkDataRequest(),
future: mockNetworkDataRequest(),
builder: (BuildContext context,
AsyncSnapshot<List<KeyRecordDataItem>> snapshot) {
//
if (snapshot.connectionState == ConnectionState.done) {
if (snapshot.hasError) {
//
return const Text('请求失败');
} else {
//
final List<KeyRecordDataItem> itemData = snapshot.data!;
//
if (snapshot.connectionState == ConnectionState.done) {
if (snapshot.hasError) {
//
return const Text('请求失败');
} else {
//
final List<KeyRecordDataItem> itemDataList = snapshot.data!;
return Column(
children: [
Expanded(child: _buildMainUI()),
],
);
}
} else {
// loading
return Container();
}
}),
return Column(
children: [
Expanded(child: _buildMainUI(itemDataList)),
],
);
}
} else {
// loading
return Container();
}
}),
);
}
//
Future<List<KeyRecordDataItem>?> mockNetworkDataRequest() async {
KeyOperationRecordEntity entity = (await ApiRepository.to
.lockRecordList('0', '63', '0', '28', '1', '1', '20', '0', '', '', ''));
Future<List<KeyRecordDataItem>> mockNetworkDataRequest() async {
KeyOperationRecordEntity entity = await ApiRepository.to
.lockRecordList('0', '63', '0', '28', '1', '1', '20', '0', '', '', '');
if (entity.errorCode!.codeIsSuccessful) {
print("操作记录列表成功:${entity.data?.itemList}");
}
if (entity.data != null) {
return entity.data!.itemList;
final data = entity.data;
if (data != null) {
return data.itemList!;
} else {
List<KeyRecordDataItem> dataList = [];
return dataList;
}
}
Widget _buildMainUI() {
Widget _buildMainUI(List<KeyRecordDataItem> itemDataList) {
return ListView.separated(
itemCount: 5,
itemBuilder: (c, index) {
return _electronicKeyItem('images/icon_recordDate.png', "张三",
"2023.6.21 11.15", "2023.6.21 11.15", () {});
KeyRecordDataItem dataItem = itemDataList[index];
int? operateDate = dataItem.operateDate;
DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(operateDate!);
String operateDateStr =
'${dateStr.toLocal().toString().substring(0, 16)} 开锁';
return _electronicKeyItem(operateDateStr, () {});
},
separatorBuilder: (BuildContext context, int index) {
return const Divider(
@ -87,8 +93,7 @@ class _KeyOperationRecordPageState extends State<KeyOperationRecordPage> {
);
}
Widget _electronicKeyItem(String lockTypeIcon, String lockTypeTitle,
String beginTime, String endTime, Function() action) {
Widget _electronicKeyItem(String operateDate, Function() action) {
return GestureDetector(
onTap: action,
child: Container(
@ -100,7 +105,7 @@ class _KeyOperationRecordPageState extends State<KeyOperationRecordPage> {
width: 30.w,
),
Image.asset(
lockTypeIcon,
'images/icon_recordDate.png',
width: 24.w,
height: 24.w,
color: AppColors.darkGrayTextColor,
@ -109,7 +114,7 @@ class _KeyOperationRecordPageState extends State<KeyOperationRecordPage> {
width: 20.w,
),
Text(
'2023-07-29 14:50:33 开锁',
operateDate,
style: TextStyle(color: AppColors.blackColor, fontSize: 20.sp),
),
SizedBox(width: 20.h),

View File

@ -7,7 +7,7 @@ class ElectronicKeyListLogic {
late ElectronicKeyListEntity dataEntity = ElectronicKeyListEntity();
void electronicKeyList() async {
var entity = await ApiRepository.to
.electronicKeyList('0', '63', '0', '28', '1', '1', '20', '0');
.electronicKeyList('0', '63', '0', '28', '1', '1', '20', '0', '0');
if (entity.errorCode!.codeIsSuccessful) {
print("电子钥匙列表成功:${entity.data?.itemList}");
dataEntity = entity;

View File

@ -27,7 +27,7 @@ class _ElectronicKeyListPageState extends State<ElectronicKeyListPage> {
//
Future<List<ElectronicKeyListItem>> mockNetworkDataRequest() async {
ElectronicKeyListEntity entity = await ApiRepository.to
.electronicKeyList('0', '63', '0', '28', '1', '1', '20', '0');
.electronicKeyList('0', '63', '0', '28', '1', '1', '20', '0', '0');
if (entity.errorCode!.codeIsSuccessful) {
print("电子钥匙列表成功:${entity.data?.itemList}");
}
@ -198,11 +198,11 @@ class _ElectronicKeyListPageState extends State<ElectronicKeyListPage> {
} else if (indexEntity.keyType == 2) {
//
DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.date!);
useDateStr = '${dateStr.toLocal().toString()} 永久';
useDateStr = '${dateStr.toLocal().toString().substring(0, 16)} 永久';
} else if (indexEntity.keyType == 3) {
//
DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.date!);
useDateStr = '${dateStr.toLocal().toString()} 单次';
useDateStr = '${dateStr.toLocal().toString().substring(0, 16)} 单次';
} else if (indexEntity.keyType == 4) {
//
useDateStr = '循环';

View File

@ -0,0 +1,22 @@
class KeyPeriodValidityModel {
late String validityText; //
late int validityIndex; //index
late bool isValidity; //
KeyPeriodValidityModel(
this.validityText, this.validityIndex, this.isValidity);
KeyPeriodValidityModel.fromJson(Map<String, dynamic> json) {
validityText = json['validityText'];
validityIndex = json['validityIndex'];
isValidity = json['isValidity'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['validityText'] = validityText;
data['validityIndex'] = validityIndex;
data['isValidity'] = isValidity;
return data;
}
}

View File

@ -1,6 +1,10 @@
import 'package:date_format/date_format.dart';
import 'package:flutter/material.dart';
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/lockDetail/electronicKey/electronicKeyPeriodValidity/KeyPeriodValidityModel.dart';
import '../../../../app_settings/app_colors.dart';
import '../../../../tools/commonItem.dart';
@ -18,6 +22,34 @@ class ElectronicKeyPeriodValidityPage extends StatefulWidget {
class _ElectronicKeyPeriodValidityPageState
extends State<ElectronicKeyPeriodValidityPage> {
List validityTextList = [
TranslationLoader.lanKeys!.sundayShort!.tr,
TranslationLoader.lanKeys!.mondayShort!.tr,
TranslationLoader.lanKeys!.tuesdayShort!.tr,
TranslationLoader.lanKeys!.wednesdayShort!.tr,
TranslationLoader.lanKeys!.thursdayShort!.tr,
TranslationLoader.lanKeys!.fridayShort!.tr,
TranslationLoader.lanKeys!.saturdayShort!.tr
];
List validityDataList = []; //
List selectIndexList = []; //
String _effectiveTime = '';
String _failureTime = '';
String _effectiveDate = '';
String _failureDate = '';
@override
void initState() {
super.initState();
for (var i = 0; i < validityTextList.length; i++) {
KeyPeriodValidityModel model =
KeyPeriodValidityModel(validityTextList[i], i, false);
validityDataList.add(model);
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
@ -26,12 +58,9 @@ class _ElectronicKeyPeriodValidityPageState
barTitle: TranslationLoader.lanKeys!.periodValidity!.tr,
haveBack: true,
backgroundColor: AppColors.mainColor),
body: Column(
body: ListView(
children: [
topWidget(),
// SizedBox(
// height: 1.h,
// ),
Container(
color: Colors.white,
height: 10.h,
@ -68,56 +97,44 @@ class _ElectronicKeyPeriodValidityPageState
itemCount: 7,
physics: const NeverScrollableScrollPhysics(),
itemBuilder: (context, index) {
return btnItem(index);
KeyPeriodValidityModel model = validityDataList[index];
return btnItem(model);
}))
],
),
);
}
Widget btnItem(int index) {
String dateStr;
switch (index) {
case 0:
dateStr = TranslationLoader.lanKeys!.sundayShort!.tr;
break;
case 1:
dateStr = TranslationLoader.lanKeys!.mondayShort!.tr;
break;
case 2:
dateStr = TranslationLoader.lanKeys!.tuesdayShort!.tr;
break;
case 3:
dateStr = TranslationLoader.lanKeys!.wednesdayShort!.tr;
break;
case 4:
dateStr = TranslationLoader.lanKeys!.thursdayShort!.tr;
break;
case 5:
dateStr = TranslationLoader.lanKeys!.fridayShort!.tr;
break;
case 6:
dateStr = TranslationLoader.lanKeys!.saturdayShort!.tr;
break;
default:
dateStr = "";
break;
}
Widget btnItem(KeyPeriodValidityModel model) {
return GestureDetector(
onTap: () {},
onTap: () {
model.isValidity = !model.isValidity;
if (model.isValidity) {
selectIndexList.add(model.validityIndex);
} else {
selectIndexList.remove(model.validityIndex);
}
setState(() {});
},
child: Container(
width: 40.w,
height: 40.w,
margin: EdgeInsets.all(10.w),
decoration: BoxDecoration(
// color: Colors.blue,
color: selectIndexList.contains(model.validityIndex)
? Colors.blue
: Colors.white,
border: Border.all(width: 1, color: AppColors.greyBackgroundColor),
borderRadius: BorderRadius.circular(30.w),
),
child: Center(
child: Text(
dateStr,
style: TextStyle(fontSize: 20.sp, color: AppColors.darkGrayTextColor),
model.validityText,
style: TextStyle(
fontSize: 20.sp,
color: selectIndexList.contains(model.validityIndex)
? Colors.white
: AppColors.darkGrayTextColor),
)),
),
);
@ -128,27 +145,63 @@ class _ElectronicKeyPeriodValidityPageState
children: [
CommonItem(
leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr,
rightTitle: "",
rightTitle: _effectiveTime,
isHaveDirection: true,
isHaveLine: true,
action: () {}),
action: () {
Pickers.showDatePicker(context, mode: DateMode.HM,
onConfirm: (p) {
DateTime getPTime = DateTime.parse(
'${intToStr(p.hour!)}:${intToStr(p.minute!)}');
_effectiveTime = formatDate(getPTime, [HH, ':', nn]);
setState(() {});
});
}),
CommonItem(
leftTitel: TranslationLoader.lanKeys!.failureTime!.tr,
rightTitle: "",
rightTitle: _failureTime,
isHaveDirection: true,
action: () {}),
action: () {
Pickers.showDatePicker(context, mode: DateMode.HM,
onConfirm: (p) {
DateTime getPTime = DateTime.parse(
'${intToStr(p.hour!)}:${intToStr(p.minute!)}');
_failureTime = formatDate(getPTime, [HH, ':', nn]);
setState(() {});
});
}),
Container(height: 10.h),
CommonItem(
leftTitel: TranslationLoader.lanKeys!.effectiveDate!.tr,
rightTitle: "",
rightTitle: _effectiveDate,
isHaveDirection: true,
isHaveLine: true,
action: () {}),
action: () {
Pickers.showDatePicker(context, mode: DateMode.YMD,
onConfirm: (p) {
DateTime getPTime = DateTime.parse(
'${intToStr(p.year!)}-${intToStr(p.month!)}-${intToStr(p.day!)}');
_effectiveDate = formatDate(getPTime, [yyyy, '-', mm, '-', dd]);
setState(() {});
});
}),
CommonItem(
leftTitel: TranslationLoader.lanKeys!.failureDate!.tr,
rightTitle: "",
rightTitle: _failureDate,
isHaveDirection: true,
action: () {}),
action: () {
Pickers.showDatePicker(context, mode: DateMode.YMD,
onConfirm: (p) {
DateTime getPTime = DateTime.parse(
'${intToStr(p.year!)}-${intToStr(p.month!)}-${intToStr(p.day!)}');
_failureDate = formatDate(getPTime, [yyyy, '-', mm, '-', dd]);
setState(() {});
});
}),
Container(height: 40.h),
SubmitBtn(
btnName: TranslationLoader.lanKeys!.sure!.tr,
@ -161,4 +214,8 @@ class _ElectronicKeyPeriodValidityPageState
],
);
}
String intToStr(int v) {
return (v < 10) ? "0$v" : "$v";
}
}

View File

@ -1,15 +1,15 @@
import 'package:date_format/date_format.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
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:fluttertoast/fluttertoast.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/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';
import '../../../../../appRouters.dart';
import '../../../../../tools/commonItem.dart';
@ -34,22 +34,28 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> {
bool _isRemoteUnlock = false; //
bool _isAuthentication = false; //
var _selectEffectiveDate = ''; //
var _selectFailureDate = ''; //
String _selectEffectiveDate = ''; //
late DateTime _effectiveDateTime;
late DateTime _failureDateTime;
String _selectFailureDate = ''; //
TextEditingController emailOrPhoneController =
TextEditingController(); ///
TextEditingController keyNameController = TextEditingController(); //
late bool _isSendSuccess;
String countryName = '中国';
String countryCode = '86';
@override
void initState() {
super.initState();
DateTime dateTime = DateTime.now();
_selectEffectiveDate =
'${dateTime.year}-${dateTime.month}-${dateTime.day} ${dateTime.hour}:${dateTime.minute}'; //
_selectFailureDate =
'${dateTime.year}-${dateTime.month}-${dateTime.day} ${dateTime.hour}:${dateTime.minute}'; //
_effectiveDateTime = dateTime;
_failureDateTime = dateTime;
_selectEffectiveDate = formatDate(
dateTime, [yyyy, '-', mm, '-', dd, ' ', HH, ':', nn]); //
_selectFailureDate = formatDate(
dateTime, [yyyy, '-', mm, '-', dd, ' ', HH, ':', nn]); //
_isSendSuccess = false;
}
@ -137,6 +143,27 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> {
isHaveRightWidget: true,
rightWidget: getTFWidget(true,
TranslationLoader.lanKeys!.pleaseEnterNumberOrEmail!.tr, 1)),
CommonItem(
leftTitel: TranslationLoader.lanKeys!.countryAndRegion!.tr,
rightTitle: "",
isHaveLine: true,
isHaveRightWidget: true,
isHaveDirection: true,
rightWidget: Text(
'$countryName +$countryCode',
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>;
countryCode = result['code'];
countryName = result['countryName'];
setState(() {});
},
),
CommonItem(
leftTitel: TranslationLoader.lanKeys!.name!.tr,
rightTitle: "",
@ -161,8 +188,10 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> {
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
onConfirm: (p) {
setState(() {
_selectEffectiveDate =
'${p.year}-${p.month}-${p.day} ${p.hour}:${p.minute}';
_effectiveDateTime = DateTime.parse(
'${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}');
_selectEffectiveDate = formatDate(_effectiveDateTime,
[yyyy, '-', mm, '-', dd, ' ', HH, ':', nn]);
});
});
}),
@ -174,8 +203,10 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> {
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
onConfirm: (p) {
setState(() {
_selectFailureDate =
'${p.year}-${p.month}-${p.day} ${p.hour}:${p.minute}';
_failureDateTime = DateTime.parse(
'${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}');
_selectFailureDate = formatDate(_failureDateTime,
[yyyy, '-', mm, '-', dd, ' ', HH, ':', nn]);
});
});
}),
@ -243,7 +274,14 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> {
//
if (emailOrPhoneController.text.isNotEmpty &&
keyNameController.text.isNotEmpty) {
sendElectronicKeyRequest();
//
if (_failureDateTime.compareTo(_effectiveDateTime) == 1) {
sendElectronicKeyRequest();
} else {
Toast.show(msg: '失效时间需大于生效时间');
}
} else {
Toast.show(msg: '请完善信息');
}
}),
Container(
@ -269,6 +307,7 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> {
);
}
//
Future<void> sendElectronicKeyRequest() async {
String getFailureDateTime = '0';
String getEffectiveDateTime = '0';
@ -276,17 +315,14 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> {
String getKeyType = (int.parse(widget.type) + 1).toString();
if (widget.type == '0') {
getFailureDateTime =
DateTime.fromMillisecondsSinceEpoch(int.parse(_selectFailureDate))
.toString()
.substring(0, 19);
getEffectiveDateTime =
DateTime.fromMillisecondsSinceEpoch(int.parse(_selectEffectiveDate))
.toString()
.substring(0, 19);
DateTime.parse(_selectFailureDate).millisecondsSinceEpoch.toString();
getEffectiveDateTime = DateTime.parse(_selectEffectiveDate)
.millisecondsSinceEpoch
.toString();
}
var entity = await ApiRepository.to.sendElectronicKey(
'0',
'0',
countryCode,
'1',
getFailureDateTime,
_isAuthentication == true ? '1' : '2',
@ -301,9 +337,11 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> {
'0',
getEffectiveDateTime, []);
if (entity.errorCode!.codeIsSuccessful) {
// print('发送电子钥匙成功');
print('发送电子钥匙成功');
_isSendSuccess = true;
setState(() {});
} else {
Toast.show(msg: '${entity.errorMsg}');
}
}
@ -470,4 +508,8 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> {
},
);
}
String intToStr(int v) {
return (v < 10) ? "0$v" : "$v";
}
}

View File

@ -34,7 +34,7 @@ class _BasicInformationPageState extends State<BasicInformationPage> {
leftTitel: TranslationLoader.lanKeys!.lockNumber!.tr,
rightTitle: "MCBN0c_8f3106",
allHeight: 70.h,
isHaveLine: false),
isHaveLine: true),
CommonItem(
leftTitel: "MAC/ID",
rightTitle: "53:66:9F:06:31:8F/9418481",

View File

@ -2,6 +2,10 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecordEntity.dart';
import 'package:star_lock/network/api_repository.dart';
import 'package:star_lock/tools/baseGetXController.dart';
import 'package:star_lock/tools/toast.dart';
import '../../../../../app_settings/app_colors.dart';
import '../../../../../tools/tf_loginInput.dart';
@ -25,6 +29,16 @@ class _EditLockNamePageState extends State<EditLockNamePage> {
_changeLockNameController.text = "MCBN0c_8f3106";
}
//
Future<void> modifyKeyNameRequest() async {
KeyOperationRecordEntity entity = await ApiRepository.to
.modifyKeyName('63', '28', _changeLockNameController.text, '0');
if (entity.errorCode!.codeIsSuccessful) {
print("修改锁名称成功啦啦啦啦啦");
Toast.show(msg: "修改成功");
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
@ -39,7 +53,9 @@ class _EditLockNamePageState extends State<EditLockNamePage> {
TranslationLoader.lanKeys!.sure!.tr,
style: TextStyle(color: Colors.white, fontSize: 24.sp),
),
onPressed: () {},
onPressed: () {
modifyKeyNameRequest();
},
),
],
),

View File

@ -1,6 +1,10 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecordEntity.dart';
import 'package:star_lock/network/api_repository.dart';
import 'package:star_lock/tools/baseGetXController.dart';
import 'package:star_lock/tools/toast.dart';
import '../../../../../app_settings/app_colors.dart';
import '../../../../../tools/submitBtn.dart';
@ -17,6 +21,16 @@ class UploadElectricQuantityPage extends StatefulWidget {
class _UploadElectricQuantityPageState
extends State<UploadElectricQuantityPage> {
//
Future<void> uploadElectricQuantityRequest() async {
KeyOperationRecordEntity entity =
await ApiRepository.to.uploadElectricQuantity('100', '28');
if (entity.errorCode!.codeIsSuccessful) {
print("锁电量更新成功啦啦啦啦啦");
Toast.show(msg: "锁电量更新成功");
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
@ -61,7 +75,9 @@ class _UploadElectricQuantityPageState
fontSize: 32.sp,
// margin: EdgeInsets.only(left: 03.w, right: 30.w, top: 20.w),
padding: EdgeInsets.only(top: 20.w, bottom: 20.w),
onClick: () {}),
onClick: () {
uploadElectricQuantityRequest();
}),
],
),
));

View File

@ -2,6 +2,7 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyListEntity.dart';
import 'package:star_lock/tools/shareModule/sharePopup.dart';
import '../../../../appRouters.dart';
@ -19,8 +20,15 @@ class PasswordKeyDetailPage extends StatefulWidget {
}
class _PasswordKeyDetailPageState extends State<PasswordKeyDetailPage> {
PasswordKeyListItem itemData = PasswordKeyListItem();
@override
Widget build(BuildContext context) {
dynamic obj = ModalRoute.of(context)?.settings.arguments;
if (obj != null && (obj["itemData"] != null)) {
itemData = obj["itemData"];
}
return Scaffold(
backgroundColor: AppColors.mainBackgroundColor,
appBar: TitleAppBar(
@ -51,7 +59,7 @@ class _PasswordKeyDetailPageState extends State<PasswordKeyDetailPage> {
children: [
CommonItem(
leftTitel: TranslationLoader.lanKeys!.password!.tr,
rightTitle: "98765432",
rightTitle: itemData.keyboardPwd,
isHaveDirection: true,
isHaveLine: true,
action: () {
@ -59,7 +67,7 @@ class _PasswordKeyDetailPageState extends State<PasswordKeyDetailPage> {
}),
CommonItem(
leftTitel: TranslationLoader.lanKeys!.name!.tr,
rightTitle: "你好",
rightTitle: itemData.keyboardPwdName,
isHaveDirection: true,
isHaveLine: true,
action: () {
@ -76,11 +84,11 @@ class _PasswordKeyDetailPageState extends State<PasswordKeyDetailPage> {
Container(height: 10.h),
CommonItem(
leftTitel: TranslationLoader.lanKeys!.sender!.tr,
rightTitle: "15080825640",
rightTitle: itemData.senderUsername,
action: () {}),
CommonItem(
leftTitel: TranslationLoader.lanKeys!.senderTime!.tr,
rightTitle: "2020.06.21 11:49",
rightTitle: itemData.sendDate.toString(),
action: () {}),
Container(height: 10.h),
CommonItem(

View File

@ -0,0 +1,134 @@
class PasswordKeyListEntity {
int? errorCode;
String? description;
String? errorMsg;
PasswordKeyListData? data;
PasswordKeyListEntity(
{this.errorCode, this.description, this.errorMsg, this.data});
PasswordKeyListEntity.fromJson(Map<String, dynamic> json) {
errorCode = json['errorCode'];
description = json['description'];
errorMsg = json['errorMsg'];
data = json['data'] != null
? PasswordKeyListData.fromJson(json['data'])
: null;
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['errorCode'] = errorCode;
data['description'] = description;
data['errorMsg'] = errorMsg;
if (this.data != null) {
data['data'] = this.data!.toJson();
}
return data;
}
}
class PasswordKeyListData {
List<PasswordKeyListItem>? itemList;
int? pageNo;
int? pageSize;
int? pages;
int? total;
PasswordKeyListData(
{this.itemList, this.pageNo, this.pageSize, this.pages, this.total});
PasswordKeyListData.fromJson(Map<String, dynamic> json) {
if (json['list'] != null) {
itemList = <PasswordKeyListItem>[];
json['list'].forEach((v) {
itemList!.add(PasswordKeyListItem.fromJson(v));
});
}
pageNo = json['pageNo'];
pageSize = json['pageSize'];
pages = json['pages'];
total = json['total'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
if (itemList != null) {
data['list'] = itemList!.map((v) => v.toJson()).toList();
}
data['pageNo'] = pageNo;
data['pageSize'] = pageSize;
data['pages'] = pages;
data['total'] = total;
return data;
}
}
class PasswordKeyListItem {
int? apiUserId;
int? lockId;
String? keyboardPwd;
String? keyboardPwdName;
int? keyboardPwdStatus;
int? keyboardPwdType;
int? startDate;
int? endDate;
int? isCustom;
String? createdAt;
String? senderUsername;
int? keyboardPwdId;
int? sendDate;
String? validTimeStr;
PasswordKeyListItem(
{this.apiUserId,
this.lockId,
this.keyboardPwd,
this.keyboardPwdName,
this.keyboardPwdStatus,
this.keyboardPwdType,
this.startDate,
this.endDate,
this.isCustom,
this.createdAt,
this.senderUsername,
this.keyboardPwdId,
this.sendDate,
this.validTimeStr});
PasswordKeyListItem.fromJson(Map<String, dynamic> json) {
apiUserId = json['apiUserId'];
lockId = json['lockId'];
keyboardPwd = json['keyboardPwd'];
keyboardPwdName = json['keyboardPwdName'];
keyboardPwdStatus = json['keyboardPwdStatus'];
keyboardPwdType = json['keyboardPwdType'];
startDate = json['startDate'];
endDate = json['endDate'];
isCustom = json['isCustom'];
createdAt = json['created_at'];
senderUsername = json['senderUsername'];
keyboardPwdId = json['keyboardPwdId'];
sendDate = json['sendDate'];
validTimeStr = json['validTimeStr'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['apiUserId'] = apiUserId;
data['lockId'] = lockId;
data['keyboardPwd'] = keyboardPwd;
data['keyboardPwdName'] = keyboardPwdName;
data['keyboardPwdStatus'] = keyboardPwdStatus;
data['keyboardPwdType'] = keyboardPwdType;
data['startDate'] = startDate;
data['endDate'] = endDate;
data['isCustom'] = isCustom;
data['created_at'] = createdAt;
data['senderUsername'] = senderUsername;
data['keyboardPwdId'] = keyboardPwdId;
data['sendDate'] = sendDate;
data['validTimeStr'] = validTimeStr;
return data;
}
}

View File

@ -1,6 +1,10 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyListEntity.dart';
import 'package:star_lock/network/api_repository.dart';
import 'package:star_lock/tools/baseGetXController.dart';
import 'package:star_lock/tools/toast.dart';
import '../../../../appRouters.dart';
import '../../../../app_settings/app_colors.dart';
@ -30,34 +34,83 @@ class _PasswordKeyListPageState extends State<PasswordKeyListPage> {
TranslationLoader.lanKeys!.reset!.tr,
style: TextStyle(color: Colors.white, fontSize: 24.sp),
),
onPressed: () {},
),
],
),
body: Column(
children: [
_searchWidget(),
SizedBox(
height: 20.h,
),
Expanded(child: _buildMainUI()),
SizedBox(
height: 20.h,
),
AddBottomWhiteBtn(
btnName: TranslationLoader.lanKeys!.getPassword!.tr,
onClick: () {
Navigator.pushNamed(context, Routers.passwordKeyManagePage);
onPressed: () {
resetPasswordKeyListRequest();
},
),
SizedBox(
height: 42.h,
)
],
),
body: FutureBuilder<List<PasswordKeyListItem>>(
future: mockNetworkDataRequest(),
builder: (BuildContext context,
AsyncSnapshot<List<PasswordKeyListItem>> snapshot) {
//
if (snapshot.connectionState == ConnectionState.done) {
if (snapshot.hasError) {
//
return const Text('请求失败');
} else {
//
final List<PasswordKeyListItem> itemData = snapshot.data!;
return Column(
children: [
_searchWidget(),
SizedBox(
height: 20.h,
),
Expanded(child: _buildMainUI(itemData)),
SizedBox(
height: 20.h,
),
AddBottomWhiteBtn(
btnName: TranslationLoader.lanKeys!.getPassword!.tr,
onClick: () {
Navigator.pushNamed(
context, Routers.passwordKeyManagePage);
},
),
SizedBox(
height: 42.h,
)
],
);
}
} else {
// loading
return Container();
}
}),
);
}
//
Future<List<PasswordKeyListItem>> mockNetworkDataRequest() async {
PasswordKeyListEntity entity =
await ApiRepository.to.passwordKeyList('0', '28', '0', '1', '20');
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.resetPasswordKey('28', '0');
if (entity.errorCode!.codeIsSuccessful) {
print("重置电子钥匙成功啦啦啦啦啦");
Toast.show(msg: "重置成功");
mockNetworkDataRequest();
setState(() {});
}
}
Widget _searchWidget() {
return Container(
height: 60.h,
@ -93,13 +146,21 @@ class _PasswordKeyListPageState extends State<PasswordKeyListPage> {
);
}
Widget _buildMainUI() {
Widget _buildMainUI(itemData) {
List<PasswordKeyListItem> getItemData = itemData;
return ListView.separated(
itemCount: 5,
itemCount: getItemData.length,
itemBuilder: (c, index) {
return _electronicKeyItem('images/icon_password.png', "张三",
"2023.6.21 11.15", "2023.6.21 11.15", () {
Navigator.pushNamed(context, Routers.passwordKeyDetailPage);
PasswordKeyListItem indexEntity = getItemData[index];
String useDateStr = ''; //使
//使
useDateStr = getUseDateStr(indexEntity);
return _electronicKeyItem('images/controls_user.png',
indexEntity.keyboardPwdName!, useDateStr, () {
Navigator.pushNamed(context, Routers.passwordKeyDetailPage,
arguments: {"itemData": indexEntity});
});
},
separatorBuilder: (BuildContext context, int index) {
@ -111,8 +172,53 @@ class _PasswordKeyListPageState extends State<PasswordKeyListPage> {
);
}
//使
/**
1 6使
2 24使
3 24使
4 使使
5
6
7
8
9
10
11
12
13
14
*/
String getUseDateStr(PasswordKeyListItem indexEntity) {
String useDateStr = '';
if (indexEntity.keyboardPwdType == 3) {
//
DateTime startDateStr =
DateTime.fromMillisecondsSinceEpoch(indexEntity.startDate!);
DateTime endDateStr =
DateTime.fromMillisecondsSinceEpoch(indexEntity.endDate!);
useDateStr =
'${startDateStr.toLocal().toString().substring(0, 16)}-${endDateStr.toLocal().toString().substring(0, 16)}';
} else if (indexEntity.keyboardPwdType == 2) {
//
DateTime dateStr =
DateTime.fromMillisecondsSinceEpoch(indexEntity.sendDate!);
useDateStr = '${dateStr.toLocal().toString().substring(0, 16)} 永久';
} else if (indexEntity.keyboardPwdType == 1) {
//
DateTime dateStr =
DateTime.fromMillisecondsSinceEpoch(indexEntity.sendDate!);
useDateStr = '${dateStr.toLocal().toString().substring(0, 16)} 单次';
} else if (indexEntity.keyboardPwdType == 4) {
//
useDateStr = '循环';
}
return useDateStr;
}
Widget _electronicKeyItem(String lockTypeIcon, String lockTypeTitle,
String beginTime, String endTime, Function()? action) {
String useDateStr, Function()? action) {
return GestureDetector(
onTap: action,
child: Container(
@ -147,18 +253,16 @@ class _PasswordKeyListPageState extends State<PasswordKeyListPage> {
],
),
SizedBox(height: 5.h),
Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
"2023.6.21 18:00 清空码",
style: TextStyle(
fontSize: 18.sp,
color: AppColors.placeholderTextColor),
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
useDateStr,
style: TextStyle(
fontSize: 18.sp,
color: AppColors.placeholderTextColor),
),
],
),
SizedBox(width: 20.h),
],

View File

@ -1,7 +1,8 @@
abstract class Api {
// final String baseUrl = "http://test.lock.star-lock.cn/api"; //
// final String baseUrl = "https://lock.star-lock.cn/api"; //
final String baseUrl = "http://wenlin.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 getVerificationCodeUrl = '/user/sendValidationCode';
@ -18,6 +19,10 @@ abstract class Api {
final String uploadElectricQuantityURL =
'/room/uploadElectricQuantity'; //
final String bindingBlueAdminURL =
'/lock/bindAdmin'; //
final String bindingBlueAdminURL = '/lock/bindAdmin'; //
final String modifyKeyNameURL = '/key/modifyKeyName'; //
final String modifyKeyNameForAdminURL =
'/key/modifyKeyNameForAdmin'; //
final String passwordKeyListURL = '/keyboardPwd/listSendRecords'; //
final String passwordKeyResetURL = '/keyboardPwd/reset'; //
}

View File

@ -101,7 +101,8 @@ class ApiProvider extends BaseProvider {
String operatorUid,
String pageNo,
String pageSize,
String startDate) =>
String startDate,
String keyRight) =>
post(
electronicKeyListURL.toUrl,
jsonEncode({
@ -113,6 +114,7 @@ class ApiProvider extends BaseProvider {
'pageNo': pageNo,
'pageSize': pageSize,
'startDate': startDate,
'keyRight': keyRight
}));
Future<Response> sendElectronicKey(
@ -164,6 +166,34 @@ class ApiProvider extends BaseProvider {
'lockId': lockId,
}));
Future<Response> modifyKeyName(
String keyId,
String lockId,
String keyName,
String operatorUid,
) =>
post(
modifyKeyNameURL.toUrl,
jsonEncode({
'keyId': keyId,
'lockId': lockId,
'keyName': keyName,
'operatorUid': operatorUid,
}));
Future<Response> modifyKeyNameForAdmin(
String keyId,
String keyNameForAdmin,
String operatorUid,
) =>
post(
modifyKeyNameForAdminURL.toUrl,
jsonEncode({
'keyId': keyId,
'keyNameForAdmin': keyNameForAdmin,
'operatorUid': operatorUid,
}));
Future<Response> resetElectronicKey(String lockId, String operatorUid) =>
post(resetElectronicKeyURL.toUrl,
jsonEncode({'lockId': lockId, 'operatorUid': operatorUid}));
@ -198,13 +228,13 @@ class ApiProvider extends BaseProvider {
//
Future<Response> bindingBlueAdmin(
String bindingDate,
String hotelMode,
String lockAlias,
String lockData,
String nbInitSuccess,
String position,
String deviceNo) =>
String bindingDate,
String hotelMode,
String lockAlias,
String lockData,
String nbInitSuccess,
String position,
String deviceNo) =>
post(
bindingBlueAdminURL.toUrl,
jsonEncode({
@ -216,8 +246,28 @@ class ApiProvider extends BaseProvider {
'position': position,
'deviceNo': deviceNo
}));
Future<Response> passwordKeyList(
String keyStatus,
String lockId,
String operatorUid,
String pageNo,
String pageSize,
) =>
post(
passwordKeyListURL.toUrl,
jsonEncode({
'keyStatus': keyStatus,
'lockId': lockId,
'operatorUid': operatorUid,
'pageNo': pageNo,
'pageSize': pageSize
}));
Future<Response> resetPasswordKey(String lockId, String operatorUid) => post(
resetElectronicKeyURL.toUrl,
jsonEncode({'lockId': lockId, 'operatorUid': operatorUid}));
}
extension ExtensionString on String {
String get toUrl => '$this';
String get toUrl => this;
}

View File

@ -53,7 +53,7 @@ class BaseProvider extends GetConnect with Api {
statusText: res.statusText,
);
}
print('得到的数据======>$res');
print('得到的数据======>${res.bodyString}');
return res;
}
}

View File

@ -1,6 +1,8 @@
import 'package:get/get.dart';
import 'package:star_lock/login/seletCountryRegion/common/countryRegionEntity.dart';
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecordEntity.dart';
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart';
import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyListEntity.dart';
import '../common/safetyVerification/entity/CheckSafetyVerificationEntity.dart';
import '../common/safetyVerification/entity/SafetyVerificationEntity.dart';
import '../login/login/entity/LoginEntity.dart';
@ -77,9 +79,9 @@ class ApiRepository {
}
// json文件
Future<LoginEntity> getCountryRegion(String type) async {
Future<CountryRegionEntity> getCountryRegion(String type) async {
final res = await apiProvider.getCountryRegion(type);
return LoginEntity.fromJson(res.body);
return CountryRegionEntity.fromJson(res.body);
}
//
@ -91,9 +93,10 @@ class ApiRepository {
String operatorUid,
String pageNo,
String pageSize,
String startDate) async {
String startDate,
String keyRight) async {
final res = await apiProvider.electronicKeyList(endDate, keyId, keyStatus,
lockId, operatorUid, pageNo, pageSize, startDate);
lockId, operatorUid, pageNo, pageSize, startDate, keyRight);
return ElectronicKeyListEntity.fromJson(res.body);
}
@ -188,5 +191,54 @@ class ApiRepository {
position,
deviceNo);
return SaveLockEntity.fromJson(res.body);
//
Future<KeyOperationRecordEntity> uploadElectricQuantity(
String electricQuantity, String lockId) async {
final res =
await apiProvider.uploadElectricQuantity(electricQuantity, lockId);
return KeyOperationRecordEntity.fromJson(res.body);
}
//
Future<KeyOperationRecordEntity> modifyKeyName(
String keyId,
String lockId,
String keyName,
String operatorUid,
) async {
final res =
await apiProvider.modifyKeyName(keyId, lockId, keyName, operatorUid);
return KeyOperationRecordEntity.fromJson(res.body);
}
//
Future<KeyOperationRecordEntity> modifyKeyNameForAdmin(
String keyId,
String keyNameForAdmin,
String operatorUid,
) async {
final res = await apiProvider.modifyKeyNameForAdmin(
keyId, keyNameForAdmin, operatorUid);
return KeyOperationRecordEntity.fromJson(res.body);
}
//
Future<PasswordKeyListEntity> passwordKeyList(
String keyStatus,
String lockId,
String operatorUid,
String pageNo,
String pageSize,
) async {
final res = await apiProvider.passwordKeyList(
keyStatus, lockId, operatorUid, pageNo, pageSize);
return PasswordKeyListEntity.fromJson(res.body);
}
//
Future<PasswordKeyListEntity> resetPasswordKey(
String lockId, String operatorUid) async {
final res = await apiProvider.resetPasswordKey(lockId, operatorUid);
return PasswordKeyListEntity.fromJson(res.body);
}
}

View File

@ -9,8 +9,17 @@ class ShowTFView extends StatelessWidget {
String? title;
String? tipTitle;
TextEditingController? controller;
Function()? sureClick;
Function()? cancelClick;
ShowTFView({Key? key, this.title, this.tipTitle, this.controller}) : super(key: key);
ShowTFView(
{Key? key,
this.title,
this.tipTitle,
this.controller,
this.sureClick,
this.cancelClick})
: super(key: key);
@override
Widget build(BuildContext context) {
@ -20,15 +29,16 @@ class ShowTFView extends StatelessWidget {
title: Text(title!),
content: Column(
children: <Widget>[
const SizedBox(height: 10,),
const SizedBox(
height: 10,
),
Container(
height: 50.h,
// color: Colors.white,
// padding: EdgeInsets.only(left:20.w, right: 110.w),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(15.w)
),
borderRadius: BorderRadius.circular(15.w)),
child: TextField(
//
maxLines: 1,
@ -36,9 +46,10 @@ class ShowTFView extends StatelessWidget {
autofocus: false,
decoration: InputDecoration(
//
contentPadding: EdgeInsets.only(top: 20.h, left: 15.0, bottom: 13.h),
contentPadding:
EdgeInsets.only(top: 20.h, left: 15.0, bottom: 13.h),
hintText: tipTitle,
hintStyle:TextStyle(fontSize: 28.sp),
hintStyle: TextStyle(fontSize: 28.sp),
//线
border: InputBorder.none,
//
@ -66,16 +77,26 @@ class ShowTFView extends StatelessWidget {
),
actions: <Widget>[
CupertinoDialogAction(
child: Text(TranslationLoader.lanKeys!.cancel!.tr, style: const TextStyle(color: Colors.black),),
child: Text(
TranslationLoader.lanKeys!.cancel!.tr,
style: const TextStyle(color: Colors.black),
),
onPressed: () {
Navigator.pop(context);
// Navigator.pop(context);
// print("取消");
if (cancelClick != null) {
cancelClick!();
}
},
),
CupertinoDialogAction(
child: Text(TranslationLoader.lanKeys!.sure!.tr, style: const TextStyle(color: Colors.black)),
child: Text(TranslationLoader.lanKeys!.sure!.tr,
style: const TextStyle(color: Colors.black)),
onPressed: () {
Navigator.pop(context);
if (sureClick != null) {
sureClick!();
}
// Navigator.pop(context);
// print("确定");
},
),

View File

@ -87,6 +87,7 @@ dependencies:
#加密解密
encrypt: ^5.0.1
crypto: ^3.0.3
date_format: ^2.0.7
#高德地图定位
amap_flutter_location: ^3.0.0
@ -125,7 +126,6 @@ flutter:
- images/lan/
- images/mine/
- images/lockType/
- assets/
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware