1,新增获取国家或地区接口URL
2,新增电子钥匙列表接口及功能逻辑 3,新增发送电子钥匙接口 4,新增锁电量更新接口URL
This commit is contained in:
parent
fae49d89b0
commit
9cefa5d4bd
@ -0,0 +1,9 @@
|
||||
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());
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
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';
|
||||
|
||||
class ElectronicKeyListLogic {
|
||||
late ElectronicKeyListEntity dataEntity = ElectronicKeyListEntity();
|
||||
void electronicKeyList() async {
|
||||
var entity = await ApiRepository.to
|
||||
.electronicKeyList('0', '63', '0', '28', '1', '1', '20', '0');
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
print("电子钥匙列表成功:${entity.data?.itemList}");
|
||||
dataEntity = entity;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,11 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.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/network/api_repository.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
|
||||
import '../../../../appRouters.dart';
|
||||
import '../../../../app_settings/app_colors.dart';
|
||||
@ -16,6 +21,23 @@ class ElectronicKeyListPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _ElectronicKeyListPageState extends State<ElectronicKeyListPage> {
|
||||
final logic = Get.put(ElectronicKeyListLogic());
|
||||
|
||||
//请求电子钥匙列表
|
||||
Future<List<ElectronicKeyListItem>> mockNetworkData() async {
|
||||
ElectronicKeyListEntity entity = await ApiRepository.to
|
||||
.electronicKeyList('0', '63', '0', '28', '1', '1', '20', '0');
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
print("电子钥匙列表成功:${entity.data?.itemList}");
|
||||
}
|
||||
if (entity.data != null) {
|
||||
return entity.data!.itemList;
|
||||
} else {
|
||||
List<ElectronicKeyListItem> dataList = [];
|
||||
return dataList;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
@ -34,24 +56,44 @@ class _ElectronicKeyListPageState extends State<ElectronicKeyListPage> {
|
||||
),
|
||||
],
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
_searchWidget(),
|
||||
SizedBox(
|
||||
height: 20.h,
|
||||
),
|
||||
Expanded(child: _buildMainUI()),
|
||||
AddBottomWhiteBtn(
|
||||
btnName: TranslationLoader.lanKeys!.sendKey!.tr,
|
||||
onClick: () {
|
||||
Navigator.pushNamed(context, Routers.sendElectronicKeyManagePage);
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 64.h,
|
||||
)
|
||||
],
|
||||
),
|
||||
body: FutureBuilder<List<ElectronicKeyListItem>>(
|
||||
future: mockNetworkData(),
|
||||
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: [
|
||||
_searchWidget(),
|
||||
SizedBox(
|
||||
height: 20.h,
|
||||
),
|
||||
Expanded(child: _buildMainUI(itemData)),
|
||||
AddBottomWhiteBtn(
|
||||
btnName: TranslationLoader.lanKeys!.sendKey!.tr,
|
||||
onClick: () {
|
||||
Navigator.pushNamed(
|
||||
context, Routers.sendElectronicKeyManagePage);
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 64.h,
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
} else {
|
||||
//请求未结束 显示loading
|
||||
return Container();
|
||||
}
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
@ -90,12 +132,30 @@ class _ElectronicKeyListPageState extends State<ElectronicKeyListPage> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildMainUI() {
|
||||
Widget _buildMainUI(itemData) {
|
||||
List<ElectronicKeyListItem> getItemData = itemData;
|
||||
return ListView.separated(
|
||||
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.senderUsername!, useDateStr, keyStatus, isAdminKey, () {
|
||||
Navigator.pushNamed(context, Routers.electronicKeyDetailPage);
|
||||
});
|
||||
},
|
||||
@ -108,8 +168,59 @@ class _ElectronicKeyListPageState extends State<ElectronicKeyListPage> {
|
||||
);
|
||||
}
|
||||
|
||||
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()} 永久';
|
||||
} else if (indexEntity.keyType == 3) {
|
||||
//单次
|
||||
DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.date!);
|
||||
useDateStr = '${dateStr.toLocal().toString()} 单次';
|
||||
} 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(
|
||||
@ -121,7 +232,7 @@ class _ElectronicKeyListPageState extends State<ElectronicKeyListPage> {
|
||||
width: 30.w,
|
||||
),
|
||||
Image.asset(
|
||||
lockTypeIcon,
|
||||
avatarURL,
|
||||
width: 60.w,
|
||||
height: 60.w,
|
||||
),
|
||||
@ -136,39 +247,39 @@ class _ElectronicKeyListPageState extends State<ElectronicKeyListPage> {
|
||||
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
lockTypeTitle,
|
||||
receiveUser,
|
||||
style: TextStyle(
|
||||
fontSize: 24.sp, color: AppColors.blackColor),
|
||||
),
|
||||
SizedBox(width: 10.w),
|
||||
Image.asset(
|
||||
'images/icon_electronicKey_admin.png',
|
||||
width: 24.w,
|
||||
height: 20.w,
|
||||
),
|
||||
isAdminKey
|
||||
? Image.asset(
|
||||
'images/icon_electronicKey_admin.png',
|
||||
width: 24.w,
|
||||
height: 20.w,
|
||||
)
|
||||
: Container(),
|
||||
Expanded(
|
||||
child: SizedBox(
|
||||
width: 20.w,
|
||||
)),
|
||||
Text(
|
||||
"待接收",
|
||||
keyStatus,
|
||||
style: TextStyle(fontSize: 18.sp, color: Colors.red),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 10.h),
|
||||
Container(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"2023.6.21 11.15-2023.6.21 11.15",
|
||||
style: TextStyle(
|
||||
fontSize: 18.sp,
|
||||
color: AppColors.placeholderTextColor),
|
||||
),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
useDate,
|
||||
style: TextStyle(
|
||||
fontSize: 18.sp,
|
||||
color: AppColors.placeholderTextColor),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(width: 20.h),
|
||||
],
|
||||
|
||||
@ -0,0 +1,164 @@
|
||||
class ElectronicKeyListEntity {
|
||||
int? errorCode;
|
||||
String? description;
|
||||
String? errorMsg;
|
||||
ElectronicKeyListData? data;
|
||||
|
||||
ElectronicKeyListEntity(
|
||||
{this.errorCode, this.description, this.errorMsg, this.data});
|
||||
|
||||
ElectronicKeyListEntity.fromJson(Map<String, dynamic> json) {
|
||||
errorCode = json['errorCode'];
|
||||
description = json['description'];
|
||||
errorMsg = json['errorMsg'];
|
||||
data = json['data'] != null
|
||||
? ElectronicKeyListData.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 ElectronicKeyListData {
|
||||
late List<ElectronicKeyListItem> itemList;
|
||||
int? pageNo;
|
||||
int? pageSize;
|
||||
int? pages;
|
||||
int? total;
|
||||
|
||||
ElectronicKeyListData(
|
||||
{required this.itemList,
|
||||
this.pageNo,
|
||||
this.pageSize,
|
||||
this.pages,
|
||||
this.total});
|
||||
|
||||
ElectronicKeyListData.fromJson(Map<String, dynamic> json) {
|
||||
if (json['list'] != null) {
|
||||
itemList = <ElectronicKeyListItem>[];
|
||||
json['list'].forEach((v) {
|
||||
itemList.add(ElectronicKeyListItem.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>{};
|
||||
data['list'] = itemList.map((v) => v.toJson()).toList();
|
||||
data['pageNo'] = pageNo;
|
||||
data['pageSize'] = pageSize;
|
||||
data['pages'] = pages;
|
||||
data['total'] = total;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class ElectronicKeyListItem {
|
||||
int? keyId;
|
||||
int? lockId;
|
||||
String? username;
|
||||
String? lockName;
|
||||
String? lockAlias;
|
||||
int? userType;
|
||||
String? keyName;
|
||||
int? keyStatus;
|
||||
int? startDate;
|
||||
int? endDate;
|
||||
int? keyRight;
|
||||
int? keyType;
|
||||
String? senderUsername;
|
||||
String? remarks;
|
||||
int? isCameraEnable;
|
||||
int? faceAuthentication;
|
||||
int? date;
|
||||
int? remoteEnable;
|
||||
int? appUnlockMustOnline;
|
||||
List<int>? weekDays;
|
||||
|
||||
ElectronicKeyListItem(
|
||||
{this.keyId,
|
||||
this.lockId,
|
||||
this.username,
|
||||
this.lockName,
|
||||
this.lockAlias,
|
||||
this.userType,
|
||||
this.keyName,
|
||||
this.keyStatus,
|
||||
this.startDate,
|
||||
this.endDate,
|
||||
this.keyRight,
|
||||
this.keyType,
|
||||
this.senderUsername,
|
||||
this.remarks,
|
||||
this.isCameraEnable,
|
||||
this.faceAuthentication,
|
||||
this.date,
|
||||
this.remoteEnable,
|
||||
this.appUnlockMustOnline,
|
||||
this.weekDays});
|
||||
|
||||
ElectronicKeyListItem.fromJson(Map<String, dynamic> json) {
|
||||
keyId = json['keyId'];
|
||||
lockId = json['lockId'];
|
||||
json['username'] != null ? username = json['username'] : "";
|
||||
json['lockName'] != null ? lockName = json['lockName'] : "";
|
||||
lockAlias = json['lockAlias'];
|
||||
userType = json['userType'];
|
||||
keyName = json['keyName'];
|
||||
keyStatus = json['keyStatus'];
|
||||
startDate = json['startDate'];
|
||||
endDate = json['endDate'];
|
||||
keyRight = json['keyRight'];
|
||||
keyType = json['keyType'];
|
||||
senderUsername = json['senderUsername'];
|
||||
json['remarks'] != null ? remarks = json['remarks'] : "";
|
||||
json['isCameraEnable'] != null
|
||||
? isCameraEnable = json['isCameraEnable']
|
||||
: 0;
|
||||
json['faceAuthentication'] != null
|
||||
? faceAuthentication = json['faceAuthentication']
|
||||
: 0;
|
||||
date = json['date'];
|
||||
remoteEnable = json['remoteEnable'];
|
||||
appUnlockMustOnline = json['appUnlockMustOnline'];
|
||||
json['weekDays'] != null ? weekDays = json['weekDays'] : [];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['keyId'] = keyId;
|
||||
data['lockId'] = lockId;
|
||||
data['username'] = username;
|
||||
data['lockName'] = lockName;
|
||||
data['lockAlias'] = lockAlias;
|
||||
data['userType'] = userType;
|
||||
data['keyName'] = keyName;
|
||||
data['keyStatus'] = keyStatus;
|
||||
data['startDate'] = startDate;
|
||||
data['endDate'] = endDate;
|
||||
data['keyRight'] = keyRight;
|
||||
data['keyType'] = keyType;
|
||||
data['senderUsername'] = senderUsername;
|
||||
data['remarks'] = remarks;
|
||||
data['isCameraEnable'] = isCameraEnable;
|
||||
data['faceAuthentication'] = faceAuthentication;
|
||||
data['date'] = date;
|
||||
data['remoteEnable'] = remoteEnable;
|
||||
data['appUnlockMustOnline'] = appUnlockMustOnline;
|
||||
data['weekDays'] = weekDays;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@ -10,20 +10,27 @@ class MassSendElectronicKeyManagePage extends StatefulWidget {
|
||||
const MassSendElectronicKeyManagePage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<MassSendElectronicKeyManagePage> createState() => _MassSendElectronicKeyManagePageState();
|
||||
State<MassSendElectronicKeyManagePage> createState() =>
|
||||
_MassSendElectronicKeyManagePageState();
|
||||
}
|
||||
|
||||
class _MassSendElectronicKeyManagePageState extends State<MassSendElectronicKeyManagePage> {
|
||||
var index=0;
|
||||
class _MassSendElectronicKeyManagePageState
|
||||
extends State<MassSendElectronicKeyManagePage> {
|
||||
var index = 0;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.mainBackgroundColor,
|
||||
appBar: TitleAppBar(barTitle: TranslationLoader.lanKeys!.sendGroupKey!.tr, haveBack:true, backgroundColor: AppColors.mainColor),
|
||||
appBar: TitleAppBar(
|
||||
barTitle: TranslationLoader.lanKeys!.sendGroupKey!.tr,
|
||||
haveBack: true,
|
||||
backgroundColor: AppColors.mainColor),
|
||||
body: Column(
|
||||
children: [
|
||||
MassSendElectronicKeyManageTabbar(initialIndex: index,),
|
||||
MassSendElectronicKeyManageTabbar(
|
||||
initialIndex: index,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
@ -0,0 +1,51 @@
|
||||
class ElectronicKeyListData {
|
||||
ElectronicKeyListData(
|
||||
{this.accessToken,
|
||||
this.userid,
|
||||
this.expiresAt,
|
||||
this.expiresAtString,
|
||||
this.mobile,
|
||||
this.headUrl,
|
||||
this.email,
|
||||
this.nickname,
|
||||
this.haveSafeAnswer,
|
||||
this.uid});
|
||||
|
||||
ElectronicKeyListData.fromJson(dynamic json) {
|
||||
accessToken = json['accessToken'];
|
||||
userid = json['userid'];
|
||||
expiresAt = json['expiresAt'];
|
||||
expiresAtString = json['expiresAtString'];
|
||||
mobile = json['mobile'];
|
||||
headUrl = json['headUrl'];
|
||||
email = json['email'];
|
||||
nickname = json['nickname'];
|
||||
haveSafeAnswer = json['haveSafeAnswer'];
|
||||
uid = json['uid'];
|
||||
}
|
||||
String? accessToken;
|
||||
int? userid;
|
||||
int? expiresAt;
|
||||
String? expiresAtString;
|
||||
String? mobile;
|
||||
String? headUrl;
|
||||
String? email;
|
||||
String? nickname;
|
||||
bool? haveSafeAnswer;
|
||||
int? uid;
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final map = <String, dynamic>{};
|
||||
map['accessToken'] = accessToken;
|
||||
map['userid'] = userid;
|
||||
map['expiresAt'] = expiresAt;
|
||||
map['expiresAtString'] = expiresAtString;
|
||||
map['mobile'] = mobile;
|
||||
map['headUrl'] = headUrl;
|
||||
map['email'] = email;
|
||||
map['nickname'] = nickname;
|
||||
map['haveSafeAnswer'] = haveSafeAnswer;
|
||||
map['uid'] = uid;
|
||||
return map;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,34 @@
|
||||
import '../../../electronicKeyList/entity/ElectronicKeyListEntity.dart';
|
||||
|
||||
class ElectronicKeyListEntity {
|
||||
ElectronicKeyListEntity({
|
||||
this.description,
|
||||
this.errorCode,
|
||||
this.data,
|
||||
this.errorMsg,
|
||||
});
|
||||
|
||||
ElectronicKeyListEntity.fromJson(dynamic json) {
|
||||
description = json['description'];
|
||||
errorCode = json['errorCode'];
|
||||
data = json['data'] != null
|
||||
? ElectronicKeyListData.fromJson(json['data'])
|
||||
: null;
|
||||
errorMsg = json['errorMsg'];
|
||||
}
|
||||
String? description;
|
||||
int? errorCode;
|
||||
ElectronicKeyListData? data;
|
||||
String? errorMsg;
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final map = <String, dynamic>{};
|
||||
map['description'] = description;
|
||||
map['errorCode'] = errorCode;
|
||||
if (data != null) {
|
||||
map['data'] = data!.toJson();
|
||||
}
|
||||
map['errorMsg'] = errorMsg;
|
||||
return map;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
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());
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,58 @@
|
||||
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';
|
||||
|
||||
class SendElectronicKeyLogic extends BaseGetXController {
|
||||
final SendElectronicKeyState state = SendElectronicKeyState();
|
||||
// final stateMyLogic = Get.put(SendElectronicKeyLogic()).state;
|
||||
|
||||
void sendElectronicKey() async {
|
||||
var entity = await ApiRepository.to.sendElectronicKey(
|
||||
'0',
|
||||
'0',
|
||||
'0',
|
||||
'0',
|
||||
'2',
|
||||
'2',
|
||||
'2',
|
||||
'0',
|
||||
'1',
|
||||
'0',
|
||||
'0',
|
||||
'小吴副号',
|
||||
'19128333512',
|
||||
'0',
|
||||
'0',
|
||||
'0');
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
print('发送电子钥匙成功');
|
||||
Get.back();
|
||||
}
|
||||
}
|
||||
|
||||
// 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();
|
||||
// }
|
||||
}
|
||||
@ -4,6 +4,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/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_logic.dart';
|
||||
|
||||
import '../../../../../appRouters.dart';
|
||||
import '../../../../../tools/commonItem.dart';
|
||||
@ -13,7 +14,7 @@ import '../../../../../translations/trans_lib.dart';
|
||||
class SendElectronicKeyPage extends StatefulWidget {
|
||||
final String type;
|
||||
|
||||
SendElectronicKeyPage({Key? key, required this.type}) : super(key: key);
|
||||
const SendElectronicKeyPage({Key? key, required this.type}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<SendElectronicKeyPage> createState() => _SendElectronicKeyPageState();
|
||||
@ -23,15 +24,17 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> {
|
||||
final FlutterContactPicker _contactPicker = FlutterContactPicker();
|
||||
late Contact _contact;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return indexChangeWidget();
|
||||
}
|
||||
final logic = Get.put(SendElectronicKeyLogic());
|
||||
// final state = Get.find<SendElectronicKeyLogic>().state;
|
||||
|
||||
bool _isRemoteUnlock = false; //是否允许远程开锁
|
||||
bool _isAuthentication = false; //是否可以实名认证
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
// TODO: implement initState
|
||||
super.initState();
|
||||
Widget build(BuildContext context) {
|
||||
return SingleChildScrollView(
|
||||
child: indexChangeWidget(),
|
||||
);
|
||||
}
|
||||
|
||||
Widget indexChangeWidget() {
|
||||
@ -102,14 +105,14 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> {
|
||||
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!.enterYourName!.tr)),
|
||||
false, TranslationLoader.lanKeys!.enterYourName!.tr, 2)),
|
||||
Container(height: 10.h),
|
||||
],
|
||||
);
|
||||
@ -148,7 +151,8 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> {
|
||||
rightTitle: "",
|
||||
isTipsImg: true,
|
||||
isHaveRightWidget: true,
|
||||
rightWidget: SizedBox(width: 60.w, height: 50.h, child: _switch()),
|
||||
rightWidget: SizedBox(
|
||||
width: 60.w, height: 50.h, child: _remoteSwitch(false)),
|
||||
action: () {}),
|
||||
],
|
||||
);
|
||||
@ -191,7 +195,12 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> {
|
||||
],
|
||||
),
|
||||
),
|
||||
SubmitBtn(btnName: TranslationLoader.lanKeys!.send!.tr, onClick: () {}),
|
||||
SubmitBtn(
|
||||
btnName: TranslationLoader.lanKeys!.send!.tr,
|
||||
onClick: () {
|
||||
//发送钥匙请求
|
||||
logic.sendElectronicKey();
|
||||
}),
|
||||
Container(
|
||||
padding: EdgeInsets.only(right: 30.w),
|
||||
// color: Colors.red,
|
||||
@ -276,14 +285,17 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> {
|
||||
}
|
||||
|
||||
// 接受者信息输入框
|
||||
Widget getTFWidget(bool isHaveBtn, String tfStr) {
|
||||
return Container(
|
||||
Widget getTFWidget(bool isHaveBtn, String tfStr, int lineIndex) {
|
||||
return SizedBox(
|
||||
height: 50.h,
|
||||
width: 320.w,
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: TextField(
|
||||
// controller: lineIndex == 1
|
||||
// ? state.emailOrPhoneController
|
||||
// : state.keyNameController,
|
||||
//输入框一行
|
||||
maxLines: 1,
|
||||
// controller: _controller,
|
||||
@ -315,9 +327,10 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> {
|
||||
alignment: Alignment.center,
|
||||
child: InkWell(
|
||||
onTap: () async {
|
||||
Contact? contact = await _contactPicker.selectContact();
|
||||
Contact? currentContact =
|
||||
await _contactPicker.selectContact();
|
||||
setState(() {
|
||||
_contact = contact!;
|
||||
_contact = currentContact!;
|
||||
// print("object111111111111 ${_contact.fullName} ${_contact.phoneNumbers}");
|
||||
});
|
||||
},
|
||||
@ -337,23 +350,28 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> {
|
||||
leftTitel: TranslationLoader.lanKeys!.remoteUnlockingAllowed!.tr,
|
||||
rightTitle: "",
|
||||
isHaveRightWidget: true,
|
||||
rightWidget: SizedBox(width: 60.w, height: 50.h, child: _switch()),
|
||||
rightWidget:
|
||||
SizedBox(width: 60.w, height: 50.h, child: _remoteSwitch(true)),
|
||||
action: () {}),
|
||||
Container(height: 10.h),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
CupertinoSwitch _switch() {
|
||||
bool _isOn = false;
|
||||
//isRemote true:远程开锁 false:实名认证
|
||||
CupertinoSwitch _remoteSwitch(bool isRemote) {
|
||||
return CupertinoSwitch(
|
||||
activeColor: CupertinoColors.activeBlue,
|
||||
trackColor: CupertinoColors.systemGrey5,
|
||||
thumbColor: CupertinoColors.white,
|
||||
value: _isOn,
|
||||
value: isRemote ? _isRemoteUnlock : _isAuthentication,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_isOn = value;
|
||||
if (isRemote) {
|
||||
_isRemoteUnlock = value;
|
||||
} else {
|
||||
_isAuthentication = value;
|
||||
}
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
@ -0,0 +1,23 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class SendElectronicKeyState {
|
||||
var emailOrPhone = ''.obs;
|
||||
var keyName = ''.obs;
|
||||
var canNext = false.obs;
|
||||
bool get isEmailOrPhoneOK => emailOrPhone.value.isNotEmpty;
|
||||
bool get isKeyNameOK => keyName.value.isNotEmpty;
|
||||
|
||||
TextEditingController emailOrPhoneController =
|
||||
TextEditingController(); //邮箱/手机号输入框
|
||||
TextEditingController keyNameController = TextEditingController(); //钥匙名输入框
|
||||
SendElectronicKeyState() {
|
||||
emailOrPhoneController.text = emailOrPhone.value;
|
||||
keyNameController.text = keyName.value;
|
||||
}
|
||||
|
||||
void onClose() {
|
||||
emailOrPhoneController.dispose();
|
||||
keyNameController.dispose();
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,7 @@
|
||||
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 = "https://lock.star-lock.cn/api"; // 测试环境
|
||||
final String baseUrl = "http://wenlin.lock.star-lock.cn/api"; //曾工
|
||||
|
||||
// 登录注册
|
||||
final String getVerificationCodeUrl = '/user/sendValidationCode';
|
||||
@ -9,4 +10,9 @@ abstract class Api {
|
||||
final String checkImgUrl = '/user/isSliderValid';
|
||||
final String loginUrl = '/user/login';
|
||||
final String resetPasswordURL = '/user/resetPassword'; //重置密码
|
||||
final String getCountryRegionURL = '/system/listCountry'; //获取国家或地区
|
||||
final String electronicKeyListURL = '/key/listUser'; //电子钥匙列表
|
||||
final String sendElectronicKeyURL = '/key/send'; //发送电子钥匙
|
||||
final String uploadElectricQuantityURL =
|
||||
'/room/uploadElectricQuantity'; //锁电量更新
|
||||
}
|
||||
|
||||
@ -89,6 +89,80 @@ class ApiProvider extends BaseProvider {
|
||||
"uniqueid": uniqueid,
|
||||
'verificationCode': verificationCode,
|
||||
}));
|
||||
|
||||
Future<Response> getCountryRegion(String type) =>
|
||||
post(getCountryRegionURL.toUrl, jsonEncode({'type': type}));
|
||||
|
||||
Future<Response> electronicKeyList(
|
||||
String endDate,
|
||||
String keyId,
|
||||
String keyStatus,
|
||||
String lockId,
|
||||
String operatorUid,
|
||||
String pageNo,
|
||||
String pageSize,
|
||||
String startDate) =>
|
||||
post(
|
||||
electronicKeyListURL.toUrl,
|
||||
jsonEncode({
|
||||
'endDate': endDate,
|
||||
'keyId': keyId,
|
||||
"keyStatus": keyStatus,
|
||||
'lockId': lockId,
|
||||
"operatorUid": operatorUid,
|
||||
'pageNo': pageNo,
|
||||
'pageSize': pageSize,
|
||||
'startDate': startDate,
|
||||
}));
|
||||
|
||||
Future<Response> sendElectronicKey(
|
||||
String createUser,
|
||||
String countryCode,
|
||||
String usernameType,
|
||||
String endDate,
|
||||
String faceAuthentication,
|
||||
String isCameraEnable,
|
||||
String isRemoteUnlock,
|
||||
String keyNameForAdmin,
|
||||
String keyRight,
|
||||
String keyType,
|
||||
String lockId,
|
||||
String operatorUid,
|
||||
String receiverUsername,
|
||||
String remarks,
|
||||
String startDate,
|
||||
String weekDays) =>
|
||||
post(
|
||||
sendElectronicKeyURL.toUrl,
|
||||
jsonEncode({
|
||||
'createUser': createUser,
|
||||
'countryCode': countryCode,
|
||||
'usernameType': usernameType,
|
||||
'endDate': endDate,
|
||||
'faceAuthentication': faceAuthentication,
|
||||
'isCameraEnable': isCameraEnable,
|
||||
'isRemoteUnlock': isRemoteUnlock,
|
||||
'keyNameForAdmin': keyNameForAdmin,
|
||||
'keyRight': keyRight,
|
||||
'keyType': keyType,
|
||||
'lockId': lockId,
|
||||
'operatorUid': operatorUid,
|
||||
'receiverUsername': receiverUsername,
|
||||
'remarks': remarks,
|
||||
'startDate': startDate,
|
||||
'weekDays': weekDays
|
||||
}));
|
||||
|
||||
Future<Response> uploadElectricQuantity(
|
||||
String electricQuantity,
|
||||
String lockId,
|
||||
) =>
|
||||
post(
|
||||
uploadElectricQuantityURL.toUrl,
|
||||
jsonEncode({
|
||||
'electricQuantity': electricQuantity,
|
||||
'lockId': lockId,
|
||||
}));
|
||||
}
|
||||
|
||||
extension ExtensionString on String {
|
||||
|
||||
@ -53,6 +53,7 @@ class BaseProvider extends GetConnect with Api {
|
||||
statusText: res.statusText,
|
||||
);
|
||||
}
|
||||
print('得到的数据======>¥res');
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart';
|
||||
import '../common/safetyVerification/entity/CheckSafetyVerificationEntity.dart';
|
||||
import '../common/safetyVerification/entity/SafetyVerificationEntity.dart';
|
||||
import '../login/login/entity/LoginEntity.dart';
|
||||
@ -52,6 +53,7 @@ class ApiRepository {
|
||||
return CheckSafetyVerificationEntity.fromJson(res.body);
|
||||
}
|
||||
|
||||
//登录
|
||||
Future<LoginEntity> login(String loginType, String password,
|
||||
String countryCode, String username) async {
|
||||
final res =
|
||||
@ -71,4 +73,63 @@ class ApiRepository {
|
||||
countryCode, account, date, newPassword, uniqueid, verificationCode);
|
||||
return LoginEntity.fromJson(res.body);
|
||||
}
|
||||
|
||||
//获取国家或地区 json文件
|
||||
Future<LoginEntity> getCountryRegion(String type) async {
|
||||
final res = await apiProvider.getCountryRegion(type);
|
||||
return LoginEntity.fromJson(res.body);
|
||||
}
|
||||
|
||||
//电子钥匙列表
|
||||
Future<ElectronicKeyListEntity> electronicKeyList(
|
||||
String endDate,
|
||||
String keyId,
|
||||
String keyStatus,
|
||||
String lockId,
|
||||
String operatorUid,
|
||||
String pageNo,
|
||||
String pageSize,
|
||||
String startDate) async {
|
||||
final res = await apiProvider.electronicKeyList(endDate, keyId, keyStatus,
|
||||
lockId, operatorUid, pageNo, pageSize, startDate);
|
||||
return ElectronicKeyListEntity.fromJson(res.body);
|
||||
}
|
||||
|
||||
//发送电子钥匙
|
||||
Future<ElectronicKeyListEntity> sendElectronicKey(
|
||||
String createUser,
|
||||
String countryCode,
|
||||
String usernameType,
|
||||
String endDate,
|
||||
String faceAuthentication,
|
||||
String isCameraEnable,
|
||||
String isRemoteUnlock,
|
||||
String keyNameForAdmin,
|
||||
String keyRight,
|
||||
String keyType,
|
||||
String lockId,
|
||||
String operatorUid,
|
||||
String receiverUsername,
|
||||
String remarks,
|
||||
String startDate,
|
||||
String weekDays) async {
|
||||
final res = await apiProvider.sendElectronicKey(
|
||||
createUser,
|
||||
countryCode,
|
||||
usernameType,
|
||||
endDate,
|
||||
faceAuthentication,
|
||||
isCameraEnable,
|
||||
isRemoteUnlock,
|
||||
keyNameForAdmin,
|
||||
keyRight,
|
||||
keyType,
|
||||
lockId,
|
||||
operatorUid,
|
||||
receiverUsername,
|
||||
remarks,
|
||||
startDate,
|
||||
weekDays);
|
||||
return ElectronicKeyListEntity.fromJson(res.body);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,3 @@
|
||||
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'package:get/get.dart';
|
||||
@ -11,16 +9,17 @@ import '../tools/storage.dart';
|
||||
import '../tools/store_service.dart';
|
||||
|
||||
FutureOr<Request> requestInterceptor(Request request) async {
|
||||
request.headers['User-Agent'] = 'StarLock/${PlatformInfoService.to.info.version}/${PlatformInfoService.to.info.buildNumber}/${GetPlatform.isAndroid ? 'Android' : 'iOS'}';
|
||||
request.headers['User-Agent'] =
|
||||
'StarLock/${PlatformInfoService.to.info.version}/${PlatformInfoService.to.info.buildNumber}/${GetPlatform.isAndroid ? 'Android' : 'iOS'}';
|
||||
request.headers['Accept-Language'] = 'zh_CN';
|
||||
request.headers['Content-Type'] = 'application/json';
|
||||
// request.headers['token'] = StoreService.to.userToken!;
|
||||
// print("11111${StoreService.to.userToken}");
|
||||
String? xToken = '';
|
||||
final data = await Storage.getData<String>('userLoginData');
|
||||
if(data != null && data.isNotEmpty){
|
||||
if (data != null && data.isNotEmpty) {
|
||||
xToken = LoginEntity.fromJson(jsonDecode(data)).data!.accessToken;
|
||||
}
|
||||
request.headers['Authorization'] = "Bearer ${xToken ?? ''}";
|
||||
return request;
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,17 +4,16 @@ import 'package:get/get_connect/http/src/request/request.dart';
|
||||
|
||||
import '../tools/manager/client_manager.dart';
|
||||
|
||||
|
||||
FutureOr<dynamic> responseInterceptor(Request request,Response response) async {
|
||||
FutureOr<dynamic> responseInterceptor(
|
||||
Request request, Response response) async {
|
||||
var statusCode = response.statusCode;
|
||||
if(statusCode == 403){
|
||||
if (statusCode == 403) {
|
||||
await ClientManager().logOff();
|
||||
// Get.offAllNamed(RouteConfig.homePage);
|
||||
return response;
|
||||
}
|
||||
if(response.isOk){
|
||||
if (response.isOk) {
|
||||
// Get.log('接口成功返回${response.body}');
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
|
||||
import 'dart:async';
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:get/get_connect/http/src/request/request.dart';
|
||||
|
||||
FutureOr<dynamic> responseLogInterceptor(Request request,Response response) {
|
||||
Get.log('HTTP RESPONSE =>\n stataCode:${response.statusCode} ${response.body} ${response.headers}');
|
||||
FutureOr<dynamic> responseLogInterceptor(Request request, Response response) {
|
||||
Get.log(
|
||||
'HTTP RESPONSE =>\n stataCode:${response.statusCode} ${response.body} ${response.headers}');
|
||||
EasyLoading.dismiss(animation: true);
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user