Merge branch 'master' of https://gitee.com/weishaoyang/star_lock
This commit is contained in:
commit
205221309c
@ -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/material.dart';
|
||||||
|
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||||
import 'package:get/get.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 '../../../../appRouters.dart';
|
||||||
import '../../../../app_settings/app_colors.dart';
|
import '../../../../app_settings/app_colors.dart';
|
||||||
@ -16,6 +21,23 @@ class ElectronicKeyListPage extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _ElectronicKeyListPageState extends State<ElectronicKeyListPage> {
|
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
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
@ -34,24 +56,44 @@ class _ElectronicKeyListPageState extends State<ElectronicKeyListPage> {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
body: Column(
|
body: FutureBuilder<List<ElectronicKeyListItem>>(
|
||||||
children: [
|
future: mockNetworkData(),
|
||||||
_searchWidget(),
|
builder: (BuildContext context,
|
||||||
SizedBox(
|
AsyncSnapshot<List<ElectronicKeyListItem>> snapshot) {
|
||||||
height: 20.h,
|
//请求结束
|
||||||
),
|
if (snapshot.connectionState == ConnectionState.done) {
|
||||||
Expanded(child: _buildMainUI()),
|
if (snapshot.hasError) {
|
||||||
AddBottomWhiteBtn(
|
//请求失败
|
||||||
btnName: TranslationLoader.lanKeys!.sendKey!.tr,
|
return const Text('请求失败');
|
||||||
onClick: () {
|
} else {
|
||||||
Navigator.pushNamed(context, Routers.sendElectronicKeyManagePage);
|
//请求成功
|
||||||
},
|
final List<ElectronicKeyListItem> itemData = snapshot.data!;
|
||||||
),
|
|
||||||
SizedBox(
|
return Column(
|
||||||
height: 64.h,
|
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(
|
return ListView.separated(
|
||||||
itemCount: 5,
|
itemCount: getItemData.length,
|
||||||
itemBuilder: (c, index) {
|
itemBuilder: (c, index) {
|
||||||
return _electronicKeyItem('images/controls_user.png', "张三",
|
ElectronicKeyListItem indexEntity = getItemData[index];
|
||||||
"2023.6.21 11.15", "2023.6.21 11.15", () {
|
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);
|
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(
|
return GestureDetector(
|
||||||
onTap: action,
|
onTap: action,
|
||||||
child: Container(
|
child: Container(
|
||||||
@ -121,7 +232,7 @@ class _ElectronicKeyListPageState extends State<ElectronicKeyListPage> {
|
|||||||
width: 30.w,
|
width: 30.w,
|
||||||
),
|
),
|
||||||
Image.asset(
|
Image.asset(
|
||||||
lockTypeIcon,
|
avatarURL,
|
||||||
width: 60.w,
|
width: 60.w,
|
||||||
height: 60.w,
|
height: 60.w,
|
||||||
),
|
),
|
||||||
@ -136,39 +247,39 @@ class _ElectronicKeyListPageState extends State<ElectronicKeyListPage> {
|
|||||||
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
lockTypeTitle,
|
receiveUser,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 24.sp, color: AppColors.blackColor),
|
fontSize: 24.sp, color: AppColors.blackColor),
|
||||||
),
|
),
|
||||||
SizedBox(width: 10.w),
|
SizedBox(width: 10.w),
|
||||||
Image.asset(
|
isAdminKey
|
||||||
'images/icon_electronicKey_admin.png',
|
? Image.asset(
|
||||||
width: 24.w,
|
'images/icon_electronicKey_admin.png',
|
||||||
height: 20.w,
|
width: 24.w,
|
||||||
),
|
height: 20.w,
|
||||||
|
)
|
||||||
|
: Container(),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
width: 20.w,
|
width: 20.w,
|
||||||
)),
|
)),
|
||||||
Text(
|
Text(
|
||||||
"待接收",
|
keyStatus,
|
||||||
style: TextStyle(fontSize: 18.sp, color: Colors.red),
|
style: TextStyle(fontSize: 18.sp, color: Colors.red),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
SizedBox(height: 10.h),
|
SizedBox(height: 10.h),
|
||||||
Container(
|
Row(
|
||||||
child: Row(
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
children: [
|
||||||
children: [
|
Text(
|
||||||
Text(
|
useDate,
|
||||||
"2023.6.21 11.15-2023.6.21 11.15",
|
style: TextStyle(
|
||||||
style: TextStyle(
|
fontSize: 18.sp,
|
||||||
fontSize: 18.sp,
|
color: AppColors.placeholderTextColor),
|
||||||
color: AppColors.placeholderTextColor),
|
),
|
||||||
),
|
],
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
SizedBox(width: 20.h),
|
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);
|
const MassSendElectronicKeyManagePage({Key? key}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<MassSendElectronicKeyManagePage> createState() => _MassSendElectronicKeyManagePageState();
|
State<MassSendElectronicKeyManagePage> createState() =>
|
||||||
|
_MassSendElectronicKeyManagePageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _MassSendElectronicKeyManagePageState extends State<MassSendElectronicKeyManagePage> {
|
class _MassSendElectronicKeyManagePageState
|
||||||
var index=0;
|
extends State<MassSendElectronicKeyManagePage> {
|
||||||
|
var index = 0;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: AppColors.mainBackgroundColor,
|
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(
|
body: Column(
|
||||||
children: [
|
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:get/get.dart';
|
||||||
import 'package:star_lock/app_settings/app_colors.dart';
|
import 'package:star_lock/app_settings/app_colors.dart';
|
||||||
import 'package:flutter_native_contact_picker/flutter_native_contact_picker.dart';
|
import 'package:flutter_native_contact_picker/flutter_native_contact_picker.dart';
|
||||||
|
import 'package:star_lock/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_logic.dart';
|
||||||
|
|
||||||
import '../../../../../appRouters.dart';
|
import '../../../../../appRouters.dart';
|
||||||
import '../../../../../tools/commonItem.dart';
|
import '../../../../../tools/commonItem.dart';
|
||||||
@ -13,7 +14,7 @@ import '../../../../../translations/trans_lib.dart';
|
|||||||
class SendElectronicKeyPage extends StatefulWidget {
|
class SendElectronicKeyPage extends StatefulWidget {
|
||||||
final String type;
|
final String type;
|
||||||
|
|
||||||
SendElectronicKeyPage({Key? key, required this.type}) : super(key: key);
|
const SendElectronicKeyPage({Key? key, required this.type}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<SendElectronicKeyPage> createState() => _SendElectronicKeyPageState();
|
State<SendElectronicKeyPage> createState() => _SendElectronicKeyPageState();
|
||||||
@ -23,15 +24,17 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> {
|
|||||||
final FlutterContactPicker _contactPicker = FlutterContactPicker();
|
final FlutterContactPicker _contactPicker = FlutterContactPicker();
|
||||||
late Contact _contact;
|
late Contact _contact;
|
||||||
|
|
||||||
@override
|
final logic = Get.put(SendElectronicKeyLogic());
|
||||||
Widget build(BuildContext context) {
|
// final state = Get.find<SendElectronicKeyLogic>().state;
|
||||||
return indexChangeWidget();
|
|
||||||
}
|
bool _isRemoteUnlock = false; //是否允许远程开锁
|
||||||
|
bool _isAuthentication = false; //是否可以实名认证
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
Widget build(BuildContext context) {
|
||||||
// TODO: implement initState
|
return SingleChildScrollView(
|
||||||
super.initState();
|
child: indexChangeWidget(),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget indexChangeWidget() {
|
Widget indexChangeWidget() {
|
||||||
@ -102,14 +105,14 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> {
|
|||||||
rightTitle: "",
|
rightTitle: "",
|
||||||
isHaveLine: true,
|
isHaveLine: true,
|
||||||
isHaveRightWidget: true,
|
isHaveRightWidget: true,
|
||||||
rightWidget: getTFWidget(
|
rightWidget: getTFWidget(true,
|
||||||
true, TranslationLoader.lanKeys!.pleaseEnterNumberOrEmail!.tr)),
|
TranslationLoader.lanKeys!.pleaseEnterNumberOrEmail!.tr, 1)),
|
||||||
CommonItem(
|
CommonItem(
|
||||||
leftTitel: TranslationLoader.lanKeys!.name!.tr,
|
leftTitel: TranslationLoader.lanKeys!.name!.tr,
|
||||||
rightTitle: "",
|
rightTitle: "",
|
||||||
isHaveRightWidget: true,
|
isHaveRightWidget: true,
|
||||||
rightWidget: getTFWidget(
|
rightWidget: getTFWidget(
|
||||||
false, TranslationLoader.lanKeys!.enterYourName!.tr)),
|
false, TranslationLoader.lanKeys!.enterYourName!.tr, 2)),
|
||||||
Container(height: 10.h),
|
Container(height: 10.h),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
@ -148,7 +151,8 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> {
|
|||||||
rightTitle: "",
|
rightTitle: "",
|
||||||
isTipsImg: true,
|
isTipsImg: true,
|
||||||
isHaveRightWidget: 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: () {}),
|
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(
|
Container(
|
||||||
padding: EdgeInsets.only(right: 30.w),
|
padding: EdgeInsets.only(right: 30.w),
|
||||||
// color: Colors.red,
|
// color: Colors.red,
|
||||||
@ -276,14 +285,17 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 接受者信息输入框
|
// 接受者信息输入框
|
||||||
Widget getTFWidget(bool isHaveBtn, String tfStr) {
|
Widget getTFWidget(bool isHaveBtn, String tfStr, int lineIndex) {
|
||||||
return Container(
|
return SizedBox(
|
||||||
height: 50.h,
|
height: 50.h,
|
||||||
width: 320.w,
|
width: 320.w,
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: TextField(
|
child: TextField(
|
||||||
|
// controller: lineIndex == 1
|
||||||
|
// ? state.emailOrPhoneController
|
||||||
|
// : state.keyNameController,
|
||||||
//输入框一行
|
//输入框一行
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
// controller: _controller,
|
// controller: _controller,
|
||||||
@ -315,9 +327,10 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> {
|
|||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
Contact? contact = await _contactPicker.selectContact();
|
Contact? currentContact =
|
||||||
|
await _contactPicker.selectContact();
|
||||||
setState(() {
|
setState(() {
|
||||||
_contact = contact!;
|
_contact = currentContact!;
|
||||||
// print("object111111111111 ${_contact.fullName} ${_contact.phoneNumbers}");
|
// print("object111111111111 ${_contact.fullName} ${_contact.phoneNumbers}");
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -337,23 +350,28 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> {
|
|||||||
leftTitel: TranslationLoader.lanKeys!.remoteUnlockingAllowed!.tr,
|
leftTitel: TranslationLoader.lanKeys!.remoteUnlockingAllowed!.tr,
|
||||||
rightTitle: "",
|
rightTitle: "",
|
||||||
isHaveRightWidget: true,
|
isHaveRightWidget: true,
|
||||||
rightWidget: SizedBox(width: 60.w, height: 50.h, child: _switch()),
|
rightWidget:
|
||||||
|
SizedBox(width: 60.w, height: 50.h, child: _remoteSwitch(true)),
|
||||||
action: () {}),
|
action: () {}),
|
||||||
Container(height: 10.h),
|
Container(height: 10.h),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
CupertinoSwitch _switch() {
|
//isRemote true:远程开锁 false:实名认证
|
||||||
bool _isOn = false;
|
CupertinoSwitch _remoteSwitch(bool isRemote) {
|
||||||
return CupertinoSwitch(
|
return CupertinoSwitch(
|
||||||
activeColor: CupertinoColors.activeBlue,
|
activeColor: CupertinoColors.activeBlue,
|
||||||
trackColor: CupertinoColors.systemGrey5,
|
trackColor: CupertinoColors.systemGrey5,
|
||||||
thumbColor: CupertinoColors.white,
|
thumbColor: CupertinoColors.white,
|
||||||
value: _isOn,
|
value: isRemote ? _isRemoteUnlock : _isAuthentication,
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
setState(() {
|
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,4 +1,3 @@
|
|||||||
|
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
@ -8,47 +7,44 @@ import '../../login/login/entity/LoginEntity.dart';
|
|||||||
import '../../tools/storage.dart';
|
import '../../tools/storage.dart';
|
||||||
|
|
||||||
class StarLockMineState {
|
class StarLockMineState {
|
||||||
|
|
||||||
final loginData = LoginEntity().obs;
|
final loginData = LoginEntity().obs;
|
||||||
|
|
||||||
///本地存储 登录信息
|
///本地存储 登录信息
|
||||||
void saveLoginData(LoginEntity data) async {
|
void saveLoginData(LoginEntity data) async {
|
||||||
print("saveLoginData:${data.data!.mobile}");
|
print("saveLoginData:${data.data!.mobile}");
|
||||||
await Storage.setString('userLoginData',jsonEncode(data));
|
await Storage.setString('userLoginData', jsonEncode(data));
|
||||||
loginData.value=data;
|
loginData.value = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
///初始化本地数据
|
///初始化本地数据
|
||||||
void initLoginData() async {
|
void initLoginData() async {
|
||||||
final data = await Storage.getString('userLoginData');
|
final data = await Storage.getString('userLoginData');
|
||||||
print("getLoginData:$data");
|
print("getLoginData:$data");
|
||||||
if(data != null && data.isNotEmpty){
|
if (data != null && data.isNotEmpty) {
|
||||||
loginData.value = LoginEntity.fromJson(jsonDecode(data));
|
loginData.value = LoginEntity.fromJson(jsonDecode(data));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
///退出登录
|
///退出登录
|
||||||
void logOut() async {
|
void logOut() async {
|
||||||
await Storage.setString('userLoginData','');
|
await Storage.setString('userLoginData', '');
|
||||||
loginData.value = LoginEntity();
|
loginData.value = LoginEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
///用户登录token
|
///用户登录token
|
||||||
String token(){
|
String token() {
|
||||||
return loginData.value.data?.accessToken??'';
|
return loginData.value.data?.accessToken ?? '';
|
||||||
}
|
}
|
||||||
|
|
||||||
String mobile(){
|
String mobile() {
|
||||||
return loginData.value.data?.mobile??'-';
|
return loginData.value.data?.mobile ?? '-';
|
||||||
}
|
}
|
||||||
|
|
||||||
///用户头像
|
///用户头像
|
||||||
String headUrl(){
|
String headUrl() {
|
||||||
return loginData.value.data!.headUrl??'';
|
return loginData.value.data!.headUrl ?? '';
|
||||||
// return "https://img2.woyaogexing.com/2022/04/14/156cdbabd5bc496abee2cd0fca527434!400x400.jpeg";
|
// return "https://img2.woyaogexing.com/2022/04/14/156cdbabd5bc496abee2cd0fca527434!400x400.jpeg";
|
||||||
}
|
}
|
||||||
|
|
||||||
void onClose() {
|
void onClose() {}
|
||||||
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
abstract class Api {
|
abstract class Api {
|
||||||
// final String baseUrl = "http://test.lock.star-lock.cn/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';
|
final String getVerificationCodeUrl = '/user/sendValidationCode';
|
||||||
@ -9,4 +10,9 @@ abstract class Api {
|
|||||||
final String checkImgUrl = '/user/isSliderValid';
|
final String checkImgUrl = '/user/isSliderValid';
|
||||||
final String loginUrl = '/user/login';
|
final String loginUrl = '/user/login';
|
||||||
final String resetPasswordURL = '/user/resetPassword'; //重置密码
|
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,
|
"uniqueid": uniqueid,
|
||||||
'verificationCode': verificationCode,
|
'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 {
|
extension ExtensionString on String {
|
||||||
|
|||||||
@ -53,6 +53,7 @@ class BaseProvider extends GetConnect with Api {
|
|||||||
statusText: res.statusText,
|
statusText: res.statusText,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
print('得到的数据======>¥res');
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import 'package:get/get.dart';
|
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/CheckSafetyVerificationEntity.dart';
|
||||||
import '../common/safetyVerification/entity/SafetyVerificationEntity.dart';
|
import '../common/safetyVerification/entity/SafetyVerificationEntity.dart';
|
||||||
import '../login/login/entity/LoginEntity.dart';
|
import '../login/login/entity/LoginEntity.dart';
|
||||||
@ -52,6 +53,7 @@ class ApiRepository {
|
|||||||
return CheckSafetyVerificationEntity.fromJson(res.body);
|
return CheckSafetyVerificationEntity.fromJson(res.body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//登录
|
||||||
Future<LoginEntity> login(String loginType, String password,
|
Future<LoginEntity> login(String loginType, String password,
|
||||||
String countryCode, String username) async {
|
String countryCode, String username) async {
|
||||||
final res =
|
final res =
|
||||||
@ -71,4 +73,63 @@ class ApiRepository {
|
|||||||
countryCode, account, date, newPassword, uniqueid, verificationCode);
|
countryCode, account, date, newPassword, uniqueid, verificationCode);
|
||||||
return LoginEntity.fromJson(res.body);
|
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:async';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
@ -11,16 +9,17 @@ import '../tools/storage.dart';
|
|||||||
import '../tools/store_service.dart';
|
import '../tools/store_service.dart';
|
||||||
|
|
||||||
FutureOr<Request> requestInterceptor(Request request) async {
|
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['Accept-Language'] = 'zh_CN';
|
||||||
request.headers['Content-Type'] = 'application/json';
|
request.headers['Content-Type'] = 'application/json';
|
||||||
// request.headers['token'] = StoreService.to.userToken!;
|
// request.headers['token'] = StoreService.to.userToken!;
|
||||||
// print("11111${StoreService.to.userToken}");
|
// print("11111${StoreService.to.userToken}");
|
||||||
String? xToken = '';
|
String? xToken = '';
|
||||||
final data = await Storage.getString('userLoginData');
|
final data = await Storage.getString('userLoginData');
|
||||||
if(data != null && data.isNotEmpty){
|
if (data != null && data.isNotEmpty) {
|
||||||
xToken = LoginEntity.fromJson(jsonDecode(data)).data!.accessToken;
|
xToken = LoginEntity.fromJson(jsonDecode(data)).data!.accessToken;
|
||||||
}
|
}
|
||||||
request.headers['Authorization'] = "Bearer ${xToken ?? ''}";
|
request.headers['Authorization'] = "Bearer ${xToken ?? ''}";
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,17 +4,16 @@ import 'package:get/get_connect/http/src/request/request.dart';
|
|||||||
|
|
||||||
import '../tools/manager/client_manager.dart';
|
import '../tools/manager/client_manager.dart';
|
||||||
|
|
||||||
|
FutureOr<dynamic> responseInterceptor(
|
||||||
FutureOr<dynamic> responseInterceptor(Request request,Response response) async {
|
Request request, Response response) async {
|
||||||
var statusCode = response.statusCode;
|
var statusCode = response.statusCode;
|
||||||
if(statusCode == 403){
|
if (statusCode == 403) {
|
||||||
await ClientManager().logOff();
|
await ClientManager().logOff();
|
||||||
// Get.offAllNamed(RouteConfig.homePage);
|
// Get.offAllNamed(RouteConfig.homePage);
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
if(response.isOk){
|
if (response.isOk) {
|
||||||
// Get.log('接口成功返回${response.body}');
|
// Get.log('接口成功返回${response.body}');
|
||||||
}
|
}
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:get/get_connect/http/src/request/request.dart';
|
import 'package:get/get_connect/http/src/request/request.dart';
|
||||||
|
|
||||||
FutureOr<dynamic> responseLogInterceptor(Request request,Response response) {
|
FutureOr<dynamic> responseLogInterceptor(Request request, Response response) {
|
||||||
Get.log('HTTP RESPONSE =>\n stataCode:${response.statusCode} ${response.body} ${response.headers}');
|
Get.log(
|
||||||
|
'HTTP RESPONSE =>\n stataCode:${response.statusCode} ${response.body} ${response.headers}');
|
||||||
EasyLoading.dismiss(animation: true);
|
EasyLoading.dismiss(animation: true);
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,8 +3,7 @@
|
|||||||
* */
|
* */
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
class Storage{
|
class Storage {
|
||||||
|
|
||||||
// Storage._internal();
|
// Storage._internal();
|
||||||
//
|
//
|
||||||
// factory Storage() => _instance;
|
// factory Storage() => _instance;
|
||||||
@ -49,70 +48,69 @@ class Storage{
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
// int
|
// int
|
||||||
static Future<void> setInt(key,value) async{
|
static Future<void> setInt(key, value) async {
|
||||||
SharedPreferences sp = await SharedPreferences.getInstance();
|
SharedPreferences sp = await SharedPreferences.getInstance();
|
||||||
sp.setInt(key, value);
|
sp.setInt(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<int?> getInt(key) async{
|
static Future<int?> getInt(key) async {
|
||||||
SharedPreferences sp = await SharedPreferences.getInstance();
|
SharedPreferences sp = await SharedPreferences.getInstance();
|
||||||
return sp.getInt(key);
|
return sp.getInt(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
// bool
|
// bool
|
||||||
static Future<void> setBool(key,value) async{
|
static Future<void> setBool(key, value) async {
|
||||||
SharedPreferences sp = await SharedPreferences.getInstance();
|
SharedPreferences sp = await SharedPreferences.getInstance();
|
||||||
sp.setBool(key, value);
|
sp.setBool(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<bool?> getBool(key) async{
|
static Future<bool?> getBool(key) async {
|
||||||
SharedPreferences sp = await SharedPreferences.getInstance();
|
SharedPreferences sp = await SharedPreferences.getInstance();
|
||||||
return sp.getBool(key);
|
return sp.getBool(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
// double
|
// double
|
||||||
static Future<void> setDouble(key,value) async{
|
static Future<void> setDouble(key, value) async {
|
||||||
SharedPreferences sp = await SharedPreferences.getInstance();
|
SharedPreferences sp = await SharedPreferences.getInstance();
|
||||||
sp.setDouble(key, value);
|
sp.setDouble(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<double?> getDouble(key) async{
|
static Future<double?> getDouble(key) async {
|
||||||
SharedPreferences sp = await SharedPreferences.getInstance();
|
SharedPreferences sp = await SharedPreferences.getInstance();
|
||||||
return sp.getDouble(key);
|
return sp.getDouble(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
// string
|
// string
|
||||||
static Future<void> setString(key,value) async{
|
static Future<void> setString(key, value) async {
|
||||||
SharedPreferences sp = await SharedPreferences.getInstance();
|
SharedPreferences sp = await SharedPreferences.getInstance();
|
||||||
sp.setString(key, value);
|
sp.setString(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<String?> getString(key) async{
|
static Future<String?> getString(key) async {
|
||||||
SharedPreferences sp = await SharedPreferences.getInstance();
|
SharedPreferences sp = await SharedPreferences.getInstance();
|
||||||
return sp.getString(key);
|
return sp.getString(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 字符串数组
|
// 字符串数组
|
||||||
static Future<void> setStringList(key,value) async{
|
static Future<void> setStringList(key, value) async {
|
||||||
SharedPreferences sp = await SharedPreferences.getInstance();
|
SharedPreferences sp = await SharedPreferences.getInstance();
|
||||||
sp.setStringList(key, value);
|
sp.setStringList(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<List<String>?> getStringList(key) async{
|
static Future<List<String>?> getStringList(key) async {
|
||||||
SharedPreferences sp = await SharedPreferences.getInstance();
|
SharedPreferences sp = await SharedPreferences.getInstance();
|
||||||
return sp.getStringList(key);
|
return sp.getStringList(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 移除数据
|
// 移除数据
|
||||||
static Future<void> removeData(key) async{
|
static Future<void> removeData(key) async {
|
||||||
SharedPreferences sp = await SharedPreferences.getInstance();
|
SharedPreferences sp = await SharedPreferences.getInstance();
|
||||||
sp.remove(key);
|
sp.remove(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 移除所有的键值对
|
// 移除所有的键值对
|
||||||
static Future<void> clearAll() async{
|
static Future<void> clearAll() async {
|
||||||
SharedPreferences sp = await SharedPreferences.getInstance();
|
SharedPreferences sp = await SharedPreferences.getInstance();
|
||||||
sp.clear();
|
sp.clear();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user