From a94c246a0c9e2b654f5a7a582455f26875371588 Mon Sep 17 00:00:00 2001 From: zhang <494089941@qq.com> Date: Mon, 22 Feb 2021 15:17:27 +0800 Subject: [PATCH] =?UTF-8?q?Revert=20"=E5=AF=B9=E6=8E=A5=E8=AE=BF=E5=AE=A2?= =?UTF-8?q?=E7=AE=A1=E7=90=86"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 32bf9d8b36961a66a895b671ddc9f8a17a786280. --- lib/const/api.dart | 9 +- lib/models/visitor/visitor_cards_model.dart | 44 ------ lib/provider/user_provider.dart | 1 + lib/tools/aku_map.dart | 10 -- .../visitor_manager/visitor_manager_card.dart | 20 +-- .../visitor_manager/visitor_manager_page.dart | 140 +++++++----------- lib/utils/manage_func.dart | 23 --- 7 files changed, 66 insertions(+), 181 deletions(-) delete mode 100644 lib/models/visitor/visitor_cards_model.dart delete mode 100644 lib/tools/aku_map.dart delete mode 100644 lib/utils/manage_func.dart diff --git a/lib/const/api.dart b/lib/const/api.dart index 56ebcf7..1cbe23e 100644 --- a/lib/const/api.dart +++ b/lib/const/api.dart @@ -13,7 +13,6 @@ class API { static const int networkTimeOut = 10000; static _Auth auth = _Auth(); static _User user = _User(); - static _Manage manage = _Manage(); } class _Auth { @@ -41,10 +40,6 @@ class _User { String get sendTelUpdateCode => '/user/personalData/sendTelUpdateCode'; ///个人资料:根据新手机号发送修改验证码 - String get updateTel => '/user/personalData/updateTel'; -} - -class _Manage { - ///访客管理:管家app显示所有的访客信息 (包含条件搜索) - String get visitorList => '/user/visitor/list'; + String get updateTel =>'/user/personalData/updateTel'; + } diff --git a/lib/models/visitor/visitor_cards_model.dart b/lib/models/visitor/visitor_cards_model.dart deleted file mode 100644 index 65ceacf..0000000 --- a/lib/models/visitor/visitor_cards_model.dart +++ /dev/null @@ -1,44 +0,0 @@ -class VisitorCardsModel { - int id; - String roomName; - String name; - int isDrive; - String carNum; - String effectiveTime; - String visitDate; - int visitorStatus; - - VisitorCardsModel( - {this.id, - this.roomName, - this.name, - this.isDrive, - this.carNum, - this.effectiveTime, - this.visitDate, - this.visitorStatus}); - - VisitorCardsModel.fromJson(Map json) { - id = json['id']; - roomName = json['roomName']; - name = json['name']; - isDrive = json['isDrive']; - carNum = json['carNum']; - effectiveTime = json['effectiveTime']; - visitDate = json['visitDate']; - visitorStatus = json['visitorStatus']; - } - - Map toJson() { - final Map data = new Map(); - data['id'] = this.id; - data['roomName'] = this.roomName; - data['name'] = this.name; - data['isDrive'] = this.isDrive; - data['carNum'] = this.carNum; - data['effectiveTime'] = this.effectiveTime; - data['visitDate'] = this.visitDate; - data['visitorStatus'] = this.visitorStatus; - return data; - } -} diff --git a/lib/provider/user_provider.dart b/lib/provider/user_provider.dart index 74a37a7..69f3fc6 100644 --- a/lib/provider/user_provider.dart +++ b/lib/provider/user_provider.dart @@ -2,6 +2,7 @@ import 'dart:io'; // Flutter imports: +import 'package:bot_toast/bot_toast.dart'; import 'package:flutter/material.dart'; // Project imports: diff --git a/lib/tools/aku_map.dart b/lib/tools/aku_map.dart deleted file mode 100644 index 7e82a85..0000000 --- a/lib/tools/aku_map.dart +++ /dev/null @@ -1,10 +0,0 @@ -import 'package:aku_community_manager/ui/sub_pages/visitor_manager/visitor_manager_page.dart'; - -class AkuMap { - static Map vistorStatus = { - 1: VisitorStatus.NOT_VISIT, - 2: VisitorStatus.VISIT_DONE, - 3: VisitorStatus.OUTDATE, - 4: VisitorStatus.CANCEL - }; -} diff --git a/lib/ui/sub_pages/visitor_manager/visitor_manager_card.dart b/lib/ui/sub_pages/visitor_manager/visitor_manager_card.dart index c70ec63..10cb374 100644 --- a/lib/ui/sub_pages/visitor_manager/visitor_manager_card.dart +++ b/lib/ui/sub_pages/visitor_manager/visitor_manager_card.dart @@ -2,7 +2,6 @@ import 'dart:math'; // Flutter imports: -import 'package:common_utils/common_utils.dart'; import 'package:flutter/material.dart'; // Package imports: @@ -49,13 +48,15 @@ class _VisitorManagerCardState extends State { _adress = widget.adress; _name = widget.name; _plate = widget.plate ?? '无信息'; - _time = widget.time; + _time = widget.time ?? '无信息'; _status = widget.status; } @override Widget build(BuildContext context) { - return + return Column( + children: [ + AkuBox.h(16), Container( color: Color(0xFFFFFFFF), width: double.infinity, @@ -109,12 +110,7 @@ class _VisitorManagerCardState extends State { height: 40.w, ), AkuBox.w(8), - Text( - _time==null - ? '无信息' - : DateUtil.formatDateStr(_time, - format: DateFormats.y_mo_d_h_m), - style: _textStyle), + Text(_time, style: _textStyle), Spacer(), ], ), @@ -134,7 +130,9 @@ class _VisitorManagerCardState extends State { ), ], ), - ); + ), + ], + ); } String _statusImage(VisitorStatus status) { @@ -145,8 +143,6 @@ class _VisitorManagerCardState extends State { return R.ASSETS_MANAGE_IC_DAOFANG_PNG; case VisitorStatus.OUTDATE: return R.ASSETS_MANAGE_IC_GUOQI_PNG; - case VisitorStatus.CANCEL: - return R.ASSETS_MANAGE_IC_GUOQI_PNG; default: return ''; } diff --git a/lib/ui/sub_pages/visitor_manager/visitor_manager_page.dart b/lib/ui/sub_pages/visitor_manager/visitor_manager_page.dart index e69e42a..20c48ea 100644 --- a/lib/ui/sub_pages/visitor_manager/visitor_manager_page.dart +++ b/lib/ui/sub_pages/visitor_manager/visitor_manager_page.dart @@ -1,10 +1,5 @@ // Flutter imports: -import 'package:aku_community_manager/models/visitor/visitor_cards_model.dart'; -import 'package:aku_community_manager/tools/aku_map.dart'; -import 'package:aku_community_manager/utils/manage_func.dart'; -import 'package:aku_community_manager/utils/network/base_list_model.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_easyrefresh/easy_refresh.dart'; // Package imports: import 'package:flutter_screenutil/flutter_screenutil.dart'; @@ -14,14 +9,21 @@ import 'package:aku_community_manager/style/app_style.dart'; import 'package:aku_community_manager/ui/sub_pages/visitor_manager/visitor_manager_card.dart'; import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart'; import 'package:aku_community_manager/ui/widgets/inner/aku_tab_bar.dart'; -import 'package:aku_community_manager/tools/extensions/list_extension_tool.dart'; -import 'package:velocity_x/velocity_x.dart'; enum VisitorStatus { NOT_VISIT, VISIT_DONE, OUTDATE, - CANCEL, +} + +class VisitorCardsModel { + String adress; + String name; + String plate; + String time; + VisitorStatus status; + VisitorCardsModel( + {this.adress, this.name, this.status, this.plate, this.time}); } class VisitorManagerPage extends StatefulWidget { @@ -35,26 +37,32 @@ class VisitorManagerPage extends StatefulWidget { class _VisitorManagerPageState extends State with TickerProviderStateMixin { List _tabs = ['全部', '未到访', '已到访', '已过期']; - int _page = 1; - int _size = 10; - EasyRefreshController _easyRefreshController; + + List _cards = [ + VisitorCardsModel( + adress: '深圳华悦茂峰1幢1单元702', + name: '马泽城', + status: VisitorStatus.VISIT_DONE, + plate: '浙BA9899', + time: '2020-10-24 12:00', + ), + VisitorCardsModel( + adress: '深圳华悦茂峰2幢2单元702', name: '刘揪心', status: VisitorStatus.NOT_VISIT), + VisitorCardsModel( + adress: '深圳华悦茂峰3幢3单元602', name: '张空间', status: VisitorStatus.OUTDATE), + ]; TabController _tabController; - List _models = []; - bool _onload = true; @override void initState() { super.initState(); _tabController = TabController(length: 4, vsync: this, initialIndex: widget.initIndex); - - _easyRefreshController = EasyRefreshController(); } @override void dispose() { _tabController?.dispose(); - _easyRefreshController?.dispose(); super.dispose(); } @@ -74,77 +82,39 @@ class _VisitorManagerPageState extends State )); } - Widget _empty() { - return Container(); - } - Widget _buildListView(int index) { - // switch (index) { - // case 0: - // _selectCards = _cards; - // break; - // case 1: - // _selectCards = _cards - // .where((element) => element.status == VisitorStatus.NOT_VISIT) - // .toList(); - // break; - // case 2: - // _selectCards = _cards - // .where((element) => element.status == VisitorStatus.VISIT_DONE) - // .toList(); - // break; - // case 3: - // _selectCards = _cards - // .where((element) => element.status == VisitorStatus.OUTDATE) - // .toList(); - // break; - // } - return EasyRefresh( - firstRefresh: true, - controller: _easyRefreshController, - header: MaterialHeader(), - // emptyWidget: Container(), - onRefresh: () async { - _page = 1; - _size = 10; - BaseListModel baseListModel = - await ManageFunc.visitorList(_page, _size, statuts: index); - _models = baseListModel.tableList - .map((e) => VisitorCardsModel.fromJson(e)) + List _selectCards; + switch (index) { + case 0: + _selectCards = _cards; + break; + case 1: + _selectCards = _cards + .where((element) => element.status == VisitorStatus.NOT_VISIT) .toList(); - _onload = false; - setState(() {}); - }, - onLoad: () async { - _page++; - BaseListModel baseListModel = - await ManageFunc.visitorList(_page, _size, statuts: index); - _models.addAll(baseListModel.tableList - .map((e) => VisitorCardsModel.fromJson(e)) - .toList()); - if (_page >= baseListModel.pageCount) { - _easyRefreshController.finishLoad(noMore: true); - } - setState(() {}); - }, - child: _onload - ? _empty() - : ListView( - padding: EdgeInsets.only( - left: 32.w, right: 32.w, top: 16.w, bottom: 16.w), - children: _models - .map( - (e) => VisitorManagerCard( - adress: e.roomName, - name: e.name, - plate: e.carNum, - time: e.visitDate, - status: AkuMap.vistorStatus[e.visitorStatus], - ), - ) - .toList() - .sepWidget(separate: 16.w.heightBox), - ), + break; + case 2: + _selectCards = _cards + .where((element) => element.status == VisitorStatus.VISIT_DONE) + .toList(); + break; + case 3: + _selectCards = _cards + .where((element) => element.status == VisitorStatus.OUTDATE) + .toList(); + break; + } + return ListView( + padding: EdgeInsets.only(left: 32.w, right: 32.w), + children: _selectCards + .map((e) => VisitorManagerCard( + adress: e.adress, + name: e.name, + plate: e.plate, + time: e.time, + status: e.status, + )) + .toList(), ); } } diff --git a/lib/utils/manage_func.dart b/lib/utils/manage_func.dart deleted file mode 100644 index 7f5eacb..0000000 --- a/lib/utils/manage_func.dart +++ /dev/null @@ -1,23 +0,0 @@ -import 'package:aku_community_manager/const/api.dart'; -import 'package:aku_community_manager/utils/network/base_list_model.dart'; -import 'package:aku_community_manager/utils/network/net_util.dart'; - -class ManageFunc { - static Future visitorList(int page, int size, {int statuts}) async { - BaseListModel baseListModel; - if (statuts == 0) { - baseListModel = await NetUtil().getList(API.manage.visitorList, params: { - 'pageNum': page, - 'size': size, - }); - } else { - baseListModel = await NetUtil().getList(API.manage.visitorList, params: { - 'pageNum': page, - 'size': size, - 'visitorStatus': statuts, - }); - } - - return baseListModel; - } -}