feat:恢复 http 日志打印
This commit is contained in:
parent
6c7e96d2cb
commit
624a43fde2
@ -4,6 +4,7 @@ import 'package:flutter_slidable/flutter_slidable.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart';
|
||||
import 'package:star_lock/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_logic.dart';
|
||||
import 'package:star_lock/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_state.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart';
|
||||
import 'package:star_lock/tools/noData.dart';
|
||||
import 'package:star_lock/tools/storage.dart';
|
||||
@ -25,8 +26,8 @@ class AuthorizedAdminListPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _AuthorizedAdminListPageState extends State<AuthorizedAdminListPage> {
|
||||
final logic = Get.put(AuthorizedAdminListLogic());
|
||||
final state = Get.find<AuthorizedAdminListLogic>().state;
|
||||
final AuthorizedAdminListLogic logic = Get.put(AuthorizedAdminListLogic());
|
||||
final AuthorizedAdminListState state = Get.find<AuthorizedAdminListLogic>().state;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@ -37,7 +38,7 @@ class _AuthorizedAdminListPageState extends State<AuthorizedAdminListPage> {
|
||||
|
||||
Future<void> mockRequest() async {
|
||||
// 获取是否是演示模式 演示模式不获取接口
|
||||
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if (isDemoMode == false) {
|
||||
logic.mockNetworkDataRequest().then((ElectronicKeyListEntity value) {
|
||||
setState(() {});
|
||||
@ -63,7 +64,7 @@ class _AuthorizedAdminListPageState extends State<AuthorizedAdminListPage> {
|
||||
mockRequest();
|
||||
},
|
||||
child: Column(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Expanded(child: _buildMainUI()),
|
||||
SizedBox(
|
||||
height: 20.h,
|
||||
@ -72,7 +73,7 @@ class _AuthorizedAdminListPageState extends State<AuthorizedAdminListPage> {
|
||||
btnName: TranslationLoader.lanKeys!.addAuthorizedAdmin!.tr,
|
||||
onClick: () {
|
||||
Navigator.pushNamed(context, Routers.authorizedAdminPage)
|
||||
.then((val) {
|
||||
.then((Object? val) {
|
||||
if (val != null) {
|
||||
logic.pageNo = 1;
|
||||
mockRequest();
|
||||
@ -89,14 +90,14 @@ class _AuthorizedAdminListPageState extends State<AuthorizedAdminListPage> {
|
||||
}
|
||||
|
||||
Widget _buildMainUI() {
|
||||
return Obx(() => state.itemDataList.value.isEmpty
|
||||
return Obx(() => state.itemDataList.isEmpty
|
||||
? NoData(noDataHeight: 1.sh - ScreenUtil().statusBarHeight - 90)
|
||||
: SlidableAutoCloseBehavior(
|
||||
child: ListView.separated(
|
||||
itemCount: state.itemDataList.value.length,
|
||||
itemBuilder: (c, index) {
|
||||
ElectronicKeyListItem indexEntity =
|
||||
state.itemDataList.value[index];
|
||||
itemCount: state.itemDataList.length,
|
||||
itemBuilder: (BuildContext c, int index) {
|
||||
final ElectronicKeyListItem indexEntity =
|
||||
state.itemDataList[index];
|
||||
String useDateStr = ''; //使用期限
|
||||
String keyStatus = ''; //钥匙状态
|
||||
|
||||
@ -116,16 +117,16 @@ class _AuthorizedAdminListPageState extends State<AuthorizedAdminListPage> {
|
||||
}
|
||||
|
||||
return Slidable(
|
||||
key: ValueKey(indexEntity.keyId),
|
||||
key: ValueKey<int?>(indexEntity.keyId),
|
||||
endActionPane: ActionPane(
|
||||
extentRatio: 0.2,
|
||||
motion: const ScrollMotion(),
|
||||
children: [
|
||||
children: <Widget>[
|
||||
SlidableAction(
|
||||
onPressed: (BuildContext context) {
|
||||
ShowTipView()
|
||||
.showDeleteAdministratorIsHaveAllDataDialog(
|
||||
'同时删除其发送的所有钥匙,钥匙删除后不能恢复', (isAllData) {
|
||||
'同时删除其发送的所有钥匙,钥匙删除后不能恢复', (bool isAllData) {
|
||||
logic.deleteKeyRequest(indexEntity.keyId.toString(),
|
||||
isAllData ? 1 : 0);
|
||||
});
|
||||
@ -145,9 +146,9 @@ class _AuthorizedAdminListPageState extends State<AuthorizedAdminListPage> {
|
||||
isAdminKey, () {
|
||||
Navigator.pushNamed(
|
||||
context, Routers.electronicKeyDetailPage,
|
||||
arguments: {
|
||||
"itemData": indexEntity,
|
||||
}).then((val) {
|
||||
arguments: <String, ElectronicKeyListItem>{
|
||||
'itemData': indexEntity,
|
||||
}).then((Object? val) {
|
||||
if (val != null) {
|
||||
logic.mockNetworkDataRequest();
|
||||
setState(() {});
|
||||
@ -172,14 +173,14 @@ class _AuthorizedAdminListPageState extends State<AuthorizedAdminListPage> {
|
||||
|
||||
if (indexEntity.keyType == XSConstantMacro.keyTypeTime) {
|
||||
//限期
|
||||
DateTime startDateStr =
|
||||
final DateTime startDateStr =
|
||||
DateTime.fromMillisecondsSinceEpoch(indexEntity.startDate!);
|
||||
DateTime endDateStr =
|
||||
final DateTime endDateStr =
|
||||
DateTime.fromMillisecondsSinceEpoch(indexEntity.endDate!);
|
||||
useDateStr =
|
||||
'${startDateStr.toLocal().toString().substring(0, 16)}-${endDateStr.toLocal().toString().substring(0, 16)}';
|
||||
} else if (indexEntity.keyType == XSConstantMacro.keyTypeLong) {
|
||||
useDateStr = "永久";
|
||||
useDateStr = '永久';
|
||||
}
|
||||
return useDateStr;
|
||||
}
|
||||
@ -192,7 +193,7 @@ class _AuthorizedAdminListPageState extends State<AuthorizedAdminListPage> {
|
||||
color: Colors.white,
|
||||
height: 100.h,
|
||||
child: Row(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
SizedBox(width: 30.w),
|
||||
Image.asset(
|
||||
avatarURL,
|
||||
@ -203,13 +204,13 @@ class _AuthorizedAdminListPageState extends State<AuthorizedAdminListPage> {
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Row(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
SizedBox(
|
||||
width: 1.sw - 110.w - 100.w,
|
||||
child: Row(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Flexible(
|
||||
child: Text(receiveUser,
|
||||
maxLines: 1,
|
||||
@ -231,7 +232,7 @@ class _AuthorizedAdminListPageState extends State<AuthorizedAdminListPage> {
|
||||
SizedBox(height: 10.h),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Text(
|
||||
useDate,
|
||||
style: TextStyle(
|
||||
|
||||
@ -0,0 +1,50 @@
|
||||
class NoticeTemplateEntity {
|
||||
|
||||
int? errorCode;
|
||||
String? description;
|
||||
String? errorMsg;
|
||||
Data? data;
|
||||
|
||||
NoticeTemplateEntity(
|
||||
{this.errorCode, this.description, this.errorMsg, this.data});
|
||||
|
||||
NoticeTemplateEntity.fromJson(Map<String, dynamic> json) {
|
||||
errorCode = json['errorCode'];
|
||||
description = json['description'];
|
||||
errorMsg = json['errorMsg'];
|
||||
if (json['data'] is Map) {
|
||||
data = Data.fromJson(json['data']);
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['errorCode'] = errorCode;
|
||||
data['description'] = description;
|
||||
data['errorMsg'] = errorMsg;
|
||||
data['data'] = this.data;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class Data {
|
||||
List<int>? userNos = [];
|
||||
|
||||
Data({
|
||||
this.userNos,
|
||||
});
|
||||
|
||||
Data.fromJson(Map<String, dynamic> json) {
|
||||
if (json['userNos'] is List) {
|
||||
json['userNos'].forEach((element) {
|
||||
userNos?.add(element);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['userNos'] = userNos;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@ -2,19 +2,21 @@ import 'dart:ffi';
|
||||
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/main/lockDetail/lockSet/basicInformation/basicInformation/KeyDetailEntity.dart';
|
||||
import 'package:star_lock/network/api_repository.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import 'package:star_lock/tools/commonDataManage.dart';
|
||||
|
||||
import 'volumeAuthorizationLock_state.dart';
|
||||
|
||||
class VolumeAuthorizationLockLogic extends BaseGetXController {
|
||||
final state = VolumeAuthorizationLockState();
|
||||
final VolumeAuthorizationLockState state = VolumeAuthorizationLockState();
|
||||
|
||||
//发送批量授权管理员
|
||||
Future<void> addAuthorizedAdminRequest() async {
|
||||
String getFailureDateTime = '0';
|
||||
String getEffectiveDateTime = '0';
|
||||
if (state.selectWidgetType == '1') {
|
||||
if (state.selectWidgetType.value == '1') {
|
||||
getFailureDateTime =
|
||||
state.failureDateTime.value.millisecondsSinceEpoch.toString();
|
||||
getEffectiveDateTime =
|
||||
@ -25,11 +27,11 @@ class VolumeAuthorizationLockLogic extends BaseGetXController {
|
||||
showToast('请选择锁'.tr);
|
||||
return;
|
||||
}
|
||||
var entity = await ApiRepository.to.addAuthorizedAdmin(
|
||||
final KeyDetailEntity entity = await ApiRepository.to.addAuthorizedAdmin(
|
||||
createUser: state.isCreateUser.value ? '1' : '0',
|
||||
endDate: getFailureDateTime,
|
||||
isRemoteUnlock: '0',
|
||||
keyGroupIdList: [],
|
||||
keyGroupIdList: <dynamic>[],
|
||||
lockIdList: state.lockIdList.value,
|
||||
name: state.keyNameController.text,
|
||||
startDate: getEffectiveDateTime,
|
||||
@ -49,4 +51,14 @@ class VolumeAuthorizationLockLogic extends BaseGetXController {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//发送消息
|
||||
Future<void> sendMsg({required bool isPhone}) async {
|
||||
if (isPhone) {
|
||||
} else {}
|
||||
var entity = await ApiRepository.to.getNoticeTemplate(
|
||||
lockId: CommonDataManage().currentKeyInfo.lockId!,
|
||||
keyId: CommonDataManage().currentKeyInfo.keyId!,
|
||||
channelType: 1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -181,7 +181,7 @@ class _VolumeAuthorizationLockPageState
|
||||
children: <Widget>[
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.lock!.tr,
|
||||
rightTitle: state.lockIdList.value.isEmpty
|
||||
rightTitle: state.lockIdList.isEmpty
|
||||
? TranslationLoader.lanKeys!.pleaseSelect!.tr
|
||||
: state.lockIdList.length.toString(),
|
||||
isHaveDirection: true,
|
||||
@ -190,11 +190,12 @@ class _VolumeAuthorizationLockPageState
|
||||
arguments: <String, String>{'keyLimits': '1'})
|
||||
.then((Object? value) {
|
||||
//得到选中的锁ID列表
|
||||
if (value != null) {
|
||||
value as Map<String, dynamic>;
|
||||
state.lockIdList.value = value['selectLockIdList'];
|
||||
|
||||
// setState(() {});
|
||||
if (value is Map<String, dynamic> && value['selectLockIdList'] is List) {
|
||||
state.lockIdList.clear();
|
||||
value['selectLockIdList'].forEach((element) {
|
||||
state.lockIdList.add(element);
|
||||
});
|
||||
setState(() {});
|
||||
}
|
||||
});
|
||||
}),
|
||||
@ -211,13 +212,6 @@ class _VolumeAuthorizationLockPageState
|
||||
width: 60.w,
|
||||
height: 50.h,
|
||||
child: _onlyManageYouCreatesUserSwitch())),
|
||||
|
||||
// CommonItem(
|
||||
// leftTitel: TranslationLoader.lanKeys!.remoteUnlockingAllowed!.tr,
|
||||
// rightTitle: '',
|
||||
// isHaveRightWidget: true,
|
||||
// rightWidget: SizedBox(width: 60.w, height: 50.h, child: _switch()),
|
||||
// action: () {}),
|
||||
Container(height: 10.h),
|
||||
],
|
||||
);
|
||||
@ -375,31 +369,10 @@ class _VolumeAuthorizationLockPageState
|
||||
btnName: '微信通知',
|
||||
onClick: () {},
|
||||
),
|
||||
SizedBox(
|
||||
height: 10.h,
|
||||
),
|
||||
OutLineBtn(
|
||||
btnName: '标记为已入住',
|
||||
onClick: () {},
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
// CupertinoSwitch _switch() {
|
||||
// return CupertinoSwitch(
|
||||
// activeColor: CupertinoColors.activeBlue,
|
||||
// trackColor: CupertinoColors.systemGrey5,
|
||||
// thumbColor: CupertinoColors.white,
|
||||
// value: state.isRemoteUnlock.value,
|
||||
// onChanged: (bool value) {
|
||||
// setState(() {
|
||||
// _isRemoteUnlock = !_isRemoteUnlock;
|
||||
// });
|
||||
// },
|
||||
// );
|
||||
// }
|
||||
|
||||
//仅管理自己创建的用户
|
||||
CupertinoSwitch _onlyManageYouCreatesUserSwitch() {
|
||||
return CupertinoSwitch(
|
||||
@ -407,7 +380,7 @@ class _VolumeAuthorizationLockPageState
|
||||
trackColor: CupertinoColors.systemGrey5,
|
||||
thumbColor: CupertinoColors.white,
|
||||
value: state.onlyManageYouCreatesUser.value,
|
||||
onChanged: (value) {
|
||||
onChanged: (bool value) {
|
||||
setState(() {
|
||||
state.onlyManageYouCreatesUser.value =
|
||||
!state.onlyManageYouCreatesUser.value;
|
||||
|
||||
@ -235,4 +235,6 @@ abstract class Api {
|
||||
|
||||
final String getUserNoList = '/key/getUserNoList'; //获取指定锁下所有userNo
|
||||
|
||||
final String getNoticeTemplateURL = '/key/getNoticeTemplate'; //获取短信或者邮箱模板
|
||||
|
||||
}
|
||||
|
||||
@ -374,12 +374,15 @@ class ApiProvider extends BaseProvider {
|
||||
}));
|
||||
|
||||
// 获取锁信息列表
|
||||
Future<Response> getStarLockListInfo(int pageNo, int pageSize,{bool isUnShowLoading = true}) => post(
|
||||
getStarLockInfoURL.toUrl,
|
||||
jsonEncode({
|
||||
"pageNo": pageNo,
|
||||
'pageSize': pageSize,
|
||||
}),isUnShowLoading: isUnShowLoading);
|
||||
Future<Response> getStarLockListInfo(int pageNo, int pageSize,
|
||||
{bool isUnShowLoading = true}) =>
|
||||
post(
|
||||
getStarLockInfoURL.toUrl,
|
||||
jsonEncode({
|
||||
"pageNo": pageNo,
|
||||
'pageSize': pageSize,
|
||||
}),
|
||||
isUnShowLoading: isUnShowLoading);
|
||||
|
||||
// 获取所有锁设置信息
|
||||
Future<Response> getLockSettingInfoData(String lockId) => post(
|
||||
@ -2078,6 +2081,17 @@ class ApiProvider extends BaseProvider {
|
||||
// 获取指定锁下所有userNo
|
||||
Future<Response> getLockUserNoList(int lockId) =>
|
||||
post(getUserNoList.toUrl, jsonEncode({'lockId': lockId}));
|
||||
|
||||
// 获取短信或者邮箱模板
|
||||
Future<Response<dynamic>> getNoticeTemplate(
|
||||
int lockId, int keyId, int channelType) =>
|
||||
post(
|
||||
getNoticeTemplateURL.toUrl,
|
||||
jsonEncode(<String, int>{
|
||||
'lockId': lockId,
|
||||
'keyId': keyId,
|
||||
'channelType': channelType,
|
||||
}));
|
||||
}
|
||||
|
||||
extension ExtensionString on String {
|
||||
|
||||
@ -2112,4 +2112,15 @@ class ApiRepository {
|
||||
final res = await apiProvider.getLockUserNoList(lockId);
|
||||
return LockUserNoListEntity.fromJson(res.body);
|
||||
}
|
||||
|
||||
// 检测certifyId是否完成认证
|
||||
Future<LockUserNoListEntity> getNoticeTemplate({
|
||||
required int lockId,
|
||||
required int keyId,
|
||||
required int channelType,
|
||||
}) async {
|
||||
final Response<dynamic> res =
|
||||
await apiProvider.getNoticeTemplate(lockId, keyId, channelType);
|
||||
return LockUserNoListEntity.fromJson(res.body);
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@ import 'package:get/get_connect/http/src/request/request.dart';
|
||||
import 'package:star_lock/app_settings/app_settings.dart';
|
||||
|
||||
FutureOr<dynamic> responseLogInterceptor(Request request, Response response) {
|
||||
// AppLog.log('HTTP request:${request.url}\n RESPONSE => stataCode:${response.statusCode} ${response.bodyString}'); // \n ${response.headers}
|
||||
AppLog.log('HTTP request:${request.url}\n RESPONSE => stataCode:${response.statusCode} ${response.bodyString}'); // \n ${response.headers}
|
||||
EasyLoading.dismiss(animation: true);
|
||||
return response;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user